Browse Source

- removed thlcgwasm.incblock, .decblock and br_blocks, as branching is now done
entirely with labels

Nikolay Nikolov 3 years ago
parent
commit
12a2c56461

+ 0 - 2
compiler/ncgset.pas

@@ -500,7 +500,6 @@ implementation
                          thlcgwasm(hlcg).a_cmp_const_reg_stack(current_asmdata.CurrAsmList, opdef, OC_A, tsetdef(right.resultdef).setmax-tsetdef(right.resultdef).setbase, pleftreg);
 
                          current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
-                         thlcgwasm(hlcg).incblock;
                          thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
 
                          hlcg.a_load_const_reg(current_asmdata.CurrAsmList, uopdef, 0, location.register);
@@ -526,7 +525,6 @@ implementation
                        begin
 {$ifdef WASM}
                          current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-                         thlcgwasm(hlcg).decblock;
 {$else WASM}
                          hlcg.a_label(current_asmdata.CurrAsmList, l2);
 {$endif WASM}

+ 0 - 5
compiler/wasm32/cpupi.pas

@@ -217,7 +217,6 @@ implementation
         thlcgwasm(hlcg).a_cmp_const_reg_stack(list, fpc_catches_res.def, OC_NE, 0, exceptloc.register);
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
-        thlcgwasm(hlcg).incblock;
         thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
 
         paraloc1.done;
