Skip to content

Commit 31ee1b4

Browse files
committed
WIP: Add ABIOverwrite type for def field
Together with #54899, this PR is intending to replicate the functionality of #54373, which allowed particular specializations to have a different ABI signature than what would be suggested by the MethodInstance's `specTypes` field. This PR handles that by adding a special `ABIOverwrite` type, which, when placed in the `def` field of a `CodeInstance` instructs the system to use the given signature instead.
1 parent aa05c98 commit 31ee1b4

20 files changed

+115
-73
lines changed

Compiler/src/stmtinfo.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function _add_edges_impl(edges::Vector{Any}, info::MethodMatchInfo, mi_edge::Boo
7070
mi = specialize_method(m) # don't allow `Method`-edge for this optimized format
7171
edge = mi
7272
else
73-
mi = edge.def
73+
mi = edge.def::MethodInstance
7474
end
7575
if mi.specTypes === m.spec_types
7676
add_one_edge!(edges, edge)
@@ -100,7 +100,7 @@ end
100100
function add_one_edge!(edges::Vector{Any}, edge::MethodInstance)
101101
for i in 1:length(edges)
102102
edgeᵢ = edges[i]
103-
edgeᵢ isa CodeInstance && (edgeᵢ = edgeᵢ.def)
103+
edgeᵢ isa CodeInstance && (edgeᵢ = edgeᵢ.def::MethodInstance)
104104
edgeᵢ isa MethodInstance || continue
105105
if edgeᵢ === edge && !(i > 1 && edges[i-1] isa Type)
106106
return # found existing covered edge
@@ -112,7 +112,7 @@ end
112112
function add_one_edge!(edges::Vector{Any}, edge::CodeInstance)
113113
for i in 1:length(edges)
114114
edgeᵢ_orig = edgeᵢ = edges[i]
115-
edgeᵢ isa CodeInstance && (edgeᵢ = edgeᵢ.def)
115+
edgeᵢ isa CodeInstance && (edgeᵢ = edgeᵢ.def::MethodInstance)
116116
edgeᵢ isa MethodInstance || continue
117117
if edgeᵢ === edge.def && !(i > 1 && edges[i-1] isa Type)
118118
if edgeᵢ_orig isa MethodInstance

base/boot.jl

+6
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,12 @@ struct InitError <: WrappedException
446446
error
447447
end
448448

449+
struct ABIOverwrite
450+
abi::Type
451+
def::MethodInstance
452+
ABIOverwrite(@nospecialize(abi::Type), def::MethodInstance) = new(abi, def)
453+
end
454+
449455
struct PrecompilableError <: Exception end
450456

451457
String(s::String) = s # no constructor yet

base/show.jl

+7-1
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,13 @@ end
13531353
show(io::IO, mi::Core.MethodInstance) = show_mi(io, mi)
13541354
function show(io::IO, codeinst::Core.CodeInstance)
13551355
print(io, "CodeInstance for ")
1356-
show_mi(io, codeinst.def)
1356+
def = codeinst.def
1357+
if isa(def, Core.ABIOverwrite)
1358+
show_mi(io, def.def)
1359+
print(io, " (ABI Overriden)")
1360+
else
1361+
show_mi(io, def::MethodInstance)
1362+
end
13571363
end
13581364

13591365
function show_mi(io::IO, mi::Core.MethodInstance, from_stackframe::Bool=false)

src/aotcompile.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void jl_get_llvm_mis_impl(void *native_code, arraylist_t* MIs)
101101
jl_native_code_desc_t *data = (jl_native_code_desc_t*)native_code;
102102
auto map = data->jl_fvar_map;
103103
for (auto &ci : map) {
104-
jl_method_instance_t *mi = ci.first->def;
104+
jl_method_instance_t *mi = jl_get_ci_mi(ci.first);
105105
arraylist_push(MIs, mi);
106106
}
107107
}
@@ -344,11 +344,11 @@ static void compile_workqueue(jl_codegen_params_t &params, CompilationPolicy pol
344344
if ((policy != CompilationPolicy::Default || params.params->trim) &&
345345
jl_atomic_load_relaxed(&codeinst->inferred) == jl_nothing) {
346346
// XXX: SOURCE_MODE_FORCE_SOURCE is wrong here (neither sufficient nor necessary)
347-
codeinst = jl_type_infer(codeinst->def, jl_atomic_load_relaxed(&codeinst->max_world), SOURCE_MODE_FORCE_SOURCE);
347+
codeinst = jl_type_infer(jl_get_ci_mi(codeinst), jl_atomic_load_relaxed(&codeinst->max_world), SOURCE_MODE_FORCE_SOURCE);
348348
}
349349
if (codeinst) {
350350
orc::ThreadSafeModule result_m =
351-
jl_create_ts_module(name_from_method_instance(codeinst->def),
351+
jl_create_ts_module(name_from_method_instance(jl_get_ci_mi(codeinst)),
352352
params.tsctx, params.DL, params.TargetTriple);
353353
auto decls = jl_emit_codeinst(result_m, codeinst, NULL, params);
354354
if (result_m)
@@ -389,7 +389,7 @@ static void compile_workqueue(jl_codegen_params_t &params, CompilationPolicy pol
389389
proto.decl->setLinkage(GlobalVariable::InternalLinkage);
390390
//protodecl->setAlwaysInline();
391391
jl_init_function(proto.decl, params.TargetTriple);
392-
jl_method_instance_t *mi = codeinst->def;
392+
jl_method_instance_t *mi = jl_get_ci_mi(codeinst);
393393
size_t nrealargs = jl_nparams(mi->specTypes); // number of actual arguments being passed
394394
bool is_opaque_closure = jl_is_method(mi->def.value) && mi->def.method->is_for_opaque_closure;
395395
// TODO: maybe this can be cached in codeinst->specfptr?
@@ -527,7 +527,7 @@ void *jl_create_native_impl(jl_array_t *methods, LLVMOrcThreadSafeModuleRef llvm
527527
}
528528
else {
529529
JL_GC_PROMISE_ROOTED(codeinst->rettype);
530-
orc::ThreadSafeModule result_m = jl_create_ts_module(name_from_method_instance(codeinst->def),
530+
orc::ThreadSafeModule result_m = jl_create_ts_module(name_from_method_instance(jl_get_ci_mi(codeinst)),
531531
params.tsctx, clone.getModuleUnlocked()->getDataLayout(),
532532
Triple(clone.getModuleUnlocked()->getTargetTriple()));
533533
jl_llvm_functions_t decls = jl_emit_codeinst(result_m, codeinst, NULL, params);
@@ -2158,7 +2158,7 @@ void jl_get_llvmf_defn_impl(jl_llvmf_dump_t* dump, jl_method_instance_t *mi, jl_
21582158
// This would also be nice, but it seems to cause OOMs on the windows32 builder
21592159
// To get correct names in the IR this needs to be at least 2
21602160
output.debug_level = params.debug_info_level;
2161-
auto decls = jl_emit_code(m, mi, src, output);
2161+
auto decls = jl_emit_code(m, mi, src, NULL, output);
21622162

21632163
Function *F = NULL;
21642164
if (m) {

src/codegen.cpp

+40-29
Original file line numberDiff line numberDiff line change
@@ -3046,9 +3046,8 @@ static bool uses_specsig(jl_value_t *sig, bool needsparams, jl_value_t *rettype,
30463046
return false; // jlcall sig won't require any box allocations
30473047
}
30483048

3049-
static std::pair<bool, bool> uses_specsig(jl_method_instance_t *lam, jl_value_t *rettype, bool prefer_specsig)
3049+
static std::pair<bool, bool> uses_specsig(jl_value_t *abi, jl_method_instance_t *lam, jl_value_t *rettype, bool prefer_specsig)
30503050
{
3051-
jl_value_t *sig = lam->specTypes;
30523051
bool needsparams = false;
30533052
if (jl_is_method(lam->def.method)) {
30543053
if ((size_t)jl_subtype_env_size(lam->def.method->sig) != jl_svec_len(lam->sparam_vals))
@@ -3058,7 +3057,7 @@ static std::pair<bool, bool> uses_specsig(jl_method_instance_t *lam, jl_value_t
30583057
needsparams = true;
30593058
}
30603059
}
3061-
return std::make_pair(uses_specsig(sig, needsparams, rettype, prefer_specsig), needsparams);
3060+
return std::make_pair(uses_specsig(abi, needsparams, rettype, prefer_specsig), needsparams);
30623061
}
30633062

30643063

@@ -4373,6 +4372,7 @@ static jl_llvm_functions_t
43734372
orc::ThreadSafeModule &TSM,
43744373
jl_method_instance_t *lam,
43754374
jl_code_info_t *src,
4375+
jl_value_t *abi,
43764376
jl_value_t *rettype,
43774377
jl_codegen_params_t &params);
43784378

@@ -5490,6 +5490,13 @@ static jl_cgval_t emit_invoke(jl_codectx_t &ctx, jl_expr_t *ex, jl_value_t *rt)
54905490
return emit_invoke(ctx, lival, argv, nargs, rt);
54915491
}
54925492

5493+
static jl_value_t *get_ci_abi(jl_code_instance_t *ci)
5494+
{
5495+
if (jl_typeof(ci->def) == (jl_value_t*)jl_abioverwrite_type)
5496+
return ((jl_abi_overwrite_t*)ci->def)->abi;
5497+
return jl_get_ci_mi(ci)->specTypes;
5498+
}
5499+
54935500
static jl_cgval_t emit_invoke(jl_codectx_t &ctx, const jl_cgval_t &lival, ArrayRef<jl_cgval_t> argv, size_t nargs, jl_value_t *rt)
54945501
{
54955502
++EmittedInvokes;
@@ -5525,7 +5532,7 @@ static jl_cgval_t emit_invoke(jl_codectx_t &ctx, const jl_cgval_t &lival, ArrayR
55255532
}
55265533
else if (invoke != jl_fptr_sparam_addr) {
55275534
bool specsig, needsparams;
5528-
std::tie(specsig, needsparams) = uses_specsig(mi, codeinst->rettype, ctx.params->prefer_specsig);
5535+
std::tie(specsig, needsparams) = uses_specsig(get_ci_abi(codeinst), mi, codeinst->rettype, ctx.params->prefer_specsig);
55295536
std::string name;
55305537
StringRef protoname;
55315538
bool need_to_emit = true;
@@ -7200,7 +7207,7 @@ Function *emit_tojlinvoke(jl_code_instance_t *codeinst, StringRef theFptrName, M
72007207
jl_init_function(f, params.TargetTriple);
72017208
if (trim_may_error(params.params->trim)) {
72027209
// TODO: Debuginfo!
7203-
push_frames(ctx, ctx.linfo, codeinst->def, 1);
7210+
push_frames(ctx, ctx.linfo, jl_get_ci_mi(codeinst), 1);
72047211
}
72057212
jl_name_jlfunc_args(params, f);
72067213
//f->setAlwaysInline();
@@ -7217,7 +7224,7 @@ Function *emit_tojlinvoke(jl_code_instance_t *codeinst, StringRef theFptrName, M
72177224
}
72187225
else {
72197226
theFunc = prepare_call(jlinvoke_func);
7220-
theFarg = literal_pointer_val(ctx, (jl_value_t*)codeinst->def);
7227+
theFarg = literal_pointer_val(ctx, (jl_value_t*)jl_get_ci_mi(codeinst));
72217228
}
72227229
theFarg = track_pjlvalue(ctx, theFarg);
72237230
auto args = f->arg_begin();
@@ -8327,13 +8334,13 @@ get_specsig_di(jl_codectx_t &ctx, jl_debugcache_t &debuginfo, jl_value_t *rt, jl
83278334
}
83288335

83298336
/* aka Core.Compiler.tuple_tfunc */
8330-
static jl_datatype_t *compute_va_type(jl_method_instance_t *lam, size_t nreq)
8337+
static jl_datatype_t *compute_va_type(jl_value_t *sig, size_t nreq)
83318338
{
8332-
size_t nvargs = jl_nparams(lam->specTypes)-nreq;
8339+
size_t nvargs = jl_nparams(sig)-nreq;
83338340
jl_svec_t *tupargs = jl_alloc_svec(nvargs);
83348341
JL_GC_PUSH1(&tupargs);
8335-
for (size_t i = nreq; i < jl_nparams(lam->specTypes); ++i) {
8336-
jl_value_t *argType = jl_nth_slot_type(lam->specTypes, i);
8342+
for (size_t i = nreq; i < jl_nparams(sig); ++i) {
8343+
jl_value_t *argType = jl_nth_slot_type(sig, i);
83378344
// n.b. specTypes is required to be a datatype by construction for specsig
83388345
if (is_uniquerep_Type(argType))
83398346
argType = jl_typeof(jl_tparam0(argType));
@@ -8373,6 +8380,7 @@ static jl_llvm_functions_t
83738380
orc::ThreadSafeModule &TSM,
83748381
jl_method_instance_t *lam,
83758382
jl_code_info_t *src,
8383+
jl_value_t *abi,
83768384
jl_value_t *jlrettype,
83778385
jl_codegen_params_t &params)
83788386
{
@@ -8453,7 +8461,7 @@ static jl_llvm_functions_t
84538461
int n_ssavalues = jl_is_long(src->ssavaluetypes) ? jl_unbox_long(src->ssavaluetypes) : jl_array_nrows(src->ssavaluetypes);
84548462
size_t vinfoslen = jl_array_dim0(src->slotflags);
84558463
ctx.slots.resize(vinfoslen, jl_varinfo_t(ctx.builder.getContext()));
8456-
assert(lam->specTypes); // the specTypes field should always be assigned
8464+
assert(abi); // the specTypes field should always be assigned
84578465

84588466

84598467
// create SAvalue locations for SSAValue objects
@@ -8462,7 +8470,7 @@ static jl_llvm_functions_t
84628470
ctx.ssavalue_usecount.assign(n_ssavalues, 0);
84638471

84648472
bool specsig, needsparams;
8465-
std::tie(specsig, needsparams) = uses_specsig(lam, jlrettype, params.params->prefer_specsig);
8473+
std::tie(specsig, needsparams) = uses_specsig(abi, lam, jlrettype, params.params->prefer_specsig);
84668474

84678475
// step 3. some variable analysis
84688476
size_t i;
@@ -8472,7 +8480,7 @@ static jl_llvm_functions_t
84728480
jl_sym_t *argname = slot_symbol(ctx, i);
84738481
if (argname == jl_unused_sym)
84748482
continue;
8475-
jl_value_t *ty = jl_nth_slot_type(lam->specTypes, i);
8483+
jl_value_t *ty = jl_nth_slot_type(abi, i);
84768484
// TODO: jl_nth_slot_type should call jl_rewrap_unionall
84778485
// specTypes is required to be a datatype by construction for specsig, but maybe not otherwise
84788486
// OpaqueClosure implicitly loads the env
@@ -8490,7 +8498,7 @@ static jl_llvm_functions_t
84908498
if (va && ctx.vaSlot != -1) {
84918499
jl_varinfo_t &varinfo = ctx.slots[ctx.vaSlot];
84928500
varinfo.isArgument = true;
8493-
vatyp = specsig ? compute_va_type(lam, nreq) : (jl_tuple_type);
8501+
vatyp = specsig ? compute_va_type(abi, nreq) : (jl_tuple_type);
84948502
varinfo.value = mark_julia_type(ctx, (Value*)NULL, false, vatyp);
84958503
}
84968504

@@ -8542,7 +8550,7 @@ static jl_llvm_functions_t
85428550
ArgNames[i] = name;
85438551
}
85448552
}
8545-
returninfo = get_specsig_function(ctx, M, NULL, declarations.specFunctionObject, lam->specTypes,
8553+
returninfo = get_specsig_function(ctx, M, NULL, declarations.specFunctionObject, abi,
85468554
jlrettype, ctx.is_opaque_closure, JL_FEAT_TEST(ctx,gcstack_arg),
85478555
ArgNames, nreq);
85488556
f = cast<Function>(returninfo.decl.getCallee());
@@ -8576,7 +8584,7 @@ static jl_llvm_functions_t
85768584
std::string wrapName;
85778585
raw_string_ostream(wrapName) << "jfptr_" << ctx.name << "_" << jl_atomic_fetch_add_relaxed(&globalUniqueGeneratedNames, 1);
85788586
declarations.functionObject = wrapName;
8579-
size_t nparams = jl_nparams(lam->specTypes);
8587+
size_t nparams = jl_nparams(abi);
85808588
gen_invoke_wrapper(lam, jlrettype, returninfo, nparams, retarg, ctx.is_opaque_closure, declarations.functionObject, M, ctx.emission_context);
85818589
// TODO: add attributes: maybe_mark_argument_dereferenceable(Arg, argType)
85828590
// TODO: add attributes: dereferenceable<sizeof(void*) * nreq>
@@ -8596,10 +8604,10 @@ static jl_llvm_functions_t
85968604
declarations.functionObject = needsparams ? "jl_fptr_sparam" : "jl_fptr_args";
85978605
}
85988606

8599-
if (ctx.emission_context.debug_level >= 2 && lam->def.method && jl_is_method(lam->def.method) && lam->specTypes != (jl_value_t*)jl_emptytuple_type) {
8607+
if (ctx.emission_context.debug_level >= 2 && lam->def.method && jl_is_method(lam->def.method) && abi != (jl_value_t*)jl_emptytuple_type) {
86008608
ios_t sigbuf;
86018609
ios_mem(&sigbuf, 0);
8602-
jl_static_show_func_sig((JL_STREAM*) &sigbuf, (jl_value_t*)lam->specTypes);
8610+
jl_static_show_func_sig((JL_STREAM*) &sigbuf, (jl_value_t*)abi);
86038611
f->addFnAttr("julia.fsig", StringRef(sigbuf.buf, sigbuf.size));
86048612
ios_close(&sigbuf);
86058613
}
@@ -8656,7 +8664,7 @@ static jl_llvm_functions_t
86568664
else if (!specsig)
86578665
subrty = debugcache.jl_di_func_sig;
86588666
else
8659-
subrty = get_specsig_di(ctx, debugcache, jlrettype, lam->specTypes, dbuilder);
8667+
subrty = get_specsig_di(ctx, debugcache, jlrettype, abi, dbuilder);
86608668
SP = dbuilder.createFunction(nullptr
86618669
,dbgFuncName // Name
86628670
,f->getName() // LinkageName
@@ -8987,7 +8995,7 @@ static jl_llvm_functions_t
89878995
nullptr, nullptr, /*isboxed*/true, AtomicOrdering::NotAtomic, false, sizeof(void*));
89888996
}
89898997
else {
8990-
jl_value_t *argType = jl_nth_slot_type(lam->specTypes, i);
8998+
jl_value_t *argType = jl_nth_slot_type(abi, i);
89918999
// TODO: jl_nth_slot_type should call jl_rewrap_unionall?
89929000
// specTypes is required to be a datatype by construction for specsig, but maybe not otherwise
89939001
bool isboxed = deserves_argbox(argType);
@@ -9061,10 +9069,10 @@ static jl_llvm_functions_t
90619069
assert(vi.boxroot == NULL);
90629070
}
90639071
else if (specsig) {
9064-
ctx.nvargs = jl_nparams(lam->specTypes) - nreq;
9072+
ctx.nvargs = jl_nparams(abi) - nreq;
90659073
SmallVector<jl_cgval_t, 0> vargs(ctx.nvargs);
9066-
for (size_t i = nreq; i < jl_nparams(lam->specTypes); ++i) {
9067-
jl_value_t *argType = jl_nth_slot_type(lam->specTypes, i);
9074+
for (size_t i = nreq; i < jl_nparams(abi); ++i) {
9075+
jl_value_t *argType = jl_nth_slot_type(abi, i);
90689076
// n.b. specTypes is required to be a datatype by construction for specsig
90699077
bool isboxed = deserves_argbox(argType);
90709078
Type *llvmArgType = isboxed ? ctx.types().T_prjlvalue : julia_type_to_llvm(ctx, argType);
@@ -10011,6 +10019,7 @@ jl_llvm_functions_t jl_emit_code(
1001110019
orc::ThreadSafeModule &m,
1001210020
jl_method_instance_t *li,
1001310021
jl_code_info_t *src,
10022+
jl_value_t *abi,
1001410023
jl_codegen_params_t &params)
1001510024
{
1001610025
JL_TIMING(CODEGEN, CODEGEN_LLVM);
@@ -10019,8 +10028,10 @@ jl_llvm_functions_t jl_emit_code(
1001910028
assert((params.params == &jl_default_cgparams /* fast path */ || !params.cache ||
1002010029
compare_cgparams(params.params, &jl_default_cgparams)) &&
1002110030
"functions compiled with custom codegen params must not be cached");
10031+
if (!abi)
10032+
abi = li->specTypes;
1002210033
JL_TRY {
10023-
decls = emit_function(m, li, src, src->rettype, params);
10034+
decls = emit_function(m, li, src, abi, src->rettype, params);
1002410035
auto stream = *jl_ExecutionEngine->get_dump_emitted_mi_name_stream();
1002510036
if (stream) {
1002610037
jl_printf(stream, "%s\t", decls.specFunctionObject.c_str());
@@ -10089,11 +10100,11 @@ jl_llvm_functions_t jl_emit_codeinst(
1008910100
jl_codegen_params_t &params)
1009010101
{
1009110102
JL_TIMING(CODEGEN, CODEGEN_Codeinst);
10092-
jl_timing_show_method_instance(codeinst->def, JL_TIMING_DEFAULT_BLOCK);
10103+
jl_timing_show_method_instance(jl_get_ci_mi(codeinst), JL_TIMING_DEFAULT_BLOCK);
1009310104
JL_GC_PUSH1(&src);
1009410105
if (!src) {
1009510106
src = (jl_code_info_t*)jl_atomic_load_relaxed(&codeinst->inferred);
10096-
jl_method_instance_t *mi = codeinst->def;
10107+
jl_method_instance_t *mi = jl_get_ci_mi(codeinst);
1009710108
jl_method_t *def = mi->def.method;
1009810109
// Check if this is the generic method for opaque closure wrappers -
1009910110
// if so, this must compile specptr such that it holds the specptr -> invoke wrapper
@@ -10111,15 +10122,15 @@ jl_llvm_functions_t jl_emit_codeinst(
1011110122
}
1011210123
}
1011310124
assert(jl_egal((jl_value_t*)jl_atomic_load_relaxed(&codeinst->debuginfo), (jl_value_t*)src->debuginfo) && "trying to generate code for a codeinst for an incompatible src");
10114-
jl_llvm_functions_t decls = jl_emit_code(m, codeinst->def, src, params);
10125+
jl_llvm_functions_t decls = jl_emit_code(m, jl_get_ci_mi(codeinst), src, get_ci_abi(codeinst), params);
1011510126

1011610127
const std::string &specf = decls.specFunctionObject;
1011710128
const std::string &f = decls.functionObject;
1011810129
if (params.cache && !f.empty()) {
1011910130
// Prepare debug info to receive this function
1012010131
// record that this function name came from this linfo,
1012110132
// so we can build a reverse mapping for debug-info.
10122-
bool toplevel = !jl_is_method(codeinst->def->def.method);
10133+
bool toplevel = !jl_is_method(jl_get_ci_mi(codeinst)->def.method);
1012310134
if (!toplevel) {
1012410135
//Safe b/c params holds context lock
1012510136
const DataLayout &DL = m.getModuleUnlocked()->getDataLayout();
@@ -10135,7 +10146,7 @@ jl_llvm_functions_t jl_emit_codeinst(
1013510146
jl_value_t *inferred = jl_atomic_load_relaxed(&codeinst->inferred);
1013610147
// don't change inferred state
1013710148
if (inferred) {
10138-
jl_method_t *def = codeinst->def->def.method;
10149+
jl_method_t *def = jl_get_ci_mi(codeinst)->def.method;
1013910150
if (// keep code when keeping everything
1014010151
!(JL_DELETE_NON_INLINEABLE) ||
1014110152
// aggressively keep code when debugging level >= 2

src/debuginfo.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void jl_add_code_in_flight(StringRef name, jl_code_instance_t *codeinst, const D
167167
// Non-opaque-closure MethodInstances are considered globally rooted
168168
// through their methods, but for OC, we need to create a global root
169169
// here.
170-
jl_method_instance_t *mi = codeinst->def;
170+
jl_method_instance_t *mi = jl_get_ci_mi(codeinst);
171171
if (jl_is_method(mi->def.value) && mi->def.method->is_for_opaque_closure)
172172
jl_as_global_root((jl_value_t*)mi, 1);
173173
getJITDebugRegistry().add_code_in_flight(name, codeinst, DL);
@@ -374,7 +374,7 @@ void JITDebugInfoRegistry::registerJITObject(const object::ObjectFile &Object,
374374
jl_method_instance_t *mi = NULL;
375375
if (codeinst) {
376376
JL_GC_PROMISE_ROOTED(codeinst);
377-
mi = codeinst->def;
377+
mi = jl_get_ci_mi(codeinst);
378378
}
379379
jl_profile_atomic([&]() JL_NOTSAFEPOINT {
380380
if (mi)

src/engine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void jl_engine_fulfill(jl_code_instance_t *ci, jl_code_info_t *src)
139139
{
140140
jl_task_t *ct = jl_current_task;
141141
std::unique_lock lock(engine_lock);
142-
auto record = Reservations.find(InferKey{ci->def, ci->owner});
142+
auto record = Reservations.find(InferKey{jl_get_ci_mi(ci), ci->owner});
143143
if (record == Reservations.end() || record->second.ci != ci)
144144
return;
145145
assert(jl_atomic_load_relaxed(&ct->tid) == record->second.tid);

0 commit comments

Comments
 (0)