|
@@ -879,9 +879,10 @@ implementation
|
|
|
|
|
|
procedure tcgtryfinallynode.handle_safecall_exception;
|
|
procedure tcgtryfinallynode.handle_safecall_exception;
|
|
var
|
|
var
|
|
- cgpara: tcgpara;
|
|
|
|
|
|
+ cgpara, resultpara: tcgpara;
|
|
selfsym: tparavarsym;
|
|
selfsym: tparavarsym;
|
|
pd: tprocdef;
|
|
pd: tprocdef;
|
|
|
|
+ safecallresult: tlocalvarsym;
|
|
begin
|
|
begin
|
|
{ call fpc_safecallhandler, passing self for methods of classes,
|
|
{ call fpc_safecallhandler, passing self for methods of classes,
|
|
nil otherwise. }
|
|
nil otherwise. }
|
|
@@ -893,14 +894,16 @@ implementation
|
|
selfsym:=tparavarsym(current_procinfo.procdef.parast.Find('self'));
|
|
selfsym:=tparavarsym(current_procinfo.procdef.parast.Find('self'));
|
|
if (selfsym=nil) or (selfsym.typ<>paravarsym) then
|
|
if (selfsym=nil) or (selfsym.typ<>paravarsym) then
|
|
InternalError(2011123101);
|
|
InternalError(2011123101);
|
|
- cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,selfsym.localloc,cgpara);
|
|
|
|
|
|
+ hlcg.a_load_loc_cgpara(current_asmdata.CurrAsmList,selfsym.vardef,selfsym.localloc,cgpara);
|
|
end
|
|
end
|
|
else
|
|
else
|
|
- cg.a_load_const_cgpara(current_asmdata.CurrAsmList,OS_ADDR,0,cgpara);
|
|
|
|
|
|
+ hlcg.a_load_const_cgpara(current_asmdata.CurrAsmList,voidpointertype,0,cgpara);
|
|
paramanager.freecgpara(current_asmdata.CurrAsmList,cgpara);
|
|
paramanager.freecgpara(current_asmdata.CurrAsmList,cgpara);
|
|
|
|
+ resultpara:=hlcg.g_call_system_proc(current_asmdata.CurrAsmList,pd,[@cgpara],nil);
|
|
cgpara.done;
|
|
cgpara.done;
|
|
- cg.g_call(current_asmdata.CurrAsmList,'FPC_SAFECALLHANDLER');
|
|
|
|
- cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_INT,OS_INT,NR_FUNCTION_RESULT_REG, NR_FUNCTION_RETURN_REG);
|
|
|
|
|
|
+ safecallresult:=tlocalvarsym(current_procinfo.procdef.localst.Find('safecallresult'));
|
|
|
|
+ hlcg.gen_load_cgpara_loc(current_asmdata.CurrAsmList,resultpara.def,resultpara,safecallresult.localloc,false);
|
|
|
|
+ resultpara.resetiftemp;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -1052,8 +1055,7 @@ implementation
|
|
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,osuinttype,OC_EQ,0,reasonreg,endfinallylabel);
|
|
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,osuinttype,OC_EQ,0,reasonreg,endfinallylabel);
|
|
{ finally code only needed to be executed on exception (-> in
|
|
{ finally code only needed to be executed on exception (-> in
|
|
if-branch -> fc_inflowcontrol) }
|
|
if-branch -> fc_inflowcontrol) }
|
|
- if (tf_safecall_exceptions in target_info.flags) and
|
|
|
|
- (current_procinfo.procdef.proccalloption=pocall_safecall) then
|
|
|
|
|
|
+ if current_procinfo.procdef.generate_safecall_wrapper then
|
|
begin
|
|
begin
|
|
handle_safecall_exception;
|
|
handle_safecall_exception;
|
|
{ we have to jump immediatly as we have to return the value of FPC_SAFECALL }
|
|
{ we have to jump immediatly as we have to return the value of FPC_SAFECALL }
|
|
@@ -1073,8 +1075,7 @@ implementation
|
|
begin
|
|
begin
|
|
if implicitframe then
|
|
if implicitframe then
|
|
begin
|
|
begin
|
|
- if (tf_safecall_exceptions in target_info.flags) and
|
|
|
|
- (current_procinfo.procdef.proccalloption=pocall_safecall) then
|
|
|
|
|
|
+ if current_procinfo.procdef.generate_safecall_wrapper then
|
|
handle_safecall_exception
|
|
handle_safecall_exception
|
|
else
|
|
else
|
|
cexceptionstatehandler.handle_reraise(current_asmdata.CurrAsmList,excepttemps,finallyexceptionstate,exceptframekind);
|
|
cexceptionstatehandler.handle_reraise(current_asmdata.CurrAsmList,excepttemps,finallyexceptionstate,exceptframekind);
|