From b6397061ddd80784e8bb92b431a814cf5c1a9516 Mon Sep 17 00:00:00 2001 From: Uri Simchoni Date: Mon, 7 Aug 2017 07:39:12 +0300 Subject: [PATCH] [profiler] Avoid instrumenting inlined methods An inlined method does not require instrumentation (if it did, it would not have been inlined). The flags that control instrumentation options are valid for the caller method and are not to be consulted. This patch replaces an assertion with a check and early return. A method that "wants to be instrumented" does not get inlined, but a method that "doesn't want to be instrumented" can get inlined. However, the flags that control instrumention options have been calculated against the caller method, hence they should not be consulted at all. The extra check renders the assertion unnecessary. --- mono/mini/mini-profiler.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mono/mini/mini-profiler.c b/mono/mini/mini-profiler.c index 1e79ecc4099..33d39e26df6 100644 --- a/mono/mini/mini-profiler.c +++ b/mono/mini/mini-profiler.c @@ -20,6 +20,13 @@ mini_profiler_emit_instrumentation_call (MonoCompile *cfg, void *func, gboolean { gboolean instrument, capture; + /* + * Do not instrument an inlined method - it becomes + * part of the current method. + */ + if (cfg->current_method != cfg->method) + return; + if (entry) { instrument = cfg->prof_flags & MONO_PROFILER_CALL_INSTRUMENTATION_PROLOGUE; capture = cfg->prof_flags & MONO_PROFILER_CALL_INSTRUMENTATION_PROLOGUE_CONTEXT; @@ -31,8 +38,6 @@ mini_profiler_emit_instrumentation_call (MonoCompile *cfg, void *func, gboolean if (!instrument) return; - g_assert (cfg->current_method == cfg->method); - MonoInst *iargs [2]; EMIT_NEW_METHODCONST (cfg, iargs [0], cfg->method); -- 2.25.1