diff options
author | Alex Rønne Petersen <alexrp@xamarin.com> | 2017-06-22 18:15:35 +0300 |
---|---|---|
committer | Alex Rønne Petersen <alexrp@xamarin.com> | 2017-07-06 12:32:29 +0300 |
commit | ea4e4a9ef6fc42570a23026adbe826cf7248290e (patch) | |
tree | 16a072acabaab62ac66a725cebc4426143ed746a /samples | |
parent | dc2e330a9ff2d5c5271693d5b8d685aa8c0dd3b2 (diff) |
[runtime] New profiler API.
* Profiler callbacks can now be changed and disabled at any point.
* API users no longer have to set event flags. The API instead uses a counter
internally for each type of callback.
* Filter functions for enter/leave instrumentation can be installed, and they
can choose whether to instrument the prologue, epilogue, or both.
* Managed allocators can now be instrumented for allocation profiling.
* A profiler must now declare that it wishes to use allocation profiling and/or
sampling in its init function.
* Sampling parameters can now be changed at any point, and the sampling thread
can be put into an idle mode when no sampling is needed.
* Only one profiler can have control over the sampling parameters. Whichever
profiler enables sampling first gets control.
* Adding new events is now very easy: One line in profiler-events.h and one
line wherever the event should be raised.
* Lifted the restriction that enter/leave instrumentation would cause an abort
in full AOT mode.
* Support for call chain sampling has been removed.
* Support for the old, platform-specific code coverage mode has been removed.
* The new profiler module entry point is mono_profiler_init. If a module has
a mono_profiler_startup symbol (the old entry point), a warning will be
printed and the module won't be loaded.
* Updated the profiler test suite to work with instrumented managed allocators.
Diffstat (limited to 'samples')
-rw-r--r-- | samples/profiler/sample.c | 18 | ||||
-rw-r--r-- | samples/size/size.c | 8 |
2 files changed, 16 insertions, 10 deletions
diff --git a/samples/profiler/sample.c b/samples/profiler/sample.c index 45c46da07d9..75e2f779590 100644 --- a/samples/profiler/sample.c +++ b/samples/profiler/sample.c @@ -35,19 +35,25 @@ sample_method_leave (MonoProfiler *prof, MonoMethod *method) { } +static MonoProfilerCallInstrumentationFlags +sample_instrumentation_filter (MonoProfiler *prof, MonoMethod *method) +{ + return MONO_PROFILER_CALL_INSTRUMENTATION_PROLOGUE | MONO_PROFILER_CALL_INSTRUMENTATION_EPILOGUE; +} + /* the entry point */ void -mono_profiler_startup (const char *desc) +mono_profiler_init (const char *desc) { MonoProfiler *prof; prof = g_new0 (MonoProfiler, 1); - mono_profiler_install (prof, sample_shutdown); - - mono_profiler_install_enter_leave (sample_method_enter, sample_method_leave); - - mono_profiler_set_events (MONO_PROFILE_ENTER_LEAVE); + MonoProfilerHandle handle = mono_profiler_install (prof); + mono_profiler_set_runtime_shutdown_callback (handle, sample_shutdown); + mono_profiler_set_call_instrumentation_filter_callback (handle, sample_instrumentation_filter); + mono_profiler_set_method_enter_callback (handle, sample_method_enter); + mono_profiler_set_method_leave_callback (handle, sample_method_leave); } diff --git a/samples/size/size.c b/samples/size/size.c index c24b417d21f..86ec27dfd6d 100644 --- a/samples/size/size.c +++ b/samples/size/size.c @@ -121,7 +121,7 @@ GetMemoryUsage (MonoObject *this) static int installed = 0; -void install_icall (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, int result) +void install_icall (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo) { if (installed) return; @@ -131,8 +131,8 @@ void install_icall (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, } void -mono_profiler_startup (const char *desc) +mono_profiler_init (const char *desc) { - mono_profiler_install_jit_end (install_icall); - mono_profiler_set_events (MONO_PROFILE_JIT_COMPILATION); + MonoProfilerHandle handle = mono_profiler_install (NULL); + mono_profiler_set_jit_done_callback (handle, install_icall); } |