Exemple #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
Exemple #2
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
Exemple #3
0
 def is_immutable(self):
     return heaptracker.is_immutable_struct(self.S)