|
@@ -1936,7 +1936,13 @@ implementation
|
|
|
|
|
|
function thlcgobj.get_call_result_cgpara(pd: tabstractprocdef; forceresdef: tdef): tcgpara;
|
|
|
begin
|
|
|
- if not assigned(forceresdef) then
|
|
|
+ if pd.generate_safecall_wrapper then
|
|
|
+ begin
|
|
|
+ if assigned(forceresdef) then
|
|
|
+ internalerror(2019112401);
|
|
|
+ result:=paramanager.get_safecallresult_funcretloc(pd,callerside)
|
|
|
+ end
|
|
|
+ else if not assigned(forceresdef) then
|
|
|
begin
|
|
|
pd.init_paraloc_info(callerside);
|
|
|
result:=pd.funcretloc[callerside];
|
|
@@ -5307,27 +5313,39 @@ implementation
|
|
|
retdef : tdef;
|
|
|
begin
|
|
|
{ Is the loading needed? }
|
|
|
- if is_void(current_procinfo.procdef.returndef) or
|
|
|
+ if (is_void(current_procinfo.procdef.returndef) and
|
|
|
+ not current_procinfo.procdef.generate_safecall_wrapper) or
|
|
|
(
|
|
|
(po_assembler in current_procinfo.procdef.procoptions) and
|
|
|
- (not(assigned(current_procinfo.procdef.funcretsym)) or
|
|
|
+ (current_procinfo.procdef.generate_safecall_wrapper or
|
|
|
+ not assigned(current_procinfo.procdef.funcretsym) or
|
|
|
(tabstractvarsym(current_procinfo.procdef.funcretsym).refs=0) or
|
|
|
- (po_nostackframe in current_procinfo.procdef.procoptions))
|
|
|
+ (po_nostackframe in current_procinfo.procdef.procoptions)
|
|
|
+ )
|
|
|
) then
|
|
|
exit;
|
|
|
|
|
|
{ constructors return self }
|
|
|
- if not current_procinfo.procdef.getfuncretsyminfo(ressym,retdef) then
|
|
|
- internalerror(2018122501);
|
|
|
- if (ressym.refs>0) or
|
|
|
- is_managed_type(retdef) then
|
|
|
+ if current_procinfo.procdef.generate_safecall_wrapper then
|
|
|
begin
|
|
|
- { was: don't do anything if funcretloc.loc in [LOC_INVALID,LOC_REFERENCE] }
|
|
|
- if not paramanager.ret_in_param(current_procinfo.procdef.returndef,current_procinfo.procdef) then
|
|
|
- gen_load_loc_function_result(list,retdef,tabstractnormalvarsym(ressym).localloc);
|
|
|
+ if not current_procinfo.procdef.get_safecall_funcretsym_info(ressym,retdef) then
|
|
|
+ internalerror(2019112402);
|
|
|
+ gen_load_loc_function_result(list,retdef,tabstractnormalvarsym(ressym).localloc);
|
|
|
end
|
|
|
else
|
|
|
- gen_load_uninitialized_function_result(list,current_procinfo.procdef,retdef,current_procinfo.procdef.funcretloc[calleeside]);
|
|
|
+ begin
|
|
|
+ if not current_procinfo.procdef.get_funcretsym_info(ressym,retdef) then
|
|
|
+ internalerror(2018122501);
|
|
|
+ if (ressym.refs>0) or
|
|
|
+ is_managed_type(retdef) then
|
|
|
+ begin
|
|
|
+ { was: don't do anything if funcretloc.loc in [LOC_INVALID,LOC_REFERENCE] }
|
|
|
+ if not paramanager.ret_in_param(current_procinfo.procdef.returndef,current_procinfo.procdef) then
|
|
|
+ gen_load_loc_function_result(list,retdef,tabstractnormalvarsym(ressym).localloc);
|
|
|
+ end
|
|
|
+ else
|
|
|
+ gen_load_uninitialized_function_result(list,current_procinfo.procdef,retdef,current_procinfo.procdef.funcretloc[calleeside]);
|
|
|
+ end;
|
|
|
if tabstractnormalvarsym(ressym).localloc.loc=LOC_REFERENCE then
|
|
|
tg.UnGetLocal(list,tabstractnormalvarsym(ressym).localloc.reference);
|
|
|
end;
|