def consider_constant(self, TYPE, value, gc): if value is not lltype.top_container(value): return if id(value) in self.seen_roots: return self.seen_roots[id(value)] = True 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)
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
def common_gcheader_initdata(self, defnode): if defnode.db.gctransformer is not None: gct = defnode.db.gctransformer hdr = gct.gcheaderbuilder.header_of_object(top_container(defnode.obj)) HDR = gct.HDR return [getattr(hdr, fldname) for fldname in HDR._names] else: return []
def common_gcheader_initdata(self, defnode): if defnode.db.gctransformer is not None: gct = defnode.db.gctransformer hdr = gct.gcheaderbuilder.header_of_object( top_container(defnode.obj)) HDR = gct.HDR return [getattr(hdr, fldname) for fldname in HDR._names] else: return []
def consider_constant(self, TYPE, value): if value is not lltype.top_container(value): return if id(value) in self.seen_roots: return self.seen_roots[id(value)] = True if isinstance(TYPE, (lltype.GcStruct, lltype.GcArray)): typeid = self.get_type_id(TYPE) hdrbuilder = self.gcdata.gc.gcheaderbuilder hdr = hdrbuilder.new_header(value) adr = llmemory.cast_ptr_to_adr(hdr) self.gcdata.gc.init_gc_object(adr, typeid) if find_gc_ptrs_in_type(TYPE): adr = llmemory.cast_ptr_to_adr(value._as_ptr()) if isinstance(TYPE, (lltype.GcStruct, lltype.GcArray)): self.static_gc_roots.append(adr) else: for a in gc_pointers_inside(value, adr): self.addresses_of_static_ptrs_in_nongc.append(a)
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
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
def common_gcheader_initdata(self, defnode): o = top_container(defnode.obj) return defnode.db.gctransformer.gc_field_values_for(o)
def common_gcheader_initdata(self, defnode): o = top_container(defnode.obj) needs_hash = self.get_prebuilt_hash(o) is not None return defnode.db.gctransformer.gc_field_values_for(o, needs_hash)
def gcheader_initdata(self, container): if needs_gcheader(container._TYPE): o = lltype.top_container(container) return self.db.gctransformer.gc_field_values_for(o) else: return []