@@ -243,7 +243,10 @@ static void jl_ci_cache_lookup(const jl_cgparams_t &cgparams, jl_method_instance
243
243
if (*src_out && jl_is_method (def)) {
244
244
PTR_PIN (def);
245
245
PTR_PIN (codeinst);
246
- *src_out = jl_uncompress_ir (def, codeinst, (jl_array_t *)*src_out);
246
+ PTR_PIN (*src_out);
247
+ auto temp = jl_uncompress_ir (def, codeinst, (jl_array_t *)*src_out);
248
+ PTR_UNPIN (*src_out);
249
+ *src_out = temp;
247
250
PTR_UNPIN (codeinst);
248
251
PTR_UNPIN (def);
249
252
}
@@ -255,7 +258,10 @@ static void jl_ci_cache_lookup(const jl_cgparams_t &cgparams, jl_method_instance
255
258
else {
256
259
*src_out = jl_type_infer (mi, world, 0 );
257
260
if (*src_out) {
258
- codeinst = jl_get_method_inferred (mi, (*src_out)->rettype , (*src_out)->min_world , (*src_out)->max_world );
261
+ auto rettype = (*src_out)->rettype ;
262
+ PTR_PIN (rettype);
263
+ codeinst = jl_get_method_inferred (mi, rettype, (*src_out)->min_world , (*src_out)->max_world );
264
+ PTR_UNPIN (rettype);
259
265
if ((*src_out)->inferred ) {
260
266
jl_value_t *null = nullptr ;
261
267
jl_atomic_cmpswap_relaxed (&codeinst->inferred , &null, jl_nothing);
@@ -326,11 +332,22 @@ void *jl_create_native_impl(jl_array_t *methods, LLVMOrcThreadSafeModuleRef llvm
326
332
// to compile, or an svec(rettype, sig) describing a C-callable alias to create.
327
333
jl_value_t *item = jl_array_ptr_ref (methods, i);
328
334
if (jl_is_simplevector (item)) {
329
- if (worlds == 1 )
330
- jl_compile_extern_c (wrap (&clone), ¶ms, NULL , jl_svecref (item, 0 ), jl_svecref (item, 1 ));
335
+ if (worlds == 1 ) {
336
+ // warp is not a safepoint, but it is a function defined in LLVM. We cannot persuade GCChecker that item won't be moved.
337
+ PTR_PIN (item);
338
+ auto el0 = jl_svecref (item, 0 );
339
+ auto el1 = jl_svecref (item, 1 );
340
+ PTR_PIN (el0);
341
+ PTR_PIN (el1);
342
+ jl_compile_extern_c (wrap (&clone), ¶ms, NULL , el0, el1);
343
+ PTR_UNPIN (el1);
344
+ PTR_UNPIN (el0);
345
+ PTR_UNPIN (item);
346
+ }
331
347
continue ;
332
348
}
333
349
mi = (jl_method_instance_t *)item;
350
+ PTR_PIN (mi);
334
351
src = NULL ;
335
352
// if this method is generally visible to the current compilation world,
336
353
// and this is either the primary world, or not applicable in the primary world
@@ -342,17 +359,18 @@ void *jl_create_native_impl(jl_array_t *methods, LLVMOrcThreadSafeModuleRef llvm
342
359
if (src && !emitted.count (codeinst)) {
343
360
// now add it to our compilation results
344
361
JL_GC_PROMISE_ROOTED (codeinst->rettype );
362
+ PTR_PIN (codeinst->rettype );
345
363
orc::ThreadSafeModule result_m = jl_create_ts_module (name_from_method_instance (codeinst->def ),
346
364
params.tsctx , params.imaging ,
347
365
clone.getModuleUnlocked ()->getDataLayout (),
348
366
Triple (clone.getModuleUnlocked ()->getTargetTriple ()));
349
- PTR_PIN (codeinst->rettype );
350
367
jl_llvm_functions_t decls = jl_emit_code (result_m, mi, src, codeinst->rettype , params);
351
368
PTR_UNPIN (codeinst->rettype );
352
369
if (result_m)
353
370
emitted[codeinst] = {std::move (result_m), std::move (decls)};
354
371
}
355
372
}
373
+ PTR_UNPIN (mi);
356
374
}
357
375
358
376
// finally, make sure all referenced methods also get compiled or fixed up
@@ -1048,8 +1066,11 @@ void jl_add_optimization_passes_impl(LLVMPassManagerRef PM, int opt_level, int l
1048
1066
extern " C" JL_DLLEXPORT
1049
1067
void jl_get_llvmf_defn_impl (jl_llvmf_dump_t * dump, jl_method_instance_t *mi, size_t world, char getwrapper, char optimize, const jl_cgparams_t params)
1050
1068
{
1051
- if (jl_is_method (mi->def .method ) && mi->def .method ->source == NULL &&
1052
- mi->def .method ->generator == NULL ) {
1069
+ // Extract this as a new var, otherwise GCChecker won't work correctly.
1070
+ auto method = mi->def .method ;
1071
+ PTR_PIN (method);
1072
+ if (jl_is_method (method) && method->source == NULL &&
1073
+ method->generator == NULL ) {
1053
1074
// not a generic function
1054
1075
dump->F = NULL ;
1055
1076
return ;
@@ -1059,27 +1080,29 @@ void jl_get_llvmf_defn_impl(jl_llvmf_dump_t* dump, jl_method_instance_t *mi, siz
1059
1080
jl_value_t *jlrettype = (jl_value_t *)jl_any_type;
1060
1081
jl_code_info_t *src = NULL ;
1061
1082
JL_GC_PUSH2 (&src, &jlrettype);
1062
- if (jl_is_method (mi-> def . method ) && mi-> def . method ->source != NULL && jl_ir_flag_inferred ((jl_array_t *)mi-> def . method ->source )) {
1063
- src = (jl_code_info_t *)mi-> def . method ->source ;
1083
+ if (jl_is_method (method) && method->source != NULL && jl_ir_flag_inferred ((jl_array_t *)method->source )) {
1084
+ src = (jl_code_info_t *)method->source ;
1064
1085
if (src && !jl_is_code_info (src))
1065
- src = jl_uncompress_ir (mi-> def . method , NULL , (jl_array_t *)src);
1086
+ src = jl_uncompress_ir (method, NULL , (jl_array_t *)src);
1066
1087
} else {
1067
1088
jl_value_t *ci = jl_rettype_inferred (mi, world, world);
1068
1089
if (ci != jl_nothing) {
1069
1090
jl_code_instance_t *codeinst = (jl_code_instance_t *)ci;
1091
+ PTR_PIN (codeinst);
1070
1092
src = (jl_code_info_t *)jl_atomic_load_relaxed (&codeinst->inferred );
1071
- if ((jl_value_t *)src != jl_nothing && !jl_is_code_info (src) && jl_is_method (mi-> def . method ))
1072
- src = jl_uncompress_ir (mi-> def . method , codeinst, (jl_array_t *)src);
1093
+ if ((jl_value_t *)src != jl_nothing && !jl_is_code_info (src) && jl_is_method (method))
1094
+ src = jl_uncompress_ir (method, codeinst, (jl_array_t *)src);
1073
1095
jlrettype = codeinst->rettype ;
1096
+ PTR_UNPIN (codeinst);
1074
1097
}
1075
1098
if (!src || (jl_value_t *)src == jl_nothing) {
1076
1099
src = jl_type_infer (mi, world, 0 );
1077
1100
if (src)
1078
1101
jlrettype = src->rettype ;
1079
- else if (jl_is_method (mi-> def . method )) {
1080
- src = mi-> def . method ->generator ? jl_code_for_staged (mi) : (jl_code_info_t *)mi-> def . method ->source ;
1081
- if (src && !jl_is_code_info (src) && jl_is_method (mi-> def . method ))
1082
- src = jl_uncompress_ir (mi-> def . method , NULL , (jl_array_t *)src);
1102
+ else if (jl_is_method (method)) {
1103
+ src = method->generator ? jl_code_for_staged (mi) : (jl_code_info_t *)method->source ;
1104
+ if (src && !jl_is_code_info (src) && jl_is_method (method))
1105
+ src = jl_uncompress_ir (method, NULL , (jl_array_t *)src);
1083
1106
}
1084
1107
// TODO: use mi->uninferred
1085
1108
}
@@ -1131,6 +1154,7 @@ void jl_get_llvmf_defn_impl(jl_llvmf_dump_t* dump, jl_method_instance_t *mi, siz
1131
1154
fname = &decls.functionObject ;
1132
1155
F = cast<Function>(m.getModuleUnlocked ()->getNamedValue (*fname));
1133
1156
}
1157
+ PTR_UNPIN (method);
1134
1158
JL_GC_POP ();
1135
1159
if (measure_compile_time_enabled) {
1136
1160
auto end = jl_hrtime ();
0 commit comments