* properly fix raise node handling on x86-64 after r24288

git-svn-id: trunk@24334 -
This commit is contained in:
florian 2013-04-26 20:17:54 +00:00
parent e212901658
commit a07af824ea
2 changed files with 14 additions and 89 deletions

View File

@ -73,7 +73,6 @@ interface
end;
tcgraisenode = class(traisenode)
procedure pass_generate_code;override;
end;
tcgtryexceptnode = class(ttryexceptnode)
@ -949,89 +948,6 @@ implementation
end;
{*****************************************************************************
SecondRaise
*****************************************************************************}
procedure tcgraisenode.pass_generate_code;
var
a : tasmlabel;
href2: treference;
paraloc1,paraloc2,paraloc3 : tcgpara;
pd : tprocdef;
begin
location_reset(location,LOC_VOID,OS_NO);
if assigned(left) then
begin
pd:=search_system_proc('fpc_raiseexception');
paraloc1.init;
paraloc2.init;
paraloc3.init;
paramanager.getintparaloc(pd,1,paraloc1);
paramanager.getintparaloc(pd,2,paraloc2);
paramanager.getintparaloc(pd,3,paraloc3);
{ multiple parameters? }
if assigned(right) then
begin
{ frame tree }
if assigned(third) then
secondpass(third);
secondpass(right);
end;
secondpass(left);
if codegenerror then
exit;
{ Push parameters }
if assigned(right) then
begin
{ frame tree }
if assigned(third) then
cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,third.location,paraloc3)
else
cg.a_load_const_cgpara(current_asmdata.CurrAsmList,OS_ADDR,0,paraloc3);
{ push address }
cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,right.location,paraloc2);
end
else
begin
{ get current address }
current_asmdata.getaddrlabel(a);
cg.a_label(current_asmdata.CurrAsmList,a);
reference_reset_symbol(href2,a,0,1);
{ push current frame }
cg.a_load_reg_cgpara(current_asmdata.CurrAsmList,OS_ADDR,NR_FRAME_POINTER_REG,paraloc3);
{ push current address }
if target_info.system <> system_powerpc_macos then
cg.a_loadaddr_ref_cgpara(current_asmdata.CurrAsmList,href2,paraloc2)
else
cg.a_load_const_cgpara(current_asmdata.CurrAsmList,OS_ADDR,0,paraloc2);
end;
cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,left.location,paraloc1);
paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc2);
paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc3);
cg.allocallcpuregisters(current_asmdata.CurrAsmList);
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_RAISEEXCEPTION',false);
cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
paraloc1.done;
paraloc2.done;
paraloc3.done;
end
else
begin
cg.allocallcpuregisters(current_asmdata.CurrAsmList);
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_POPADDRSTACK',false);
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_RERAISE',false);
cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
end;
end;
{*****************************************************************************
SecondTryExcept
*****************************************************************************}
@ -1665,3 +1581,4 @@ begin
ctryfinallynode:=tcgtryfinallynode;
connode:=tcgonnode;
end.

View File

@ -30,7 +30,7 @@ interface
type
tx64raisenode=class(tcgraisenode)
procedure pass_generate_code;override;
function pass_1 : tnode;override;
end;
tx64onnode=class(tcgonnode)
@ -66,14 +66,22 @@ implementation
{ tx64raisenode }
procedure tx64raisenode.pass_generate_code;
function tx64raisenode.pass_1 : tnode;
var
statements : tstatementnode;
raisenode : tcallnode;
begin
{ difference from generic code is that address stack is not popped on reraise }
if (target_info.system<>system_x86_64_win64) or assigned(left) then
inherited pass_generate_code
result:=inherited pass_1
else
cg.g_call(current_asmdata.CurrAsmList,'FPC_RERAISE');
end;
begin
result:=internalstatements(statements);
raisenode:=ccallnode.createintern('fpc_reraise',nil);
include(raisenode.callnodeflags,cnf_call_never_returns);
addstatement(statements,raisenode);
end;
end;
{ tx64onnode }