Skip to content
Merged
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
35 changes: 23 additions & 12 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2469,7 +2469,8 @@ static void record_dispatch_statement(jl_method_instance_t *mi)
s_dispatch = (JL_STREAM*) &f_dispatch;
}
}
if (!jl_has_free_typevars(mi->specTypes)) {
// NOTE: Sometimes the specType is just `Tuple`, which is not useful to print.
if (!jl_has_free_typevars(mi->specTypes) && (jl_datatype_t*)mi->specTypes != jl_tuple_type) {
jl_printf(s_dispatch, "precompile(");
jl_static_show(s_dispatch, mi->specTypes);
jl_printf(s_dispatch, ")\n");
Expand All @@ -2479,6 +2480,19 @@ static void record_dispatch_statement(jl_method_instance_t *mi)
JL_UNLOCK(&dispatch_statement_out_lock);
}

static void record_dispatch_statement_on_first_dispatch(jl_method_instance_t *mfunc) {
uint8_t force_trace_dispatch = jl_atomic_load_relaxed(&jl_force_trace_dispatch_enabled);
if (force_trace_dispatch || jl_options.trace_dispatch != NULL) {
uint8_t miflags = jl_atomic_load_relaxed(&mfunc->flags);
uint8_t was_dispatched = miflags & JL_MI_FLAGS_MASK_DISPATCHED;
if (!was_dispatched) {
miflags |= JL_MI_FLAGS_MASK_DISPATCHED;
jl_atomic_store_relaxed(&mfunc->flags, miflags);
record_dispatch_statement(mfunc);
}
}
}

jl_method_instance_t *jl_normalize_to_compilable_mi(jl_method_instance_t *mi JL_PROPAGATES_ROOT);

jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t world)
Expand Down Expand Up @@ -3162,6 +3176,11 @@ STATIC_INLINE jl_method_instance_t *jl_lookup_generic_(jl_value_t *F, jl_value_t
jl_atomic_store_relaxed(&pick_which[cache_idx[0]], which);
jl_atomic_store_release(&call_cache[cache_idx[which & 3]], entry);
}
if (entry) {
// mfunc was found in slow path, so log --trace-dispatch
jl_method_instance_t *mfunc = entry->func.linfo;
record_dispatch_statement_on_first_dispatch(mfunc);
}
}

jl_method_instance_t *mfunc;
Expand All @@ -3188,23 +3207,15 @@ STATIC_INLINE jl_method_instance_t *jl_lookup_generic_(jl_value_t *F, jl_value_t
jl_method_error(F, args, nargs, world);
// unreachable
}
// mfunc is about to be dispatched
uint8_t force_trace_dispatch = jl_atomic_load_relaxed(&jl_force_trace_dispatch_enabled);
if (force_trace_dispatch || jl_options.trace_dispatch != NULL) {
uint8_t miflags = jl_atomic_load_relaxed(&mfunc->flags);
uint8_t was_dispatched = miflags & JL_MI_FLAGS_MASK_DISPATCHED;
if (!was_dispatched) {
miflags |= JL_MI_FLAGS_MASK_DISPATCHED;
jl_atomic_store_relaxed(&mfunc->flags, miflags);
record_dispatch_statement(mfunc);
}
}
// mfunc was found in slow path, so log --trace-dispatch
record_dispatch_statement_on_first_dispatch(mfunc);
}

#ifdef JL_TRACE
if (traceen)
jl_printf(JL_STDOUT, " at %s:%d\n", jl_symbol_name(mfunc->def.method->file), mfunc->def.method->line);
#endif

return mfunc;
}

Expand Down