Browse Source

* more precise stack tracking in thlcgwasm.prepare_stack_for_ref

git-svn-id: branches/wasm@48264 -
nickysn 4 years ago
parent
commit
e4c9f030af
1 changed files with 7 additions and 2 deletions
  1. 7 2
      compiler/wasm32/hlcgcpu.pas

+ 7 - 2
compiler/wasm32/hlcgcpu.pas

@@ -1111,15 +1111,19 @@ implementation
         begin
         begin
           // it's just faster to sum two of those together
           // it's just faster to sum two of those together
           list.Concat(taicpu.op_reg(a_get_local, ref.base));
           list.Concat(taicpu.op_reg(a_get_local, ref.base));
+          incstack(list,1);
           list.Concat(taicpu.op_reg(a_get_local, ref.index));
           list.Concat(taicpu.op_reg(a_get_local, ref.index));
-          list.Concat(taicpu.op_none(a_i32_add));
           incstack(list,1);
           incstack(list,1);
+          list.Concat(taicpu.op_none(a_i32_add));
+          decstack(list,1);
           if dup then
           if dup then
             begin
             begin
               list.Concat(taicpu.op_reg(a_get_local, ref.base));
               list.Concat(taicpu.op_reg(a_get_local, ref.base));
+              incstack(list,1);
               list.Concat(taicpu.op_reg(a_get_local, ref.index));
               list.Concat(taicpu.op_reg(a_get_local, ref.index));
-              list.Concat(taicpu.op_none(a_i32_add));
               incstack(list,1);
               incstack(list,1);
+              list.Concat(taicpu.op_none(a_i32_add));
+              decstack(list,1);
             end;
             end;
           ref.base:=NR_NO;
           ref.base:=NR_NO;
           ref.index:=NR_NO;
           ref.index:=NR_NO;
@@ -1140,6 +1144,7 @@ implementation
           else // if (ref.base = NR_FRAME_POINTER_REG) then
           else // if (ref.base = NR_FRAME_POINTER_REG) then
             begin
             begin
               list.Concat(taicpu.op_sym(a_get_local, current_asmdata.RefAsmSymbol(FRAME_POINTER_SYM,AT_ADDR) ));
               list.Concat(taicpu.op_sym(a_get_local, current_asmdata.RefAsmSymbol(FRAME_POINTER_SYM,AT_ADDR) ));
+              incstack(list,1);
             end;
             end;
         end
         end
       else
       else