[pypy-svn] r65416 - pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp

benjamin at codespeak.net benjamin at codespeak.net
Tue May 26 02:01:28 CEST 2009


Author: benjamin
Date: Tue May 26 02:01:26 2009
New Revision: 65416

Modified:
   pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py
Log:
change optimize methods to return True to remove the operation

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py	Tue May 26 02:01:26 2009
@@ -119,12 +119,12 @@
         self.additional_setarrayitems = {}
         newoperations = []
         for op in self.loop.operations:
-            newop = op
+            remove_op = False
             for opt in self.optimizations[op.opnum]:
-                newop = opt(op, self)
-                if newop is None:
+                remove_op = opt(op, self)
+                if remove_op:
                     break
-            if newop is None:
+            if remove_op:
                 continue
             if op.is_guard():
                 op = self.optimize_guard(op)
@@ -161,9 +161,9 @@
     def optimize_guard_class(op, spec):
         instnode = spec.getnode(op.args[0])
         if instnode.cls is not None:
-            return None
+            return True
         instnode.cls = op.args[1]
-        return op
+        return False
 
 class SimpleVirtualizableOpt(object):
     @staticmethod
@@ -171,61 +171,61 @@
         instnode = spec.getnode(op.args[0])
         instnode.virtualized = True
         instnode.vdesc = op.vdesc
-        return None
+        return True
 
     @staticmethod
     def optimize_getfield_gc(op, spec):
         instnode = spec.getnode(op.args[0])
         if not instnode.virtualized:
-            return op
+            return False
         field = op.descr
         if field not in instnode.vdesc.virtuals:
-            return op
+            return False
         node = instnode.cleanfields.get(field, None)
         if node is not None:
             spec.nodes[op.result] = node
-            return None
+            return True
         node = spec.getnode(op.result)
         node.possibly_virtualized_list = True
         instnode.cleanfields[field] = node
-        return op
+        return False
 
     @staticmethod
     def optimize_setfield_gc(op, spec):
         instnode = spec.getnode(op.args[0])
         if not instnode.virtualized:
-            return op
+            return False
         field = op.descr
         if field not in instnode.vdesc.virtuals:
-            return op
+            return False
         node = spec.getnode(op.args[1])
         instnode.cleanfields[field] = node
         # we never set it here
         d = spec.additional_stores.setdefault(instnode, {})
         d[field] = node
-        return None
+        return True
 
     @staticmethod
     def optimize_getarrayitem_gc(op, spec):
         instnode = spec.getnode(op.args[0])
         if not instnode.possibly_virtualized_list:
-            return op
+            return False
         if not spec.getnode(op.args[1]).const:
             raise VirtualizedListAccessedWithVariableArg()
         field = spec.getnode(op.args[1]).source
         node = instnode.cleanfields.get(field, None)
         if node is not None:
             spec.nodes[op.result] = node
-            return None
+            return True
         node = spec.getnode(op.result)
         instnode.cleanfields[field] = node
-        return op
+        return False
 
     @staticmethod
     def optimize_setarrayitem_gc(op, spec):
         instnode = spec.getnode(op.args[0])
         if not instnode.possibly_virtualized_list:
-            return op
+            return False
         argnode = spec.getnode(op.args[1])
         if not argnode.const:
             raise VirtualizedListAccessedWithVariableArg()
@@ -234,7 +234,7 @@
         instnode.cleanfields[field] = fieldnode
         d = spec.additional_setarrayitems.setdefault(instnode, {})
         d[field] = (fieldnode, op.descr)
-        return None
+        return True
 
 specializer = Specializer([SimpleVirtualizableOpt(),
                            ConsecutiveGuardClassRemoval()])



More information about the Pypy-commit mailing list