@@ -2651,20 +2651,30 @@ JL_DLLEXPORT jl_value_t *jl_rettype_inferred_native(jl_method_instance_t *mi, si
26512651
26522652JL_DLLEXPORT jl_value_t * (* const jl_rettype_inferred_addr )(jl_method_instance_t * mi , size_t min_world , size_t max_world ) JL_NOTSAFEPOINT = jl_rettype_inferred_native ;
26532653
2654- jl_code_instance_t * jl_method_compiled (jl_method_instance_t * mi , size_t world )
2654+ STATIC_INLINE jl_callptr_t jl_method_compiled_callptr (jl_method_instance_t * mi , size_t world , jl_code_instance_t * * codeinst_out ) JL_NOTSAFEPOINT
26552655{
26562656 jl_code_instance_t * codeinst = jl_atomic_load_relaxed (& mi -> cache );
26572657 for (; codeinst ; codeinst = jl_atomic_load_relaxed (& codeinst -> next )) {
26582658 if (codeinst -> owner != jl_nothing )
26592659 continue ;
26602660 if (jl_atomic_load_relaxed (& codeinst -> min_world ) <= world && world <= jl_atomic_load_relaxed (& codeinst -> max_world )) {
2661- if (jl_atomic_load_relaxed (& codeinst -> invoke ) != NULL )
2662- return codeinst ;
2661+ jl_callptr_t invoke = jl_atomic_load_acquire (& codeinst -> invoke );
2662+ if (!invoke )
2663+ continue ;
2664+ * codeinst_out = codeinst ;
2665+ return invoke ;
26632666 }
26642667 }
26652668 return NULL ;
26662669}
26672670
2671+ jl_code_instance_t * jl_method_compiled (jl_method_instance_t * mi , size_t world ) JL_NOTSAFEPOINT
2672+ {
2673+ jl_code_instance_t * codeinst = NULL ;
2674+ jl_method_compiled_callptr (mi , world , & codeinst );
2675+ return codeinst ;
2676+ }
2677+
26682678jl_mutex_t precomp_statement_out_lock ;
26692679
26702680_Atomic(uint8_t ) jl_force_trace_compile_timing_enabled = 0 ;
@@ -3465,17 +3475,11 @@ STATIC_INLINE jl_value_t *verify_type(jl_value_t *v) JL_NOTSAFEPOINT
34653475
34663476STATIC_INLINE jl_value_t * _jl_invoke (jl_value_t * F , jl_value_t * * args , uint32_t nargs , jl_method_instance_t * mfunc , size_t world )
34673477{
3468- // manually inlined copy of jl_method_compiled
3469- jl_code_instance_t * codeinst = jl_atomic_load_relaxed (& mfunc -> cache );
3470- while (codeinst ) {
3471- if (jl_atomic_load_relaxed (& codeinst -> min_world ) <= world && world <= jl_atomic_load_relaxed (& codeinst -> max_world )) {
3472- jl_callptr_t invoke = jl_atomic_load_acquire (& codeinst -> invoke );
3473- if (invoke != NULL ) {
3474- jl_value_t * res = invoke (F , args , nargs , codeinst );
3475- return verify_type (res );
3476- }
3477- }
3478- codeinst = jl_atomic_load_relaxed (& codeinst -> next );
3478+ jl_code_instance_t * codeinst = NULL ;
3479+ jl_callptr_t invoke = jl_method_compiled_callptr (mfunc , world , & codeinst );
3480+ if (invoke ) {
3481+ jl_value_t * res = invoke (F , args , nargs , codeinst );
3482+ return verify_type (res );
34793483 }
34803484 int64_t last_alloc = jl_options .malloc_log ? jl_gc_diff_total_bytes () : 0 ;
34813485 int last_errno = errno ;
@@ -3489,7 +3493,7 @@ STATIC_INLINE jl_value_t *_jl_invoke(jl_value_t *F, jl_value_t **args, uint32_t
34893493 errno = last_errno ;
34903494 if (jl_options .malloc_log )
34913495 jl_gc_sync_total_bytes (last_alloc ); // discard allocation count from compilation
3492- jl_callptr_t invoke = jl_atomic_load_acquire (& codeinst -> invoke );
3496+ invoke = jl_atomic_load_acquire (& codeinst -> invoke );
34933497 jl_value_t * res = invoke (F , args , nargs , codeinst );
34943498 return verify_type (res );
34953499}
0 commit comments