@@ -229,7 +228,6 @@ implementation
     class procedure twasmexceptionstatehandler_nativeexceptions.end_catch(list: TAsmList);
       begin
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-        thlcgwasm(hlcg).decblock;
       end;
 
 {*****************************************************************************
@@ -302,7 +300,6 @@ implementation
         thlcgwasm(hlcg).a_cmp_const_reg_stack(list, fpc_catches_res.def, OC_NE, 0, exceptloc.register);
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
-        thlcgwasm(hlcg).incblock;
         thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
 
         paraloc1.done;
@@ -314,7 +311,6 @@ implementation
     class procedure twasmexceptionstatehandler_bfexceptions.end_catch(list: TAsmList);
       begin
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-        thlcgwasm(hlcg).decblock;
       end;
 
 {*****************************************************************************
@@ -351,7 +347,6 @@ implementation
     procedure tcpuprocinfo.generate_exit_label(list: tasmlist);
       begin
         list.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         inherited generate_exit_label(list);
       end;
 

+ 0 - 30
compiler/wasm32/hlcgcpu.pas

@@ -55,15 +55,11 @@ uses
         }
       function is_methodptr_like_type(d:tdef): boolean;
      public
-      br_blocks: integer;
       fntypelookup : TWasmProcTypeLookup;
 
       constructor create;
       destructor Destroy; override;
 
-      procedure incblock;
-      procedure decblock;
-
       procedure incstack(list : TAsmList;slots: longint);
       procedure decstack(list : TAsmList;slots: longint);
 
@@ -320,7 +316,6 @@ implementation
     begin
       fevalstackheight:=0;
       fmaxevalstackheight:=0;
-      br_blocks:=0;
       fntypelookup:=TWasmProcTypeLookup.Create;
     end;
 
@@ -330,18 +325,6 @@ implementation
       inherited Destroy;
     end;
 
-  procedure thlcgwasm.incblock;
-    begin
-      inc(br_blocks);
-    end;
-
-  procedure thlcgwasm.decblock;
-    begin
-      dec(br_blocks);
-      if br_blocks<0 then
-        Internalerror(2019091807); // out of block
-    end;
-
   procedure thlcgwasm.incstack(list: TAsmList; slots: longint);
     begin
       if (fevalstackheight<0) and
@@ -552,7 +535,6 @@ implementation
             else if (op=OP_NOT) and is_cbool(size) then
               begin
                 current_asmdata.CurrAsmList.Concat(taicpu.op_functype(a_if,TWasmFuncType.Create([],[wbt_i32])));
-                incblock;
                 decstack(current_asmdata.CurrAsmList,1);
                 current_asmdata.CurrAsmList.Concat( taicpu.op_const(a_i32_const, 0) );
                 incstack(current_asmdata.CurrAsmList,1);
@@ -570,7 +552,6 @@ implementation
                 end;
                 incstack(current_asmdata.CurrAsmList,1);
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-                thlcgwasm(hlcg).decblock;
               end
             else
               begin
@@ -608,7 +589,6 @@ implementation
               begin
                 list.concat(taicpu.op_none(a_i64_eqz));
                 current_asmdata.CurrAsmList.Concat(taicpu.op_functype(a_if,TWasmFuncType.Create([],[wbt_i64])));
-                incblock;
                 decstack(current_asmdata.CurrAsmList,1);
                 current_asmdata.CurrAsmList.Concat( taicpu.op_const(a_i64_const, -1) );
                 incstack(current_asmdata.CurrAsmList,1);
@@ -617,7 +597,6 @@ implementation
                 current_asmdata.CurrAsmList.Concat( taicpu.op_const(a_i64_const, 0) );
                 incstack(current_asmdata.CurrAsmList,1);
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-                thlcgwasm(hlcg).decblock;
               end
             else
               begin
@@ -1353,7 +1332,6 @@ implementation
       a_cmp_const_reg_stack(list,osuinttype,OC_A,loadbitsize-sref.bitlen,sref.bitindexreg);
 
       current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
-      incblock;
       decstack(current_asmdata.CurrAsmList,1);
 
       { Y-x = -(Y-x) }
@@ -1369,7 +1347,6 @@ implementation
       a_op_reg_reg(list,OP_OR,osuinttype,extra_value_reg,valuereg);
 
       current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-      decblock;
 
       { sign extend or mask other bits }
       if is_signed(subsetsize) then
@@ -1564,7 +1541,6 @@ implementation
               { make sure we do not read/write past the end of the array }
               a_cmp_const_reg_stack(list,osuinttype,OC_A,loadbitsize-sref.bitlen,sref.bitindexreg);
               current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
-              incblock;
               decstack(current_asmdata.CurrAsmList,1);
 
               a_load_ref_reg(list,loadsize,osuinttype,tmpref,extra_value_reg);
@@ -1614,7 +1590,6 @@ implementation
 {$endif}
 
               current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-              decblock;
             end;
         end;
     end;
@@ -2164,13 +2139,11 @@ implementation
       a_cmp_stack_stack(list,maxdef,OC_A);
 
       current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
-      thlcgwasm(hlcg).incblock;
       thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
 
       g_call_system_proc(list,'fpc_rangeerror',[],nil).resetiftemp;
 
       current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-      thlcgwasm(hlcg).decblock;
     end;
 
   procedure thlcgwasm.g_overflowcheck(list: TAsmList; const Loc: tlocation; def: tdef);
@@ -2200,15 +2173,12 @@ implementation
     begin
       inherited;
       list.concat(taicpu.op_none(a_block));
-      incblock;
       list.concat(taicpu.op_none(a_block));
-      incblock;
     end;
 
   procedure thlcgwasm.gen_exit_code(list: TAsmList);
     begin
       list.concat(taicpu.op_none(a_end_block));
-      thlcgwasm(hlcg).decblock;
       if ts_wasm_bf_exceptions in current_settings.targetswitches then
         a_label(list,tcpuprocinfo(current_procinfo).CurrRaiseLabel);
       if fevalstackheight<>0 then

+ 0 - 2
compiler/wasm32/nwasmadd.pas

@@ -309,7 +309,6 @@ interface
             current_asmdata.CurrAsmList.Concat(taicpu.op_functype(a_if,TWasmFuncType.Create([],[wbt_i64])))
           else
             current_asmdata.CurrAsmList.Concat(taicpu.op_functype(a_if,TWasmFuncType.Create([],[wbt_i32])));
-          thlcgwasm(hlcg).incblock;
           thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
 
           case nodetype of
@@ -354,7 +353,6 @@ interface
                 Internalerror(2019091902);
               end;
           current_asmdata.CurrAsmList.Concat( taicpu.op_none(a_end_if) );
-          thlcgwasm(hlcg).decblock;
           set_result_location_reg;
           thlcgwasm(hlcg).a_load_stack_loc(current_asmdata.CurrAsmList,resultdef,location);
         end else

+ 0 - 2
compiler/wasm32/nwasmbas.pas

@@ -52,7 +52,6 @@ implementation
         if nf_block_with_exit in flags then
           begin
             current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-            thlcgwasm(hlcg).incblock;
           end;
 
         inherited pass_generate_code;
@@ -60,7 +59,6 @@ implementation
         if nf_block_with_exit in flags then
           begin
             current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-            thlcgwasm(hlcg).decblock;
           end;
       end;
 

+ 0 - 6
compiler/wasm32/nwasmcnv.pas

@@ -139,7 +139,6 @@ implementation
               current_asmdata.CurrAsmList.Concat(taicpu.op_functype(a_if,TWasmFuncType.Create([],[wbt_i64])))
             else
               current_asmdata.CurrAsmList.Concat(taicpu.op_functype(a_if,TWasmFuncType.Create([],[wbt_i32])));
-            thlcgwasm(hlcg).incblock;
             thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
             if is_64bit(resultdef) then
               current_asmdata.CurrAsmList.Concat( taicpu.op_const(a_i64_const, -1) )
@@ -160,7 +159,6 @@ implementation
               current_asmdata.CurrAsmList.Concat( taicpu.op_const(a_i32_const, 0) );
             thlcgwasm(hlcg).incstack(current_asmdata.CurrAsmList,1);
             current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-            thlcgwasm(hlcg).decblock;
           end
         else
           thlcgwasm(hlcg).resize_stack_int_val(current_asmdata.CurrAsmList,u32inttype,resultdef,false);
@@ -177,7 +175,6 @@ implementation
         thlcgwasm(hlcg).a_cmp_const_loc_stack(current_asmdata.CurrAsmList,left.resultdef,OC_NE,0,left.location);
 
         current_asmdata.CurrAsmList.Concat(taicpu.op_functype(a_if,TWasmFuncType.Create([],[wbt_i32])));
-        thlcgwasm(hlcg).incblock;
         thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
 
         thlcgwasm(hlcg).a_load_loc_stack(current_asmdata.CurrAsmList,left.resultdef,left.location);
@@ -192,7 +189,6 @@ implementation
         thlcgwasm(hlcg).a_loadaddr_ref_stack(current_asmdata.CurrAsmList,cwidechartype,resultdef,hr);
 
         current_asmdata.CurrAsmList.Concat( taicpu.op_none(a_end_if) );
-        thlcgwasm(hlcg).decblock;
 
         location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
         location.register:=hlcg.getaddressregister(current_asmdata.CurrAsmList,resultdef);
@@ -244,13 +240,11 @@ implementation
                       thlcgwasm(hlcg).a_cmp_const_reg_stack(current_asmdata.CurrAsmList,resultdef,OC_NE,0,location.register);
 
                       current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
-                      thlcgwasm(hlcg).incblock;
                       thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
 
                       hlcg.a_op_const_reg(current_asmdata.CurrAsmList,OP_ADD,resultdef,ImplIntf.ioffset,location.register);
 
                       current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-                      thlcgwasm(hlcg).decblock;
                       break;
                     end;
                   else

+ 0 - 82
compiler/wasm32/nwasmflw.pas

@@ -147,9 +147,7 @@ implementation
         exclude(flowcontrol,fc_unwind_loop);
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_loop));
-        thlcgwasm(hlcg).incblock;
 
         if lnf_testatbegin in loopflags then
         begin
