Commits

Maciej Fijalkowski committed d0dcc32

cleanups and pass one more test

Comments (0)

Files changed (3)

pypy/jit/metainterp/optimizeopt/optimizer.py

     def __init__(self):
         pass # make rpython happy
 
-    #def propagate_forward(self, op):
-    #    raise NotImplementedError
-
-    #def emit_operation(self, op):
-    #    self.last_emitted_operation = op
-    #    self.next_optimization.propagate_forward(op)
-
     def process_inputargs(self, args):
         pass
 
     def replace(self, op, with_):
         self.getforwarded(op)._forwarded = with_
 
-    def copy_op_if_modified_by_optimization(self, op):
-        xxxx
-        new_op = op.copy_if_modified_by_optimization(self)
-        if new_op is not op:
-            self.replace(op, new_op)
-        return new_op
-
-    # XXX some RPython magic needed
-    def copy_and_change(self, op, *args, **kwds):
-        xxx
-        new_op = op.copy_and_change(*args, **kwds)
-        if new_op is not op:
-            self.replace(op, new_op)
-        return new_op
-
     def ensure_imported(self, value):
         pass
 
         for opt in self.optimizations:
             opt.process_inputargs(self.loop.inputargs)
         while i < len(self.loop.operations):
-            op = self.loop.operations[i]
-            orig_op = op
+            orig_op = self.loop.operations[i]
+            op = orig_op
             for opt in self.optimizations:
                 op = opt.optimize_operation(op)
+                # result can be either None, the same thing or a new operation
                 if op is None:
                     break
             else:

pypy/jit/metainterp/optimizeopt/pure.py

             else:
                 self.pure_operations.set(orig_op, op)
                 self.remember_emitting_pure(op)
-
         # otherwise, the operation remains
         if nextop:
             return nextop
                 self.replace(op, oldop)
                 self.last_emitted_operation = REMOVED
                 return
-            else:
-                new_op = self.optimizer.getforwarded(op)
-                self.pure_operations.set(new_op, op)
-                self.remember_emitting_pure(op)
-
+            new_op = self.optimizer.getforwarded(op)
+            self.pure_operations.set(op, new_op)
+            self.remember_emitting_pure(new_op)
             # replace CALL_PURE with just CALL
-            xxx
-            self.emit_operation(self.optimizer.copy_and_change(op, opnum))
+            return new_op.make_forwarded_copy(opnum)
         return optimize_CALL_PURE
     optimize_CALL_PURE_i = _new_optimize_call_pure(rop.CALL_i)
     optimize_CALL_PURE_f = _new_optimize_call_pure(rop.CALL_f)

pypy/jit/metainterp/optimizeopt/rewrite.py

         elif v2.is_null():
             self.optimizer.replace(op, op.getarg(0))
         else:
-            self.emit_operation(op)
+            return op
 
     def optimize_INT_SUB(self, op):
         v2 = self.getforwarded(op.getarg(1))