[pypy-commit] pypy jit-opaque-licm: test and fix

hakanardo noreply at buildbot.pypy.org
Mon Jul 23 20:04:21 CEST 2012


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-opaque-licm
Changeset: r56413:8d6c12547231
Date: 2012-07-23 20:00 +0200
http://bitbucket.org/pypy/pypy/changeset/8d6c12547231/

Log:	test and fix

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_multilabel.py b/pypy/jit/metainterp/optimizeopt/test/test_multilabel.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_multilabel.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_multilabel.py
@@ -459,6 +459,25 @@
         """
         self.optimize_loop(ops, expected)
 
+    def test_opaque_pointer_fails_to_close_loop(self):
+        ops = """
+        [p1, p11]
+        p2 = getfield_gc(p1, descr=nextdescr) 
+        guard_class(p2, ConstClass(node_vtable)) []
+        mark_opaque_ptr(p2)        
+        i3 = getfield_gc(p2, descr=otherdescr)
+        label(p1, p11)
+        p12 = getfield_gc(p1, descr=nextdescr) 
+        i13 = getfield_gc(p2, descr=otherdescr)
+        i14 = call(i13, descr=nonwritedescr)        
+        jump(p11, p1)
+        """
+        with raises(InvalidLoop):
+            self.optimize_loop(ops, ops)
+
+            
+
+
 class OptRenameStrlen(Optimization):
     def propagate_forward(self, op):
         dispatch_opt(self, op)
diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -343,7 +343,10 @@
             self.optimizer.send_extra_operation(newop)
             if op.result in self.short_boxes.assumed_classes:
                 classbox = self.getvalue(newop.result).get_constant_class(self.optimizer.cpu)
-                assert classbox.same_constant(self.short_boxes.assumed_classes[op.result])
+                assumed_classbox = self.short_boxes.assumed_classes[op.result]
+                if not classbox or not classbox.same_constant(assumed_classbox):
+                    raise InvalidLoop('Class of opaque pointer needed in short ' +
+                                      'preamble unknown at en of loop')
             i += 1
 
         # Import boxes produced in the preamble but used in the loop


More information about the pypy-commit mailing list