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

antocuni at codespeak.net antocuni at codespeak.net
Sat May 23 19:09:46 CEST 2009


Author: antocuni
Date: Sat May 23 19:09:44 2009
New Revision: 65367

Modified:
   pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize3.py
Log:
move new_arguments back to ConstFold, which has been renamed.  The specializer
relies on it to be the last item of the list to work correctly.



Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize3.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize3.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize3.py	Sat May 23 19:09:44 2009
@@ -25,6 +25,9 @@
     nodes = None
 
     def __init__(self, optlist):
+        for opt in optlist:
+            assert not isinstance(opt, CloneAndConstFold), 'automatically added'
+        optlist.append(CloneAndConstFold())
         self.optlist = optlist
 
     def getnode(self, box):
@@ -84,8 +87,6 @@
                 if newop is None:
                     break
             if newop is not None:
-                newop = newop.clone()
-                newop.args = self.new_arguments(op)
                 newoperations.append(newop)
         print "Length of the loop:", len(newoperations)
         self.loop.operations = newoperations
@@ -131,9 +132,16 @@
         return op
 
 
-class ConstFold(AbstractOptimization):
+class CloneAndConstFold(AbstractOptimization):
+    """
+    Automatically inserted as the last optimization of the list.
+    """
 
     def handle_default_op(self, spec, op):
+        if op.is_guard():
+            return op # TODO
+        op = op.clone()
+        op.args = spec.new_arguments(op)
         if op.is_always_pure():
             for box in op.args:
                 if isinstance(box, Box):
@@ -145,10 +153,6 @@
                 instnode = InstanceNode(box.constbox(), const=True)
                 spec.nodes[box] = instnode
                 return
-        elif not op.has_no_side_effect():
-            # XXX
-            pass
-            #spec.clean_up_caches(newoperations)
         return op
 
 
@@ -195,7 +199,6 @@
 
 OPTLIST = [
     OptimizeGuards(),
-    ConstFold(),
     ]
 specializer = Specializer(OPTLIST)
 



More information about the Pypy-commit mailing list