Browse Source

* improved the accuracy of the stack tracking in g_adjust_stack_after_call

git-svn-id: branches/wasm@48257 -
nickysn 4 years ago
parent
commit
dd00619e1a
1 changed files with 4 additions and 10 deletions
  1. 4 10
      compiler/wasm32/hlcgcpu.pas

+ 4 - 10
compiler/wasm32/hlcgcpu.pas

@@ -1949,23 +1949,17 @@ implementation
     var
     var
       totalremovesize: longint;
       totalremovesize: longint;
       realresdef: tdef;
       realresdef: tdef;
+      ft: TWasmFuncType;
     begin
     begin
-      if not assigned(forceresdef) then
-        realresdef:=pd.returndef
-      else
-        realresdef:=forceresdef;
-      { a constructor doesn't actually return a value in the jvm }
-      if (tabstractprocdef(pd).proctypeoption=potype_constructor) then
-        totalremovesize:=paraheight
-      else
-        { even a byte takes up a full stackslot -> align size to multiple of 4 }
-        totalremovesize:=paraheight-(align(realresdef.size,4) shr 2);
+      ft:=tcpuprocdef(pd).create_functype;
+      totalremovesize:=Length(ft.params)-Length(ft.results);
       { remove parameters from internal evaluation stack counter (in case of
       { remove parameters from internal evaluation stack counter (in case of
         e.g. no parameters and a result, it can also increase) }
         e.g. no parameters and a result, it can also increase) }
       if totalremovesize>0 then
       if totalremovesize>0 then
         decstack(list,totalremovesize)
         decstack(list,totalremovesize)
       else if totalremovesize<0 then
       else if totalremovesize<0 then
         incstack(list,-totalremovesize);
         incstack(list,-totalremovesize);
+      ft.free;
     end;
     end;