@@ -7065,44 +7065,43 @@ static void emit_specsig_to_specsig(
7065
7065
emit_specsig_to_specsig (gf_thunk, returninfo.cc , returninfo.return_roots , calltype, rettype, is_for_opaque_closure, nargs, params, target, targetsig, targetrt, targetspec, rettype_const);
7066
7066
}
7067
7067
7068
- std::string emit_abi_converter (Module *M, jl_codegen_params_t ¶ms, jl_value_t *declrt, jl_value_t *sigt, size_t nargs, bool specsig , jl_code_instance_t *codeinst, Value *target, bool target_specsig)
7068
+ std::string emit_abi_converter (Module *M, jl_codegen_params_t ¶ms, jl_abi_t from_abi , jl_code_instance_t *codeinst, Value *target, bool target_specsig)
7069
7069
{
7070
7070
// this builds a method that calls a method with the same arguments but a different specsig
7071
7071
// build a specsig -> specsig converter thunk
7072
7072
// build a specsig -> arg1 converter thunk
7073
7073
// build a args1 -> specsig converter thunk (gen_invoke_wrapper)
7074
7074
// build a args1 -> args1 converter thunk (to add typeassert on result)
7075
7075
bool needsparams = false ;
7076
- bool is_opaque_closure = false ;
7076
+ bool target_is_opaque_closure = false ;
7077
7077
jl_method_instance_t *mi = jl_get_ci_mi (codeinst);
7078
- std::string gf_thunk_name = get_function_name (specsig, needsparams, name_from_method_instance (mi), params.TargetTriple );
7078
+ std::string gf_thunk_name = get_function_name (from_abi. specsig , needsparams, name_from_method_instance (mi), params.TargetTriple );
7079
7079
gf_thunk_name += " _gfthunk" ;
7080
7080
if (target_specsig) {
7081
7081
jl_value_t *abi = get_ci_abi (codeinst);
7082
- jl_returninfo_t targetspec = get_specsig_function (params, M, target, " " , abi, codeinst->rettype , is_opaque_closure );
7083
- if (specsig)
7084
- emit_specsig_to_specsig (M, gf_thunk_name, sigt, declrt, is_opaque_closure, nargs, params,
7082
+ jl_returninfo_t targetspec = get_specsig_function (params, M, target, " " , abi, codeinst->rettype , target_is_opaque_closure );
7083
+ if (from_abi. specsig )
7084
+ emit_specsig_to_specsig (M, gf_thunk_name, from_abi. sigt , from_abi. rt , from_abi. is_opaque_closure , from_abi. nargs , params,
7085
7085
target, mi->specTypes , codeinst->rettype , &targetspec, nullptr );
7086
7086
else
7087
- gen_invoke_wrapper (mi, abi, codeinst->rettype , declrt , targetspec, nargs, -1 , is_opaque_closure, gf_thunk_name, M, params);
7087
+ gen_invoke_wrapper (mi, abi, codeinst->rettype , from_abi. rt , targetspec, from_abi. nargs , -1 , from_abi. is_opaque_closure , gf_thunk_name, M, params);
7088
7088
}
7089
7089
else {
7090
- if (specsig)
7091
- emit_specsig_to_specsig (M, gf_thunk_name, sigt, declrt, is_opaque_closure, nargs, params,
7090
+ if (from_abi. specsig )
7091
+ emit_specsig_to_specsig (M, gf_thunk_name, from_abi. sigt , from_abi. rt , from_abi. is_opaque_closure , from_abi. nargs , params,
7092
7092
target, mi->specTypes , codeinst->rettype , nullptr , nullptr );
7093
7093
else
7094
- emit_fptr1_wrapper (M, gf_thunk_name, target, nullptr , declrt , codeinst->rettype , params);
7094
+ emit_fptr1_wrapper (M, gf_thunk_name, target, nullptr , from_abi. rt , codeinst->rettype , params);
7095
7095
}
7096
7096
return gf_thunk_name;
7097
7097
}
7098
7098
7099
- std::string emit_abi_dispatcher (Module *M, jl_codegen_params_t ¶ms, jl_value_t *declrt, jl_value_t *sigt, size_t nargs, bool specsig , jl_code_instance_t *codeinst, Value *invoke)
7099
+ std::string emit_abi_dispatcher (Module *M, jl_codegen_params_t ¶ms, jl_abi_t from_abi , jl_code_instance_t *codeinst, Value *invoke)
7100
7100
{
7101
7101
// this builds a method that calls a method with the same arguments but a different specsig
7102
7102
// build a specsig -> args1 (apply_generic) or invoke (emit_tojlinvoke) call
7103
7103
// build a args1 -> args1 call (emit_fptr1_wrapper)
7104
7104
// build a args1 -> invoke call (emit_tojlinvoke)
7105
- bool is_opaque_closure = false ;
7106
7105
Value *target;
7107
7106
if (!codeinst)
7108
7107
target = prepare_call_in (M, jlapplygeneric_func);
@@ -7114,33 +7113,40 @@ std::string emit_abi_dispatcher(Module *M, jl_codegen_params_t ¶ms, jl_value
7114
7113
else
7115
7114
raw_string_ostream (gf_thunk_name) << " j_" ;
7116
7115
raw_string_ostream (gf_thunk_name) << jl_atomic_fetch_add_relaxed (&globalUniqueGeneratedNames, 1 ) << " _gfthunk" ;
7117
- if (specsig)
7118
- emit_specsig_to_specsig (M, gf_thunk_name, sigt, declrt, is_opaque_closure, nargs, params,
7119
- target, sigt, codeinst ? codeinst->rettype : (jl_value_t *)jl_any_type, nullptr , nullptr );
7116
+ if (from_abi. specsig )
7117
+ emit_specsig_to_specsig (M, gf_thunk_name, from_abi. sigt , from_abi. rt , from_abi. is_opaque_closure , from_abi. nargs , params,
7118
+ target, from_abi. sigt , codeinst ? codeinst->rettype : (jl_value_t *)jl_any_type, nullptr , nullptr );
7120
7119
else
7121
- emit_fptr1_wrapper (M, gf_thunk_name, target, nullptr , declrt , codeinst ? codeinst->rettype : (jl_value_t *)jl_any_type, params);
7120
+ emit_fptr1_wrapper (M, gf_thunk_name, target, nullptr , from_abi. rt , codeinst ? codeinst->rettype : (jl_value_t *)jl_any_type, params);
7122
7121
return gf_thunk_name;
7123
7122
}
7124
7123
7125
- std::string emit_abi_constreturn (Module *M, jl_codegen_params_t ¶ms, jl_value_t *declrt, jl_value_t *sigt, size_t nargs, bool specsig , jl_value_t *rettype_const)
7124
+ std::string emit_abi_constreturn (Module *M, jl_codegen_params_t ¶ms, jl_abi_t from_abi , jl_value_t *rettype_const)
7126
7125
{
7127
- bool is_opaque_closure = false ;
7128
7126
std::string gf_thunk_name;
7129
7127
raw_string_ostream (gf_thunk_name) << " jconst_" << jl_atomic_fetch_add_relaxed (&globalUniqueGeneratedNames, 1 );
7130
- if (specsig) {
7131
- emit_specsig_to_specsig (M, gf_thunk_name, sigt, declrt, is_opaque_closure, nargs, params,
7132
- nullptr , sigt, jl_typeof (rettype_const), nullptr , rettype_const);
7128
+ if (from_abi. specsig ) {
7129
+ emit_specsig_to_specsig (M, gf_thunk_name, from_abi. sigt , from_abi. rt , from_abi. is_opaque_closure , from_abi. nargs , params,
7130
+ nullptr , from_abi. sigt , jl_typeof (rettype_const), nullptr , rettype_const);
7133
7131
}
7134
7132
else {
7135
- emit_fptr1_wrapper (M, gf_thunk_name, nullptr , rettype_const, declrt , jl_typeof (rettype_const), params);
7133
+ emit_fptr1_wrapper (M, gf_thunk_name, nullptr , rettype_const, from_abi. rt , jl_typeof (rettype_const), params);
7136
7134
}
7137
7135
return gf_thunk_name;
7138
7136
}
7139
7137
7140
7138
std::string emit_abi_constreturn (Module *M, jl_codegen_params_t ¶ms, bool specsig, jl_code_instance_t *codeinst)
7141
7139
{
7142
- jl_value_t *abi = get_ci_abi (codeinst);
7143
- return emit_abi_constreturn (M, params, codeinst->rettype , abi, specsig ? jl_nparams (abi) : 0 , specsig, codeinst->rettype_const );
7140
+ jl_value_t *sigt = get_ci_abi (codeinst);
7141
+ jl_value_t *rt = codeinst->rettype ;
7142
+
7143
+ jl_method_instance_t *mi = jl_get_ci_mi (codeinst);
7144
+ bool is_opaque_closure = jl_is_method (mi->def .value ) && mi->def .method ->is_for_opaque_closure ;
7145
+
7146
+ size_t nargs = specsig ? jl_nparams (sigt) : 0 ;
7147
+ jl_abi_t abi = {sigt, rt, nargs, specsig, is_opaque_closure};
7148
+
7149
+ return emit_abi_constreturn (M, params, abi, codeinst->rettype_const );
7144
7150
}
7145
7151
7146
7152
// release jl_world_counter
@@ -7196,7 +7202,8 @@ static jl_cgval_t emit_abi_call(jl_codectx_t &ctx, jl_value_t *declrt, jl_value_
7196
7202
cw->setAttributes (getcaller->getAttributes ());
7197
7203
return cw;
7198
7204
});
7199
- ctx.emission_context .cfuncs .push_back ({declrt, sigt, nargs, specsig, cfuncdata});
7205
+ jl_abi_t cfuncabi = {sigt, declrt, nargs, specsig, is_opaque_closure};
7206
+ ctx.emission_context .cfuncs .push_back ({cfuncabi, cfuncdata});
7200
7207
if (specsig) {
7201
7208
// TODO: could we force this to guarantee passing a box for `f` here (since we
7202
7209
// know we had it here) and on the receiver end (emit_abi_converter /
0 commit comments