[pypy-svn] r51820 - pypy/branch/unified-rtti/pypy/translator/c

arigo at codespeak.net arigo at codespeak.net
Sat Feb 23 12:12:14 CET 2008


Author: arigo
Date: Sat Feb 23 12:12:13 2008
New Revision: 51820

Modified:
   pypy/branch/unified-rtti/pypy/translator/c/gc.py
   pypy/branch/unified-rtti/pypy/translator/c/node.py
Log:
Database ordering issue, take #8317.


Modified: pypy/branch/unified-rtti/pypy/translator/c/gc.py
==============================================================================
--- pypy/branch/unified-rtti/pypy/translator/c/gc.py	(original)
+++ pypy/branch/unified-rtti/pypy/translator/c/gc.py	Sat Feb 23 12:12:13 2008
@@ -42,22 +42,14 @@
     def array_gcheader_initdata(self, defnode):
         return self.common_gcheader_initdata(defnode)
 
-    def enum_gcheader_dependencies(self, TYPE):
-        if TYPE._gckind != 'gc':
-            return []
-        # make sure that the rtti object of the TYPE is seen by the
-        # database early, i.e. before finish_helpers() on the
-        # gctransformer.  In particular, this should follow the
-        # ll_finalizer helper function stored in the typeinfo.
-        gct = self.db.gctransformer
-        rtti = gct.gcheaderbuilder.getRtti(TYPE)
-        result = [rtti]
-        # The ll_finalizer helpers are delayed func pointers computed
-        # only in finish_helpers().  But we need to follow the regular
-        # destructor before finish_helpers(), in case it uses new types.
-        if rtti is not None and rtti.destructor_funcptr is not None:
-            result.append(rtti.destructor_funcptr)
-        return result
+    def follow_rtti_dependencies(self, rtti):
+        # Issue: the typeinfo corresponding to the rtti contains, as
+        # destructor, a pointer to some ll_finalizer helper.  However it
+        # is a delayed func pointer computed only in finish_helpers().
+        # But we need to follow the regular destructor before
+        # finish_helpers(), in case it uses new types.
+        if rtti.destructor_funcptr is not None:
+            self.db.get(rtti.destructor_funcptr)
 
     def struct_after_definition(self, defnode):
         return []
@@ -86,6 +78,7 @@
 
     def convert_prebuilt_object(self, obj):
         if isinstance(obj, lltype._rtti):
+            self.follow_rtti_dependencies(obj)
             return self.db.gctransformer.convert_rtti(obj)._obj
         elif isinstance(obj, llmemory._wref):
             ptarget = obj._dereference()

Modified: pypy/branch/unified-rtti/pypy/translator/c/node.py
==============================================================================
--- pypy/branch/unified-rtti/pypy/translator/c/node.py	(original)
+++ pypy/branch/unified-rtti/pypy/translator/c/node.py	Sat Feb 23 12:12:13 2008
@@ -68,8 +68,6 @@
         db = self.db
         STRUCT = self.STRUCT
         varlength = self.varlength
-        for ptr in db.gcpolicy.enum_gcheader_dependencies(STRUCT):
-            db.get(ptr)
         if needs_gcheader(self.STRUCT):
             for fname, T in db.gcpolicy.struct_gcheader_definition(self):
                 self.fields.append((fname, db.gettype(T, who_asks=self)))
@@ -198,8 +196,6 @@
             return      # setup() was already called, likely by __init__
         db = self.db
         ARRAY = self.ARRAY
-        for ptr in db.gcpolicy.enum_gcheader_dependencies(ARRAY):
-            db.get(ptr)
         if needs_gcheader(ARRAY):
             for fname, T in db.gcpolicy.array_gcheader_definition(self):
                 self.gcfields.append((fname, db.gettype(T, who_asks=self)))



More information about the Pypy-commit mailing list