[profiler] Split method_leave callback into a method_tail_call callback.
[mono.git] / mono / profiler / log.c
index 847ee26184cb93824366892581ba1eee5685eeb6..8a3790aac248ed44baa2d156137da838cfb65e42 100644 (file)
@@ -1760,7 +1760,7 @@ class_loaded (MonoProfiler *prof, MonoClass *klass)
 }
 
 static void
-method_enter (MonoProfiler *prof, MonoMethod *method)
+method_enter (MonoProfiler *prof, MonoMethod *method, MonoProfilerCallContext *ctx)
 {
        if (get_thread ()->call_depth++ <= log_config.max_call_depth) {
                ENTER_LOG (&method_entries_ctr, logbuffer,
@@ -1776,7 +1776,7 @@ method_enter (MonoProfiler *prof, MonoMethod *method)
 }
 
 static void
-method_leave (MonoProfiler *prof, MonoMethod *method)
+method_leave (MonoProfiler *prof, MonoMethod *method, MonoProfilerCallContext *ctx)
 {
        if (--get_thread ()->call_depth <= log_config.max_call_depth) {
                ENTER_LOG (&method_exits_ctr, logbuffer,
@@ -1791,6 +1791,12 @@ method_leave (MonoProfiler *prof, MonoMethod *method)
        }
 }
 
+static void
+tail_call (MonoProfiler *prof, MonoMethod *method, MonoMethod *target)
+{
+       method_leave (prof, method, NULL);
+}
+
 static void
 method_exc_leave (MonoProfiler *prof, MonoMethod *method, MonoObject *exc)
 {
@@ -1810,7 +1816,10 @@ method_exc_leave (MonoProfiler *prof, MonoMethod *method, MonoObject *exc)
 static MonoProfilerCallInstrumentationFlags
 method_filter (MonoProfiler *prof, MonoMethod *method)
 {
-       return MONO_PROFILER_CALL_INSTRUMENTATION_PROLOGUE | MONO_PROFILER_CALL_INSTRUMENTATION_EPILOGUE;
+       return MONO_PROFILER_CALL_INSTRUMENTATION_ENTER |
+              MONO_PROFILER_CALL_INSTRUMENTATION_LEAVE |
+              MONO_PROFILER_CALL_INSTRUMENTATION_TAIL_CALL |
+              MONO_PROFILER_CALL_INSTRUMENTATION_EXCEPTION_LEAVE;
 }
 
 static void
@@ -4626,28 +4635,11 @@ create_profiler (const char *args, const char *filename, GPtrArray *filters)
        log_profiler.startup_time = current_time ();
 }
 
-/*
- * declaration to silence the compiler: this is the entry point that
- * mono will load from the shared library and call.
- */
-extern void
-mono_profiler_init (const char *desc);
-
-extern void
+MONO_API void
 mono_profiler_init_log (const char *desc);
 
-/*
- * this is the entry point that will be used when the profiler
- * is embedded inside the main executable.
- */
 void
 mono_profiler_init_log (const char *desc)
-{
-       mono_profiler_init (desc);
-}
-
-void
-mono_profiler_init (const char *desc)
 {
        GPtrArray *filters = NULL;
 
@@ -4670,7 +4662,7 @@ mono_profiler_init (const char *desc)
 
        mono_lls_init (&log_profiler.profiler_thread_list, NULL);
 
-       MonoProfilerHandle handle = log_profiler.handle = mono_profiler_install (&log_profiler);
+       MonoProfilerHandle handle = log_profiler.handle = mono_profiler_create (&log_profiler);
 
        /*
         * Required callbacks. These are either necessary for the profiler itself
@@ -4752,11 +4744,14 @@ mono_profiler_init (const char *desc)
                mono_profiler_set_call_instrumentation_filter_callback (handle, method_filter);
                mono_profiler_set_method_enter_callback (handle, method_enter);
                mono_profiler_set_method_leave_callback (handle, method_leave);
+               mono_profiler_set_method_tail_call_callback (handle, tail_call);
                mono_profiler_set_method_exception_leave_callback (handle, method_exc_leave);
        }
 
-       if (log_config.collect_coverage)
+       if (log_config.collect_coverage) {
+               mono_profiler_enable_coverage ();
                mono_profiler_set_coverage_filter_callback (handle, coverage_filter);
+       }
 
        mono_profiler_enable_allocations ();
        mono_profiler_enable_sampling (handle);