Browse Source

+ generate exception checks after calls to fpc_overflow class in WebAssembly
branchful exceptions mode, because fpc_overflow can raise an exception in case
unit SysUtils is included.

Nikolay Nikolov 3 years ago
parent
commit
9b16fafc52
2 changed files with 3 additions and 0 deletions
  1. 1 0
      compiler/wasm32/hlcgcpu.pas
  2. 2 0
      compiler/wasm32/nwasmmat.pas

+ 1 - 0
compiler/wasm32/hlcgcpu.pas

@@ -2169,6 +2169,7 @@ implementation
       list.concat(taicpu.op_none(a_block));
       list.concat(taicpu.op_none(a_block));
       a_cmp_const_loc_label(list,s32inttype,OC_EQ,0,ovloc,hl);
       a_cmp_const_loc_label(list,s32inttype,OC_EQ,0,ovloc,hl);
       g_call_system_proc(list,'fpc_overflow',[],nil);
       g_call_system_proc(list,'fpc_overflow',[],nil);
+      hlcg.g_maybe_checkforexceptions(current_asmdata.CurrAsmList);
       list.concat(taicpu.op_none(a_end_block));
       list.concat(taicpu.op_none(a_end_block));
       a_label(list,hl);
       a_label(list,hl);
     end;
     end;

+ 2 - 0
compiler/wasm32/nwasmmat.pas

@@ -162,6 +162,7 @@ implementation
              current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
              current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
              hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,resultdef,OC_NE,-1,tmpreg,lab);
              hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,resultdef,OC_NE,-1,tmpreg,lab);
              hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_overflow',[],nil);
              hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_overflow',[],nil);
+             hlcg.g_maybe_checkforexceptions(current_asmdata.CurrAsmList);
              hlcg.a_label(current_asmdata.CurrAsmList,lab);
              hlcg.a_label(current_asmdata.CurrAsmList,lab);
              current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
              current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
            end;
            end;
@@ -228,6 +229,7 @@ implementation
             current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
             current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
             hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,resultdef,OC_NE,torddef(resultdef).low.svalue,left.location.register,hl);
             hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,resultdef,OC_NE,torddef(resultdef).low.svalue,left.location.register,hl);
             hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_overflow',[],nil).resetiftemp;
             hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_overflow',[],nil).resetiftemp;
+            hlcg.g_maybe_checkforexceptions(current_asmdata.CurrAsmList);
             hlcg.a_label(current_asmdata.CurrAsmList,hl);
             hlcg.a_label(current_asmdata.CurrAsmList,hl);
             current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
             current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
           end;
           end;