Browse Source

+ partial disposing of temp. ansistrings

florian 27 years ago
parent
commit
f4bf391b48
4 changed files with 54 additions and 12 deletions
  1. 9 2
      compiler/cg386add.pas
  2. 22 3
      compiler/cg386flw.pas
  3. 10 6
      compiler/hcodegen.pas
  4. 13 1
      compiler/pass_2.pas

+ 9 - 2
compiler/cg386add.pas

@@ -117,6 +117,7 @@ implementation
         pushed,
         cmpop      : boolean;
         savedunused : tregisterset;
+        hr : treference;
 
       begin
         { string operations are not commutative }
@@ -146,7 +147,6 @@ implementation
                           LOC_REGISTER,LOC_CREGISTER:
                             ungetregister32(p^.left^.location.register);
                         end;
-                        { that's not nice, but how can we avoid, }
 
                         savedunused:=unused;
                         { push the still used registers }
@@ -172,6 +172,10 @@ implementation
                         maybe_loadesi;
                         ungetiftemp(p^.left^.location.reference);
                         ungetiftemp(p^.right^.location.reference);
+                        gettempofsizereference(4,hr);
+                        temptoremove^.concat(new(ptemptodestroy,init(hr,p^.resulttype)));
+                        exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,p^.location.register,
+                          newreference(hr))));
                      end;
                    ltn,lten,gtn,gten,
                    equaln,unequaln:
@@ -1398,7 +1402,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.22  1998-10-28 18:26:12  pierre
+  Revision 1.23  1998-10-29 15:42:43  florian
+    + partial disposing of temp. ansistrings
+
+  Revision 1.22  1998/10/28 18:26:12  pierre
    * removed some erros after other errors (introduced by useexcept)
    * stabs works again correctly (for how long !)
 

+ 22 - 3
compiler/cg386flw.pas

@@ -112,9 +112,14 @@ implementation
 *****************************************************************************}
 
     procedure secondifn(var p : ptree);
+
       var
          hl,otlabel,oflabel : plabel;
+         oldrl : plinkedlist;
+
       begin
+         oldrl:=temptoremove;
+         temptoremove:=new(plinkedlist,init);
          otlabel:=truelabel;
          oflabel:=falselabel;
          getlabel(truelabel);
@@ -125,6 +130,7 @@ implementation
          if assigned(p^.right) then
            begin
               emitl(A_LABEL,truelabel);
+              removetemps(exprasmlist,temptoremove);
               cleartempgen;
               secondpass(p^.right);
            end;
@@ -138,19 +144,29 @@ implementation
                    emitl(A_JMP,hl);
                 end;
               emitl(A_LABEL,falselabel);
+              removetemps(exprasmlist,temptoremove);
               cleartempgen;
               secondpass(p^.t1);
               if assigned(p^.right) then
                 emitl(A_LABEL,hl);
            end
          else
-           emitl(A_LABEL,falselabel);
+           begin
+              emitl(A_LABEL,falselabel);
+              removetemps(exprasmlist,temptoremove);
+           end;
          if not(assigned(p^.right)) then
-           emitl(A_LABEL,truelabel);
+           begin
+              emitl(A_LABEL,truelabel);
+              removetemps(exprasmlist,temptoremove);
+           end;
          freelabel(truelabel);
          freelabel(falselabel);
          truelabel:=otlabel;
          falselabel:=oflabel;
+         releasedata(temptoremove);
+         dispose(temptoremove,done);
+         temptoremove:=oldrl;
       end;
 
 
@@ -737,7 +753,10 @@ do_jmp:
 end.
 {
   $Log$
-  Revision 1.21  1998-10-26 22:58:16  florian
+  Revision 1.22  1998-10-29 15:42:44  florian
+    + partial disposing of temp. ansistrings
+
+  Revision 1.21  1998/10/26 22:58:16  florian
     * new introduded problem with classes fix, the parent class wasn't set
       correct, if the class was defined forward before
 

+ 10 - 6
compiler/hcodegen.pas

@@ -96,10 +96,11 @@ unit hcodegen;
        { some kind of temp. types needs to be destructed }
        { for example ansistring, this is done using this }
        { list                                            }
+       ptemptodestroy = ^ttemptodestroy;
        ttemptodestroy = object(tlinkedlist_item)
-          typ : tdef;
+          typ : pdef;
           address : treference;
-          constructor init(const a : treference;t : tdef);
+          constructor init(const a : treference;p : pdef);
        end;
 
     var
@@ -168,7 +169,7 @@ unit hcodegen;
        make_const_global : boolean = false;
 
     var
-       temptoremove : tlinkedlist;
+       temptoremove : plinkedlist;
 
 implementation
 
@@ -391,19 +392,22 @@ implementation
            end;
       end;
 
-    constructor ttemptodestroy.init(const a : treference;t : tdef);
+    constructor ttemptodestroy.init(const a : treference;p : pdef);
 
       begin
          inherited init;
          address:=a;
-         typ:=t;
+         typ:=p;
       end;
 
 end.
 
 {
   $Log$
-  Revision 1.19  1998-10-26 22:58:18  florian
+  Revision 1.20  1998-10-29 15:42:48  florian
+    + partial disposing of temp. ansistrings
+
+  Revision 1.19  1998/10/26 22:58:18  florian
     * new introduded problem with classes fix, the parent class wasn't set
       correct, if the class was defined forward before
 

+ 13 - 1
compiler/pass_2.pas

@@ -82,6 +82,8 @@ implementation
     procedure secondstatement(var p : ptree);
       var
          hp : ptree;
+         oldrl : plinkedlist;
+
       begin
          hp:=p;
          while assigned(hp) do
@@ -89,7 +91,13 @@ implementation
             if assigned(hp^.right) then
              begin
                cleartempgen;
+               oldrl:=temptoremove;
+               temptoremove:=new(plinkedlist,init);
                secondpass(hp^.right);
+               removetemps(exprasmlist,temptoremove);
+               releasedata(temptoremove);
+               dispose(temptoremove,done);
+               temptoremove:=oldrl;
              end;
             hp:=hp^.left;
           end;
@@ -297,6 +305,7 @@ implementation
       label
          nextreg;
       begin
+         temptoremove:=nil;
          cleartempgen;
          { when size optimization only count occurrence }
          if cs_littlesize in aktglobalswitches then
@@ -486,7 +495,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.7  1998-10-26 22:58:19  florian
+  Revision 1.8  1998-10-29 15:42:49  florian
+    + partial disposing of temp. ansistrings
+
+  Revision 1.7  1998/10/26 22:58:19  florian
     * new introduded problem with classes fix, the parent class wasn't set
       correct, if the class was defined forward before