[pypy-svn] r49783 - in pypy/dist/pypy/rpython/memory: . gctransform

arigo at codespeak.net arigo at codespeak.net
Fri Dec 14 15:03:23 CET 2007


Author: arigo
Date: Fri Dec 14 15:03:23 2007
New Revision: 49783

Modified:
   pypy/dist/pypy/rpython/memory/gctransform/framework.py
   pypy/dist/pypy/rpython/memory/gctypelayout.py
   pypy/dist/pypy/rpython/memory/gcwrapper.py
Log:
Move the GCData class from gctransform/framework.py to gctypelayout.py
and use it for the gcwrapper case too.  This reduces some code
duplication and makes the details of the TYPE_INFO table encoding
local to gctypelayout.py.


Modified: pypy/dist/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform/framework.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctransform/framework.py	Fri Dec 14 15:03:23 2007
@@ -91,8 +91,6 @@
         print "found %s initializing stores in %s" % (len(result), graph.name)
     return result
 
-ADDRESS_VOID_FUNC = lltype.FuncType([llmemory.Address], lltype.Void)
-
 class FrameworkGCTransformer(GCTransformer):
     use_stackless = False
     root_stack_depth = 163840
@@ -111,80 +109,18 @@
             # for regular translation: pick the GC from the config
             GCClass, GC_PARAMS = choose_gc_from_config(translator.config)
 
-        self.FINALIZERTYPE = lltype.Ptr(ADDRESS_VOID_FUNC)
-        class GCData(object):
-            # types of the GC information tables
-            OFFSETS_TO_GC_PTR = lltype.Array(lltype.Signed)
-            TYPE_INFO = lltype.Struct("type_info",
-                ("isvarsize",   lltype.Bool),
-                ("gcptrinvarsize", lltype.Bool),
-                ("gcarrayofgcptr", lltype.Bool),
-                ("finalizer",   self.FINALIZERTYPE),
-                ("fixedsize",   lltype.Signed),
-                ("ofstoptrs",   lltype.Ptr(OFFSETS_TO_GC_PTR)),
-                ("varitemsize", lltype.Signed),
-                ("ofstovar",    lltype.Signed),
-                ("ofstolength", lltype.Signed),
-                ("varofstoptrs",lltype.Ptr(OFFSETS_TO_GC_PTR)),
-                ("weakptrofs",  lltype.Signed),
-                )
-            TYPE_INFO_TABLE = lltype.Array(TYPE_INFO)
-
-        def q_is_varsize(typeid):
-            ll_assert(typeid > 0, "invalid type_id")
-            return gcdata.type_info_table[typeid].isvarsize
-
-        def q_has_gcptr_in_varsize(typeid):
-            ll_assert(typeid > 0, "invalid type_id")
-            return gcdata.type_info_table[typeid].gcptrinvarsize
-
-        def q_is_gcarrayofgcptr(typeid):
-            ll_assert(typeid > 0, "invalid type_id")
-            return gcdata.type_info_table[typeid].gcarrayofgcptr
-
-        def q_finalizer(typeid):
-            ll_assert(typeid > 0, "invalid type_id")
-            return gcdata.type_info_table[typeid].finalizer
-
-        def q_offsets_to_gc_pointers(typeid):
-            ll_assert(typeid > 0, "invalid type_id")
-            return gcdata.type_info_table[typeid].ofstoptrs
-
-        def q_fixed_size(typeid):
-            ll_assert(typeid > 0, "invalid type_id")
-            return gcdata.type_info_table[typeid].fixedsize
-
-        def q_varsize_item_sizes(typeid):
-            ll_assert(typeid > 0, "invalid type_id")
-            return gcdata.type_info_table[typeid].varitemsize
-
-        def q_varsize_offset_to_variable_part(typeid):
-            ll_assert(typeid > 0, "invalid type_id")
-            return gcdata.type_info_table[typeid].ofstovar
-
-        def q_varsize_offset_to_length(typeid):
-            ll_assert(typeid > 0, "invalid type_id")
-            return gcdata.type_info_table[typeid].ofstolength
-
-        def q_varsize_offsets_to_gcpointers_in_var_part(typeid):
-            ll_assert(typeid > 0, "invalid type_id")
-            return gcdata.type_info_table[typeid].varofstoptrs
-
-        def q_weakpointer_offset(typeid):
-            ll_assert(typeid > 0, "invalid type_id")
-            return gcdata.type_info_table[typeid].weakptrofs
-
         self.layoutbuilder = TransformerLayoutBuilder(self)
         self.get_type_id = self.layoutbuilder.get_type_id
 
