From c84ec623ddf8bca47704a7c3979f5e36da698829 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 20 Aug 2011 07:36:14 +0000 Subject: [PATCH] * made setfirsttemp() virtual and override it in jvm/tgcpu so it no longer aligns the temp offset in case it's odd (not required for jvm) * ignore the "def" argument in alloctemp() for the jvm since all stack slots can be reused for anything there, and reformatted its alloctemp() git-svn-id: branches/jvmbackend@18297 - --- compiler/jvm/tgcpu.pas | 48 ++++++++++++++++++++++++++++-------------- compiler/tgobj.pas | 2 +- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/compiler/jvm/tgcpu.pas b/compiler/jvm/tgcpu.pas index c0827ccb62..b60e78c282 100644 --- a/compiler/jvm/tgcpu.pas +++ b/compiler/jvm/tgcpu.pas @@ -29,7 +29,9 @@ unit tgcpu; interface uses - tgobj; + globtype, + aasmdata, + symtype,tgobj; type @@ -38,25 +40,39 @@ unit tgcpu; ttgjvm = class(ttgobj) protected function alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint; override; + public + procedure setfirsttemp(l : longint); override; end; -implementation + implementation -{ ttgjvm } + uses + verbose; -function ttgjvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint; -begin - { the JVM only support s1 slot (= 4 bytes in FPC) and 2 slot (= 8 bytes in - FPC) temps on the stack. double and int64 are 2 slots, the rest is one slot. - There are no problems with reusing the same slot for a vakue of a different - type. There are no alignment requirements either. } - if size<4 then - size:=4; - if not(size in [4,8]) then - internalerror(2010121401); - Result:=inherited alloctemp(list, size div 4, 1, temptype, def); -end; + + { ttgjvm } + + function ttgjvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint; + begin + { the JVM only supports 1 slot (= 4 bytes in FPC) and 2 slot (= 8 bytes in + FPC) temps on the stack. double and int64 are 2 slots, the rest is one slot. + There are no problems with reusing the same slot for a value of a different + type. There are no alignment requirements either. } + if size<4 then + size:=4; + if not(size in [4,8]) then + internalerror(2010121401); + { don't pass on "def", since we don't care if a slot is used again for a + different type } + result:=inherited alloctemp(list, size shr 2, 1, temptype, nil); + end; + + procedure ttgjvm.setfirsttemp(l: longint); + begin + firsttemp:=l; + lasttemp:=l; + end; begin - tgclass:=ttgjvm; + tgobjclass:=ttgjvm; end. diff --git a/compiler/tgobj.pas b/compiler/tgobj.pas index e6c79b47e4..5ddcc3a11a 100644 --- a/compiler/tgobj.pas +++ b/compiler/tgobj.pas @@ -78,7 +78,7 @@ unit tgobj; @param(l start offset where temps will start in stack) } - procedure setfirsttemp(l : longint); + procedure setfirsttemp(l : longint); virtual; procedure gettemp(list: TAsmList; size, alignment : longint;temptype:ttemptype;out ref : treference); procedure gettemptyped(list: TAsmList; def:tdef;temptype:ttemptype;out ref : treference);