Browse Source

* modified copyshortstring so it takes an extra paramter which allows it
to delete the sref itself (so the reg deallocations are put in the
right place for the optimizer)

Jonas Maebe 25 years ago
parent
commit
55988e6f55
3 changed files with 34 additions and 11 deletions
  1. 9 3
      compiler/cg386add.pas
  2. 9 3
      compiler/cg386cnv.pas
  3. 16 5
      compiler/cgai386.pas

+ 9 - 3
compiler/cg386add.pas

@@ -281,9 +281,10 @@ implementation
                              { therefore produce a temporary string }
                              { therefore produce a temporary string }
 
 
                              gettempofsizereference(256,href);
                              gettempofsizereference(256,href);
-                             copyshortstring(href,p^.left^.location.reference,255,false);
+                             copyshortstring(href,p^.left^.location.reference,255,false,true);
                              { release the registers }
                              { release the registers }
-                             del_reference(p^.left^.location.reference);
+{                             done by copyshortstring now (JM)           }
+{                             del_reference(p^.left^.location.reference); }
                              ungetiftemp(p^.left^.location.reference);
                              ungetiftemp(p^.left^.location.reference);
 
 
                              { does not hurt: }
                              { does not hurt: }
@@ -2270,7 +2271,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.97  2000-02-29 23:57:36  pierre
+  Revision 1.98  2000-04-10 12:23:19  jonas
+    * modified copyshortstring so it takes an extra paramter which allows it
+      to delete the sref itself (so the reg deallocations are put in the
+      right place for the optimizer)
+
+  Revision 1.97  2000/02/29 23:57:36  pierre
     Use $GOTO ON
     Use $GOTO ON
 
 
   Revision 1.96  2000/02/18 21:25:48  florian
   Revision 1.96  2000/02/18 21:25:48  florian

+ 9 - 3
compiler/cg386cnv.pas

@@ -364,8 +364,9 @@ implementation
                    begin
                    begin
                       gettempofsizereference(pto^.resulttype^.size,pto^.location.reference);
                       gettempofsizereference(pto^.resulttype^.size,pto^.location.reference);
                       copyshortstring(pto^.location.reference,pfrom^.location.reference,
                       copyshortstring(pto^.location.reference,pfrom^.location.reference,
-                        pstringdef(pto^.resulttype)^.len,false);
-                      del_reference(pfrom^.location.reference);
+                        pstringdef(pto^.resulttype)^.len,false,true);
+{                      done by copyshortstring now (JM)          }
+{                      del_reference(pfrom^.location.reference); }
                       ungetiftemp(pfrom^.location.reference);
                       ungetiftemp(pfrom^.location.reference);
                    end;
                    end;
                  st_longstring:
                  st_longstring:
@@ -1536,7 +1537,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.104  2000-03-31 22:56:45  pierre
+  Revision 1.105  2000-04-10 12:23:19  jonas
+    * modified copyshortstring so it takes an extra paramter which allows it
+      to delete the sref itself (so the reg deallocations are put in the
+      right place for the optimizer)
+
+  Revision 1.104  2000/03/31 22:56:45  pierre
     * fix the handling of value parameters in cdecl function
     * fix the handling of value parameters in cdecl function
 
 
   Revision 1.103  2000/02/19 10:12:47  florian
   Revision 1.103  2000/02/19 10:12:47  florian

+ 16 - 5
compiler/cgai386.pas

@@ -91,7 +91,8 @@ unit cgai386;
     procedure emit_mov_reg_loc(reg: TRegister; const t:tlocation);
     procedure emit_mov_reg_loc(reg: TRegister; const t:tlocation);
     procedure emit_movq_reg_loc(reghigh,reglow: TRegister;t:tlocation);
     procedure emit_movq_reg_loc(reghigh,reglow: TRegister;t:tlocation);
 
 
-    procedure copyshortstring(const dref,sref : treference;len : byte;loadref:boolean);
+    procedure copyshortstring(const dref,sref : treference;len : byte;
+                        loadref, del_sref: boolean);
     procedure loadansistring(p : ptree);
     procedure loadansistring(p : ptree);
 
 
     procedure finalize(t : pdef;const ref : treference;is_already_ref : boolean);
     procedure finalize(t : pdef;const ref : treference;is_already_ref : boolean);
@@ -894,9 +895,14 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                            Emit String Functions
                            Emit String Functions
 *****************************************************************************}
 *****************************************************************************}
 
 
-    procedure copyshortstring(const dref,sref : treference;len : byte;loadref:boolean);
+    procedure copyshortstring(const dref,sref : treference;len : byte;
+                loadref, del_sref: boolean);
       begin
       begin
          emitpushreferenceaddr(dref);
          emitpushreferenceaddr(dref);
+          { if it's deleted right before it's used, the optimizer can move }
+          { the reg deallocations to the right places (JM)                 }
+         if del_sref then
+           del_reference(sref);
          if loadref then
          if loadref then
           emit_push_mem(sref)
           emit_push_mem(sref)
          else
          else
@@ -3012,7 +3018,7 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
               reset_reference(href2);
               reset_reference(href2);
               href2.base:=procinfo^.framepointer;
               href2.base:=procinfo^.framepointer;
               href2.offset:=-pvarsym(p)^.localvarsym^.address+pvarsym(p)^.localvarsym^.owner^.address_fixup;
               href2.offset:=-pvarsym(p)^.localvarsym^.address+pvarsym(p)^.localvarsym^.owner^.address_fixup;
-              copyshortstring(href2,href1,pstringdef(pvarsym(p)^.vartype.def)^.len,true);
+              copyshortstring(href2,href1,pstringdef(pvarsym(p)^.vartype.def)^.len,true,false);
             end
             end
            else
            else
             begin
             begin
@@ -3893,7 +3899,12 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.95  2000-04-10 09:01:15  pierre
+  Revision 1.96  2000-04-10 12:23:18  jonas
+    * modified copyshortstring so it takes an extra paramter which allows it
+      to delete the sref itself (so the reg deallocations are put in the
+      right place for the optimizer)
+
+  Revision 1.95  2000/04/10 09:01:15  pierre
    * fix for bug 922 in copyvalueparas
    * fix for bug 922 in copyvalueparas
 
 
   Revision 1.94  2000/04/03 20:51:22  florian
   Revision 1.94  2000/04/03 20:51:22  florian
@@ -4036,4 +4047,4 @@ end.
 
 
   Revision 1.59  1999/11/15 14:04:00  pierre
   Revision 1.59  1999/11/15 14:04:00  pierre
    * self pointer stabs for local function was wrong
    * self pointer stabs for local function was wrong
-}
+}