-        gcdata = GCData()
         # set up dummy a table, to be overwritten with the real one in finish()
-        gcdata.type_info_table = lltype.malloc(GCData.TYPE_INFO_TABLE, 0,
-                                               immortal=True)
+        type_info_table = lltype.malloc(gctypelayout.GCData.TYPE_INFO_TABLE, 0,
+                                        immortal=True)
+        gcdata = gctypelayout.GCData(type_info_table)
+
         # initialize the following two fields with a random non-NULL address,
         # to make the annotator happy.  The fields are patched in finish()
-        # to point to a real array (not 'static_roots', another one).
-        a_random_address = llmemory.cast_ptr_to_adr(gcdata.type_info_table)
+        # to point to a real array (not 'type_info_table', another one).
+        a_random_address = llmemory.cast_ptr_to_adr(type_info_table)
         gcdata.static_root_start = a_random_address      # patched in finish()
         gcdata.static_root_nongcstart = a_random_address # patched in finish()
         gcdata.static_root_end = a_random_address        # patched in finish()
@@ -202,30 +138,16 @@
             # run-time initialization code
             StackRootIterator.setup_root_stack()
             gcdata.gc.setup()
-            gcdata.gc.set_query_functions(
-                q_is_varsize,
-                q_has_gcptr_in_varsize,
-                q_is_gcarrayofgcptr,
-                q_finalizer,
-                q_offsets_to_gc_pointers,
-                q_fixed_size,
-                q_varsize_item_sizes,
-                q_varsize_offset_to_variable_part,
-                q_varsize_offset_to_length,
-                q_varsize_offsets_to_gcpointers_in_var_part,
-                q_weakpointer_offset)
+            gcdata.set_query_functions(gcdata.gc)
 
         bk = self.translator.annotator.bookkeeper
 
         # the point of this little dance is to not annotate
         # self.gcdata.type_info_table as a constant.
-        data_classdef = bk.getuniqueclassdef(GCData)
+        data_classdef = bk.getuniqueclassdef(gctypelayout.GCData)
         data_classdef.generalize_attr(
             'type_info_table',
-            annmodel.SomePtr(lltype.Ptr(GCData.TYPE_INFO_TABLE)))
-        data_classdef.generalize_attr(
-            'static_roots',
-            annmodel.SomePtr(lltype.Ptr(lltype.Array(llmemory.Address))))
+            annmodel.SomePtr(lltype.Ptr(gctypelayout.GCData.TYPE_INFO_TABLE)))
         data_classdef.generalize_attr(
             'static_root_start',
             annmodel.SomeAddress())
@@ -571,7 +493,7 @@
 
         c_type_id = rmodel.inputconst(lltype.Signed, type_id)
         info = self.layoutbuilder.type_info_list[type_id]
-        c_size = rmodel.inputconst(lltype.Signed, info["fixedsize"])
+        c_size = rmodel.inputconst(lltype.Signed, info.fixedsize)
         has_finalizer = bool(self.finalizer_funcptr_for_type(TYPE))
         c_has_finalizer = rmodel.inputconst(lltype.Bool, has_finalizer)
 
@@ -590,8 +512,8 @@
                     c_has_finalizer, rmodel.inputconst(lltype.Bool, False)]
         else:
             v_length = op.args[-1]
