@@ -3096,7 +3096,8 @@ static void record_dispatch_statement(jl_method_instance_t *mi)
3096
3096
s_dispatch = (JL_STREAM * ) & f_dispatch ;
3097
3097
}
3098
3098
}
3099
- if (!jl_has_free_typevars (mi -> specTypes )) {
3099
+ // NOTE: For builtin functions, the specType is just `Tuple`, which is not useful to print.
3100
+ if (!jl_has_free_typevars (mi -> specTypes ) && (jl_datatype_t * )mi -> specTypes != jl_tuple_type ) {
3100
3101
jl_printf (s_dispatch , "precompile(" );
3101
3102
jl_static_show (s_dispatch , mi -> specTypes );
3102
3103
jl_printf (s_dispatch , ")\n" );
@@ -3106,6 +3107,19 @@ static void record_dispatch_statement(jl_method_instance_t *mi)
3106
3107
JL_UNLOCK (& dispatch_statement_out_lock );
3107
3108
}
3108
3109
3110
+ static void record_dispatch_statement_on_first_dispatch (jl_method_instance_t * mfunc ) {
3111
+ uint8_t force_trace_dispatch = jl_atomic_load_relaxed (& jl_force_trace_dispatch_enabled );
3112
+ if (force_trace_dispatch || jl_options .trace_dispatch != NULL ) {
3113
+ uint8_t miflags = jl_atomic_load_relaxed (& mfunc -> flags );
3114
+ uint8_t was_dispatched = miflags & JL_MI_FLAGS_MASK_DISPATCHED ;
3115
+ if (!was_dispatched ) {
3116
+ miflags |= JL_MI_FLAGS_MASK_DISPATCHED ;
3117
+ jl_atomic_store_relaxed (& mfunc -> flags , miflags );
3118
+ record_dispatch_statement (mfunc );
3119
+ }
3120
+ }
3121
+ }
3122
+
3109
3123
// If waitcompile is 0, this will return NULL if compiling is on-going in the JIT. This is
3110
3124
// useful for the JIT itself, since it just doesn't cause redundant work or missed updates,
3111
3125
// but merely causes it to look into the current JIT worklist.
@@ -3941,6 +3955,11 @@ STATIC_INLINE jl_method_instance_t *jl_lookup_generic_(jl_value_t *F, jl_value_t
3941
3955
jl_atomic_store_relaxed (& pick_which [cache_idx [0 ]], which );
3942
3956
jl_atomic_store_release (& call_cache [cache_idx [which & 3 ]], entry );
3943
3957
}
3958
+ if (entry ) {
3959
+ // mfunc was found in slow path, so log --trace-dispatch
3960
+ jl_method_instance_t * mfunc = entry -> func .linfo ;
3961
+ record_dispatch_statement_on_first_dispatch (mfunc );
3962
+ }
3944
3963
}
3945
3964
3946
3965
jl_method_instance_t * mfunc ;
@@ -3963,23 +3982,15 @@ STATIC_INLINE jl_method_instance_t *jl_lookup_generic_(jl_value_t *F, jl_value_t
3963
3982
jl_method_error (F , args , nargs , world );
3964
3983
// unreachable
3965
3984
}
3966
- // mfunc is about to be dispatched
3967
- uint8_t force_trace_dispatch = jl_atomic_load_relaxed (& jl_force_trace_dispatch_enabled );
3968
- if (force_trace_dispatch || jl_options .trace_dispatch != NULL ) {
3969
- uint8_t miflags = jl_atomic_load_relaxed (& mfunc -> flags );
3970
- uint8_t was_dispatched = miflags & JL_MI_FLAGS_MASK_DISPATCHED ;
3971
- if (!was_dispatched ) {
3972
- miflags |= JL_MI_FLAGS_MASK_DISPATCHED ;
3973
- jl_atomic_store_relaxed (& mfunc -> flags , miflags );
3974
- record_dispatch_statement (mfunc );
3975
- }
3976
- }
3985
+ // mfunc was found in slow path, so log --trace-dispatch
3986
+ record_dispatch_statement_on_first_dispatch (mfunc );
3977
3987
}
3978
3988
3979
3989
#ifdef JL_TRACE
3980
3990
if (traceen )
3981
3991
jl_printf (JL_STDOUT , " at %s:%d\n" , jl_symbol_name (mfunc -> def .method -> file ), mfunc -> def .method -> line );
3982
3992
#endif
3993
+
3983
3994
return mfunc ;
3984
3995
}
3985
3996
0 commit comments