Skip to content

Commit 34ba8c7

Browse files
jeromelabanpavelsavarailonatommy
authored
[wasm] Enable the log profiler (#107434)
* feat(wasm): Enable the log profiler * chore: Disable for wasi * chore: Add log profiler docs * chore: Adjust flush logs syntax * chore: Adjust defines, add conditionals, remove Module dependency * chore: Adjust buffer_unlock exclusion * chore: Adjust doc * chore: Add log profiler sample * chore: Add more sample logging * chore: Remove unused makefile target * chore: Remove icall, use jit interception to take heap sot * chore: Remove unused logs * chore: Remove unused dependency * Revert "chore: Remove unused dependency" This reverts commit 33221c4. * remove ENABLE_BROWSER_PROFILER from default build * Draft of WBT. * Miss-commit, there's no profiler.js in the sample. * Shift the responsibility of checking profile's size to the browser. * Test linking of all 3 types of loggers + running one of them. * link all 3 at the same time * fix [Fact] * Treat a list of loggers as one argument. Avoid "MSBUILD : error MSB1005: Specify a property and its value." * fix? --------- Co-authored-by: pavelsavara <pavel.savara@gmail.com> Co-authored-by: Ilona Tomkowicz <itomkowicz@microsoft.com> Co-authored-by: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com> Co-authored-by: Pavel Savara <pavelsavara@microsoft.com>
1 parent d7948dc commit 34ba8c7

File tree

29 files changed

+426
-8
lines changed

29 files changed

+426
-8
lines changed

src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@
220220
<PlatformManifestFileEntry Include="libmono-ee-interp.a" IsNative="true" />
221221
<PlatformManifestFileEntry Include="libmono-icall-table.a" IsNative="true" />
222222
<PlatformManifestFileEntry Include="libmono-profiler-aot.a" IsNative="true" />
223+
<PlatformManifestFileEntry Include="libmono-profiler-log.a" IsNative="true" />
223224
<PlatformManifestFileEntry Include="libmono-profiler-browser.a" IsNative="true" />
224225
<PlatformManifestFileEntry Include="libmono-wasm-eh-js.a" IsNative="true" />
225226
<PlatformManifestFileEntry Include="libmono-wasm-eh-wasm.a" IsNative="true" />

src/mono/browser/browser.proj

+2-2
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@
385385
<PInvokeTableFile>$(ArtifactsObjDir)wasm/pinvoke-table.h</PInvokeTableFile>
386386
<InterpToNativeTableFile>$(ArtifactsObjDir)wasm/wasm_m2n_invoke.g.h</InterpToNativeTableFile>
387387

388-
<CMakeConfigurationEmccFlags Condition="'$(Configuration)' == 'Debug'">-g -Os -DDEBUG=1 -DENABLE_AOT_PROFILER=1 -DENABLE_BROWSER_PROFILER=1</CMakeConfigurationEmccFlags>
389-
<CMakeConfigurationEmccFlags Condition="'$(Configuration)' == 'Release'">-Oz -DENABLE_BROWSER_PROFILER=1</CMakeConfigurationEmccFlags>
388+
<CMakeConfigurationEmccFlags Condition="'$(Configuration)' == 'Debug'">-g -Os -DDEBUG=1 -DENABLE_AOT_PROFILER=1 -DENABLE_BROWSER_PROFILER=1 -DENABLE_LOG_PROFILER=1</CMakeConfigurationEmccFlags>
389+
<CMakeConfigurationEmccFlags Condition="'$(Configuration)' == 'Release'">-Oz</CMakeConfigurationEmccFlags>
390390

391391
<CMakeConfigurationLinkFlags Condition="'$(Configuration)' == 'Debug'" >$(CMakeConfigurationEmccFlags) -s ASSERTIONS=1 </CMakeConfigurationLinkFlags>
392392
<CMakeConfigurationLinkFlags Condition="'$(Configuration)' == 'Release'">-O2</CMakeConfigurationLinkFlags>

src/mono/browser/build/BrowserWasmApp.targets

+2
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@
314314
<_EmccCFlags Include="-DLINK_ICALLS=1" Condition="'$(WasmLinkIcalls)' == 'true'" />
315315
<_EmccCFlags Include="-DENABLE_AOT_PROFILER=1" Condition="$(WasmProfilers.Contains('aot'))" />
316316
<_EmccCFlags Include="-DENABLE_BROWSER_PROFILER=1" Condition="$(WasmProfilers.Contains('browser'))" />
317+
<_EmccCFlags Include="-DENABLE_LOG_PROFILER=1" Condition="$(WasmProfilers.Contains('log'))" />
317318
<_EmccCFlags Include="-DENABLE_JS_INTEROP_BY_VALUE=1" Condition="'$(WasmEnableJsInteropByValue)' == 'true'" />
318319

319320
<_EmccCFlags Include="-DGEN_PINVOKE=1" />
@@ -368,6 +369,7 @@
368369
<EmscriptenEnvVars Include="WASM_ENABLE_EH=0" Condition="'$(WasmEnableExceptionHandling)' == 'false'" />
369370
<EmscriptenEnvVars Include="ENABLE_AOT_PROFILER=$([System.Convert]::ToInt32($(WasmProfilers.Contains('aot'))))" />
370371
<EmscriptenEnvVars Include="ENABLE_BROWSER_PROFILER=$([System.Convert]::ToInt32($(WasmProfilers.Contains('browser'))))" />
372+
<EmscriptenEnvVars Include="ENABLE_LOG_PROFILER=$([System.Convert]::ToInt32($(WasmProfilers.Contains('log'))))" />
371373
<EmscriptenEnvVars Include="RUN_AOT_COMPILATION=1" Condition="'$(RunAOTCompilation)' == 'true'" />
372374
<EmscriptenEnvVars Include="RUN_AOT_COMPILATION=0" Condition="'$(RunAOTCompilation)' != 'true'" />
373375

src/mono/browser/runtime/cwraps.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ const fn_signatures: SigLine[] = [
6565
[false, "mono_wasm_exit", "void", ["number"]],
6666
[true, "mono_wasm_getenv", "number", ["string"]],
6767
[true, "mono_wasm_set_main_args", "void", ["number", "number"]],
68-
// These two need to be lazy because they may be missing
68+
// These three need to be lazy because they may be missing
6969
[() => !runtimeHelpers.emscriptenBuildOptions.enableAotProfiler, "mono_wasm_profiler_init_aot", "void", ["string"]],
7070
[() => !runtimeHelpers.emscriptenBuildOptions.enableBrowserProfiler, "mono_wasm_profiler_init_browser", "void", ["string"]],
71+
[() => !runtimeHelpers.emscriptenBuildOptions.enableLogProfiler, "mono_wasm_profiler_init_log", "void", ["string"]],
7172
[true, "mono_wasm_profiler_init_browser", "void", ["number"]],
7273
[false, "mono_wasm_exec_regression", "number", ["number", "string"]],
7374
[false, "mono_wasm_invoke_jsexport", "void", ["number", "number"]],
@@ -165,6 +166,7 @@ export interface t_ThreadingCwraps {
165166
export interface t_ProfilerCwraps {
166167
mono_wasm_profiler_init_aot(desc: string): void;
167168
mono_wasm_profiler_init_browser(desc: string): void;
169+
mono_wasm_profiler_init_log(desc: string): void;
168170
}
169171

170172
export interface t_Cwraps {

src/mono/browser/runtime/driver.c

+12
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,18 @@ mono_wasm_profiler_init_browser (const char *desc)
430430

431431
#endif
432432

433+
#ifdef ENABLE_LOG_PROFILER
434+
435+
void mono_profiler_init_log (const char *desc);
436+
437+
EMSCRIPTEN_KEEPALIVE void
438+
mono_wasm_profiler_init_log (const char *desc)
439+
{
440+
mono_profiler_init_log (desc);
441+
}
442+
443+
#endif
444+
433445
EMSCRIPTEN_KEEPALIVE void
434446
mono_wasm_init_finalizer_thread (void)
435447
{

src/mono/browser/runtime/es6/dotnet.es6.lib.js

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const WASM_ENABLE_SIMD = process.env.WASM_ENABLE_SIMD === "1";
1111
const WASM_ENABLE_EH = process.env.WASM_ENABLE_EH === "1";
1212
const ENABLE_BROWSER_PROFILER = process.env.ENABLE_BROWSER_PROFILER === "1";
1313
const ENABLE_AOT_PROFILER = process.env.ENABLE_AOT_PROFILER === "1";
14+
const ENABLE_LOG_PROFILER = process.env.ENABLE_LOG_PROFILER === "1";
1415
const RUN_AOT_COMPILATION = process.env.RUN_AOT_COMPILATION === "1";
1516
var methodIndexByName = undefined;
1617
var gitHash = undefined;
@@ -88,6 +89,7 @@ function injectDependencies() {
8889
`wasmEnableEH: ${WASM_ENABLE_EH ? "true" : "false"},` +
8990
`enableAotProfiler: ${ENABLE_AOT_PROFILER ? "true" : "false"}, ` +
9091
`enableBrowserProfiler: ${ENABLE_BROWSER_PROFILER ? "true" : "false"}, ` +
92+
`enableLogProfiler: ${ENABLE_LOG_PROFILER ? "true" : "false"}, ` +
9193
`runAOTCompilation: ${RUN_AOT_COMPILATION ? "true" : "false"}, ` +
9294
`wasmEnableThreads: ${USE_PTHREADS ? "true" : "false"}, ` +
9395
`gitHash: "${gitHash}", ` +

src/mono/browser/runtime/profiler.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
import { ENVIRONMENT_IS_WEB, mono_assert, runtimeHelpers } from "./globals";
5-
import { MonoMethod, AOTProfilerOptions, BrowserProfilerOptions } from "./types/internal";
5+
import { MonoMethod, AOTProfilerOptions, BrowserProfilerOptions, LogProfilerOptions } from "./types/internal";
66
import { profiler_c_functions as cwraps } from "./cwraps";
77
import { utf8ToString } from "./strings";
88

@@ -34,6 +34,12 @@ export function mono_wasm_init_browser_profiler (options: BrowserProfilerOptions
3434
cwraps.mono_wasm_profiler_init_browser(arg);
3535
}
3636

37+
export function mono_wasm_init_log_profiler (options: LogProfilerOptions): void {
38+
mono_assert(runtimeHelpers.emscriptenBuildOptions.enableLogProfiler, "Log profiler is not enabled, please use <WasmProfilers>log;</WasmProfilers> in your project file.");
39+
mono_assert(options.takeHeapshot, "Log profiler is not enabled, the takeHeapshot method must be defined in LogProfilerOptions.takeHeapshot");
40+
cwraps.mono_wasm_profiler_init_log( (options.configuration || "log:alloc,output=output.mlpd") + `,take-heapshot-method=${options.takeHeapshot}`);
41+
}
42+
3743
export const enum MeasuredBlock {
3844
emscriptenStartup = "mono.emscriptenStartup",
3945
instantiateWasm = "mono.instantiateWasm",

src/mono/browser/runtime/startup.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { exportedRuntimeAPI, INTERNAL, loaderHelpers, Module, runtimeHelpers, cr
99
import cwraps, { init_c_exports, threads_c_functions as tcwraps } from "./cwraps";
1010
import { mono_wasm_raise_debug_event, mono_wasm_runtime_ready } from "./debug";
1111
import { toBase64StringImpl } from "./base64";
12-
import { mono_wasm_init_aot_profiler, mono_wasm_init_browser_profiler } from "./profiler";
12+
import { mono_wasm_init_aot_profiler, mono_wasm_init_browser_profiler, mono_wasm_init_log_profiler } from "./profiler";
1313
import { initialize_marshalers_to_cs } from "./marshal-to-cs";
1414
import { initialize_marshalers_to_js } from "./marshal-to-js";
1515
import { init_polyfills_async } from "./polyfills";
@@ -544,6 +544,9 @@ export async function start_runtime () {
544544
if (runtimeHelpers.config.browserProfilerOptions)
545545
mono_wasm_init_browser_profiler(runtimeHelpers.config.browserProfilerOptions);
546546

547+
if (runtimeHelpers.config.logProfilerOptions)
548+
mono_wasm_init_log_profiler(runtimeHelpers.config.logProfilerOptions);
549+
547550
if (WasmEnableThreads) {
548551
// this is not mono-attached thread, so we can start it earlier
549552
await mono_wasm_init_diagnostics();

src/mono/browser/runtime/types/internal.ts

+7
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export type MonoConfigInternal = MonoConfig & {
7777
assets?: AssetEntryInternal[],
7878
runtimeOptions?: string[], // array of runtime options as strings
7979
aotProfilerOptions?: AOTProfilerOptions, // dictionary-style Object. If omitted, aot profiler will not be initialized.
80+
logProfilerOptions?: LogProfilerOptions, // dictionary-style Object. If omitted, log profiler will not be initialized.
8081
browserProfilerOptions?: BrowserProfilerOptions, // dictionary-style Object. If omitted, browser profiler will not be initialized.
8182
waitForDebugger?: number,
8283
appendElementOnExit?: boolean
@@ -274,6 +275,11 @@ export type AOTProfilerOptions = {
274275
export type BrowserProfilerOptions = {
275276
}
276277

278+
export type LogProfilerOptions = {
279+
takeHeapshot?: string,
280+
configuration?: string // log profiler options string"
281+
}
282+
277283
// how we extended emscripten Module
278284
export type DotnetModule = EmscriptenModule & DotnetModuleConfig;
279285
export type DotnetModuleInternal = EmscriptenModule & DotnetModuleConfig & EmscriptenModuleInternal;
@@ -290,6 +296,7 @@ export type EmscriptenBuildOptions = {
290296
wasmEnableEH: boolean,
291297
enableAotProfiler: boolean,
292298
enableBrowserProfiler: boolean,
299+
enableLogProfiler: boolean,
293300
runAOTCompilation: boolean,
294301
wasmEnableThreads: boolean,
295302
gitHash: string,

src/mono/mono.proj

+3
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,9 @@ JS_ENGINES = [NODE_JS]
11851185
<_MonoRuntimeArtifacts Condition="'$(TargetsBrowser)' == 'true' and '$(BuildMonoAOTCrossCompilerOnly)' != 'true'" Include="$(MonoObjDir)out\lib\libmono-profiler-aot.a">
11861186
<Destination>$(RuntimeBinDir)libmono-profiler-aot.a</Destination>
11871187
</_MonoRuntimeArtifacts>
1188+
<_MonoRuntimeArtifacts Condition="'$(TargetsBrowser)' == 'true' and '$(BuildMonoAOTCrossCompilerOnly)' != 'true'" Include="$(MonoObjDir)out\lib\libmono-profiler-log.a">
1189+
<Destination>$(RuntimeBinDir)libmono-profiler-log.a</Destination>
1190+
</_MonoRuntimeArtifacts>
11881191
<_MonoRuntimeArtifacts Condition="'$(TargetsBrowser)' == 'true' and '$(BuildMonoAOTCrossCompilerOnly)' != 'true'" Include="$(MonoObjDir)out\lib\libmono-profiler-browser.a">
11891192
<Destination>$(RuntimeBinDir)libmono-profiler-browser.a</Destination>
11901193
</_MonoRuntimeArtifacts>

src/mono/mono/mini/mini-wasm.c

-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,6 @@ mono_init_native_crash_info (void)
577577
void
578578
mono_runtime_setup_stat_profiler (void)
579579
{
580-
g_error ("mono_runtime_setup_stat_profiler");
581580
}
582581

583582
gboolean

src/mono/mono/profiler/CMakeLists.txt

+15
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ include_directories(
66
${PROJECT_BINARY_DIR}/../../mono/eglib
77
${CMAKE_CURRENT_SOURCE_DIR}/../..
88
${PROJECT_SOURCE_DIR}/../
9+
${PROJECT_SOURCE_DIR}/../../../native/public
910
${PROJECT_SOURCE_DIR}/../eglib
1011
${PROJECT_SOURCE_DIR}/../sgen)
1112

@@ -47,4 +48,18 @@ if(NOT DISABLE_LIBS)
4748
set_target_properties(mono-profiler-browser-static PROPERTIES OUTPUT_NAME mono-profiler-browser)
4849
install(TARGETS mono-profiler-browser-static LIBRARY)
4950
endif()
51+
52+
if(HOST_BROWSER)
53+
add_library(mono-profiler-log-static STATIC helper.c log.c log-args.c)
54+
set_target_properties(mono-profiler-log-static PROPERTIES OUTPUT_NAME mono-profiler-log)
55+
install(TARGETS mono-profiler-log-static LIBRARY)
56+
57+
if(NOT DISABLE_LOG_PROFILER_GZ)
58+
if (CLR_CMAKE_USE_SYSTEM_ZLIB)
59+
target_link_libraries(mono-profiler-log-static PRIVATE ${Z_LIBS})
60+
else()
61+
target_link_libraries(mono-profiler-log-static PRIVATE zlib)
62+
endif()
63+
endif()
64+
endif()
5065
endif()

src/mono/mono/profiler/helper.c

+6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
#include <config.h>
1010

11+
#if !defined (HOST_WASM)
1112
#include <mono/utils/mono-logger-internals.h>
13+
#endif
1214

1315
#ifdef HAVE_UNISTD_H
1416
#include <unistd.h>
@@ -42,6 +44,7 @@ mono_profhelper_close_socket_fd (SOCKET fd)
4244
void
4345
mono_profhelper_setup_command_server (SOCKET *server_socket, int *command_port, const char* profiler_name)
4446
{
47+
#if !defined (HOST_WASM)
4548
*server_socket = socket (PF_INET, SOCK_STREAM, 0);
4649

4750
if (*server_socket == INVALID_SOCKET) {
@@ -77,11 +80,13 @@ mono_profhelper_setup_command_server (SOCKET *server_socket, int *command_port,
7780
}
7881

7982
*command_port = ntohs (server_address.sin_port);
83+
#endif
8084
}
8185

8286
void
8387
mono_profhelper_add_to_fd_set (fd_set *set, SOCKET fd, int *max_fd)
8488
{
89+
#if !defined (HOST_WASM)
8590
/*
8691
* This should only trigger for the basic FDs (server socket, pipes) at
8792
* startup if for some mysterious reason they're too large. In this case,
@@ -99,4 +104,5 @@ mono_profhelper_add_to_fd_set (fd_set *set, SOCKET fd, int *max_fd)
99104

100105
if (*max_fd < GUINT64_TO_INT(fd))
101106
*max_fd = (int)fd;
107+
#endif
102108
}

src/mono/mono/profiler/log-args.c

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <config.h>
2+
#include <mono/metadata/debug-helpers.h>
23
#include <mono/utils/mono-logger-internals.h>
34
#include <mono/utils/mono-proclib.h>
45
#include <mono/utils/w32subset.h>
@@ -98,6 +99,9 @@ parse_arg (const char *arg, ProfilerConfig *config)
9899
} else if (match_option (arg, "heapshot-on-shutdown", NULL)) {
99100
config->hs_on_shutdown = TRUE;
100101
config->enable_mask |= PROFLOG_HEAPSHOT_ALIAS;
102+
} else if (match_option (arg, "take-heapshot-method", &val)) {
103+
printf ("take-heapshot-method: %s\n", val);
104+
set_log_profiler_take_heapshot_method(val);
101105
} else if (match_option (arg, "sample", &val)) {
102106
set_sample_freq (config, val);
103107
config->sampling_mode = MONO_PROFILER_SAMPLE_MODE_PROCESS;

src/mono/mono/profiler/log.c

+62-1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ typedef struct {
189189
int small_id;
190190
} MonoProfilerThread;
191191

192+
static MonoMethodDesc *log_profiler_take_heapshot_method;
193+
192194
// Default value in `profiler_tls` for new threads.
193195
#define MONO_PROFILER_THREAD_ZERO ((MonoProfilerThread *) NULL)
194196

@@ -617,6 +619,7 @@ buffer_lock_helper (void);
617619
static void
618620
buffer_lock (void)
619621
{
622+
#if !defined (HOST_WASM)
620623
/*
621624
* If the thread holding the exclusive lock tries to modify the
622625
* reader count, just make it a no-op. This way, we also avoid
@@ -657,6 +660,8 @@ buffer_lock (void)
657660
}
658661

659662
mono_memory_barrier ();
663+
664+
#endif // HOST_WASM
660665
}
661666

662667
static void
@@ -685,6 +690,7 @@ buffer_lock_helper (void)
685690
static void
686691
buffer_unlock (void)
687692
{
693+
#if !defined (HOST_WASM)
688694
mono_memory_barrier ();
689695

690696
gint32 state = mono_atomic_load_i32 (&log_profiler.buffer_lock_state);
@@ -697,6 +703,7 @@ buffer_unlock (void)
697703
g_assert (!(state >> 16) && "Why is the exclusive lock held?");
698704

699705
mono_atomic_dec_i32 (&log_profiler.buffer_lock_state);
706+
#endif // HOST_WASM
700707
}
701708

702709
static void
@@ -3499,6 +3506,7 @@ runtime_initialized (MonoProfiler *profiler)
34993506

35003507
mono_os_sem_init (&log_profiler.attach_threads_sem, 0);
35013508

3509+
#if !defined (HOST_WASM)
35023510
/*
35033511
* We must start the helper thread before the writer thread. This is
35043512
* because start_helper_thread () sets up the command port which is written
@@ -3507,6 +3515,9 @@ runtime_initialized (MonoProfiler *profiler)
35073515
start_helper_thread ();
35083516
start_writer_thread ();
35093517
start_dumper_thread ();
3518+
#else
3519+
dump_header ();
3520+
#endif
35103521

35113522
/*
35123523
* Wait for all the internal threads to be started. If we don't do this, we
@@ -3588,7 +3599,7 @@ create_profiler (const char *args, const char *filename, GPtrArray *filters)
35883599
}
35893600
}
35903601
if (*nf == '|') {
3591-
#if HAVE_API_SUPPORT_WIN32_PIPE_OPEN_CLOSE && !defined (HOST_WIN32)
3602+
#if HAVE_API_SUPPORT_WIN32_PIPE_OPEN_CLOSE && !defined (HOST_WIN32) && !defined (HOST_WASM)
35923603
log_profiler.file = popen (nf + 1, "w");
35933604
log_profiler.pipe_output = 1;
35943605
#else
@@ -3636,6 +3647,44 @@ create_profiler (const char *args, const char *filename, GPtrArray *filters)
36363647
log_profiler.startup_time = current_time ();
36373648
}
36383649

3650+
void
3651+
set_log_profiler_take_heapshot_method (const char *val)
3652+
{
3653+
log_profiler_take_heapshot_method = mono_method_desc_new (val, TRUE);
3654+
3655+
if (!log_profiler_take_heapshot_method) {
3656+
mono_profiler_printf_err ("Could not parse method description: %s", val);
3657+
exit (1);
3658+
}
3659+
}
3660+
3661+
static void
3662+
proflog_trigger_heapshot (void);
3663+
3664+
static void
3665+
prof_jit_done (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo)
3666+
{
3667+
MonoImage *image = mono_class_get_image (mono_method_get_class (method));
3668+
3669+
if (!image->assembly || method->wrapper_type || !log_profiler_take_heapshot_method)
3670+
return;
3671+
3672+
if (log_profiler_take_heapshot_method && mono_method_desc_match (log_profiler_take_heapshot_method, method)) {
3673+
printf ("log-profiler | taking heapshot\n");
3674+
proflog_trigger_heapshot ();
3675+
return;
3676+
}
3677+
else {
3678+
printf ("log-profiler not called (%p)\n", log_profiler_take_heapshot_method);
3679+
}
3680+
}
3681+
3682+
static void
3683+
prof_inline_method (MonoProfiler *prof, MonoMethod *method, MonoMethod *inlined_method)
3684+
{
3685+
prof_jit_done (prof, inlined_method, NULL);
3686+
}
3687+
36393688
MONO_API void
36403689
mono_profiler_init_log (const char *desc);
36413690

@@ -3758,6 +3807,9 @@ mono_profiler_init_log (const char *desc)
37583807
mono_profiler_enable_allocations ();
37593808
mono_profiler_enable_clauses ();
37603809
mono_profiler_enable_sampling (handle);
3810+
mono_profiler_set_jit_done_callback (handle, prof_jit_done);
3811+
mono_profiler_set_inline_method_callback (handle, prof_inline_method);
3812+
37613813

37623814
/*
37633815
* If no sample option was given by the user, this just leaves the sampling
@@ -3770,3 +3822,12 @@ mono_profiler_init_log (const char *desc)
37703822
done:
37713823
;
37723824
}
3825+
3826+
static void
3827+
proflog_trigger_heapshot (void)
3828+
{
3829+
trigger_heapshot ();
3830+
3831+
while (handle_writer_queue_entry ());
3832+
while (handle_dumper_queue_entry ());
3833+
}

0 commit comments

Comments
 (0)