@@ -158,7 +156,6 @@ implementation
         end;
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         current_procinfo.CurrContinueLabel:=lcont;
         current_procinfo.CurrBreakLabel:=lbreak;
@@ -169,7 +166,6 @@ implementation
           current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,1) ); // jump back to the external loop
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         if not (lnf_testatbegin in loopflags) then
           begin
             hlcg.a_label(current_asmdata.CurrAsmList,lcont);
@@ -178,9 +174,7 @@ implementation
         current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,0) ); // jump back to loop
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_loop));
-        thlcgwasm(hlcg).decblock;
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         hlcg.a_label(current_asmdata.CurrAsmList,lbreak);
 
         current_procinfo.CurrContinueLabel:=oldclabel;
@@ -220,7 +214,6 @@ implementation
           end;
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
-        thlcgwasm(hlcg).incblock;
         thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
 
         if Assigned(right) then
@@ -233,7 +226,6 @@ implementation
           end;
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-        thlcgwasm(hlcg).decblock;
 
         flowcontrol := oldflowcontrol + (flowcontrol - [fc_inflowcontrol]);
       end;
@@ -473,7 +465,6 @@ implementation
         cexceptionstatehandler.new_exception(current_asmdata.CurrAsmList,excepttemps,tek_except,trystate);
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
-        thlcgwasm(hlcg).incblock;
 
         { try block }
         secondpass(left);