-            c_ofstolength = rmodel.inputconst(lltype.Signed, info['ofstolength'])
-            c_varitemsize = rmodel.inputconst(lltype.Signed, info['varitemsize'])
+            c_ofstolength = rmodel.inputconst(lltype.Signed, info.ofstolength)
+            c_varitemsize = rmodel.inputconst(lltype.Signed, info.varitemsize)
             malloc_ptr = self.malloc_varsize_clear_ptr
 ##             if op.opname.startswith('zero'):
 ##                 malloc_ptr = self.malloc_varsize_clear_ptr
@@ -622,7 +544,7 @@
 
         c_type_id = rmodel.inputconst(lltype.Signed, type_id)
         info = self.layoutbuilder.type_info_list[type_id]
-        c_size = rmodel.inputconst(lltype.Signed, info["fixedsize"])
+        c_size = rmodel.inputconst(lltype.Signed, info.fixedsize)
         has_finalizer = bool(self.finalizer_funcptr_for_type(TYPE))
         assert not has_finalizer
 
@@ -633,8 +555,8 @@
             args = [self.c_const_gc, v_coallocator, c_type_id, c_size]
         else:
             v_length = op.args[-1]
-            c_ofstolength = rmodel.inputconst(lltype.Signed, info['ofstolength'])
-            c_varitemsize = rmodel.inputconst(lltype.Signed, info['varitemsize'])
+            c_ofstolength = rmodel.inputconst(lltype.Signed, info.ofstolength)
+            c_varitemsize = rmodel.inputconst(lltype.Signed, info.varitemsize)
             malloc_ptr = self.coalloc_varsize_clear_ptr
             args = [self.c_const_gc, v_coallocator, c_type_id, v_length, c_size,
                     c_varitemsize, c_ofstolength]
@@ -696,7 +618,7 @@
 
         c_type_id = rmodel.inputconst(lltype.Signed, type_id)
         info = self.layoutbuilder.type_info_list[type_id]
-        c_size = rmodel.inputconst(lltype.Signed, info["fixedsize"])
+        c_size = rmodel.inputconst(lltype.Signed, info.fixedsize)
         malloc_ptr = self.malloc_fixedsize_ptr
         c_has_finalizer = rmodel.inputconst(lltype.Bool, False)
         c_has_weakptr = c_can_collect = rmodel.inputconst(lltype.Bool, True)
@@ -854,31 +776,9 @@
                                                     [llmemory.Address],
                                                     lltype.Void)
         else:
-            fptr = lltype.nullptr(ADDRESS_VOID_FUNC)
+            fptr = lltype.nullptr(gctypelayout.GCData.FINALIZERTYPE.TO)
         return fptr
 
-    def offsets2table(self, offsets, TYPE):
-        try:
-            return self.offsettable_cache[TYPE]
-        except KeyError:
-            gcdata = self.transformer.gcdata
-            cachedarray = lltype.malloc(gcdata.OFFSETS_TO_GC_PTR,
-                                        len(offsets), immortal=True)
-            for i, value in enumerate(offsets):
-                cachedarray[i] = value
-            self.offsettable_cache[TYPE] = cachedarray
-            return cachedarray
-
-    def flatten_table(self):
-        self.can_add_new_types = False
-        table = lltype.malloc(self.transformer.gcdata.TYPE_INFO_TABLE,
-                              len(self.type_info_list), immortal=True)
-        for tableentry, newcontent in zip(table, self.type_info_list):
-            for key, value in newcontent.items():
-                setattr(tableentry, key, value)
-        self.offsettable_cache = None
-        return table
-
 
 def gen_zero_gc_pointers(TYPE, v, llops, previous_steps=None):
     if previous_steps is None:

Modified: pypy/dist/pypy/rpython/memory/gctypelayout.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctypelayout.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctypelayout.py	Fri Dec 14 15:03:23 2007
@@ -1,12 +1,109 @@
 from pypy.rpython.lltypesystem import lltype, llmemory, llarena
