Exemple #1
0
def get_field_descr(gccache, STRUCT, fieldname):
    cache = gccache._cache_field
    try:
        return cache[STRUCT][fieldname]
    except KeyError:
        offset, size = symbolic.get_field_token(STRUCT, fieldname,
                                                gccache.translate_support_code)
        FIELDTYPE = getattr(STRUCT, fieldname)
        flag = get_type_flag(FIELDTYPE)
        name = '%s.%s' % (STRUCT._name, fieldname)
        index_in_parent = heaptracker.get_fielddescr_index_in(STRUCT, fieldname)
        is_pure = STRUCT._immutable_field(fieldname) != False
        fielddescr = FieldDescr(name, offset, size, flag, index_in_parent,
                                is_pure)
        cachedict = cache.setdefault(STRUCT, {})
        cachedict[fieldname] = fielddescr
        if STRUCT is rclass.OBJECT:
            vtable = lltype.nullptr(rclass.OBJECT_VTABLE)
        else:
            vtable = heaptracker.get_vtable_for_gcstruct(gccache, STRUCT)
        fielddescr.parent_descr = get_size_descr(gccache, STRUCT, vtable)
        return fielddescr
Exemple #2
0
def get_field_descr(gccache, STRUCT, fieldname):
    cache = gccache._cache_field
    try:
        return cache[STRUCT][fieldname]
    except KeyError:
        offset, size = symbolic.get_field_token(STRUCT, fieldname,
                                                gccache.translate_support_code)
        FIELDTYPE = getattr(STRUCT, fieldname)
        flag = get_type_flag(FIELDTYPE)
        name = '%s.%s' % (STRUCT._name, fieldname)
        index_in_parent = heaptracker.get_fielddescr_index_in(STRUCT, fieldname)
        is_pure = STRUCT._immutable_field(fieldname) != False
        fielddescr = FieldDescr(name, offset, size, flag, index_in_parent,
                                is_pure)
        cachedict = cache.setdefault(STRUCT, {})
        cachedict[fieldname] = fielddescr
        if STRUCT is rclass.OBJECT:
            vtable = lltype.nullptr(rclass.OBJECT_VTABLE)
        else:
            vtable = heaptracker.get_vtable_for_gcstruct(gccache, STRUCT)
        fielddescr.parent_descr = get_size_descr(gccache, STRUCT, vtable)
        return fielddescr
Exemple #3
0
 def get_vtable(self):
     assert self._vtable is not None
     if self._vtable is Ellipsis:
         self._vtable = heaptracker.get_vtable_for_gcstruct(self._runner,
                                                            self.S)
     return heaptracker.adr2int(llmemory.cast_ptr_to_adr(self._vtable))