Browse Source

+ insert try and end_try instructions in the try..finally code in native
WebAssembly exceptions mode

Nikolay Nikolov 3 years ago
parent
commit
619a27cbfc
1 changed files with 9 additions and 1 deletions
  1. 9 1
      compiler/wasm32/nwasmflw.pas

+ 9 - 1
compiler/wasm32/nwasmflw.pas

@@ -605,6 +605,10 @@ implementation
             thlcgwasm(hlcg).loopContBr:=thlcgwasm(hlcg).br_blocks;
             thlcgwasm(hlcg).loopContBr:=thlcgwasm(hlcg).br_blocks;
           end;
           end;
 
 
+        { the inner 'try..end_try' block }
+        current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
+        thlcgwasm(hlcg).incblock;
+
         { try code }
         { try code }
         if assigned(left) then
         if assigned(left) then
           begin
           begin
@@ -620,7 +624,11 @@ implementation
 
 
         { we've reached the end of the 'try' block, with no exceptions/exit/break/continue, so set exceptionreason:=0 }
         { we've reached the end of the 'try' block, with no exceptions/exit/break/continue, so set exceptionreason:=0 }
         hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,0,excepttemps.reasonbuf);
         hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,0,excepttemps.reasonbuf);
-        current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,3)); // jump to the 'finally' section
+        current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,4)); // jump to the 'finally' section
+
+        { exit the inner 'try..end_try' block }
+        current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
+        thlcgwasm(hlcg).decblock;
 
 
         { exit the 'continue' block }
         { exit the 'continue' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));