From 08565ce5bef46840b87b1937ac6aeadf9ef24c32 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Mon, 21 Nov 2011 18:48:19 +0000 Subject: [PATCH] * save/restore the current_except_loc instead of invalidating it after each use (since try/except statements can be nested) git-svn-id: branches/jvmbackend@19666 - --- compiler/jvm/njvmflw.pas | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/jvm/njvmflw.pas b/compiler/jvm/njvmflw.pas index 100d73186f..e03580a981 100644 --- a/compiler/jvm/njvmflw.pas +++ b/compiler/jvm/njvmflw.pas @@ -167,6 +167,7 @@ implementation defaultcatchlabel: tasmlabel; oldflowcontrol,tryflowcontrol, exceptflowcontrol : tflowcontrol; + prev_except_loc: tlocation; begin location_reset(location,LOC_VOID,OS_NO); @@ -216,6 +217,7 @@ implementation { get the exception object from the stack and store it for use by the exception code (in case of an anonymous "raise") } current_asmdata.CurrAsmList.concat(tai_marker.create(mark_NoLineInfoStart)); + prev_except_loc:=current_except_loc; location_reset_ref(current_except_loc,LOC_REFERENCE,OS_ADDR,4); tg.GetLocal(current_asmdata.CurrAsmList,sizeof(pint),java_jlthrowable,current_except_loc.reference); thlcgjvm(hlcg).incstack(current_asmdata.CurrAsmList,1); @@ -227,7 +229,7 @@ implementation { free the temp containing the exception and invalidate } tg.UngetLocal(current_asmdata.CurrAsmList,current_except_loc.reference); - current_except_loc.loc:=LOC_INVALID; + current_except_loc:=prev_except_loc; exceptflowcontrol:=flowcontrol; end @@ -255,6 +257,7 @@ implementation thisonlabel : tasmlabel; oldflowcontrol : tflowcontrol; exceptvarsym : tlocalvarsym; + prev_except_loc : tlocation; begin location_reset(location,LOC_VOID,OS_NO); @@ -281,6 +284,7 @@ implementation { 1) prepare the location where we'll store it } location_reset_ref(exceptvarsym.localloc,LOC_REFERENCE,OS_ADDR,sizeof(pint)); tg.GetLocal(current_asmdata.CurrAsmList,sizeof(pint),exceptvarsym.vardef,exceptvarsym.localloc.reference); + prev_except_loc:=current_except_loc; current_except_loc:=exceptvarsym.localloc; { 2) the exception variable is at the top of the evaluation stack (placed there by the JVM) -> adjust stack count, then store it } @@ -293,7 +297,7 @@ implementation { clear some stuff } tg.UngetLocal(current_asmdata.CurrAsmList,exceptvarsym.localloc.reference); exceptvarsym.localloc.loc:=LOC_INVALID; - current_except_loc.loc:=LOC_INVALID; + current_except_loc:=prev_except_loc; hlcg.a_jmp_always(current_asmdata.CurrAsmList,endexceptlabel); flowcontrol:=oldflowcontrol+(flowcontrol-[fc_inflowcontrol]);