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)]
class SizeDescr(AbstractDescr): size = 0 # help translation tid = llop.combine_ushort(lltype.Signed, 0, 0) def __init__(self, size, count_fields_if_immut=-1, gc_fielddescrs=None): self.size = size self.count_fields_if_immut = count_fields_if_immut self.gc_fielddescrs = gc_fielddescrs def count_fields_if_immutable(self): return self.count_fields_if_immut def repr_of_descr(self): return '<SizeDescr %s>' % self.size
class SizeDescr(AbstractDescr): size = 0 # help translation tid = llop.combine_ushort(lltype.Signed, 0, 0) vtable = lltype.nullptr(rclass.OBJECT_VTABLE) immutable_flag = False def __init__(self, size, gc_fielddescrs=None, all_fielddescrs=None, vtable=lltype.nullptr(rclass.OBJECT_VTABLE), immutable_flag=False): assert lltype.typeOf(vtable) == lltype.Ptr(rclass.OBJECT_VTABLE) self.size = size self.gc_fielddescrs = gc_fielddescrs self.all_fielddescrs = all_fielddescrs self.vtable = vtable self.immutable_flag = immutable_flag def get_all_fielddescrs(self): return self.all_fielddescrs def repr_of_descr(self): return '<SizeDescr %s>' % self.size def is_object(self): return bool(self.vtable) def is_valid_class_for(self, struct): objptr = lltype.cast_opaque_ptr(rclass.OBJECTPTR, struct) cls = llmemory.cast_adr_to_ptr(heaptracker.int2adr(self.get_vtable()), lltype.Ptr(rclass.OBJECT_VTABLE)) # this first comparison is necessary, since we want to make sure # that vtable for JitVirtualRef is the same without actually reading # fields return objptr.typeptr == cls or rclass.ll_isinstance(objptr, cls) def is_immutable(self): return self.immutable_flag def get_vtable(self): return heaptracker.adr2int(llmemory.cast_ptr_to_adr(self.vtable)) def get_type_id(self): assert self.tid return self.tid
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 get_actual_typeid(self, gcptr): # Read the whole GC header word. Return the typeid from the # lower half-word. hdr = rffi.cast(self.HDRPTR, gcptr) type_id = llop.extract_ushort(llgroup.HALFWORD, hdr.tid) return llop.combine_ushort(lltype.Signed, type_id, 0)
def init_array_descr(self, A, descr): if not isinstance(A, (lltype.GcArray, lltype.GcStruct)): return 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): 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 get_actual_typeid(self, gcptr): # Read the whole GC header word. Return the typeid from the # lower half-word. hdr = rffi.cast(self.HDRPTR, gcptr) type_id = llop.extract_ushort(llgroup.HALFWORD, hdr.tid) return llop.combine_ushort(lltype.Signed, type_id, 0)
def init_array_descr(self, A, descr): if not isinstance(A, (lltype.GcArray, lltype.GcStruct)): return 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): if not isinstance(S, lltype.GcStruct): return if self.layoutbuilder is not None: type_id = self.layoutbuilder.get_type_id(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 combine(self, typeid16, flags): return llop.combine_ushort(lltype.Signed, typeid16, flags)
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_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 combine(self, typeid16, flags): return llop.combine_ushort(lltype.Signed, typeid16, flags)
def init_size_descr(self, S, descr): if not isinstance(S, lltype.GcStruct): return if self.layoutbuilder is not None: type_id = self.layoutbuilder.get_type_id(S) descr.tid = llop.combine_ushort(lltype.Signed, type_id, 0)