[profiler] Avoid instrumenting inlined methods
[mono.git] / mono / mini / mini-profiler.c
index 3b6149d92728edccfbec18bc89fd6c087be26dd2..33d39e26df6dfd138048a92d165837685dc546ea 100644 (file)
@@ -4,6 +4,8 @@
  * See the LICENSE file in the project root for more information.
  */
 
+#include <config.h>
+
 #include <mono/metadata/abi-details.h>
 #include <mono/metadata/mono-debug.h>
 
 #include "ir-emit.h"
 #include "mini.h"
 
+#ifndef DISABLE_JIT
+
 void
 mini_profiler_emit_instrumentation_call (MonoCompile *cfg, void *func, gboolean entry, MonoInst **ret, MonoType *rtype)
 {
        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;
@@ -27,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);
@@ -64,6 +73,8 @@ mini_profiler_emit_instrumentation_call (MonoCompile *cfg, void *func, gboolean
        mono_emit_jit_icall (cfg, func, iargs);
 }
 
+#endif
+
 void
 mini_profiler_context_enable (void)
 {