Beispiel #1
0
    def consider_constant(self, TYPE, value, gc):
        if value is not lltype.top_container(value):
            return
        if value in self.iseen_roots:
            return
        self.iseen_roots[value] = True

        if isinstance(TYPE, lltype.GcOpaqueType):
            self.consider_constant(lltype.typeOf(value.container),
                                   value.container, gc)
            return

        if isinstance(TYPE, (lltype.GcStruct, lltype.GcArray)):
            typeid = self.get_type_id(TYPE)
            hdr = gc.gcheaderbuilder.new_header(value)
            adr = llmemory.cast_ptr_to_adr(hdr)
            gc.init_gc_object_immortal(adr, typeid)
            self.all_prebuilt_gc.append(value)

        # The following collects the addresses of all the fields that have
        # a GC Pointer type, inside the current prebuilt object.  All such
        # fields are potential roots: unless the structure is immutable,
        # they could be changed later to point to GC heap objects.
        adr = llmemory.cast_ptr_to_adr(value._as_ptr())
        if TYPE._gckind == "gc":
            if gc.prebuilt_gc_objects_are_static_roots or gc.DEBUG:
                appendto = self.addresses_of_static_ptrs
            else:
                return
        else:
            appendto = self.addresses_of_static_ptrs_in_nongc
        for a in gc_pointers_inside(value, adr, mutable_only=True):
            appendto.append(a)
Beispiel #2
0
    def consider_constant(self, TYPE, value, gc):
        if value is not lltype.top_container(value):
            return
        if value in self.iseen_roots:
            return
        self.iseen_roots[value] = True

        if isinstance(TYPE, lltype.GcOpaqueType):
            self.consider_constant(lltype.typeOf(value.container),
                                   value.container, gc)
            return

        if isinstance(TYPE, (lltype.GcStruct, lltype.GcArray)):
            typeid = self.get_type_id(TYPE)
            hdr = gc.gcheaderbuilder.new_header(value)
            adr = llmemory.cast_ptr_to_adr(hdr)
            gc.init_gc_object_immortal(adr, typeid)
            self.all_prebuilt_gc.append(value)

        # The following collects the addresses of all the fields that have
        # a GC Pointer type, inside the current prebuilt object.  All such
        # fields are potential roots: unless the structure is immutable,
        # they could be changed later to point to GC heap objects.
        adr = llmemory.cast_ptr_to_adr(value._as_ptr())
        if TYPE._gckind == "gc":
            if gc.prebuilt_gc_objects_are_static_roots or gc.DEBUG:
                appendto = self.addresses_of_static_ptrs
            else:
                return
        else:
            appendto = self.addresses_of_static_ptrs_in_nongc
        for a in gc_pointers_inside(value, adr, mutable_only=True):
            appendto.append(a)
Beispiel #3
0
 def consider_constant(self, TYPE, value):
     if value is not lltype.top_container(value):
         return
     if isinstance(TYPE, (lltype.GcStruct, lltype.GcArray)):
         p = value._as_ptr()
         if not self.gcheaderbuilder.get_header(p):
             hdr = self.gcheaderbuilder.new_header(p)
             hdr.refcount = sys.maxint // 2
Beispiel #4
0
 def consider_constant(self, TYPE, value):
     if value is not lltype.top_container(value):
             return
     if isinstance(TYPE, (lltype.GcStruct, lltype.GcArray)):
         p = value._as_ptr()
         if not self.gcheaderbuilder.get_header(p):
             hdr = self.gcheaderbuilder.new_header(p)
             hdr.refcount = sys.maxint // 2
             hdr.hash = lltype.identityhash_nocache(p)
Beispiel #5
0
 def gcheader_initdata(self, obj):
     top = lltype.top_container(obj)
     return self.gcheaderbuilder.header_of_object(top)._obj
Beispiel #6
0
 def common_gcheader_initdata(self, defnode):
     o = top_container(defnode.obj)
     needs_hash = self.get_prebuilt_hash(o) is not None
     hdr = defnode.db.gctransformer.gc_header_for(o, needs_hash)
     return hdr._obj
Beispiel #7
0
 def common_gcheader_initdata(self, defnode):
     if defnode.db.gctransformer is not None:
         gct = defnode.db.gctransformer
         top = top_container(defnode.obj)
         return gct.gcheaderbuilder.header_of_object(top)._obj
     return None
Beispiel #8
0
 def gcheader_initdata(self, obj):
     top = lltype.top_container(obj)
     return self.gcheaderbuilder.header_of_object(top)._obj
Beispiel #9
0
 def common_gcheader_initdata(self, defnode):
     o = top_container(defnode.obj)
     needs_hash = self.get_prebuilt_hash(o) is not None
     hdr = defnode.db.gctransformer.gc_header_for(o, needs_hash)
     return hdr._obj
Beispiel #10
0
 def common_gcheader_initdata(self, defnode):
     if defnode.db.gctransformer is not None:
         gct = defnode.db.gctransformer
         top = top_container(defnode.obj)
         return gct.gcheaderbuilder.header_of_object(top)._obj
     return None