@@ -522,11 +513,9 @@ implementation
                   afteronflowcontrol;
 
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
-                thlcgwasm(hlcg).incblock;
 
                 { the 'exit' block }
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-                thlcgwasm(hlcg).incblock;
 
                 oldCurrExitLabel:=current_procinfo.CurrExitLabel;
                 current_asmdata.getjumplabel(NewCurrExitLabel);
@@ -534,7 +523,6 @@ implementation
 
                 { the 'break' block }
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-                thlcgwasm(hlcg).incblock;
 
                 if in_loop then
                   begin
@@ -545,7 +533,6 @@ implementation
 
                 { the 'continue' block }
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-                thlcgwasm(hlcg).incblock;
 
                 if in_loop then
                   begin
@@ -563,7 +550,6 @@ implementation
 
                 { exit the 'continue' block }
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-                thlcgwasm(hlcg).decblock;
                 if in_loop then
                   hlcg.a_label(current_asmdata.CurrAsmList,NewContinueLabel);
                 if fc_continue in doobjectdestroyandreraisestate.newflowcontrol then
@@ -574,7 +560,6 @@ implementation
 
                 { exit the 'break' block }
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));  // break
-                thlcgwasm(hlcg).decblock;
                 if in_loop then
                   hlcg.a_label(current_asmdata.CurrAsmList,NewBreakLabel);
                 if fc_break in doobjectdestroyandreraisestate.newflowcontrol then
@@ -585,7 +570,6 @@ implementation
 
                 { exit the 'exit' block }
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));  // exit
-                thlcgwasm(hlcg).decblock;
                 hlcg.a_label(current_asmdata.CurrAsmList,NewCurrExitLabel);
                 if fc_exit in doobjectdestroyandreraisestate.newflowcontrol then
                   begin
@@ -605,7 +589,6 @@ implementation
                 hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_raise_nested',[],nil).resetiftemp;
 
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
-                thlcgwasm(hlcg).decblock;
               end
             else
               begin
@@ -620,7 +603,6 @@ implementation
           end;
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
-        thlcgwasm(hlcg).decblock;
 
       errorexit:
         { return all used control flow statements }
@@ -664,10 +646,8 @@ implementation
         cexceptionstatehandler.new_exception(current_asmdata.CurrAsmList,excepttemps,tek_except,trystate);
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
         oldCurrRaiseLabel:=tcpuprocinfo(current_procinfo).CurrRaiseLabel;
         current_asmdata.getjumplabel(NewCurrRaiseLabel);
         tcpuprocinfo(current_procinfo).CurrRaiseLabel:=NewCurrRaiseLabel;
@@ -681,7 +661,6 @@ implementation
 
         current_asmdata.CurrAsmList.concat(taicpu.op_const(a_br,1));
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         hlcg.a_label(current_asmdata.CurrAsmList,NewCurrRaiseLabel);
 
         hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_clear_exception_flag',[],nil).resetiftemp;
