Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/mono/mono/metadata/jit-icall-reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ MONO_JIT_ICALL (mono_throw_platform_not_supported) \
MONO_JIT_ICALL (mono_throw_invalid_program) \
MONO_JIT_ICALL (mono_throw_type_load) \
MONO_JIT_ICALL (mono_trace_enter_method) \
MONO_JIT_ICALL (mono_trace_samplepoint_method) \
MONO_JIT_ICALL (mono_trace_leave_method) \
MONO_JIT_ICALL (mono_trace_tail_method) \
MONO_JIT_ICALL (mono_upgrade_remote_class_wrapper) \
Expand Down
9 changes: 7 additions & 2 deletions src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3969,6 +3969,11 @@ mono_interp_profiler_raise_tail_call (InterpFrame *frame, MonoMethod *new_method
mono_interp_profiler_raise (frame, mono_profiler_raise_method_ ## name_lower); \
}

#define INTERP_PROFILER_RAISE_SAMPLEPOINT() \
if ((flag & PROFILING_FLAG) && MONO_PROFILER_ENABLED (method_samplepoint)) { \
frame->state.ip = ip; \
mono_interp_profiler_raise (frame, mono_profiler_raise_method_samplepoint); \
}

/*
* If CLAUSE_ARGS is non-null, start executing from it.
Expand Down Expand Up @@ -7696,7 +7701,7 @@ MINT_IN_CASE(MINT_BRTRUE_I8_SP) ZEROP_SP(gint64, !=); MINT_IN_BREAK;
MINT_IN_CASE(MINT_PROF_SAMPLEPOINT) {
guint16 flag = ip [1];
ip += 2;
INTERP_PROFILER_RAISE(samplepoint, SAMPLEPOINT);
INTERP_PROFILER_RAISE_SAMPLEPOINT();
MINT_IN_BREAK;
}
MINT_IN_CASE(MINT_PROF_EXIT)
Expand Down Expand Up @@ -9231,7 +9236,7 @@ EMSCRIPTEN_KEEPALIVE void
mono_jiterp_prof_samplepoint (InterpFrame *frame, guint16 *ip)
{
guint16 flag = ip [1];
INTERP_PROFILER_RAISE(samplepoint, SAMPLEPOINT);
INTERP_PROFILER_RAISE_SAMPLEPOINT();
}

EMSCRIPTEN_KEEPALIVE void
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ handle_branch (TransformData *td, int long_op, int offset)
guint16 samplepoint_profiling = 0;
if (mono_jit_trace_calls != NULL && mono_trace_eval (rtm->method))
samplepoint_profiling |= TRACING_FLAG;
if (rtm->prof_flags & (MONO_PROFILER_CALL_INSTRUMENTATION_SAMPLEPOINT | MONO_PROFILER_CALL_INSTRUMENTATION_SAMPLEPOINT_CONTEXT ))
if (rtm->prof_flags & (MONO_PROFILER_CALL_INSTRUMENTATION_SAMPLEPOINT))
samplepoint_profiling |= PROFILING_FLAG;
if (samplepoint_profiling) {
interp_add_ins (td, MINT_PROF_SAMPLEPOINT);
Expand Down
16 changes: 5 additions & 11 deletions src/mono/mono/mini/mini-profiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,19 @@ mini_profiler_emit_samplepoint (MonoCompile *cfg)
if (cfg->current_method != cfg->method)
return;

gboolean trace = mono_jit_trace_calls != NULL && mono_trace_eval (cfg->method);

if (!trace && (!(MONO_CFG_PROFILE (cfg, SAMPLEPOINT) || MONO_CFG_PROFILE (cfg, SAMPLEPOINT_CONTEXT)) || (cfg->compile_aot && !can_encode_method_ref (cfg->method))))
if (!MONO_CFG_PROFILE (cfg, SAMPLEPOINT) || (cfg->compile_aot && !can_encode_method_ref (cfg->method)))
return;

MonoInst *iargs [3];

EMIT_NEW_METHODCONST (cfg, iargs [0], cfg->method);
EMIT_NEW_PCONST (cfg, iargs [1], NULL);
if (MONO_CFG_PROFILE (cfg, SAMPLEPOINT_CONTEXT))
iargs [2] = emit_fill_call_ctx (cfg, iargs [0], NULL);
else
EMIT_NEW_PCONST (cfg, iargs [2], NULL);
// SAMPLEPOINT_CONTEXT alternative is not implemented because emit_fill_call_ctx would stack-allocate inside of a loop
EMIT_NEW_PCONST (cfg, iargs [2], NULL);

/* void mono_profiler_raise_method_samplepoint (MonoMethod *method, MonoJitInfo *ji, MonoProfilerCallContext *ctx) */
if (trace)
mono_emit_jit_icall (cfg, mono_trace_samplepoint_method, iargs);
else
mono_emit_jit_icall (cfg, mono_profiler_raise_method_samplepoint, iargs);
mono_emit_jit_icall (cfg, mono_profiler_raise_method_samplepoint, iargs);

}

void
Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/mini/mini-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -4934,7 +4934,6 @@ register_icalls (void)
register_icall (mono_profiler_raise_exception_clause, mono_icall_sig_void_ptr_int_int_object, TRUE);

