Browse Source

[PATCH 33/83] do the proper preparation for memory (ref) access

From a3f4e2440270248a15475566596c1be8dff32854 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Mon, 16 Sep 2019 09:14:21 -0400

git-svn-id: branches/wasm@45910 -
nickysn 5 years ago
parent
commit
7e96f42210
1 changed files with 4 additions and 5 deletions
  1. 4 5
      compiler/wasm/hlcgcpu.pas

+ 4 - 5
compiler/wasm/hlcgcpu.pas

@@ -999,6 +999,10 @@ implementation
       { fake location that indicates the value is already on the stack? }
       if (ref.base=NR_EVAL_STACK_BASE) then
         exit;
+
+      // setting up memory offset
+      list.Concat(taicpu.op_const(a_i32_const, 0)); //todo: this should not be 0, this should be reference to a global "memory"
+
         { non-array accesses cannot have an index reg }
         if ref.index<>NR_NO then
           internalerror(2010120509);
@@ -1926,8 +1930,6 @@ implementation
       if ref.base=NR_EVAL_STACK_BASE then
         exit;
       opc:=loadstoreopcref(size,false,ref,finishandval);
-      if opc in AsmOp_LoadStore then
-        list.Concat(taicpu.op_const(a_i32_const, 0)); //todo: this should not be 0, this should be reference to a global "memory"
 
       list.concat(taicpu.op_ref(opc,ref));
       { avoid problems with getting the size of an open array etc }
@@ -1961,9 +1963,6 @@ implementation
         exit;
       opc:=loadstoreopcref(size,true,ref,finishandval);
 
-      if opc in AsmOp_LoadStore then
-        list.Concat(taicpu.op_const(a_i32_const, 0)); //todo: this should not be 0, this should be reference to a global "memory"
-
       list.concat(taicpu.op_ref(opc,ref));
 
       { avoid problems with getting the size of an open array etc }