@@ -725,17 +704,14 @@ implementation
                   afteronflowcontrol;
 
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-                thlcgwasm(hlcg).incblock;
 
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-                thlcgwasm(hlcg).incblock;
                 oldCurrRaiseLabel:=tcpuprocinfo(current_procinfo).CurrRaiseLabel;
                 current_asmdata.getjumplabel(NewCurrRaiseLabel);
                 tcpuprocinfo(current_procinfo).CurrRaiseLabel:=NewCurrRaiseLabel;
 
                 { the 'exit' block }
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-                thlcgwasm(hlcg).incblock;
 
                 oldCurrExitLabel:=current_procinfo.CurrExitLabel;
                 current_asmdata.getjumplabel(NewCurrExitLabel);
@@ -743,7 +719,6 @@ implementation
 
                 { the 'break' block }
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-                thlcgwasm(hlcg).incblock;
 
                 if in_loop then
                   begin
@@ -754,7 +729,6 @@ implementation
 
                 { the 'continue' block }
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-                thlcgwasm(hlcg).incblock;
 
                 if in_loop then
                   begin
@@ -772,7 +746,6 @@ implementation
 
                 { exit the 'continue' block }
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-                thlcgwasm(hlcg).decblock;
                 if in_loop then
                   hlcg.a_label(current_asmdata.CurrAsmList,NewContinueLabel);
                 if fc_continue in doobjectdestroyandreraisestate.newflowcontrol then
@@ -783,7 +756,6 @@ implementation
 
                 { exit the 'break' block }
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));  // break
-                thlcgwasm(hlcg).decblock;
                 if in_loop then
                   hlcg.a_label(current_asmdata.CurrAsmList,NewBreakLabel);
                 if fc_break in doobjectdestroyandreraisestate.newflowcontrol then
@@ -794,7 +766,6 @@ implementation
 
                 { exit the 'exit' block }
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));  // exit
-                thlcgwasm(hlcg).decblock;
                 hlcg.a_label(current_asmdata.CurrAsmList,NewCurrExitLabel);
                 if fc_exit in doobjectdestroyandreraisestate.newflowcontrol then
                   begin
@@ -803,7 +774,6 @@ implementation
                   end;
 
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-                thlcgwasm(hlcg).decblock;
                 hlcg.a_label(current_asmdata.CurrAsmList,NewCurrRaiseLabel);
 
                 current_procinfo.CurrExitLabel:=oldCurrExitLabel;
@@ -819,7 +789,6 @@ implementation
                 hlcg.g_maybe_checkforexceptions(current_asmdata.CurrAsmList);
 
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-                thlcgwasm(hlcg).decblock;
               end
             else
               begin
@@ -835,7 +804,6 @@ implementation
           end;
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
 
       errorexit:
         { return all used control flow statements }
