[pypy-svn] r52948 - in pypy/branch/jit-hotpath/pypy/jit: rainbow/test timeshifter

antocuni at codespeak.net antocuni at codespeak.net
Tue Mar 25 23:11:16 CET 2008


Author: antocuni
Date: Tue Mar 25 23:11:15 2008
New Revision: 52948

Modified:
   pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py
   pypy/branch/jit-hotpath/pypy/jit/timeshifter/rcontainer.py
Log:
test_merge_structures passes on ootype. I'm not sure about the changes
to rcontainer.py, reviews are welcome :-)



Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py	Tue Mar 25 23:11:15 2008
@@ -104,9 +104,7 @@
         S = lltype.GcStruct(name, *fields, **kwds)
         return S
 
-    @staticmethod
-    def malloc(S):
-        return lltype.malloc(S)
+    malloc = staticmethod(lltype.malloc)
 
     def setup_class(cls):
         cls.on_llgraph = cls.RGenOp is LLRGenOp
@@ -899,9 +897,10 @@
         # this checks that red boxes are able to be virtualized dynamically by
         # the compiler (the P_NOVIRTUAL policy prevents the hint-annotator from
         # marking variables in blue)
-        S = lltype.GcStruct('S', ('n', lltype.Signed))
+        S = self.GcStruct('S', ('n', lltype.Signed))
+        malloc = self.malloc
         def ll_function(n):
-            s = lltype.malloc(S)
+            s = malloc(S)
             s.n = n
             return s.n
         res = self.interpret(ll_function, [42], [])
@@ -996,9 +995,10 @@
         assert len(res.item0) == 3
 
     def test_red_propagate(self):
-        S = lltype.GcStruct('S', ('n', lltype.Signed))
+        S = self.GcStruct('S', ('n', lltype.Signed))
+        malloc = self.malloc
         def ll_function(n, k):
-            s = lltype.malloc(S)
+            s = malloc(S)
             s.n = n
             if k < 0:
                 return -123
@@ -1042,20 +1042,21 @@
 
 
     def test_merge_structures(self):
-        S = lltype.GcStruct('S', ('n', lltype.Signed))
-        T = lltype.GcStruct('T', ('s', lltype.Ptr(S)), ('n', lltype.Signed))
+        S = self.GcStruct('S', ('n', lltype.Signed))
+        T = self.GcStruct('T', ('s', self.Ptr(S)), ('n', lltype.Signed))
+        malloc = self.malloc
 
         def ll_function(flag):
             if flag:
-                s = lltype.malloc(S)
+                s = malloc(S)
                 s.n = 1
-                t = lltype.malloc(T)
+                t = malloc(T)
                 t.s = s
                 t.n = 2
             else:
-                s = lltype.malloc(S)
+                s = malloc(S)
                 s.n = 5
-                t = lltype.malloc(T)
+                t = malloc(T)
                 t.s = s
                 t.n = 6
             return t.n + t.s.n
@@ -1996,9 +1997,7 @@
         I = ootype.Instance(name, ootype.ROOT, dict(fields), **kwds)
         return I
 
-    @staticmethod
-    def malloc(I):
-        return ootype.new(I)
+    malloc = staticmethod(ootype.new)
 
     def translate_insns(self, insns):
         replace = {
@@ -2022,15 +2021,12 @@
     test_degenerated_at_return = _skip
     test_degenerated_via_substructure = _skip
     test_plus_minus = _skip
-    test_red_virtual_container = _skip
     test_red_array = _skip
     test_red_struct_array = _skip
     test_red_varsized_struct = _skip
     test_array_of_voids = _skip
-    test_red_propagate = _skip
     test_red_subcontainer = _skip
     test_red_subcontainer_cast = _skip
-    test_merge_structures = _skip
     test_deepfrozen_interior = _skip
     test_compile_time_const_tuple = _skip
     test_residual_red_call = _skip

Modified: pypy/branch/jit-hotpath/pypy/jit/timeshifter/rcontainer.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/timeshifter/rcontainer.py	(original)
+++ pypy/branch/jit-hotpath/pypy/jit/timeshifter/rcontainer.py	Tue Mar 25 23:11:15 2008
@@ -605,18 +605,18 @@
             RESTYPE = lltype.Ptr(RESTYPE)
             self.fieldnonnull = True
         elif isinstance(RESTYPE, lltype.Ptr):
+            self._set_hints(PTRTYPE, RESTYPE)
             T = RESTYPE.TO
-            if hasattr(T, '_hints'):
-                # xxx hack for simple recursive cases
-                if not PTRTYPE.TO._hints.get('virtualizable', False):
-                    self.virtualizable = T._hints.get('virtualizable', False)
             self.gcref = T._gckind == 'gc'
             if isinstance(T, lltype.ContainerType):
                 if not T._is_varsize() or hasattr(T, 'll_newlist'):
                     self.canbevirtual = True
             else:
                 T = None
-            self.fieldnonnull = PTRTYPE.TO._hints.get('shouldntbenull', False)
+        elif isinstance(RESTYPE, ootype.Instance):
+            self._set_hints(PTRTYPE, RESTYPE)
+            self.gcref = True        # XXX: is it right?
+            self.canbevirtual = True # XXX: is it right?
         elif isinstance(RESTYPE, ootype.OOType):
             assert False, 'XXX: TODO'
         self.RESTYPE = RESTYPE
@@ -633,6 +633,14 @@
             
         self.immutable = deref(PTRTYPE)._hints.get('immutable', False)
 
+    def _set_hints(self, PTRTYPE, RESTYPE):
+        T = deref(RESTYPE)
+        if hasattr(T, '_hints'):
+            # xxx hack for simple recursive cases
+            if not deref(PTRTYPE)._hints.get('virtualizable', False):
+                self.virtualizable = T._hints.get('virtualizable', False)
+        self.fieldnonnull = deref(PTRTYPE)._hints.get('shouldntbenull', False)
+
     def _freeze_(self):
         return True
 


More information about the pypy-svn mailing list