2
0
Эх сурвалжийг харах

* fixed memory leaks in ppc peephole optimizer

git-svn-id: trunk@5569 -
Jonas Maebe 18 жил өмнө
parent
commit
32e06e7a7a

+ 9 - 4
compiler/aasmtai.pas

@@ -593,6 +593,7 @@ interface
            procedure loadreg(opidx:longint;r:tregister);
            procedure loadreg(opidx:longint;r:tregister);
            procedure loadoper(opidx:longint;o:toper);
            procedure loadoper(opidx:longint;o:toper);
            procedure clearop(opidx:longint);
            procedure clearop(opidx:longint);
+           procedure freeop(opidx:longint);
            { register allocator }
            { register allocator }
            function is_same_reg_move(regtype: Tregistertype):boolean;virtual;
            function is_same_reg_move(regtype: Tregistertype):boolean;virtual;
            function spilling_get_operation_type(opnr: longint): topertype;virtual;
            function spilling_get_operation_type(opnr: longint): topertype;virtual;
@@ -1992,10 +1993,7 @@ implementation
         i : integer;
         i : integer;
       begin
       begin
         for i:=0 to opercnt-1 do
         for i:=0 to opercnt-1 do
-          begin
-            clearop(i);
-            dispose(oper[i]);
-          end;
+          freeop(i);
         inherited destroy;
         inherited destroy;
       end;
       end;
 
 
@@ -2182,6 +2180,13 @@ implementation
       end;
       end;
 
 
 
 
+    procedure tai_cpu_abstract.freeop(opidx:longint);
+      begin
+        clearop(opidx);
+        dispose(oper[opidx]);
+      end;
+
+
 { ---------------------------------------------------------------------
 { ---------------------------------------------------------------------
     Miscellaneous methods.
     Miscellaneous methods.
   ---------------------------------------------------------------------}
   ---------------------------------------------------------------------}

+ 9 - 9
compiler/powerpc/aoptcpu.pas

@@ -374,9 +374,9 @@ const
                             // masks have no bits in common
                             // masks have no bits in common
                             taicpu(p).opcode := A_LI;
                             taicpu(p).opcode := A_LI;
                             taicpu(p).loadconst(1,0);
                             taicpu(p).loadconst(1,0);
-                            taicpu(p).clearop(2);
-                            taicpu(p).clearop(3);
-                            taicpu(p).clearop(4);
+                            taicpu(p).freeop(2);
+                            taicpu(p).freeop(3);
+                            taicpu(p).freeop(4);
                             taicpu(p).ops := 2;
                             taicpu(p).ops := 2;
                             taicpu(p).opercnt := 2;
                             taicpu(p).opercnt := 2;
                             asml.remove(next1);
                             asml.remove(next1);
@@ -480,20 +480,20 @@ const
                         taicpu(p).oper[2]^.val := word(
                         taicpu(p).oper[2]^.val := word(
                           ((1 shl (16-taicpu(p).oper[3]^.val)) - 1) xor
                           ((1 shl (16-taicpu(p).oper[3]^.val)) - 1) xor
                           ((1 shl (15-taicpu(p).oper[4]^.val)) - 1));
                           ((1 shl (15-taicpu(p).oper[4]^.val)) - 1));
-                        taicpu(p).clearop(3);
-                        taicpu(p).clearop(4);
+                        taicpu(p).freeop(3);
+                        taicpu(p).freeop(4);
                         taicpu(p).ops := 3;
                         taicpu(p).ops := 3;
-                        taicpu(p).opercnt := 2;
+                        taicpu(p).opercnt := 3;
                       end
                       end
                     else if (taicpu(p).oper[3]^.val >= 16) and
                     else if (taicpu(p).oper[3]^.val >= 16) and
                        (taicpu(p).oper[4]^.val >= 16) then
                        (taicpu(p).oper[4]^.val >= 16) then
                       begin
                       begin
                         taicpu(p).opcode := A_ANDI_;
                         taicpu(p).opcode := A_ANDI_;
                         taicpu(p).oper[2]^.val := word(rlwinm2mask(taicpu(p).oper[3]^.val,taicpu(p).oper[4]^.val));
                         taicpu(p).oper[2]^.val := word(rlwinm2mask(taicpu(p).oper[3]^.val,taicpu(p).oper[4]^.val));
-                        taicpu(p).clearop(3);
-                        taicpu(p).clearop(4);
+                        taicpu(p).freeop(3);
+                        taicpu(p).freeop(4);
                         taicpu(p).ops := 3;
                         taicpu(p).ops := 3;
-                        taicpu(p).opercnt := 2;
+                        taicpu(p).opercnt := 3;
                       end;
                       end;
                 end;
                 end;
             end;
             end;