[pypy-svn] r56153 - in pypy/branch/oo-jit/pypy/jit/rainbow: . test

antocuni at codespeak.net antocuni at codespeak.net
Sat Jun 28 17:38:21 CEST 2008


Author: antocuni
Date: Sat Jun 28 17:38:21 2008
New Revision: 56153

Modified:
   pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py
   pypy/branch/oo-jit/pypy/jit/rainbow/test/test_promotion.py
Log:
if we are asserting the class of a vstruct, we don't need to do anything



Modified: pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py	Sat Jun 28 17:38:21 2008
@@ -631,6 +631,8 @@
 
     @arguments("red", "green", "fielddesc", returns="red")
     def opimpl_assert_class(self, objbox, gv_class, fielddesc):
+        if isinstance(objbox.content, rcontainer.VirtualStruct):
+            return objbox
         classbox = self.PtrRedBox(gv_class)
         objbox.remember_field(fielddesc, classbox)
         return objbox

Modified: pypy/branch/oo-jit/pypy/jit/rainbow/test/test_promotion.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/test/test_promotion.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/rainbow/test/test_promotion.py	Sat Jun 28 17:38:21 2008
@@ -499,6 +499,19 @@
         self.check_insns(malloc=0)
         self.check_insns(new=0)
 
+    def test_promote_class_vstruct(self):
+        class A:
+            def m(self):
+                return 42
+
+        def ll_function():
+            x = A()
+            y = hint(x, promote_class=True)
+            return y.m()
+        res = self.interpret(ll_function, [], [])
+        assert res == 42
+        self.check_insns(malloc=0)
+        self.check_insns(new=0)
 
 class TestLLType(BaseTestPromotion):
     type_system = "lltype"



More information about the Pypy-commit mailing list