소스 검색

* fixed calculating the number of stack slots removed by a call
(pushedparasize is already expressed in number of stackslots rather
than in bytes)
o when determining the number of stack slots to pop after calling a function
and not using its function result, round up the function result size to
the nearest multiple of 4 before determining the number os tack slots (to
correctly handle byte/word-sized results)

git-svn-id: branches/jvmbackend@18362 -

Jonas Maebe 14 년 전
부모
커밋
df2d83f110
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      compiler/jvm/njvmcal.pas

+ 4 - 3
compiler/jvm/njvmcal.pas

@@ -121,13 +121,14 @@ implementation
         if (tprocdef(procdefinition).proctypeoption=potype_constructor) then
           totalremovesize:=pushedparasize
         else
-          totalremovesize:=pushedparasize-realresdef.size;
+          { even a byte takes up a full stackslot -> align size to multiple of 4 }
+          totalremovesize:=pushedparasize-(align(realresdef.size,4) shr 2);
         { 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
-          thlcgjvm(hlcg).decstack(current_asmdata.CurrAsmList,totalremovesize shr 2)
+          thlcgjvm(hlcg).decstack(current_asmdata.CurrAsmList,totalremovesize)
         else if totalremovesize<0 then
-          thlcgjvm(hlcg).incstack(current_asmdata.CurrAsmList,(-totalremovesize) shr 2);
+          thlcgjvm(hlcg).incstack(current_asmdata.CurrAsmList,-totalremovesize);
       end;