+from pypy.rlib.debug import ll_assert
 
 
+class GCData(object):
+    """The GC information tables, and the query functions that the GC
+    calls to decode their content.  The encoding of this information
+    is done by TypeLayoutBuilder.get_type_id().  These two places
+    should be in sync, obviously, but in principle no other code
+    should depend on the details of the encoding in TYPE_INFO.
+    """
+    _alloc_flavor_ = 'raw'
+
+    OFFSETS_TO_GC_PTR = lltype.Array(lltype.Signed)
+    ADDRESS_VOID_FUNC = lltype.FuncType([llmemory.Address], lltype.Void)
+    FINALIZERTYPE = lltype.Ptr(ADDRESS_VOID_FUNC)
+
+    # structure describing the layout of a typeid
+    TYPE_INFO = lltype.Struct("type_info",
+        ("isvarsize",      lltype.Bool),
+        ("gcptrinvarsize", lltype.Bool),
+        ("gcarrayofgcptr", lltype.Bool),
+        ("finalizer",      FINALIZERTYPE),
+        ("fixedsize",      lltype.Signed),
+        ("ofstoptrs",      lltype.Ptr(OFFSETS_TO_GC_PTR)),
+        ("varitemsize",    lltype.Signed),
+        ("ofstovar",       lltype.Signed),
+        ("ofstolength",    lltype.Signed),
+        ("varofstoptrs",   lltype.Ptr(OFFSETS_TO_GC_PTR)),
+        ("weakptrofs",     lltype.Signed),
+        )
+    TYPE_INFO_TABLE = lltype.Array(TYPE_INFO)
+
+    def __init__(self, type_info_table):
+        self.type_info_table = type_info_table
+        # 'type_info_table' is a list of TYPE_INFO structures when
+        # running with gcwrapper, or a real TYPE_INFO_TABLE after
+        # the gctransformer.
+
+    def q_is_varsize(self, typeid):
+        ll_assert(typeid > 0, "invalid type_id")
+        return self.type_info_table[typeid].isvarsize
+
+    def q_has_gcptr_in_varsize(self, typeid):
+        ll_assert(typeid > 0, "invalid type_id")
+        return self.type_info_table[typeid].gcptrinvarsize
+
+    def q_is_gcarrayofgcptr(self, typeid):
+        ll_assert(typeid > 0, "invalid type_id")
+        return self.type_info_table[typeid].gcarrayofgcptr
+
+    def q_finalizer(self, typeid):
+        ll_assert(typeid > 0, "invalid type_id")
+        return self.type_info_table[typeid].finalizer
+
+    def q_offsets_to_gc_pointers(self, typeid):
+        ll_assert(typeid > 0, "invalid type_id")
+        return self.type_info_table[typeid].ofstoptrs
+
+    def q_fixed_size(self, typeid):
+        ll_assert(typeid > 0, "invalid type_id")
+        return self.type_info_table[typeid].fixedsize
+
+    def q_varsize_item_sizes(self, typeid):
+        ll_assert(typeid > 0, "invalid type_id")
+        return self.type_info_table[typeid].varitemsize
+
+    def q_varsize_offset_to_variable_part(self, typeid):
+        ll_assert(typeid > 0, "invalid type_id")
+        return self.type_info_table[typeid].ofstovar
+
+    def q_varsize_offset_to_length(self, typeid):
+        ll_assert(typeid > 0, "invalid type_id")
+        return self.type_info_table[typeid].ofstolength
+
+    def q_varsize_offsets_to_gcpointers_in_var_part(self, typeid):
+        ll_assert(typeid > 0, "invalid type_id")
+        return self.type_info_table[typeid].varofstoptrs
+
+    def q_weakpointer_offset(self, typeid):
+        ll_assert(typeid > 0, "invalid type_id")
+        return self.type_info_table[typeid].weakptrofs
+
+    def set_query_functions(self, gc):
+        gc.set_query_functions(
+            self.q_is_varsize,
+            self.q_has_gcptr_in_varsize,
+            self.q_is_gcarrayofgcptr,
+            self.q_finalizer,
+            self.q_offsets_to_gc_pointers,
+            self.q_fixed_size,
+            self.q_varsize_item_sizes,
+            self.q_varsize_offset_to_variable_part,
+            self.q_varsize_offset_to_length,
+            self.q_varsize_offsets_to_gcpointers_in_var_part,
+            self.q_weakpointer_offset)
+
+# ____________________________________________________________
+
 class TypeLayoutBuilder(object):
     can_add_new_types = True
 
     def __init__(self):
