浏览代码

* fixed unit reloading after the addition of the def field to tcgpara
as used in the function return location (and loading in case of
an explicit para location)

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

Jonas Maebe 14 年之前
父节点
当前提交
90d82ad826
共有 2 个文件被更改,包括 34 次插入0 次删除
  1. 18 0
      compiler/parabase.pas
  2. 16 0
      compiler/symdef.pas

+ 18 - 0
compiler/parabase.pas

@@ -67,6 +67,7 @@ unit parabase;
           Alignment : ShortInt;
           Alignment : ShortInt;
           Size      : TCGSize;  { Size of the parameter included in all locations }
           Size      : TCGSize;  { Size of the parameter included in all locations }
           Def       : tdef; { Type of the parameter }
           Def       : tdef; { Type of the parameter }
+          DefDeref  : tderef;
 {$ifdef powerpc}
 {$ifdef powerpc}
           composite: boolean; { under the AIX abi, how certain parameters are passed depends on whether they are composite or not }
           composite: boolean; { under the AIX abi, how certain parameters are passed depends on whether they are composite or not }
 {$endif powerpc}
 {$endif powerpc}
@@ -78,6 +79,8 @@ unit parabase;
           function    add_location:pcgparalocation;
           function    add_location:pcgparalocation;
           procedure   get_location(var newloc:tlocation);
           procedure   get_location(var newloc:tlocation);
 
 
+          procedure   buildderef;
+          procedure   deref;
           procedure   ppuwrite(ppufile:tcompilerppufile);
           procedure   ppuwrite(ppufile:tcompilerppufile);
           procedure   ppuload(ppufile:tcompilerppufile);
           procedure   ppuload(ppufile:tcompilerppufile);
        end;
        end;
@@ -117,6 +120,7 @@ implementation
         size:=OS_NO;
         size:=OS_NO;
         intsize:=0;
         intsize:=0;
         location:=nil;
         location:=nil;
+        def:=nil;
 {$ifdef powerpc}
 {$ifdef powerpc}
         composite:=false;
         composite:=false;
 {$endif powerpc}
 {$endif powerpc}
@@ -245,6 +249,18 @@ implementation
       end;
       end;
 
 
 
 
+    procedure TCGPara.buildderef;
+      begin
+        defderef.build(def);
+      end;
+
+
+    procedure TCGPara.deref;
+      begin
+        def:=tdef(defderef.resolve);
+      end;
+
+
     procedure TCGPara.ppuwrite(ppufile: tcompilerppufile);
     procedure TCGPara.ppuwrite(ppufile: tcompilerppufile);
       var
       var
         hparaloc: PCGParaLocation;
         hparaloc: PCGParaLocation;
@@ -256,6 +272,7 @@ implementation
 {$ifdef powerpc}
 {$ifdef powerpc}
         ppufile.putbyte(byte(composite));
         ppufile.putbyte(byte(composite));
 {$endif}
 {$endif}
+        ppufile.putderef(defderef);
         nparaloc:=0;
         nparaloc:=0;
         hparaloc:=location;
         hparaloc:=location;
         while assigned(hparaloc) do
         while assigned(hparaloc) do
@@ -313,6 +330,7 @@ implementation
 {$ifdef powerpc}
 {$ifdef powerpc}
         composite:=boolean(ppufile.getbyte);
         composite:=boolean(ppufile.getbyte);
 {$endif}
 {$endif}
+        ppufile.getderef(defderef);
         nparaloc:=ppufile.getbyte;
         nparaloc:=ppufile.getbyte;
         while nparaloc>0 do
         while nparaloc>0 do
           begin
           begin

+ 16 - 0
compiler/symdef.pas

@@ -3441,6 +3441,8 @@ implementation
            exit;
            exit;
          inherited buildderef;
          inherited buildderef;
          returndefderef.build(returndef);
          returndefderef.build(returndef);
+         if po_explicitparaloc in procoptions then
+           funcretloc[callerside].buildderef;
          { parast }
          { parast }
          tparasymtable(parast).buildderef;
          tparasymtable(parast).buildderef;
       end;
       end;
@@ -3450,6 +3452,20 @@ implementation
       begin
       begin
          inherited deref;
          inherited deref;
          returndef:=tdef(returndefderef.resolve);
          returndef:=tdef(returndefderef.resolve);
+         if po_explicitparaloc in procoptions then
+           begin
+             funcretloc[callerside].deref;
+             has_paraloc_info:=callerside;
+            end
+         else
+           begin
+             { deref is called after loading from a ppu, but also after another
+               unit has been reloaded/recompiled and all references must be
+               re-resolved. Since the funcretloc contains a reference to a tdef,
+               reset it so that we won't try to access the stale def }
+             funcretloc[callerside].init;
+             has_paraloc_info:=callnoside;
+           end;
          { parast }
          { parast }
          tparasymtable(parast).deref;
          tparasymtable(parast).deref;
          { recalculated parameters }
          { recalculated parameters }