@@ -1225,17 +1225,19 @@ jl_generic_fptr_t jl_generate_fptr(jl_method_instance_t *li, void *_F, size_t wo
12251225 return fptr;
12261226}
12271227
1228- static Function *jl_cfunction_object (jl_function_t *f, jl_value_t *rt, jl_tupletype_t *argt);
1228+ static Function *jl_cfunction_object (jl_function_t *f, jl_value_t *rt, jl_tupletype_t *argt, size_t world );
12291229// get the address of a C-callable entry point for a function
12301230extern " C" JL_DLLEXPORT
12311231void *jl_function_ptr (jl_function_t *f, jl_value_t *rt, jl_value_t *argt)
12321232{
1233+ jl_ptls_t ptls = jl_get_ptls_states ();
12331234 JL_GC_PUSH1 (&argt);
12341235 if (jl_is_tuple (argt)) {
12351236 // TODO: maybe deprecation warning, better checking
12361237 argt = (jl_value_t *)jl_apply_tuple_type_v ((jl_value_t **)jl_data_ptr (argt), jl_nfields (argt));
12371238 }
1238- Function *llvmf = jl_cfunction_object (f, rt, (jl_tupletype_t *)argt);
1239+ Function *llvmf = jl_cfunction_object (f, rt, (jl_tupletype_t *)argt,
1240+ ptls->world_age );
12391241 JL_GC_POP ();
12401242 return (void *)getAddressForFunction (llvmf);
12411243}
@@ -1255,8 +1257,10 @@ void *jl_function_ptr_by_llvm_name(char *name) {
12551257extern " C" JL_DLLEXPORT
12561258void jl_extern_c (jl_function_t *f, jl_value_t *rt, jl_value_t *argt, char *name)
12571259{
1260+ jl_ptls_t ptls = jl_get_ptls_states ();
12581261 assert (jl_is_tuple_type (argt));
1259- Function *llvmf = jl_cfunction_object (f, rt, (jl_tupletype_t *)argt);
1262+ Function *llvmf = jl_cfunction_object (f, rt, (jl_tupletype_t *)argt,
1263+ ptls->world_age );
12601264 if (llvmf) {
12611265 // force eager emission of the function (llvm 3.3 gets confused otherwise and tries to do recursive compilation)
12621266 uint64_t Addr = getAddressForFunction (llvmf);
@@ -3739,7 +3743,7 @@ static Function *gen_cfun_wrapper(jl_function_t *ff, jl_value_t *jlrettype, jl_t
37393743 ctx.f = cw;
37403744 ctx.linfo = lam;
37413745 ctx.code = NULL ;
3742- ctx.world = jl_world_counter ;
3746+ ctx.world = world ;
37433747 ctx.sret = false ;
37443748 ctx.spvals_ptr = NULL ;
37453749 ctx.params = &jl_default_cgparams;
@@ -4000,7 +4004,7 @@ const struct jl_typemap_info cfunction_cache = {
40004004// Get the LLVM Function* for the C-callable entry point for a certain function
40014005// and argument types.
40024006// here argt does not include the leading function type argument
4003- static Function *jl_cfunction_object (jl_function_t *ff, jl_value_t *declrt, jl_tupletype_t *argt)
4007+ static Function *jl_cfunction_object (jl_function_t *ff, jl_value_t *declrt, jl_tupletype_t *argt, size_t world )
40044008{
40054009 // validate and unpack the arguments
40064010 JL_TYPECHK (cfunction, type, declrt);
@@ -4051,7 +4055,6 @@ static Function *jl_cfunction_object(jl_function_t *ff, jl_value_t *declrt, jl_t
40514055 cfunc_sig = (jl_value_t *)jl_apply_tuple_type ((jl_svec_t *)cfunc_sig);
40524056
40534057 // check the cache
4054- size_t world = jl_world_counter;
40554058 if (jl_cfunction_list.unknown != jl_nothing) {
40564059 jl_typemap_entry_t *sf = jl_typemap_assoc_by_type (jl_cfunction_list, (jl_tupletype_t *)cfunc_sig, NULL , 1 , 0 , /* offs*/ 0 , world);
40574060 if (sf) {
0 commit comments