Пример #1
0
def get_size_descr(gccache,
                   STRUCT,
                   vtable=lltype.nullptr(rclass.OBJECT_VTABLE)):
    cache = gccache._cache_size
    assert not isinstance(vtable, bool)
    try:
        return cache[STRUCT]
    except KeyError:
        size = symbolic.get_size(STRUCT, gccache.translate_support_code)
        immutable_flag = heaptracker.is_immutable_struct(STRUCT)
        if vtable:
            assert heaptracker.has_gcstruct_a_vtable(STRUCT)
        else:
            assert not heaptracker.has_gcstruct_a_vtable(STRUCT)
        sizedescr = SizeDescr(size,
                              vtable=vtable,
                              immutable_flag=immutable_flag)
        gccache.init_size_descr(STRUCT, sizedescr)
        cache[STRUCT] = sizedescr
        # XXX do we really need gc_fielddescrs if we also have
        # all_fielddescrs and can ask is_pointer_field() on them?
        gc_fielddescrs = heaptracker.gc_fielddescrs(gccache, STRUCT)
        sizedescr.gc_fielddescrs = gc_fielddescrs
        all_fielddescrs = heaptracker.all_fielddescrs(gccache, STRUCT)
        sizedescr.all_fielddescrs = all_fielddescrs
        return sizedescr
Пример #2
0
 def check_is_object(self, gcptr):
     """Check if the given, non-null gcptr refers to an rclass.OBJECT
     or not at all (an unrelated GcStruct or a GcArray).  Only usable
     in the llgraph backend, or after translation of a real backend."""
     ptr = lltype.normalizeptr(gcptr._obj.container._as_ptr())
     T = lltype.typeOf(ptr).TO
     return heaptracker.has_gcstruct_a_vtable(T) or T is rclass.OBJECT
Пример #3
0
def get_size_descr(gccache, STRUCT):
    cache = gccache._cache_size
    try:
        return cache[STRUCT]
    except KeyError:
        size = symbolic.get_size(STRUCT, gccache.translate_support_code)
        count_fields_if_immut = heaptracker.count_fields_if_immutable(STRUCT)
        if heaptracker.has_gcstruct_a_vtable(STRUCT):
            sizedescr = SizeDescrWithVTable(size, count_fields_if_immut)
        else:
            sizedescr = SizeDescr(size, count_fields_if_immut)
        gccache.init_size_descr(STRUCT, sizedescr)
        cache[STRUCT] = sizedescr
        return sizedescr
Пример #4
0
def get_size_descr(gccache, STRUCT, vtable=lltype.nullptr(rclass.OBJECT_VTABLE)):
    cache = gccache._cache_size
    assert not isinstance(vtable, bool)
    try:
        return cache[STRUCT]
    except KeyError:
        size = symbolic.get_size(STRUCT, gccache.translate_support_code)
        immutable_flag = heaptracker.is_immutable_struct(STRUCT)
        if vtable:
            assert heaptracker.has_gcstruct_a_vtable(STRUCT)
        else:
            assert not heaptracker.has_gcstruct_a_vtable(STRUCT)
        sizedescr = SizeDescr(size, vtable=vtable,
                              immutable_flag=immutable_flag)
        gccache.init_size_descr(STRUCT, sizedescr)
        cache[STRUCT] = sizedescr
        # XXX do we really need gc_fielddescrs if we also have
        # all_fielddescrs and can ask is_pointer_field() on them?
        gc_fielddescrs = heaptracker.gc_fielddescrs(gccache, STRUCT)
        sizedescr.gc_fielddescrs = gc_fielddescrs
        all_fielddescrs = heaptracker.all_fielddescrs(gccache, STRUCT)
        sizedescr.all_fielddescrs = all_fielddescrs
        return sizedescr
Пример #5
0
 def fielddescrof(self, S, fieldname):
     key = ('field', S, fieldname)
     try:
         return self.descrs[key]
     except KeyError:
         descr = FieldDescr(S, fieldname)
         self.descrs[key] = descr
         if (isinstance(S, lltype.GcStruct) and
                 heaptracker.has_gcstruct_a_vtable(S)):
             vtable = Ellipsis
         else:
             vtable = None
         descr.parent_descr = self.sizeof(S, vtable)
         if self.vinfo_for_tests is not None:
             descr.vinfo = self.vinfo_for_tests
         return descr
Пример #6
0
def get_size_descr(gccache, STRUCT):
    cache = gccache._cache_size
    try:
        return cache[STRUCT]
    except KeyError:
        size = symbolic.get_size(STRUCT, gccache.translate_support_code)
        count_fields_if_immut = heaptracker.count_fields_if_immutable(STRUCT)
        gc_fielddescrs = heaptracker.gc_fielddescrs(gccache, STRUCT)
        if heaptracker.has_gcstruct_a_vtable(STRUCT):
            sizedescr = SizeDescrWithVTable(size, count_fields_if_immut,
                                            gc_fielddescrs)
        else:
            sizedescr = SizeDescr(size, count_fields_if_immut,
                                  gc_fielddescrs)
        gccache.init_size_descr(STRUCT, sizedescr)
        cache[STRUCT] = sizedescr
        return sizedescr