Răsfoiți Sursa

* made alloctemp more generic

git-svn-id: trunk@24023 -
Jonas Maebe 12 ani în urmă
părinte
comite
477eeadaca
2 a modificat fișierele cu 10 adăugiri și 21 ștergeri
  1. 3 3
      compiler/jvm/tgcpu.pas
  2. 7 18
      compiler/tgobj.pas

+ 3 - 3
compiler/jvm/tgcpu.pas

@@ -42,7 +42,7 @@ unit tgcpu;
         protected
         protected
          procedure getimplicitobjtemp(list: TAsmList; def: tdef; temptype: ttemptype; out ref: treference);
          procedure getimplicitobjtemp(list: TAsmList; def: tdef; temptype: ttemptype; out ref: treference);
          function getifspecialtemp(list: TAsmList; def: tdef; forcesize: aint; temptype: ttemptype; out ref: treference): boolean;
          function getifspecialtemp(list: TAsmList; def: tdef; forcesize: aint; temptype: ttemptype; out ref: treference): boolean;
-         function alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint; override;
+         procedure alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; out ref: treference); override;
         public
         public
          procedure setfirsttemp(l : longint); override;
          procedure setfirsttemp(l : longint); override;
          procedure getlocal(list: TAsmList; size: longint; alignment: shortint; def: tdef; var ref: treference); override;
          procedure getlocal(list: TAsmList; size: longint; alignment: shortint; def: tdef; var ref: treference); override;
@@ -215,7 +215,7 @@ unit tgcpu;
       end;
       end;
 
 
 
 
-    function ttgjvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint;
+    procedure ttgjvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; out ref: treference);
       begin
       begin
         { the JVM only supports 1 slot (= 4 bytes in FPC) and 2 slot (= 8 bytes in
         { 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.
           FPC) temps on the stack. double and int64 are 2 slots, the rest is one slot.
@@ -227,7 +227,7 @@ unit tgcpu;
           internalerror(2010121401);
           internalerror(2010121401);
         { don't pass on "def", since we don't care if a slot is used again for a
         { don't pass on "def", since we don't care if a slot is used again for a
           different type }
           different type }
-        result:=inherited alloctemp(list, size shr 2, 1, temptype, nil);
+        inherited alloctemp(list, size shr 2, 1, temptype, nil,ref);
       end;
       end;
 
 
 
 

+ 7 - 18
compiler/tgobj.pas

@@ -59,8 +59,8 @@ unit tgobj;
        protected
        protected
           { contains all free temps using nextfree links }
           { contains all free temps using nextfree links }
           tempfreelist  : ptemprecord;
           tempfreelist  : ptemprecord;
-          function alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype; def:tdef) : longint; virtual;
-          procedure freetemp(list: TAsmList; pos:longint;temptypes:ttemptypeset);
+          procedure alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype; def:tdef; out ref: treference); virtual;
+          procedure freetemp(list: TAsmList; pos:longint;temptypes:ttemptypeset);virtual;
           procedure gettempinternal(list: TAsmList; size, alignment : longint;temptype:ttemptype;def: tdef;out ref : treference);
           procedure gettempinternal(list: TAsmList; size, alignment : longint;temptype:ttemptype;def: tdef;out ref : treference);
        public
        public
           { contains all temps }
           { contains all temps }
@@ -107,7 +107,7 @@ unit tgobj;
 
 
              @param(ref reference to verify)
              @param(ref reference to verify)
           }
           }
-          function istemp(const ref : treference) : boolean;
+          function istemp(const ref : treference) : boolean; virtual;
           {# Frees a reference @var(ref) which was allocated in the volatile temporary memory space.
           {# Frees a reference @var(ref) which was allocated in the volatile temporary memory space.
              The freed space can later be reallocated and reused. If this reference
              The freed space can later be reallocated and reused. If this reference
              is not in the temporary memory, it is simply not freed.
              is not in the temporary memory, it is simply not freed.
@@ -236,7 +236,7 @@ implementation
       end;
       end;
 
 
 
 
-    function ttgobj.AllocTemp(list: TAsmList; size,alignment : longint; temptype : ttemptype;def : tdef) : longint;
+    procedure ttgobj.alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype;def : tdef; out ref: treference);
       var
       var
          tl,htl,
          tl,htl,
          bestslot,bestprev,
          bestslot,bestprev,
@@ -247,7 +247,6 @@ implementation
          fitatbegin,
          fitatbegin,
          fitatend : boolean;
          fitatend : boolean;
       begin
       begin
-         AllocTemp:=0;
          bestprev:=nil;
          bestprev:=nil;
          bestslot:=nil;
          bestslot:=nil;
          tl:=nil;
          tl:=nil;
@@ -430,7 +429,7 @@ implementation
 {$else}
 {$else}
          list.concat(tai_tempalloc.alloc(tl^.pos,tl^.size));
          list.concat(tai_tempalloc.alloc(tl^.pos,tl^.size));
 {$endif}
 {$endif}
-         AllocTemp:=tl^.pos;
+         reference_reset_base(ref,current_procinfo.framepointer,tl^.pos,alignment);
       end;
       end;
 
 
 
 
@@ -543,12 +542,7 @@ implementation
         varalign : shortint;
         varalign : shortint;
       begin
       begin
         varalign:=used_align(alignment,current_settings.alignment.localalignmin,current_settings.alignment.localalignmax);
         varalign:=used_align(alignment,current_settings.alignment.localalignmin,current_settings.alignment.localalignmax);
-        { can't use reference_reset_base, because that will let tgobj depend
-          on cgobj (PFV) }
-        fillchar(ref,sizeof(ref),0);
-        ref.base:=current_procinfo.framepointer;
-        ref.offset:=alloctemp(list,size,varalign,temptype,def);
-        ref.alignment:=varalign;
+        alloctemp(list,size,varalign,temptype,def,ref);
       end;
       end;
 
 
 
 
@@ -684,12 +678,7 @@ implementation
     procedure ttgobj.getlocal(list: TAsmList; size : longint; alignment : shortint; def:tdef;var ref : treference);
     procedure ttgobj.getlocal(list: TAsmList; size : longint; alignment : shortint; def:tdef;var ref : treference);
       begin
       begin
         alignment:=used_align(alignment,current_settings.alignment.localalignmin,current_settings.alignment.localalignmax);
         alignment:=used_align(alignment,current_settings.alignment.localalignmin,current_settings.alignment.localalignmax);
-        { can't use reference_reset_base, because that will let tgobj depend
-          on cgobj (PFV) }
-        fillchar(ref,sizeof(ref),0);
-        ref.base:=current_procinfo.framepointer;
-        ref.offset:=alloctemp(list,size,alignment,tt_persistent,nil);
-        ref.alignment:=alignment;
+        alloctemp(list,size,alignment,tt_persistent,nil,ref);
       end;
       end;