- Exception handling: calling FPC_CATCHES(-1) is obsolete, it does not change any state and its return value is not used. Removed.

- Don't generate guard frame around 'except' block if it contains no code (tryexceptnode.t1 is an empty blocknode in this case).

git-svn-id: trunk@19415 -
This commit is contained in:
sergei 2011-10-08 12:57:58 +00:00
parent fa4b78363c
commit 9ed2fa6f7b

View File

@ -98,7 +98,7 @@ implementation
nld,ncon,
tgobj,paramgr,
regvars,
cgutils,cgobj
cgutils,cgobj,nutils
;
{*****************************************************************************
@ -1158,20 +1158,16 @@ implementation
{ default handling except handling }
if assigned(t1) then
begin
{ FPC_CATCHES must be called with
'default handler' flag (=-1)
{ FPC_CATCHES with 'default handler' flag (=-1) need no longer be called,
it doesn't change any state and its return value is ignored (Sergei)
}
paraloc1.init;
paramanager.getintparaloc(pocall_default,1,paraloc1);
cg.a_load_const_cgpara(current_asmdata.CurrAsmList,OS_ADDR,-1,paraloc1);
paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
cg.allocallcpuregisters(current_asmdata.CurrAsmList);
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_CATCHES',false);
cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
paraloc1.done;
{ the destruction of the exception object must be also }
{ guarded by an exception frame }
{ guarded by an exception frame, but it can be omitted }
{ if there's no user code in 'except' block }
if not (has_no_code(t1)) then
begin
current_asmdata.getjumplabel(doobjectdestroy);
current_asmdata.getjumplabel(doobjectdestroyandreraise);
@ -1212,10 +1208,18 @@ implementation
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_RERAISE',false);
cg.a_label(current_asmdata.CurrAsmList,doobjectdestroy);
cleanupobjectstack;
unget_exception_temps(current_asmdata.CurrAsmList,destroytemps);
cg.a_jmp_always(current_asmdata.CurrAsmList,endexceptlabel);
end
else
begin
exceptflowcontrol:=flowcontrol;
cleanupobjectstack;
cg.a_jmp_always(current_asmdata.CurrAsmList,endexceptlabel);
end;
end
else
begin
cg.a_call_name(current_asmdata.CurrAsmList,'FPC_RERAISE',false);