Pārlūkot izejas kodu

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

Nikolay Nikolov 3 gadi atpakaļ
vecāks
revīzija
619a27cbfc
1 mainītis faili ar 9 papildinājumiem un 1 dzēšanām
  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;
           end;
 
+        { the inner 'try..end_try' block }
+        current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
+        thlcgwasm(hlcg).incblock;
+
         { try code }
         if assigned(left) then
           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 }
         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 }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));