@@ -2469,7 +2469,8 @@ static void record_dispatch_statement(jl_method_instance_t *mi)
24692469 s_dispatch = (JL_STREAM * ) & f_dispatch ;
24702470 }
24712471 }
2472- if (!jl_has_free_typevars (mi -> specTypes )) {
2472+ // NOTE: Sometimes the specType is just `Tuple`, which is not useful to print.
2473+ if (!jl_has_free_typevars (mi -> specTypes ) && (jl_datatype_t * )mi -> specTypes != jl_tuple_type ) {
24732474 jl_printf (s_dispatch , "precompile(" );
24742475 jl_static_show (s_dispatch , mi -> specTypes );
24752476 jl_printf (s_dispatch , ")\n" );
@@ -2479,6 +2480,19 @@ static void record_dispatch_statement(jl_method_instance_t *mi)
24792480 JL_UNLOCK (& dispatch_statement_out_lock );
24802481}
24812482
2483+ static void record_dispatch_statement_on_first_dispatch (jl_method_instance_t * mfunc ) {
2484+ uint8_t force_trace_dispatch = jl_atomic_load_relaxed (& jl_force_trace_dispatch_enabled );
2485+ if (force_trace_dispatch || jl_options .trace_dispatch != NULL ) {
2486+ uint8_t miflags = jl_atomic_load_relaxed (& mfunc -> flags );
2487+ uint8_t was_dispatched = miflags & JL_MI_FLAGS_MASK_DISPATCHED ;
2488+ if (!was_dispatched ) {
2489+ miflags |= JL_MI_FLAGS_MASK_DISPATCHED ;
2490+ jl_atomic_store_relaxed (& mfunc -> flags , miflags );
2491+ record_dispatch_statement (mfunc );
2492+ }
2493+ }
2494+ }
2495+
24822496jl_method_instance_t * jl_normalize_to_compilable_mi (jl_method_instance_t * mi JL_PROPAGATES_ROOT );
24832497
24842498jl_code_instance_t * jl_compile_method_internal (jl_method_instance_t * mi , size_t world )
@@ -3162,6 +3176,11 @@ STATIC_INLINE jl_method_instance_t *jl_lookup_generic_(jl_value_t *F, jl_value_t
31623176 jl_atomic_store_relaxed (& pick_which [cache_idx [0 ]], which );
31633177 jl_atomic_store_release (& call_cache [cache_idx [which & 3 ]], entry );
31643178 }
3179+ if (entry ) {
3180+ // mfunc was found in slow path, so log --trace-dispatch
3181+ jl_method_instance_t * mfunc = entry -> func .linfo ;
3182+ record_dispatch_statement_on_first_dispatch (mfunc );
3183+ }
31653184 }
31663185
31673186 jl_method_instance_t * mfunc ;
@@ -3188,23 +3207,15 @@ STATIC_INLINE jl_method_instance_t *jl_lookup_generic_(jl_value_t *F, jl_value_t
31883207 jl_method_error (F , args , nargs , world );
31893208 // unreachable
31903209 }
3191- // mfunc is about to be dispatched
3192- uint8_t force_trace_dispatch = jl_atomic_load_relaxed (& jl_force_trace_dispatch_enabled );
3193- if (force_trace_dispatch || jl_options .trace_dispatch != NULL ) {
3194- uint8_t miflags = jl_atomic_load_relaxed (& mfunc -> flags );
3195- uint8_t was_dispatched = miflags & JL_MI_FLAGS_MASK_DISPATCHED ;
3196- if (!was_dispatched ) {
3197- miflags |= JL_MI_FLAGS_MASK_DISPATCHED ;
3198- jl_atomic_store_relaxed (& mfunc -> flags , miflags );
3199- record_dispatch_statement (mfunc );
3200- }
3201- }
3210+ // mfunc was found in slow path, so log --trace-dispatch
3211+ record_dispatch_statement_on_first_dispatch (mfunc );
32023212 }
32033213
32043214#ifdef JL_TRACE
32053215 if (traceen )
32063216 jl_printf (JL_STDOUT , " at %s:%d\n" , jl_symbol_name (mfunc -> def .method -> file ), mfunc -> def .method -> line );
32073217#endif
3218+
32083219 return mfunc ;
32093220}
32103221
0 commit comments