def init_size_descr(self, S, descr): type_id = self.layoutbuilder.get_type_id(S) assert not self.layoutbuilder.is_weakref_type(S) has_finalizer = bool(self.layoutbuilder.has_finalizer(S)) has_light_finalizer = bool(self.layoutbuilder.has_light_finalizer(S)) flags = (int(has_finalizer) << llgroup.HALFSHIFT | int(has_light_finalizer) << (llgroup.HALFSHIFT + 1)) descr.tid = llop.combine_ushort(lltype.Signed, type_id, flags)
def test_gc_malloc_unicode(self): p = self.gc_ll_descr.gc_malloc_unicode(10) type_id = self.gc_ll_descr.layoutbuilder.get_type_id(rstr.UNICODE) tid = llop.combine_ushort(lltype.Signed, type_id, 0) basesize, itemsize, ofs_length = symbolic.get_array_token( rstr.UNICODE, True) assert self.llop1.record == [("varsize", tid, 10, repr(basesize), repr(itemsize), repr(ofs_length), p)]
def test_gc_malloc_unicode(self): p = self.gc_ll_descr.gc_malloc_unicode(10) type_id = self.gc_ll_descr.layoutbuilder.get_type_id(rstr.UNICODE) tid = llop.combine_ushort(lltype.Signed, type_id, 0) basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.UNICODE, True) assert self.llop1.record == [("varsize", tid, 10, repr(basesize), repr(itemsize), repr(ofs_length), p)]
def do_malloc_fixedsize_clear(self, RESTYPE, type_id, size, can_collect, has_finalizer, contains_weakptr): assert can_collect assert not contains_weakptr p = llmemory.raw_malloc(size) p = llmemory.cast_adr_to_ptr(p, RESTYPE) flags = int(has_finalizer) << 16 tid = llop.combine_ushort(lltype.Signed, type_id, flags) self.record.append(("fixedsize", repr(size), tid, p)) return p
def do_malloc_varsize_clear(self, RESTYPE, type_id, length, size, itemsize, offset_to_length): p = llmemory.raw_malloc(size + itemsize * length) (p + offset_to_length).signed[0] = length p = llmemory.cast_adr_to_ptr(p, RESTYPE) tid = llop.combine_ushort(lltype.Signed, type_id, 0) self.record.append(("varsize", tid, length, repr(size), repr(itemsize), repr(offset_to_length), p)) return p
def do_malloc_fixedsize_clear(self, RESTYPE, type_id, size, can_collect, has_finalizer, contains_weakptr): assert can_collect assert not contains_weakptr p = llmemory.raw_malloc(size) p = llmemory.cast_adr_to_ptr(p, RESTYPE) flags = int(has_finalizer) << 16 tid = llop.combine_ushort(lltype.Signed, type_id, flags) self.record.append(("fixedsize", repr(size), tid, p)) return p
def do_malloc_varsize_clear(self, RESTYPE, type_id, length, size, itemsize, offset_to_length, can_collect): assert can_collect p = llmemory.raw_malloc(size + itemsize * length) (p + offset_to_length).signed[0] = length p = llmemory.cast_adr_to_ptr(p, RESTYPE) tid = llop.combine_ushort(lltype.Signed, type_id, 0) self.record.append(("varsize", tid, length, repr(size), repr(itemsize), repr(offset_to_length), p)) return p
def do_malloc_fixedsize_clear(self, RESTYPE, type_id, size, has_finalizer, has_light_finalizer, contains_weakptr): assert not contains_weakptr assert not has_finalizer # in these tests assert not has_light_finalizer # in these tests p = llmemory.raw_malloc(size) p = llmemory.cast_adr_to_ptr(p, RESTYPE) tid = llop.combine_ushort(lltype.Signed, type_id, 0) self.record.append(("fixedsize", repr(size), tid, p)) return p
class SizeDescr(AbstractDescr): size = 0 # help translation tid = llop.combine_ushort(lltype.Signed, 0, 0) def __init__(self, size, count_fields_if_immut=-1): self.size = size self.count_fields_if_immut = count_fields_if_immut def count_fields_if_immutable(self): return self.count_fields_if_immut def repr_of_descr(self): return '<SizeDescr %s>' % self.size
def init_array_descr(self, A, descr): type_id = self.layoutbuilder.get_type_id(A) descr.tid = llop.combine_ushort(lltype.Signed, type_id, 0)
def init_size_descr(self, S, descr): type_id = self.layoutbuilder.get_type_id(S) assert not self.layoutbuilder.is_weakref_type(S) assert not self.layoutbuilder.has_finalizer(S) descr.tid = llop.combine_ushort(lltype.Signed, type_id, 0)
def combine(self, typeid16, flags): return llop.combine_ushort(lltype.Signed, typeid16, flags)
def init_size_descr(self, S, descr): type_id = self.layoutbuilder.get_type_id(S) assert not self.layoutbuilder.is_weakref(type_id) has_finalizer = bool(self.layoutbuilder.has_finalizer(S)) flags = int(has_finalizer) << 16 descr.tid = llop.combine_ushort(lltype.Signed, type_id, flags)
def _malloc(self, type_id, size): tid = llop.combine_ushort(lltype.Signed, type_id, 0) x = llmemory.raw_malloc(self.gcheaderbuilder.size_gc_header + size) x += self.gcheaderbuilder.size_gc_header return x, tid
def combine(self, typeid16, flags): return llop.combine_ushort(lltype.Signed, typeid16, flags)
def init_size_descr(self, S, descr): if self.layoutbuilder is not None: type_id = self.layoutbuilder.get_type_id(S) assert not self.layoutbuilder.is_weakref_type(S) assert not self.layoutbuilder.has_finalizer(S) descr.tid = llop.combine_ushort(lltype.Signed, type_id, 0)
def _malloc(self, type_id, size): tid = llop.combine_ushort(lltype.Signed, type_id, 0) x = llmemory.raw_malloc(self.gcheaderbuilder.size_gc_header + size) x += self.gcheaderbuilder.size_gc_header return x, tid
def init_array_descr(self, A, descr): if self.layoutbuilder is not None: type_id = self.layoutbuilder.get_type_id(A) descr.tid = llop.combine_ushort(lltype.Signed, type_id, 0)
def init_size_descr(self, S, descr): type_id = self.layoutbuilder.get_type_id(S) assert not self.layoutbuilder.is_weakref(type_id) has_finalizer = bool(self.layoutbuilder.has_finalizer(S)) flags = int(has_finalizer) << 16 descr.tid = llop.combine_ushort(lltype.Signed, type_id, flags)