From dd00619e1ad4137d27f582e92d41fc784a93a8f7 Mon Sep 17 00:00:00 2001 From: nickysn Date: Thu, 21 Jan 2021 04:34:43 +0000 Subject: [PATCH] * improved the accuracy of the stack tracking in g_adjust_stack_after_call git-svn-id: branches/wasm@48257 - --- compiler/wasm32/hlcgcpu.pas | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/compiler/wasm32/hlcgcpu.pas b/compiler/wasm32/hlcgcpu.pas index 99cde4374d..f0d9ca8b70 100644 --- a/compiler/wasm32/hlcgcpu.pas +++ b/compiler/wasm32/hlcgcpu.pas @@ -1949,23 +1949,17 @@ implementation var totalremovesize: longint; realresdef: tdef; + ft: TWasmFuncType; 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 e.g. no parameters and a result, it can also increase) } if totalremovesize>0 then decstack(list,totalremovesize) else if totalremovesize<0 then incstack(list,-totalremovesize); + ft.free; end;