Browse Source

* replaced the 'if br end_if' sequence with the 'br_if' instruction, when
generating WebAssembly code for try..finally blocks (in all exception modes)

Nikolay Nikolov 3 years ago
parent
commit
0da5d57c1e
1 changed files with 3 additions and 15 deletions
  1. 3 15
      compiler/wasm32/nwasmflw.pas

+ 3 - 15
compiler/wasm32/nwasmflw.pas

@@ -893,12 +893,8 @@ implementation
             reasonreg:=hlcg.getintregister(current_asmdata.CurrAsmList,exceptionreasontype);
             reasonreg:=hlcg.getintregister(current_asmdata.CurrAsmList,exceptionreasontype);
             hlcg.g_exception_reason_load(current_asmdata.CurrAsmList,exceptionreasontype,exceptionreasontype,excepttemps.reasonbuf,reasonreg);
             hlcg.g_exception_reason_load(current_asmdata.CurrAsmList,exceptionreasontype,exceptionreasontype,excepttemps.reasonbuf,reasonreg);
             thlcgwasm(hlcg).a_cmp_const_reg_stack(current_asmdata.CurrAsmList,exceptionreasontype,OC_EQ,reason,reasonreg);
             thlcgwasm(hlcg).a_cmp_const_reg_stack(current_asmdata.CurrAsmList,exceptionreasontype,OC_EQ,reason,reasonreg);
-            current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
-            thlcgwasm(hlcg).incblock;
+            current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br_if,br));
             thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
             thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
-            current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,br+1));
-            current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-            thlcgwasm(hlcg).decblock;
           end;
           end;
 
 
       begin
       begin
@@ -1080,12 +1076,8 @@ implementation
           reasonreg:=hlcg.getintregister(current_asmdata.CurrAsmList,exceptionreasontype);
           reasonreg:=hlcg.getintregister(current_asmdata.CurrAsmList,exceptionreasontype);
           hlcg.g_exception_reason_load(current_asmdata.CurrAsmList,exceptionreasontype,exceptionreasontype,excepttemps.reasonbuf,reasonreg);
           hlcg.g_exception_reason_load(current_asmdata.CurrAsmList,exceptionreasontype,exceptionreasontype,excepttemps.reasonbuf,reasonreg);
           thlcgwasm(hlcg).a_cmp_const_reg_stack(current_asmdata.CurrAsmList,exceptionreasontype,OC_EQ,reason,reasonreg);
           thlcgwasm(hlcg).a_cmp_const_reg_stack(current_asmdata.CurrAsmList,exceptionreasontype,OC_EQ,reason,reasonreg);
-          current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
-          thlcgwasm(hlcg).incblock;
+          current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br_if,br));
           thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
           thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
-          current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,br+1));
-          current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-          thlcgwasm(hlcg).decblock;
         end;
         end;
 
 
       procedure generate_exceptreason_throw(reason: tcgint);
       procedure generate_exceptreason_throw(reason: tcgint);
@@ -1292,12 +1284,8 @@ implementation
           reasonreg:=hlcg.getintregister(current_asmdata.CurrAsmList,exceptionreasontype);
           reasonreg:=hlcg.getintregister(current_asmdata.CurrAsmList,exceptionreasontype);
           hlcg.g_exception_reason_load(current_asmdata.CurrAsmList,exceptionreasontype,exceptionreasontype,excepttemps.reasonbuf,reasonreg);
           hlcg.g_exception_reason_load(current_asmdata.CurrAsmList,exceptionreasontype,exceptionreasontype,excepttemps.reasonbuf,reasonreg);
           thlcgwasm(hlcg).a_cmp_const_reg_stack(current_asmdata.CurrAsmList,exceptionreasontype,OC_EQ,reason,reasonreg);
           thlcgwasm(hlcg).a_cmp_const_reg_stack(current_asmdata.CurrAsmList,exceptionreasontype,OC_EQ,reason,reasonreg);
-          current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
-          thlcgwasm(hlcg).incblock;
+          current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br_if,br));
           thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
           thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
-          current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,br+1));
-          current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-          thlcgwasm(hlcg).decblock;
         end;
         end;
 
 
       procedure generate_exceptreason_reraise(reason: tcgint);
       procedure generate_exceptreason_reraise(reason: tcgint);