@@ -7065,44 +7065,43 @@ static void emit_specsig_to_specsig(
70657065 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);
70667066}
70677067
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)
70697069{
70707070 // this builds a method that calls a method with the same arguments but a different specsig
70717071 // build a specsig -> specsig converter thunk
70727072 // build a specsig -> arg1 converter thunk
70737073 // build a args1 -> specsig converter thunk (gen_invoke_wrapper)
70747074 // build a args1 -> args1 converter thunk (to add typeassert on result)
70757075 bool needsparams = false ;
7076- bool is_opaque_closure = false ;
7076+ bool target_is_opaque_closure = false ;
70777077 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 );
70797079 gf_thunk_name += " _gfthunk" ;
70807080 if (target_specsig) {
70817081 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,
70857085 target, mi->specTypes , codeinst->rettype , &targetspec, nullptr );
70867086 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);
70887088 }
70897089 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,
70927092 target, mi->specTypes , codeinst->rettype , nullptr , nullptr );
70937093 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);
70957095 }
70967096 return gf_thunk_name;
70977097}
70987098
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)
71007100{
71017101 // this builds a method that calls a method with the same arguments but a different specsig
71027102 // build a specsig -> args1 (apply_generic) or invoke (emit_tojlinvoke) call
71037103 // build a args1 -> args1 call (emit_fptr1_wrapper)
71047104 // build a args1 -> invoke call (emit_tojlinvoke)
7105- bool is_opaque_closure = false ;
71067105 Value *target;
71077106 if (!codeinst)
71087107 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
71147113 else
71157114 raw_string_ostream (gf_thunk_name) << " j_" ;
71167115 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 );
71207119 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);
71227121 return gf_thunk_name;
71237122}
71247123
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)
71267125{
7127- bool is_opaque_closure = false ;
71287126 std::string gf_thunk_name;
71297127 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);
71337131 }
71347132 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);
71367134 }
71377135 return gf_thunk_name;
71387136}
71397137
71407138std::string emit_abi_constreturn (Module *M, jl_codegen_params_t ¶ms, bool specsig, jl_code_instance_t *codeinst)
71417139{
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 );
71447150}
71457151
71467152// 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_
71967202 cw->setAttributes (getcaller->getAttributes ());
71977203 return cw;
71987204 });
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});
72007207 if (specsig) {
72017208 // TODO: could we force this to guarantee passing a box for `f` here (since we
72027209 // know we had it here) and on the receiver end (emit_abi_converter /
0 commit comments