[pypy-svn] r55817 - in pypy/branch/oo-jit/pypy/jit: rainbow/test timeshifter

antocuni at codespeak.net antocuni at codespeak.net
Fri Jun 13 16:27:35 CEST 2008


Author: antocuni
Date: Fri Jun 13 16:27:35 2008
New Revision: 55817

Modified:
   pypy/branch/oo-jit/pypy/jit/rainbow/test/test_promotion.py
   pypy/branch/oo-jit/pypy/jit/timeshifter/rcontainer.py
Log:
(antocuni, arigato around) since InstanceTypeDesc is a cachedtype, the
fielddescs were shared between a typedesc and the typedescs of its
superclasses. Fixing it makes test_raise_result_mixup passing.



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	Fri Jun 13 16:27:35 2008
@@ -6,7 +6,7 @@
 from pypy.jit.rainbow.test.test_vlist import P_OOPSPEC
 from pypy.jit.rainbow.test.test_interpreter import OOTypeMixin
 from pypy.rlib.jit import hint
-from pypy.rpython.module.support import LLSupport
+from pypy.rpython.module.support import LLSupport, OOSupport
 
 class BaseTestPromotion(InterpretationTest):
     small = True
@@ -337,6 +337,7 @@
         assert res == 22
 
     def test_raise_result_mixup(self):
+        from pypy.rpython.annlowlevel import hlstr
         def w(x):
             pass
         class E(Exception):
@@ -348,7 +349,9 @@
                 w(e)
                 raise e                
             return x
-        def ll_function(c, x):
+        def ll_function(c1, x):
+            # needed so that both lltype and ootype can index the string with []
+            c = hlstr(c1)
             i = 0
             while True:
                 hint(None, global_merge_point=True)
@@ -362,9 +365,9 @@
                     i = x
             r = hint(i, variable=True)
             return r
-        ll_function.convert_arguments = [LLSupport.to_rstr, int]
+        ll_function.convert_arguments = [self.to_rstr, int]
         
-        assert ll_function("oe", 1) == 1
+        assert ll_function(self.to_rstr("oe"), 1) == 1
 
         res = self.interpret(ll_function, ["oe", 1], [],
                              policy=StopAtXPolicy(w))
@@ -470,12 +473,13 @@
 
 class TestLLType(BaseTestPromotion):
     type_system = "lltype"
+    to_rstr = staticmethod(LLSupport.to_rstr)
 
 class TestOOType(OOTypeMixin, BaseTestPromotion):
     type_system = "ootype"
+    to_rstr = staticmethod(OOSupport.to_rstr)
 
     def skip(self):
         py.test.skip('in progress')
 
-    test_raise_result_mixup = skip
     test_raise_result_mixup_some_more = skip

Modified: pypy/branch/oo-jit/pypy/jit/timeshifter/rcontainer.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/timeshifter/rcontainer.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/timeshifter/rcontainer.py	Fri Jun 13 16:27:35 2008
@@ -281,10 +281,15 @@
 
     def _iter_fields(self, TYPE):
         try:
-            fields = TYPE._fields
+            fields = TYPE._fields.items()
+            if isinstance(TYPE, ootype.Instance):
+                T = TYPE._superclass
+                while T is not None:
+                    fields = T._fields.items() + fields
+                    T = T._superclass
         except AttributeError:
             return
-        for name, (FIELDTYPE, defl) in fields.iteritems():
+        for name, (FIELDTYPE, defl) in fields:
             yield name, FIELDTYPE
 
     def _get_type_name(self, TYPE):
@@ -293,16 +298,6 @@
         except AttributeError:
             return TYPE._short_name()
 
-    def _compute_fielddescs(self, RGenOp):
-        AbstractStructTypeDesc._compute_fielddescs(self, RGenOp)
-        TYPE = self.TYPE
-        if isinstance(TYPE, ootype.Instance):
-            SUPERTYPE = TYPE._superclass
-            if SUPERTYPE is not None:
-                desc = InstanceTypeDesc(RGenOp, SUPERTYPE)
-                self.fielddescs = desc.fielddescs + self.fielddescs
-                self.fielddesc_by_name.update(desc.fielddesc_by_name)
-
 def create_varsize(jitstate, contdesc, sizebox):
     gv_size = sizebox.getgenvar(jitstate)
     alloctoken = contdesc.varsizealloctoken



More information about the Pypy-commit mailing list