-        dummy = {"weakptrofs": -1,
-                 "ofstolength": -1}
+        dummy = lltype.malloc(GCData.TYPE_INFO, immortal=True, zero=True)
+        dummy.weakptrofs = -1
+        dummy.ofstolength = -1
         self.type_info_list = [dummy]   # don't use typeid 0, helps debugging
         self.id_of_type = {}      # {LLTYPE: type_id}
         self.seen_roots = {}
@@ -18,6 +115,7 @@
         # this lists contains pointers in raw Structs and Arrays
         self.addresses_of_static_ptrs_in_nongc = []
         self.finalizer_funcptrs = {}
+        self.offsettable_cache = {}
 
     def get_type_id(self, TYPE):
         try:
@@ -30,60 +128,81 @@
             # Struct("type_info") in flatten_table().
             type_id = len(self.type_info_list)
             assert type_id & 0xffff == type_id # make sure it fits into 2 bytes
-            info = {}
+            info = lltype.malloc(GCData.TYPE_INFO, immortal=True, zero=True)
             self.type_info_list.append(info)
             self.id_of_type[TYPE] = type_id
             offsets = offsets_to_gc_pointers(TYPE)
-            info["ofstoptrs"] = self.offsets2table(offsets, TYPE)
-            info["finalizer"] = self.make_finalizer_funcptr_for_type(TYPE)
-            info["weakptrofs"] = weakpointer_offset(TYPE)
+            info.ofstoptrs = self.offsets2table(offsets, TYPE)
+            info.finalizer = self.make_finalizer_funcptr_for_type(TYPE)
+            info.weakptrofs = weakpointer_offset(TYPE)
             if not TYPE._is_varsize():