register_icall (mono_trace_enter_method, mono_icall_sig_void_ptr_ptr_ptr, TRUE);
register_icall (mono_trace_samplepoint_method, mono_icall_sig_void_ptr_ptr_ptr, TRUE);
register_icall (mono_trace_leave_method, mono_icall_sig_void_ptr_ptr_ptr, TRUE);
register_icall (mono_trace_tail_method, mono_icall_sig_void_ptr_ptr_ptr, TRUE);
g_assert (mono_get_lmf_addr == mono_tls_get_lmf_addr);
Expand Down
5 changes: 2 additions & 3 deletions src/mono/mono/mini/mini.c
Original file line number Diff line number Diff line change
Expand Up @@ -3456,8 +3456,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, JitFlags flags, int parts
if (trace)
cfg->prof_flags = (MonoProfilerCallInstrumentationFlags)(
MONO_PROFILER_CALL_INSTRUMENTATION_ENTER | MONO_PROFILER_CALL_INSTRUMENTATION_ENTER_CONTEXT |
MONO_PROFILER_CALL_INSTRUMENTATION_LEAVE | MONO_PROFILER_CALL_INSTRUMENTATION_LEAVE_CONTEXT |
MONO_PROFILER_CALL_INSTRUMENTATION_SAMPLEPOINT | MONO_PROFILER_CALL_INSTRUMENTATION_SAMPLEPOINT_CONTEXT);
MONO_PROFILER_CALL_INSTRUMENTATION_LEAVE | MONO_PROFILER_CALL_INSTRUMENTATION_LEAVE_CONTEXT );

/* The debugger has no liveness information, so avoid sharing registers/stack slots */
if (mini_debug_options.mdb_optimizations || MONO_CFG_PROFILE_CALL_CONTEXT (cfg)) {
Expand Down Expand Up @@ -3750,7 +3749,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, JitFlags flags, int parts
mono_cfg_dump_ir (cfg, "insert_safepoints");
}

if (MONO_CFG_PROFILE (cfg, SAMPLEPOINT) || MONO_CFG_PROFILE (cfg, SAMPLEPOINT_CONTEXT)) {
if (MONO_CFG_PROFILE (cfg, SAMPLEPOINT)) {
MONO_TIME_TRACK (mono_jit_stats.jit_insert_samplepoints, insert_samplepoints (cfg));
mono_cfg_dump_ir (cfg, "insert_samplepoints");
}
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/mini.h
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,7 @@ typedef struct {
G_UNLIKELY ((cfg)->prof_flags & MONO_PROFILER_CALL_INSTRUMENTATION_ ## flag)

#define MONO_CFG_PROFILE_CALL_CONTEXT(cfg) \
(MONO_CFG_PROFILE (cfg, ENTER_CONTEXT) || MONO_CFG_PROFILE (cfg, SAMPLEPOINT_CONTEXT) || MONO_CFG_PROFILE (cfg, LEAVE_CONTEXT))
(MONO_CFG_PROFILE (cfg, ENTER_CONTEXT) || MONO_CFG_PROFILE (cfg, LEAVE_CONTEXT))

typedef enum {
MONO_CFG_HAS_ALLOCA = 1 << 0,
Expand Down
16 changes: 1 addition & 15 deletions src/mono/mono/mini/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,8 @@ frame_kind (MonoJitInfo *ji)
return 'c';
}

static void mono_trace_enter_method_impl (const char *prefix, MonoMethod *method, MonoJitInfo *ji, MonoProfilerCallContext *ctx);

void
mono_trace_enter_method (MonoMethod *method, MonoJitInfo *ji, MonoProfilerCallContext *ctx)
{
mono_trace_enter_method_impl ("ENTER:%c %s(", method, ji, ctx);
}

void
mono_trace_samplepoint_method (MonoMethod *method, MonoJitInfo *ji, MonoProfilerCallContext *ctx)
{
mono_trace_enter_method_impl ("SAMPLEPOINT:%c %s(", method, ji, ctx);
}

static void
mono_trace_enter_method_impl (const char *prefix, MonoMethod *method, MonoJitInfo *ji, MonoProfilerCallContext *ctx)
{
int i;
MonoClass *klass;
Expand All @@ -176,7 +162,7 @@ mono_trace_enter_method_impl (const char *prefix, MonoMethod *method, MonoJitInf
if (!ji)
ji = mini_jit_info_table_find ((char *)MONO_RETURN_ADDRESS ());

printf (prefix, frame_kind (ji), fname);
printf ("ENTER:%c %s(", frame_kind (ji), fname);
g_free (fname);

sig = mono_method_signature_internal (method);
Expand Down
4 changes: 0 additions & 4 deletions src/mono/mono/mini/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ ICALL_EXPORT
void
mono_trace_enter_method (MonoMethod *method, MonoJitInfo *ji, MonoProfilerCallContext *ctx);

ICALL_EXPORT
void
mono_trace_samplepoint_method (MonoMethod *method, MonoJitInfo *ji, MonoProfilerCallContext *ctx);

ICALL_EXPORT
void
mono_trace_leave_method (MonoMethod *method, MonoJitInfo *ji, MonoProfilerCallContext *ctx);
Expand Down
4 changes: 0 additions & 4 deletions src/native/public/mono/metadata/details/profiler-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ typedef enum {
* Instrument method samplepoints
*/
MONO_PROFILER_CALL_INSTRUMENTATION_SAMPLEPOINT = 1 << 7,
/**
* Instrument method samplepoints with context.
*/
MONO_PROFILER_CALL_INSTRUMENTATION_SAMPLEPOINT_CONTEXT = 1 << 8,
} MonoProfilerCallInstrumentationFlags;

typedef MonoProfilerCallInstrumentationFlags (*MonoProfilerCallInstrumentationFilterCallback) (MonoProfiler *prof, MonoMethod *method);
Expand Down
Loading