@@ -923,11 +891,9 @@ implementation
 
         { the outer 'try..finally' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         { the 'exit' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         oldCurrExitLabel:=current_procinfo.CurrExitLabel;
         exitfinallylabel:=get_jump_out_of_try_finally_frame_label(finallyexceptionstate);
@@ -935,7 +901,6 @@ implementation
 
         { the 'break' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         if in_loop then
           begin
@@ -946,7 +911,6 @@ implementation
 
         { the 'continue' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         if in_loop then
           begin
@@ -974,7 +938,6 @@ implementation
 
         { exit the 'continue' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         if in_loop then
           hlcg.a_label(current_asmdata.CurrAsmList,continuefinallylabel);
         { exceptionreason:=4 (continue) }
@@ -983,7 +946,6 @@ implementation
 
         { exit the 'break' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         if in_loop then
           hlcg.a_label(current_asmdata.CurrAsmList,breakfinallylabel);
         { exceptionreason:=3 (break) }
@@ -992,7 +954,6 @@ implementation
 
         { exit the 'exit' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         hlcg.a_label(current_asmdata.CurrAsmList,exitfinallylabel);
         { exceptionreason:=2 (exit) }
         hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,2,excepttemps.reasonbuf);
@@ -1000,7 +961,6 @@ implementation
 
         { exit the outer 'try..finally' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
 
         { end cleanup }
         current_asmdata.CurrAsmList.concat(tai_marker.create(mark_NoLineInfoEnd));
@@ -1090,11 +1050,9 @@ implementation
           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);
           current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
-          thlcgwasm(hlcg).incblock;
           thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
           current_asmdata.CurrAsmList.Concat(taicpu.op_sym(a_throw,current_asmdata.WeakRefAsmSymbol(FPC_EXCEPTION_TAG_SYM,AT_WASM_EXCEPTION_TAG)));
           current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-          thlcgwasm(hlcg).decblock;
         end;
 
       begin
@@ -1123,11 +1081,9 @@ implementation
 
         { the outer 'try..finally' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         { the 'exit' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         oldCurrExitLabel:=current_procinfo.CurrExitLabel;
         exitfinallylabel:=get_jump_out_of_try_finally_frame_label(finallyexceptionstate);
@@ -1135,7 +1091,6 @@ implementation
 
         { the 'break' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         if in_loop then
           begin
@@ -1146,7 +1101,6 @@ implementation
 
         { the 'continue' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         if in_loop then
           begin
@@ -1157,7 +1111,6 @@ implementation
 
         { the inner 'try..end_try' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
-        thlcgwasm(hlcg).incblock;
 
         { try code }
         if assigned(left) then
@@ -1183,11 +1136,9 @@ implementation
 
         { 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));
-        thlcgwasm(hlcg).decblock;
         if in_loop then
           hlcg.a_label(current_asmdata.CurrAsmList,continuefinallylabel);
         { exceptionreason:=4 (continue) }
@@ -1196,7 +1147,6 @@ implementation
 
         { exit the 'break' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         if in_loop then
           hlcg.a_label(current_asmdata.CurrAsmList,breakfinallylabel);
         { exceptionreason:=3 (break) }
@@ -1205,7 +1155,6 @@ implementation
 
         { exit the 'exit' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         hlcg.a_label(current_asmdata.CurrAsmList,exitfinallylabel);
         { exceptionreason:=2 (exit) }
         hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,2,excepttemps.reasonbuf);
@@ -1213,7 +1162,6 @@ implementation
 
         { exit the outer 'try..finally' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
 
         { end cleanup }
         current_asmdata.CurrAsmList.concat(tai_marker.create(mark_NoLineInfoEnd));
@@ -1301,12 +1249,10 @@ implementation
           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);
           current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if));
-          thlcgwasm(hlcg).incblock;
           thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
           hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_reraise',[],nil).resetiftemp;
           hlcg.g_maybe_checkforexceptions(current_asmdata.CurrAsmList);
           current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_if));
-          thlcgwasm(hlcg).decblock;
         end;
 
       begin
@@ -1336,11 +1282,9 @@ implementation
 
         { the outer 'try..finally' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         { the 'exit' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         oldCurrExitLabel:=current_procinfo.CurrExitLabel;
         exitfinallylabel:=get_jump_out_of_try_finally_frame_label(finallyexceptionstate);
@@ -1348,7 +1292,6 @@ implementation
 
         { the 'break' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         if in_loop then
           begin
@@ -1359,7 +1302,6 @@ implementation
 
         { the 'continue' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         if in_loop then
           begin
@@ -1370,7 +1312,6 @@ implementation
 
         { the inner 'try..end_try' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
         oldCurrRaiseLabel:=tcpuprocinfo(current_procinfo).CurrRaiseLabel;
         current_asmdata.getjumplabel(raisefinallylabel);
         tcpuprocinfo(current_procinfo).CurrRaiseLabel:=raisefinallylabel;
@@ -1394,7 +1335,6 @@ implementation
 
         { exit the inner 'try..end_try' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         hlcg.a_label(current_asmdata.CurrAsmList,raisefinallylabel);
 
         { exceptionreason:=1 (exception) }
@@ -1404,7 +1344,6 @@ implementation
 
         { exit the 'continue' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         if in_loop then
           hlcg.a_label(current_asmdata.CurrAsmList,continuefinallylabel);
         { exceptionreason:=4 (continue) }
@@ -1413,7 +1352,6 @@ implementation
 
         { exit the 'break' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         if in_loop then
           hlcg.a_label(current_asmdata.CurrAsmList,breakfinallylabel);
         { exceptionreason:=3 (break) }
@@ -1422,7 +1360,6 @@ implementation
 
         { exit the 'exit' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         hlcg.a_label(current_asmdata.CurrAsmList,exitfinallylabel);
         { exceptionreason:=2 (exit) }
         hlcg.g_exception_reason_save_const(current_asmdata.CurrAsmList,exceptionreasontype,2,excepttemps.reasonbuf);
@@ -1430,7 +1367,6 @@ implementation
 
         { exit the outer 'try..finally' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
 
         { end cleanup }
         current_asmdata.CurrAsmList.concat(tai_marker.create(mark_NoLineInfoEnd));
@@ -1554,11 +1490,9 @@ implementation
           we've to destroy the old one, so create a new
           exception frame for the catch-handler }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_try));
-        thlcgwasm(hlcg).incblock;
 
         { the 'exit' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         oldCurrExitLabel:=current_procinfo.CurrExitLabel;
         current_asmdata.getjumplabel(NewCurrExitLabel);
@@ -1566,7 +1500,6 @@ implementation
 
         { the 'break' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         if in_loop then
           begin
@@ -1577,7 +1510,6 @@ implementation
 
         { the 'continue' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         if in_loop then
           begin
@@ -1596,7 +1528,6 @@ implementation
 
         { exit the 'continue' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         if in_loop then
           hlcg.a_label(current_asmdata.CurrAsmList,NewContinueLabel);
         if fc_continue in doobjectdestroyandreraisestate.newflowcontrol then
@@ -1607,7 +1538,6 @@ implementation
 
         { exit the 'break' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));  // break
-        thlcgwasm(hlcg).decblock;
         if in_loop then
           hlcg.a_label(current_asmdata.CurrAsmList,NewBreakLabel);
         if fc_break in doobjectdestroyandreraisestate.newflowcontrol then
@@ -1618,7 +1548,6 @@ implementation
 
         { exit the 'exit' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));  // exit
-        thlcgwasm(hlcg).decblock;
         hlcg.a_label(current_asmdata.CurrAsmList,NewCurrExitLabel);
         if fc_exit in doobjectdestroyandreraisestate.newflowcontrol then
           begin
@@ -1638,7 +1567,6 @@ implementation
         hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_raise_nested',[],nil).resetiftemp;
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_try));
-        thlcgwasm(hlcg).decblock;
 
         { clear some stuff }
         if assigned(exceptvarsym) then
@@ -1708,17 +1636,14 @@ implementation
           we've to destroy the old one, so create a new
           exception frame for the catch-handler }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
         oldCurrRaiseLabel:=tcpuprocinfo(current_procinfo).CurrRaiseLabel;
         current_asmdata.getjumplabel(NewCurrRaiseLabel);
         tcpuprocinfo(current_procinfo).CurrRaiseLabel:=NewCurrRaiseLabel;
 
         { the 'exit' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         oldCurrExitLabel:=current_procinfo.CurrExitLabel;
         current_asmdata.getjumplabel(NewCurrExitLabel);
@@ -1726,7 +1651,6 @@ implementation
 
         { the 'break' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         if in_loop then
           begin
@@ -1737,7 +1661,6 @@ implementation
 
         { the 'continue' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         if in_loop then
           begin
@@ -1756,7 +1679,6 @@ implementation
 
         { exit the 'continue' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         if in_loop then
           hlcg.a_label(current_asmdata.CurrAsmList,NewContinueLabel);
         if fc_continue in doobjectdestroyandreraisestate.newflowcontrol then
@@ -1767,7 +1689,6 @@ implementation
 
         { exit the 'break' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));  // break
-        thlcgwasm(hlcg).decblock;
         if in_loop then
           hlcg.a_label(current_asmdata.CurrAsmList,NewBreakLabel);
         if fc_break in doobjectdestroyandreraisestate.newflowcontrol then
@@ -1778,7 +1699,6 @@ implementation
 
         { exit the 'exit' block }
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));  // exit
-        thlcgwasm(hlcg).decblock;
         hlcg.a_label(current_asmdata.CurrAsmList,NewCurrExitLabel);
         if fc_exit in doobjectdestroyandreraisestate.newflowcontrol then
           begin
@@ -1787,7 +1707,6 @@ implementation
           end;
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         hlcg.a_label(current_asmdata.CurrAsmList,NewCurrRaiseLabel);
 
         current_procinfo.CurrExitLabel:=oldCurrExitLabel;
@@ -1803,7 +1722,6 @@ implementation
         hlcg.g_maybe_checkforexceptions(current_asmdata.CurrAsmList);
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
 
         { clear some stuff }
         if assigned(exceptvarsym) then

+ 0 - 4
compiler/wasm32/nwasminl.pas

@@ -250,7 +250,6 @@ implementation
           end;
         { if not nil }
         current_asmdata.CurrAsmList.Concat(taicpu.op_functype(a_if,TWasmFuncType.Create([],[hightype])));
-        thlcgwasm(hlcg).incblock;
         thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
         { volatility of the dyn. array refers to the volatility of the
           string pointer, not of the string data }
@@ -269,7 +268,6 @@ implementation
         thlcgwasm(hlcg).a_load_const_stack(current_asmdata.CurrAsmList,resultdef,-1,R_INTREGISTER);
         { endif }
         current_asmdata.CurrAsmList.Concat(taicpu.op_none(a_end_if));
-        thlcgwasm(hlcg).decblock;
 
         location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
 {$if not defined(cpu64bitalu) and not defined(cpuhighleveltarget)}
@@ -504,7 +502,6 @@ implementation
             thlcgwasm(hlcg).a_cmp_const_reg_stack(current_asmdata.CurrAsmList,left.resultdef,OC_EQ,0,left.location.register);
 
             current_asmdata.CurrAsmList.Concat(taicpu.op_functype(a_if,TWasmFuncType.Create([],[wbt_i32])));
-            thlcgwasm(hlcg).incblock;
             thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
 
             current_asmdata.CurrAsmList.Concat(taicpu.op_const(a_i32_const,0));
@@ -537,7 +534,6 @@ implementation
               thlcgwasm(hlcg).a_op_const_stack(current_asmdata.CurrAsmList,OP_ADD,resultdef,1);
 
             current_asmdata.CurrAsmList.Concat( taicpu.op_none(a_end_if) );
-            thlcgwasm(hlcg).decblock;
 
             location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
             location.register:=hlcg.getregisterfordef(current_asmdata.CurrAsmList,resultdef);

+ 0 - 6
compiler/wasm32/nwasmset.pas

@@ -94,7 +94,6 @@ implementation
             Result := False;
             current_asmdata.getjumplabel(_Label);
             current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-            thlcgwasm(hlcg).incblock;
             Exit;
           end;
 
@@ -135,7 +134,6 @@ implementation
         { Create unique label }
         Result := False;
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
         current_asmdata.getjumplabel(_Label);
       end;
 
@@ -309,7 +307,6 @@ implementation
         current_asmdata.getjumplabel(endlabel);
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
-        thlcgwasm(hlcg).incblock;
 
         { Do some optimisation to deal with empty else blocks }
         ShortcutElse := GetBranchLabel(elseblock, elselabel);
@@ -455,7 +452,6 @@ implementation
             if not shortcut then
               begin
                 current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-                thlcgwasm(hlcg).decblock;
                 hlcg.a_label(current_asmdata.CurrAsmList,blocklabel);
 
                 secondpass(statement);
@@ -472,7 +468,6 @@ implementation
         if not ShortcutElse then
           begin
             current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-            thlcgwasm(hlcg).decblock;
             hlcg.a_label(current_asmdata.CurrAsmList,elselabel);
           end;
 
@@ -486,7 +481,6 @@ implementation
           end;
 
         current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
-        thlcgwasm(hlcg).decblock;
         hlcg.a_label(current_asmdata.CurrAsmList,endlabel);
 
         flowcontrol := oldflowcontrol + (flowcontrol - [fc_inflowcontrol]);