[pypy-svn] r73720 - in pypy/trunk/pypy/jit/metainterp: . test

arigo at codespeak.net arigo at codespeak.net
Tue Apr 13 15:30:34 CEST 2010


Author: arigo
Date: Tue Apr 13 15:30:32 2010
New Revision: 73720

Modified:
   pypy/trunk/pypy/jit/metainterp/optimizefindnode.py
   pypy/trunk/pypy/jit/metainterp/test/test_optimizefindnode.py
   pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py
Log:
(cfbolz around, arigo)

Fix the two failing tests.  The issue is that intersect() did not
call mark_escaped() on inputnodes even when they are found to
match an escaped exitnode.  This was usually not a problem, except
in obscure cases shown by the tests.



Modified: pypy/trunk/pypy/jit/metainterp/optimizefindnode.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/optimizefindnode.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/optimizefindnode.py	Tue Apr 13 15:30:32 2010
@@ -343,12 +343,16 @@
         # computed by NodeFinder.find_nodes().
         op = loop.operations[-1]
         assert op.opnum == rop.JUMP
-        specnodes = []
         assert len(self.inputnodes) == len(op.args)
-        for i in range(len(op.args)):
-            inputnode = self.inputnodes[i]
-            exitnode = self.getnode(op.args[i])
-            specnodes.append(self.intersect(inputnode, exitnode))
+        while True:
+            self.restart_needed = False
+            specnodes = []
+            for i in range(len(op.args)):
+                inputnode = self.inputnodes[i]
+                exitnode = self.getnode(op.args[i])
+                specnodes.append(self.intersect(inputnode, exitnode))
+            if not self.restart_needed:
+                break
         loop.token.specnodes = specnodes
 
     def intersect(self, inputnode, exitnode):
@@ -363,6 +367,15 @@
             return prebuiltNotSpecNode
         unique = exitnode.unique
         if unique == UNIQUE_NO:
+            if inputnode is not self.node_fromstart:
+                # Mark the input node as escaped, and schedule a complete
+                # restart of intersect().  This is needed because there is
+                # an order dependency: calling inputnode.mark_escaped()
+                # might set the field exitnode.unique to UNIQUE_NO in some
+                # other node.  If inputnode is node_fromstart, there is no
+                # problem (and it must not be mutated by mark_escaped() then).
+                inputnode.mark_escaped()
+                self.restart_needed = True
             return prebuiltNotSpecNode
         if unique == UNIQUE_INST:
             return self.intersect_instance(inputnode, exitnode)

Modified: pypy/trunk/pypy/jit/metainterp/test/test_optimizefindnode.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_optimizefindnode.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_optimizefindnode.py	Tue Apr 13 15:30:32 2010
@@ -301,8 +301,8 @@
         boxes, getnode = self.find_nodes(ops,
                                          'Virtual(node_vtable, nextdescr=Not)')
         assert not getnode(boxes.p0).escaped
-        assert not getnode(boxes.p1).escaped
-        assert not getnode(boxes.p2).escaped
+        assert getnode(boxes.p1).escaped
+        assert getnode(boxes.p2).escaped
         assert getnode(boxes.p0).fromstart
         assert getnode(boxes.p1).fromstart
         assert getnode(boxes.p2).fromstart

Modified: pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py	Tue Apr 13 15:30:32 2010
@@ -1740,7 +1740,6 @@
         self.optimize_loop(ops, 'Not, VArray(arraydescr2, Not)',
                            expected)
 
-    @py.test.mark.xfail
     def test_bug_3(self):
         ops = """
         [p1]
@@ -1761,9 +1760,18 @@
         setfield_gc(p1a, p3a, descr=otherdescr)
         jump(p1a)
         """
-        self.optimize_loop(ops, 'Virtual(node_vtable2, nextdescr=Virtual(node_vtable), otherdescr=Not)', None)
+        expected = """
+        [p2, p3]
+        guard_class(p2, ConstClass(node_vtable)) []
+        guard_class(p3, ConstClass(node_vtable)) []
+        setfield_gc(p3, p2, descr=otherdescr)
+        p3a = new_with_vtable(ConstClass(node_vtable))
+        escape(p3a)
+        p2a = new_with_vtable(ConstClass(node_vtable))
+        jump(p2a, p3a)
+        """
+        self.optimize_loop(ops, 'Virtual(node_vtable2, nextdescr=Not, otherdescr=Not)', expected)
 
-    @py.test.mark.xfail
     def test_bug_3bis(self):
         ops = """
         [p1]
@@ -1784,7 +1792,17 @@
         setfield_gc(p1a, p3a, descr=otherdescr)
         jump(p1a)
         """
-        self.optimize_loop(ops, 'Virtual(node_vtable2, nextdescr=Virtual(node_vtable), otherdescr=Not)', None)
+        expected = """
+        [p2, p3]
+        guard_class(p2, ConstClass(node_vtable)) []
+        guard_class(p3, ConstClass(node_vtable)) []
+        p2a = new_with_vtable(ConstClass(node_vtable))
+        setfield_gc(p3, p2a, descr=otherdescr)
+        p3a = new_with_vtable(ConstClass(node_vtable))
+        escape(p3a)
+        jump(p2a, p3a)
+        """
+        self.optimize_loop(ops, 'Virtual(node_vtable2, nextdescr=Not, otherdescr=Not)', expected)
 
     def test_invalid_loop_1(self):
         ops = """



More information about the Pypy-commit mailing list