mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 01:29:21 +02:00
* cleaner temp get/unget for exceptions
This commit is contained in:
parent
8d078ada18
commit
207e3b1231
@ -98,9 +98,6 @@ implementation
|
|||||||
{$endif cpu64bit}
|
{$endif cpu64bit}
|
||||||
;
|
;
|
||||||
|
|
||||||
const
|
|
||||||
EXCEPT_BUF_SIZE = 12;
|
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
Second_While_RepeatN
|
Second_While_RepeatN
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
@ -863,25 +860,6 @@ implementation
|
|||||||
endexceptlabel : tasmlabel;
|
endexceptlabel : tasmlabel;
|
||||||
|
|
||||||
|
|
||||||
procedure try_new_exception(list : taasmoutput;var jmpbuf,envbuf, href : treference;
|
|
||||||
a : aword; exceptlabel : tasmlabel);
|
|
||||||
begin
|
|
||||||
tg.GetTemp(list,EXCEPT_BUF_SIZE,tt_persistent,envbuf);
|
|
||||||
tg.GetTemp(list,JMP_BUF_SIZE,tt_persistent,jmpbuf);
|
|
||||||
tg.GetTemp(list,sizeof(aword),tt_persistent,href);
|
|
||||||
new_exception(list, jmpbuf,envbuf, href, a, exceptlabel);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure try_free_exception(list : taasmoutput;var jmpbuf, envbuf : treference;const href : treference;
|
|
||||||
a : aword ; endexceptlabel : tasmlabel; onlyfree : boolean);
|
|
||||||
begin
|
|
||||||
free_exception(list, jmpbuf, envbuf, href, a, endexceptlabel, onlyfree);
|
|
||||||
tg.Ungettemp(list,jmpbuf);
|
|
||||||
tg.ungettemp(list,envbuf);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ does the necessary things to clean up the object stack }
|
{ does the necessary things to clean up the object stack }
|
||||||
{ in the except block }
|
{ in the except block }
|
||||||
procedure cleanupobjectstack;
|
procedure cleanupobjectstack;
|
||||||
@ -919,8 +897,8 @@ implementation
|
|||||||
oldaktbreaklabel : tasmlabel;
|
oldaktbreaklabel : tasmlabel;
|
||||||
oldflowcontrol,tryflowcontrol,
|
oldflowcontrol,tryflowcontrol,
|
||||||
exceptflowcontrol : tflowcontrol;
|
exceptflowcontrol : tflowcontrol;
|
||||||
tempbuf,tempaddr : treference;
|
destroytemps,
|
||||||
href : treference;
|
excepttemps : texceptiontemps;
|
||||||
paraloc1 : tparalocation;
|
paraloc1 : tparalocation;
|
||||||
label
|
label
|
||||||
errorexit;
|
errorexit;
|
||||||
@ -956,7 +934,8 @@ implementation
|
|||||||
objectlibrary.getlabel(endexceptlabel);
|
objectlibrary.getlabel(endexceptlabel);
|
||||||
objectlibrary.getlabel(lastonlabel);
|
objectlibrary.getlabel(lastonlabel);
|
||||||
|
|
||||||
try_new_exception(exprasmlist,tempbuf,tempaddr,href,1,exceptlabel);
|
get_exception_temps(exprasmlist,excepttemps);
|
||||||
|
new_exception(exprasmlist,excepttemps,1,exceptlabel);
|
||||||
|
|
||||||
{ try block }
|
{ try block }
|
||||||
{ set control flow labels for the try block }
|
{ set control flow labels for the try block }
|
||||||
@ -975,7 +954,7 @@ implementation
|
|||||||
|
|
||||||
cg.a_label(exprasmlist,exceptlabel);
|
cg.a_label(exprasmlist,exceptlabel);
|
||||||
|
|
||||||
try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,endexceptlabel,false);
|
free_exception(exprasmlist, excepttemps, 0, endexceptlabel, false);
|
||||||
|
|
||||||
cg.a_label(exprasmlist,doexceptlabel);
|
cg.a_label(exprasmlist,doexceptlabel);
|
||||||
|
|
||||||
@ -1013,7 +992,8 @@ implementation
|
|||||||
objectlibrary.getlabel(doobjectdestroy);
|
objectlibrary.getlabel(doobjectdestroy);
|
||||||
objectlibrary.getlabel(doobjectdestroyandreraise);
|
objectlibrary.getlabel(doobjectdestroyandreraise);
|
||||||
|
|
||||||
try_new_exception(exprasmlist,tempbuf,tempaddr,href,1,doobjectdestroyandreraise);
|
get_exception_temps(exprasmlist,destroytemps);
|
||||||
|
new_exception(exprasmlist,destroytemps,1,doobjectdestroyandreraise);
|
||||||
|
|
||||||
{ here we don't have to reset flowcontrol }
|
{ here we don't have to reset flowcontrol }
|
||||||
{ the default and on flowcontrols are handled equal }
|
{ the default and on flowcontrols are handled equal }
|
||||||
@ -1022,7 +1002,7 @@ implementation
|
|||||||
|
|
||||||
cg.a_label(exprasmlist,doobjectdestroyandreraise);
|
cg.a_label(exprasmlist,doobjectdestroyandreraise);
|
||||||
|
|
||||||
try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,doobjectdestroy,false);
|
free_exception(exprasmlist,destroytemps,0,doobjectdestroy,false);
|
||||||
|
|
||||||
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
|
cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
|
||||||
@ -1041,6 +1021,7 @@ implementation
|
|||||||
|
|
||||||
cg.a_label(exprasmlist,doobjectdestroy);
|
cg.a_label(exprasmlist,doobjectdestroy);
|
||||||
cleanupobjectstack;
|
cleanupobjectstack;
|
||||||
|
unget_exception_temps(exprasmlist,destroytemps);
|
||||||
cg.a_jmp_always(exprasmlist,endexceptlabel);
|
cg.a_jmp_always(exprasmlist,endexceptlabel);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -1058,7 +1039,7 @@ implementation
|
|||||||
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
|
cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
|
||||||
cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.g_exception_reason_load(exprasmlist,href);
|
cg.g_exception_reason_load(exprasmlist,excepttemps.reasonbuf);
|
||||||
cleanupobjectstack;
|
cleanupobjectstack;
|
||||||
cg.a_jmp_always(exprasmlist,oldaktexitlabel);
|
cg.a_jmp_always(exprasmlist,oldaktexitlabel);
|
||||||
end;
|
end;
|
||||||
@ -1071,7 +1052,7 @@ implementation
|
|||||||
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
|
cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
|
||||||
cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.g_exception_reason_load(exprasmlist,href);
|
cg.g_exception_reason_load(exprasmlist,excepttemps.reasonbuf);
|
||||||
cleanupobjectstack;
|
cleanupobjectstack;
|
||||||
cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
|
cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
|
||||||
end;
|
end;
|
||||||
@ -1084,7 +1065,7 @@ implementation
|
|||||||
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
|
cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
|
||||||
cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.g_exception_reason_load(exprasmlist,href);
|
cg.g_exception_reason_load(exprasmlist,excepttemps.reasonbuf);
|
||||||
cleanupobjectstack;
|
cleanupobjectstack;
|
||||||
cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
|
cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
|
||||||
end;
|
end;
|
||||||
@ -1096,7 +1077,7 @@ implementation
|
|||||||
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
|
cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
|
||||||
cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.g_exception_reason_load(exprasmlist,href);
|
cg.g_exception_reason_load(exprasmlist,excepttemps.reasonbuf);
|
||||||
cg.a_jmp_always(exprasmlist,oldaktexitlabel);
|
cg.a_jmp_always(exprasmlist,oldaktexitlabel);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1106,7 +1087,7 @@ implementation
|
|||||||
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
|
cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
|
||||||
cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.g_exception_reason_load(exprasmlist,href);
|
cg.g_exception_reason_load(exprasmlist,excepttemps.reasonbuf);
|
||||||
cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
|
cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1116,10 +1097,10 @@ implementation
|
|||||||
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
|
cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
|
||||||
cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.g_exception_reason_load(exprasmlist,href);
|
cg.g_exception_reason_load(exprasmlist,excepttemps.reasonbuf);
|
||||||
cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
|
cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
|
||||||
end;
|
end;
|
||||||
tg.ungettemp(exprasmlist,href);
|
unget_exception_temps(exprasmlist,excepttemps);
|
||||||
cg.a_label(exprasmlist,endexceptlabel);
|
cg.a_label(exprasmlist,endexceptlabel);
|
||||||
|
|
||||||
errorexit:
|
errorexit:
|
||||||
@ -1152,9 +1133,8 @@ implementation
|
|||||||
doobjectdestroy,
|
doobjectdestroy,
|
||||||
oldaktbreaklabel : tasmlabel;
|
oldaktbreaklabel : tasmlabel;
|
||||||
oldflowcontrol : tflowcontrol;
|
oldflowcontrol : tflowcontrol;
|
||||||
|
excepttemps : texceptiontemps;
|
||||||
exceptref,
|
exceptref,
|
||||||
tempbuf,tempaddr : treference;
|
|
||||||
href : treference;
|
|
||||||
href2: treference;
|
href2: treference;
|
||||||
paraloc1 : tparalocation;
|
paraloc1 : tparalocation;
|
||||||
begin
|
begin
|
||||||
@ -1183,9 +1163,9 @@ implementation
|
|||||||
tvarsym(exceptsymtable.symindex.first).localloc.loc:=LOC_REFERENCE;
|
tvarsym(exceptsymtable.symindex.first).localloc.loc:=LOC_REFERENCE;
|
||||||
tg.GetLocal(exprasmlist,POINTER_SIZE,voidpointertype.def,
|
tg.GetLocal(exprasmlist,POINTER_SIZE,voidpointertype.def,
|
||||||
tvarsym(exceptsymtable.symindex.first).localloc.reference);
|
tvarsym(exceptsymtable.symindex.first).localloc.reference);
|
||||||
reference_reset_base(href,tvarsym(exceptsymtable.symindex.first).localloc.reference.index,
|
reference_reset_base(href2,tvarsym(exceptsymtable.symindex.first).localloc.reference.index,
|
||||||
tvarsym(exceptsymtable.symindex.first).localloc.reference.offset);
|
tvarsym(exceptsymtable.symindex.first).localloc.reference.offset);
|
||||||
cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,href);
|
cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,href2);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -1199,7 +1179,8 @@ implementation
|
|||||||
objectlibrary.getlabel(doobjectdestroyandreraise);
|
objectlibrary.getlabel(doobjectdestroyandreraise);
|
||||||
|
|
||||||
{ call setjmp, and jump to finally label on non-zero result }
|
{ call setjmp, and jump to finally label on non-zero result }
|
||||||
try_new_exception(exprasmlist,tempbuf,tempaddr,href,1,doobjectdestroyandreraise);
|
get_exception_temps(exprasmlist,excepttemps);
|
||||||
|
new_exception(exprasmlist,excepttemps,1,doobjectdestroyandreraise);
|
||||||
|
|
||||||
if assigned(right) then
|
if assigned(right) then
|
||||||
begin
|
begin
|
||||||
@ -1221,7 +1202,7 @@ implementation
|
|||||||
objectlibrary.getlabel(doobjectdestroy);
|
objectlibrary.getlabel(doobjectdestroy);
|
||||||
cg.a_label(exprasmlist,doobjectdestroyandreraise);
|
cg.a_label(exprasmlist,doobjectdestroyandreraise);
|
||||||
|
|
||||||
try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,doobjectdestroy,false);
|
free_exception(exprasmlist,excepttemps,0,doobjectdestroy,false);
|
||||||
|
|
||||||
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
|
cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
|
||||||
@ -1281,6 +1262,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
unget_exception_temps(exprasmlist,excepttemps);
|
||||||
cg.a_label(exprasmlist,nextonlabel);
|
cg.a_label(exprasmlist,nextonlabel);
|
||||||
flowcontrol:=oldflowcontrol+flowcontrol;
|
flowcontrol:=oldflowcontrol+flowcontrol;
|
||||||
{ next on node }
|
{ next on node }
|
||||||
@ -1305,9 +1287,7 @@ implementation
|
|||||||
oldaktbreaklabel : tasmlabel;
|
oldaktbreaklabel : tasmlabel;
|
||||||
oldflowcontrol,tryflowcontrol : tflowcontrol;
|
oldflowcontrol,tryflowcontrol : tflowcontrol;
|
||||||
decconst : longint;
|
decconst : longint;
|
||||||
tempbuf,tempaddr : treference;
|
excepttemps : texceptiontemps;
|
||||||
href : treference;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
location_reset(location,LOC_VOID,OS_NO);
|
location_reset(location,LOC_VOID,OS_NO);
|
||||||
|
|
||||||
@ -1345,7 +1325,8 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{ call setjmp, and jump to finally label on non-zero result }
|
{ call setjmp, and jump to finally label on non-zero result }
|
||||||
try_new_exception(exprasmlist,tempbuf,tempaddr,href,1,finallylabel);
|
get_exception_temps(exprasmlist,excepttemps);
|
||||||
|
new_exception(exprasmlist,excepttemps,1,finallylabel);
|
||||||
|
|
||||||
{ try code }
|
{ try code }
|
||||||
if assigned(left) then
|
if assigned(left) then
|
||||||
@ -1358,7 +1339,7 @@ implementation
|
|||||||
|
|
||||||
cg.a_label(exprasmlist,finallylabel);
|
cg.a_label(exprasmlist,finallylabel);
|
||||||
{ just free the frame information }
|
{ just free the frame information }
|
||||||
try_free_exception(exprasmlist,tempbuf,tempaddr,href,1,finallylabel,true);
|
free_exception(exprasmlist,excepttemps,1,finallylabel,true);
|
||||||
|
|
||||||
{ finally code }
|
{ finally code }
|
||||||
flowcontrol:=[];
|
flowcontrol:=[];
|
||||||
@ -1369,7 +1350,7 @@ implementation
|
|||||||
exit;
|
exit;
|
||||||
|
|
||||||
{ the value should now be in the exception handler }
|
{ the value should now be in the exception handler }
|
||||||
cg.g_exception_reason_load(exprasmlist,href);
|
cg.g_exception_reason_load(exprasmlist,excepttemps.reasonbuf);
|
||||||
if implicitframe then
|
if implicitframe then
|
||||||
begin
|
begin
|
||||||
cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,endfinallylabel);
|
cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,endfinallylabel);
|
||||||
@ -1414,27 +1395,27 @@ implementation
|
|||||||
if fc_exit in tryflowcontrol then
|
if fc_exit in tryflowcontrol then
|
||||||
begin
|
begin
|
||||||
cg.a_label(exprasmlist,exitfinallylabel);
|
cg.a_label(exprasmlist,exitfinallylabel);
|
||||||
cg.g_exception_reason_load(exprasmlist,href);
|
cg.g_exception_reason_load(exprasmlist,excepttemps.reasonbuf);
|
||||||
cg.g_exception_reason_save_const(exprasmlist,href,2);
|
cg.g_exception_reason_save_const(exprasmlist,excepttemps.reasonbuf,2);
|
||||||
cg.a_jmp_always(exprasmlist,finallylabel);
|
cg.a_jmp_always(exprasmlist,finallylabel);
|
||||||
end;
|
end;
|
||||||
if fc_break in tryflowcontrol then
|
if fc_break in tryflowcontrol then
|
||||||
begin
|
begin
|
||||||
cg.a_label(exprasmlist,breakfinallylabel);
|
cg.a_label(exprasmlist,breakfinallylabel);
|
||||||
cg.g_exception_reason_load(exprasmlist,href);
|
cg.g_exception_reason_load(exprasmlist,excepttemps.reasonbuf);
|
||||||
cg.g_exception_reason_save_const(exprasmlist,href,3);
|
cg.g_exception_reason_save_const(exprasmlist,excepttemps.reasonbuf,3);
|
||||||
cg.a_jmp_always(exprasmlist,finallylabel);
|
cg.a_jmp_always(exprasmlist,finallylabel);
|
||||||
end;
|
end;
|
||||||
if fc_continue in tryflowcontrol then
|
if fc_continue in tryflowcontrol then
|
||||||
begin
|
begin
|
||||||
cg.a_label(exprasmlist,continuefinallylabel);
|
cg.a_label(exprasmlist,continuefinallylabel);
|
||||||
cg.g_exception_reason_load(exprasmlist,href);
|
cg.g_exception_reason_load(exprasmlist,excepttemps.reasonbuf);
|
||||||
cg.g_exception_reason_save_const(exprasmlist,href,4);
|
cg.g_exception_reason_save_const(exprasmlist,excepttemps.reasonbuf,4);
|
||||||
cg.a_jmp_always(exprasmlist,finallylabel);
|
cg.a_jmp_always(exprasmlist,finallylabel);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
unget_exception_temps(exprasmlist,excepttemps);
|
||||||
cg.a_label(exprasmlist,endfinallylabel);
|
cg.a_label(exprasmlist,endfinallylabel);
|
||||||
tg.ungettemp(exprasmlist,href);
|
|
||||||
|
|
||||||
current_procinfo.aktexitlabel:=oldaktexitlabel;
|
current_procinfo.aktexitlabel:=oldaktexitlabel;
|
||||||
if assigned(aktbreaklabel) then
|
if assigned(aktbreaklabel) then
|
||||||
@ -1462,7 +1443,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.94 2004-03-02 00:36:33 olle
|
Revision 1.95 2004-03-29 14:43:47 peter
|
||||||
|
* cleaner temp get/unget for exceptions
|
||||||
|
|
||||||
|
Revision 1.94 2004/03/02 00:36:33 olle
|
||||||
* big transformation of Tai_[const_]Symbol.Create[data]name*
|
* big transformation of Tai_[const_]Symbol.Create[data]name*
|
||||||
|
|
||||||
Revision 1.93 2004/02/27 10:21:05 florian
|
Revision 1.93 2004/02/27 10:21:05 florian
|
||||||
|
@ -84,10 +84,20 @@ interface
|
|||||||
be modified, all temps should be allocated on the heap instead of the
|
be modified, all temps should be allocated on the heap instead of the
|
||||||
stack.
|
stack.
|
||||||
}
|
}
|
||||||
procedure new_exception(list:TAAsmoutput;const jmpbuf,envbuf, href : treference;
|
|
||||||
a : aword; exceptlabel : tasmlabel);
|
const
|
||||||
procedure free_exception(list:TAAsmoutput;const jmpbuf, envbuf, href : treference;
|
EXCEPT_BUF_SIZE = 12;
|
||||||
a : aword ; endexceptlabel : tasmlabel; onlyfree : boolean);
|
type
|
||||||
|
texceptiontemps=record
|
||||||
|
jmpbuf,
|
||||||
|
envbuf,
|
||||||
|
reasonbuf : treference;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure get_exception_temps(list:taasmoutput;var t:texceptiontemps);
|
||||||
|
procedure unget_exception_temps(list:taasmoutput;const t:texceptiontemps);
|
||||||
|
procedure new_exception(list:TAAsmoutput;const t:texceptiontemps;a:aword;exceptlabel:tasmlabel);
|
||||||
|
procedure free_exception(list:TAAsmoutput;const t:texceptiontemps;a:aword;endexceptlabel:tasmlabel;onlyfree:boolean);
|
||||||
|
|
||||||
procedure insertconstdata(sym : ttypedconstsym);
|
procedure insertconstdata(sym : ttypedconstsym);
|
||||||
procedure insertbssdata(sym : tvarsym);
|
procedure insertbssdata(sym : tvarsym);
|
||||||
@ -268,9 +278,23 @@ implementation
|
|||||||
EXCEPTION MANAGEMENT
|
EXCEPTION MANAGEMENT
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
|
|
||||||
procedure new_exception(list:TAAsmoutput;const jmpbuf,envbuf, href : treference;
|
procedure get_exception_temps(list:taasmoutput;var t:texceptiontemps);
|
||||||
a : aword; exceptlabel : tasmlabel);
|
begin
|
||||||
|
tg.GetTemp(list,EXCEPT_BUF_SIZE,tt_persistent,t.envbuf);
|
||||||
|
tg.GetTemp(list,JMP_BUF_SIZE,tt_persistent,t.jmpbuf);
|
||||||
|
tg.GetTemp(list,sizeof(aword),tt_persistent,t.reasonbuf);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure unget_exception_temps(list:taasmoutput;const t:texceptiontemps);
|
||||||
|
begin
|
||||||
|
tg.Ungettemp(list,t.jmpbuf);
|
||||||
|
tg.ungettemp(list,t.envbuf);
|
||||||
|
tg.ungettemp(list,t.reasonbuf);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure new_exception(list:TAAsmoutput;const t:texceptiontemps;a:aword;exceptlabel:tasmlabel);
|
||||||
var
|
var
|
||||||
paraloc1,paraloc2,paraloc3 : tparalocation;
|
paraloc1,paraloc2,paraloc3 : tparalocation;
|
||||||
begin
|
begin
|
||||||
@ -278,9 +302,9 @@ implementation
|
|||||||
paraloc2:=paramanager.getintparaloc(pocall_default,2);
|
paraloc2:=paramanager.getintparaloc(pocall_default,2);
|
||||||
paraloc3:=paramanager.getintparaloc(pocall_default,3);
|
paraloc3:=paramanager.getintparaloc(pocall_default,3);
|
||||||
paramanager.allocparaloc(list,paraloc3);
|
paramanager.allocparaloc(list,paraloc3);
|
||||||
cg.a_paramaddr_ref(list,envbuf,paraloc3);
|
cg.a_paramaddr_ref(list,t.envbuf,paraloc3);
|
||||||
paramanager.allocparaloc(list,paraloc2);
|
paramanager.allocparaloc(list,paraloc2);
|
||||||
cg.a_paramaddr_ref(list,jmpbuf,paraloc2);
|
cg.a_paramaddr_ref(list,t.jmpbuf,paraloc2);
|
||||||
{ push type of exceptionframe }
|
{ push type of exceptionframe }
|
||||||
paramanager.allocparaloc(list,paraloc1);
|
paramanager.allocparaloc(list,paraloc1);
|
||||||
cg.a_param_const(list,OS_S32,1,paraloc1);
|
cg.a_param_const(list,OS_S32,1,paraloc1);
|
||||||
@ -299,14 +323,12 @@ implementation
|
|||||||
cg.a_call_name(list,'FPC_SETJMP');
|
cg.a_call_name(list,'FPC_SETJMP');
|
||||||
cg.deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
|
|
||||||
cg.g_exception_reason_save(list, href);
|
cg.g_exception_reason_save(list, t.reasonbuf);
|
||||||
cg.a_cmp_const_reg_label(list,OS_S32,OC_NE,0,cg.makeregsize(NR_FUNCTION_RESULT_REG,OS_S32),exceptlabel);
|
cg.a_cmp_const_reg_label(list,OS_S32,OC_NE,0,cg.makeregsize(NR_FUNCTION_RESULT_REG,OS_S32),exceptlabel);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure free_exception(list:TAAsmoutput;const jmpbuf, envbuf, href : treference;
|
procedure free_exception(list:TAAsmoutput;const t:texceptiontemps;a:aword;endexceptlabel:tasmlabel;onlyfree:boolean);
|
||||||
a : aword ; endexceptlabel : tasmlabel; onlyfree : boolean);
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
cg.allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
cg.allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
|
||||||
cg.a_call_name(list,'FPC_POPADDRSTACK');
|
cg.a_call_name(list,'FPC_POPADDRSTACK');
|
||||||
@ -314,7 +336,7 @@ implementation
|
|||||||
|
|
||||||
if not onlyfree then
|
if not onlyfree then
|
||||||
begin
|
begin
|
||||||
cg.g_exception_reason_load(list, href);
|
cg.g_exception_reason_load(list, t.reasonbuf);
|
||||||
cg.a_cmp_const_reg_label(list,OS_INT,OC_EQ,a,NR_FUNCTION_RESULT_REG,endexceptlabel);
|
cg.a_cmp_const_reg_label(list,OS_INT,OC_EQ,a,NR_FUNCTION_RESULT_REG,endexceptlabel);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2124,7 +2146,10 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.196 2004-03-03 22:02:52 peter
|
Revision 1.197 2004-03-29 14:43:47 peter
|
||||||
|
* cleaner temp get/unget for exceptions
|
||||||
|
|
||||||
|
Revision 1.196 2004/03/03 22:02:52 peter
|
||||||
* use loadnode and finalize_data_node for init/final code to support
|
* use loadnode and finalize_data_node for init/final code to support
|
||||||
threadvars correctly
|
threadvars correctly
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user