[pypy-svn] r65835 - in pypy/branch/pyjitpl5/pypy/jit/metainterp: . test

antocuni at codespeak.net antocuni at codespeak.net
Sat Jun 20 14:53:25 CEST 2009


Author: antocuni
Date: Sat Jun 20 14:53:22 2009
New Revision: 65835

Modified:
   pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize3.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize3.py
Log:
a test and a fix: make sure to create the appropriate InstanceValue for all
those boxes that have been virtualized away



Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize3.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize3.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize3.py	Sat Jun 20 14:53:22 2009
@@ -52,12 +52,13 @@
         self.optlist = optlist
         self.nodes = None
         self.loop = None
-        self.dependency_graph = [] # XXX: it's used only by OptimizeVirtuals
+        self.dependency_graph = None
         
     def _init(self, loop):
         self.nodes = {}
         self.loop = loop
-
+        self.dependency_graph = [] # XXX: it's used only by OptimizeVirtuals
+        
     def newnode(self, *args, **kwds): # XXX RPython
         node = InstanceNode(*args, **kwds)
         for opt in self.optlist:
@@ -73,6 +74,7 @@
             return node
 
     def find_nodes(self):
+        assert not self.nodes
         for box in self.loop.inputargs:
             self.nodes[box] = self.newnode(box, escaped=False,)
                                            #startbox=True)
@@ -192,6 +194,14 @@
         self.loop.operations = newoperations
 
     def optimize_operations(self, newinputargs):
+        assert not self.values
+        # create values for boxes that have been virtualized away,
+        # i.e. those boxes whose node.source points to somewhere else
+        for box, node in self.spec.nodes.iteritems():
+            if box is not node.source:
+                self.setval(box)
+                self.getval(box).box = node.source
+
         for box in newinputargs:
             self.setval(box) #  startbox=True)
         newoperations = []
@@ -351,7 +361,7 @@
     def handle_default_op(self, spec, op):
         return op
 
-    def rebuild_box(self, oplist, node, box):
+    def rebuild_box(self, opt, oplist, memo, node, box):
         pass
 
 
@@ -589,6 +599,7 @@
 # -------------------------------------------------------------------
 
 OPTLIST = [
+    OptimizeVirtuals(),
     OptimizeGuards(),
     ]
 

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize3.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize3.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_optimize3.py	Sat Jun 20 14:53:22 2009
@@ -232,9 +232,7 @@
         jump(0)
         """
         loop = self.parse(ops)
-        # cheat
-        loop.operations[1].result.value = 1
-        loop.operations[3].result.value = 3
+        loop.setvalues(i0 = 0, i1 = 1, i2 = 3)
         loop = self.optimize(loop, [OptimizeGuards()])
         self.assert_equal(loop, expected)
 
@@ -275,6 +273,35 @@
         self.check_optimize_loop(opt, loop)
 
 
+class MallocRemoval(BaseVirtualTest):
+
+    def getloop(self):
+        ops = """
+        [i0]
+        p0 = new_with_vtable(ConstClass(node_vtable), descr=nodesize)
+        setfield_gc(p0, i0, descr=valuedescr)
+        i1 = getfield_gc(p0, descr=valuedescr)
+        i2 = int_add(i1, 1)
+        jump(i2)
+        """
+        loop = self.parse(ops)
+        loop.setvalues(i0 = 40, i1 = 40, i2 = 41)
+        return loop
+
+    def test_find_nodes(self):
+        pass
+
+    def test_intersect_input_and_output(self):
+        pass
+
+    def check_optimize_loop(self, opt, loop):
+        expected = """
+        [i0]
+        i2 = int_add(i0, 1)
+        jump(i2)
+        """
+        self.assert_equal(loop, expected)
+
 
 class VirtualSimpleLoop(BaseVirtualTest):
 
@@ -491,6 +518,9 @@
         """
         self.assert_equal(loop, expected)
 
+
+
+
 def create_tests(ns):
     for name, value in ns.items():
         if (isinstance(value, type) and



More information about the Pypy-commit mailing list