Skip to content

Commit

Permalink
[mono][inline] Allow inlining methods containing ctor calls if they h…
Browse files Browse the repository at this point in the history
…ave the aggressive inlining flag. (#84660)

Re: dotnet/perf-autofiling-issues#15660.
  • Loading branch information
vargaz authored Apr 12, 2023
1 parent ae4c82b commit 8699942
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/mono/mono/metadata/class-inlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ m_method_is_synchronized (MonoMethod *method)
return (method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) != 0;
}

static inline gboolean
m_method_is_aggressive_inlining (MonoMethod *method)
{
return (method->iflags & METHOD_IMPL_ATTRIBUTE_AGGRESSIVE_INLINING) != 0;
}

static inline gboolean
m_method_is_pinvoke (MonoMethod *method)
{
Expand Down
9 changes: 5 additions & 4 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -5850,7 +5850,8 @@ handle_ctor_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fs

/* Avoid virtual calls to ctors if possible */
if (!context_used && !rgctx_arg) {
INLINE_FAILURE ("inline failure");
if (!m_method_is_aggressive_inlining (cfg->current_method) && !m_method_is_aggressive_inlining (cmethod))
INLINE_FAILURE ("ctor call");
// FIXME-VT: Clean this up
if (cfg->gsharedvt && mini_is_gsharedvt_signature (fsig))
GSHAREDVT_FAILURE(*ip);
Expand Down Expand Up @@ -12159,21 +12160,21 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b

mono_error_exit:
if (cfg->verbose_level > 3)
g_print ("exiting due to error");
g_print ("exiting due to error\n");

g_assert (!is_ok (cfg->error));
goto cleanup;

exception_exit:
if (cfg->verbose_level > 3)
g_print ("exiting due to exception");
g_print ("exiting due to exception\n");

g_assert (cfg->exception_type != MONO_EXCEPTION_NONE);
goto cleanup;

unverified:
if (cfg->verbose_level > 3)
g_print ("exiting due to invalid il");
g_print ("exiting due to invalid il\n");

set_exception_type_from_invalid_il (cfg, method, ip);
goto cleanup;
Expand Down

0 comments on commit 8699942

Please sign in to comment.