-                info["isvarsize"] = False
-                info["gcptrinvarsize"] = False
-                info["fixedsize"] = llarena.round_up_for_allocation(
+                info.isvarsize = False
+                info.gcptrinvarsize = False
+                info.fixedsize = llarena.round_up_for_allocation(
                     llmemory.sizeof(TYPE))
-                info["ofstolength"] = -1
+                info.ofstolength = -1
                 # note about round_up_for_allocation(): in the 'info' table
                 # we put a rounded-up size only for fixed-size objects.  For
                 # varsize ones, the GC must anyway compute the size at run-time
                 # and round up that result.
             else:
-                info["isvarsize"] = True
-                info["fixedsize"] = llmemory.sizeof(TYPE, 0)
+                info.isvarsize = True
+                info.fixedsize = llmemory.sizeof(TYPE, 0)
                 if isinstance(TYPE, lltype.Struct):
                     ARRAY = TYPE._flds[TYPE._arrayfld]
                     ofs1 = llmemory.offsetof(TYPE, TYPE._arrayfld)
-                    info["ofstolength"] = ofs1 + llmemory.ArrayLengthOffset(ARRAY)
+                    info.ofstolength = ofs1 + llmemory.ArrayLengthOffset(ARRAY)
                     if ARRAY.OF != lltype.Void:
-                        info["ofstovar"] = ofs1 + llmemory.itemoffsetof(ARRAY, 0)
+                        info.ofstovar = ofs1 + llmemory.itemoffsetof(ARRAY, 0)
                     else:
-                        info["fixedsize"] = ofs1 + llmemory.sizeof(lltype.Signed)
+                        info.fixedsize = ofs1 + llmemory.sizeof(lltype.Signed)
+                    # XXX we probably don't need isrpystring any more
                     if ARRAY._hints.get('isrpystring'):
-                        info["fixedsize"] = llmemory.sizeof(TYPE, 1)
+                        info.fixedsize = llmemory.sizeof(TYPE, 1)
                 else:
                     ARRAY = TYPE
-                    info["ofstolength"] = llmemory.ArrayLengthOffset(ARRAY)
+                    info.ofstolength = llmemory.ArrayLengthOffset(ARRAY)
                     if ARRAY.OF != lltype.Void:
-                        info["ofstovar"] = llmemory.itemoffsetof(TYPE, 0)
+                        info.ofstovar = llmemory.itemoffsetof(TYPE, 0)
                     else:
-                        info["fixedsize"] = llmemory.ArrayLengthOffset(ARRAY) + llmemory.sizeof(lltype.Signed)
+                        info.fixedsize = (llmemory.ArrayLengthOffset(ARRAY) +
+                                          llmemory.sizeof(lltype.Signed))
                 assert isinstance(ARRAY, lltype.Array)
                 if ARRAY.OF != lltype.Void:
                     offsets = offsets_to_gc_pointers(ARRAY.OF)
                 else:
                     offsets = ()
-                info["varofstoptrs"] = self.offsets2table(offsets, ARRAY.OF)
-                info["varitemsize"] = llmemory.sizeof(ARRAY.OF)
-                info["gcptrinvarsize"] = len(offsets) > 0
+                info.varofstoptrs = self.offsets2table(offsets, ARRAY.OF)
+                info.varitemsize = llmemory.sizeof(ARRAY.OF)
+                info.gcptrinvarsize = len(offsets) > 0
             # if the type is of the shape GcArray(gcptr) then we record,
             # for now, a flag in the 'info'.  XXX could use a bit in typeid
-            info["gcarrayofgcptr"] = (isinstance(TYPE, lltype.GcArray)
-                                      and isinstance(TYPE.OF, lltype.Ptr)
-                                      and TYPE.OF.TO._gckind == 'gc')
+            info.gcarrayofgcptr = (isinstance(TYPE, lltype.GcArray)
+                                   and isinstance(TYPE.OF, lltype.Ptr)
+                                   and TYPE.OF.TO._gckind == 'gc')
             return type_id
 
     def offsets2table(self, offsets, TYPE):
-        return offsets
+        try:
+            return self.offsettable_cache[TYPE]
+        except KeyError:
+            cachedarray = lltype.malloc(GCData.OFFSETS_TO_GC_PTR,
+                                        len(offsets), immortal=True)
+            for i, value in enumerate(offsets):
+                cachedarray[i] = value
+            self.offsettable_cache[TYPE] = cachedarray
+            return cachedarray
+
+    def flatten_table(self):
+        self.can_add_new_types = False
+        self.offsettable_cache = None
+        table = lltype.malloc(GCData.TYPE_INFO_TABLE, len(self.type_info_list),
+                              immortal=True)
+        fieldnames = GCData.TYPE_INFO._names
+        for tableentry, newcontent in zip(table, self.type_info_list):
+            for name in fieldnames:
+                setattr(tableentry, name, getattr(newcontent, name))
+        return table
 
     def finalizer_funcptr_for_type(self, TYPE):
         if TYPE in self.finalizer_funcptrs:
@@ -95,62 +214,8 @@
     def make_finalizer_funcptr_for_type(self, TYPE):
         return None   # must be overridden for proper finalizer support
 
-    def q_is_varsize(self, typeid):
-        assert typeid > 0
-        return self.type_info_list[typeid]["isvarsize"]
-
-    def q_has_gcptr_in_varsize(self, typeid):
-        assert typeid > 0
-        return self.type_info_list[typeid]["gcptrinvarsize"]
-
-    def q_is_gcarrayofgcptr(self, typeid):
-        assert typeid > 0
-        return self.type_info_list[typeid]["gcarrayofgcptr"]
-
-    def q_finalizer(self, typeid):
-        assert typeid > 0
-        return self.type_info_list[typeid]["finalizer"]
-
-    def q_offsets_to_gc_pointers(self, typeid):
-        assert typeid > 0
-        return self.type_info_list[typeid]["ofstoptrs"]
-
-    def q_fixed_size(self, typeid):
-        assert typeid > 0
-        return self.type_info_list[typeid]["fixedsize"]
-
-    def q_varsize_item_sizes(self, typeid):
-        assert typeid > 0
-        return self.type_info_list[typeid]["varitemsize"]
-
-    def q_varsize_offset_to_variable_part(self, typeid):
-        assert typeid > 0
-        return self.type_info_list[typeid]["ofstovar"]
-
-    def q_varsize_offset_to_length(self, typeid):
-        assert typeid > 0
-        return self.type_info_list[typeid]["ofstolength"]
-
-    def q_varsize_offsets_to_gcpointers_in_var_part(self, typeid):
-        assert typeid > 0
-        return self.type_info_list[typeid]["varofstoptrs"]
-
-    def q_weakpointer_offset(self, typeid):
-        assert typeid > 0
-        return self.type_info_list[typeid]["weakptrofs"]
-
-    def get_query_functions(self):
-        return (self.q_is_varsize,
-                self.q_has_gcptr_in_varsize,
-                self.q_is_gcarrayofgcptr,
-                self.q_finalizer,
-                self.q_offsets_to_gc_pointers,
-                self.q_fixed_size,
-                self.q_varsize_item_sizes,
-                self.q_varsize_offset_to_variable_part,
-                self.q_varsize_offset_to_length,
-                self.q_varsize_offsets_to_gcpointers_in_var_part,
-                self.q_weakpointer_offset)
+    def initialize_gc_query_function(self, gc):
+        return GCData(self.type_info_list).set_query_functions(gc)
 
     def consider_constant(self, TYPE, value, gc):
         if value is not lltype.top_container(value):

Modified: pypy/dist/pypy/rpython/memory/gcwrapper.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gcwrapper.py	(original)
+++ pypy/dist/pypy/rpython/memory/gcwrapper.py	Fri Dec 14 15:03:23 2007
@@ -1,5 +1,6 @@
 from pypy.rpython.lltypesystem import lltype, llmemory, llheap
 from pypy.rpython import llinterp
+from pypy.rpython.annlowlevel import llhelper
 from pypy.rpython.memory.support import get_address_linked_list
 from pypy.rpython.memory import gctypelayout
 from pypy.objspace.flow.model import Constant
@@ -18,7 +19,7 @@
     def prepare_graphs(self, flowgraphs):
         layoutbuilder = DirectRunLayoutBuilder(self.llinterp)
         self.get_type_id = layoutbuilder.get_type_id
-        self.gc.set_query_functions(*layoutbuilder.get_query_functions())
+        layoutbuilder.initialize_gc_query_function(self.gc)
 
         constants = collect_constants(flowgraphs)
         for obj in constants:
@@ -141,7 +142,7 @@
             DESTR_ARG = lltype.typeOf(destrptr).TO.ARGS[0]
             destrgraph = destrptr._obj.graph
         else:
-            return None
+            return lltype.nullptr(gctypelayout.GCData.FINALIZERTYPE.TO)
 
         assert not type_contains_pyobjs(TYPE), "not implemented"
         def ll_finalizer(addr):
@@ -151,7 +152,7 @@
             except llinterp.LLException:
                 raise RuntimeError(
                     "a finalizer raised an exception, shouldn't happen")
-        return ll_finalizer
+        return llhelper(gctypelayout.GCData.FINALIZERTYPE, ll_finalizer)
 
 
 def collect_constants(graphs):



More information about the Pypy-commit mailing list