@@ -2316,8 +2316,10 @@ jl_code_instance_t *jl_method_compiled(jl_method_instance_t *mi, size_t world)
2316
2316
jl_code_instance_t * codeinst = jl_atomic_load_relaxed (& mi -> cache );
2317
2317
while (codeinst ) {
2318
2318
if (codeinst -> min_world <= world && world <= codeinst -> max_world ) {
2319
- if (jl_atomic_load_relaxed (& codeinst -> invoke ) != NULL )
2319
+ jl_callptr_t invoke = jl_atomic_load_acquire (& codeinst -> invoke );
2320
+ if (invoke != NULL ) {
2320
2321
return codeinst ;
2322
+ }
2321
2323
}
2322
2324
codeinst = jl_atomic_load_relaxed (& codeinst -> next );
2323
2325
}
@@ -2859,20 +2861,19 @@ STATIC_INLINE jl_value_t *verify_type(jl_value_t *v) JL_NOTSAFEPOINT
2859
2861
return v ;
2860
2862
}
2861
2863
2864
+ STATIC_INLINE jl_value_t * invoke_codeinst (jl_value_t * F , jl_value_t * * args , uint32_t nargs , jl_code_instance_t * codeinst )
2865
+ {
2866
+ jl_callptr_t invoke = jl_atomic_load_acquire (& codeinst -> invoke );
2867
+ jl_value_t * res = invoke (F , args , nargs , codeinst );
2868
+ return verify_type (res );
2869
+ }
2870
+
2862
2871
STATIC_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 )
2863
2872
{
2864
2873
// manually inlined copy of jl_method_compiled
2865
- jl_code_instance_t * codeinst = jl_atomic_load_relaxed (& mfunc -> cache );
2866
- while (codeinst ) {
2867
- if (codeinst -> min_world <= world && world <= codeinst -> max_world ) {
2868
- jl_callptr_t invoke = jl_atomic_load_acquire (& codeinst -> invoke );
2869
- if (invoke != NULL ) {
2870
- jl_value_t * res = invoke (F , args , nargs , codeinst );
2871
- return verify_type (res );
2872
- }
2873
- }
2874
- codeinst = jl_atomic_load_relaxed (& codeinst -> next );
2875
- }
2874
+ jl_code_instance_t * codeinst = jl_method_compiled (mfunc , world );
2875
+ if (codeinst )
2876
+ return invoke_codeinst (F , args , nargs , codeinst );
2876
2877
int64_t last_alloc = jl_options .malloc_log ? jl_gc_diff_total_bytes () : 0 ;
2877
2878
int last_errno = errno ;
2878
2879
#ifdef _OS_WINDOWS_
@@ -2885,9 +2886,7 @@ STATIC_INLINE jl_value_t *_jl_invoke(jl_value_t *F, jl_value_t **args, uint32_t
2885
2886
errno = last_errno ;
2886
2887
if (jl_options .malloc_log )
2887
2888
jl_gc_sync_total_bytes (last_alloc ); // discard allocation count from compilation
2888
- jl_callptr_t invoke = jl_atomic_load_acquire (& codeinst -> invoke );
2889
- jl_value_t * res = invoke (F , args , nargs , codeinst );
2890
- return verify_type (res );
2889
+ return invoke_codeinst (F , args , nargs , codeinst );
2891
2890
}
2892
2891
2893
2892
JL_DLLEXPORT jl_value_t * jl_invoke (jl_value_t * F , jl_value_t * * args , uint32_t nargs , jl_method_instance_t * mfunc )
0 commit comments