Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)]
Exemplo n.º 3
0
 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)]
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 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
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
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
Exemplo n.º 10
0
 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)
Exemplo n.º 11
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)
Exemplo n.º 12
0
 def combine(self, typeid16, flags):
     return llop.combine_ushort(lltype.Signed, typeid16, flags)
Exemplo n.º 13
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)
Exemplo n.º 14
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
Exemplo n.º 15
0
 def combine(self, typeid16, flags):
     return llop.combine_ushort(lltype.Signed, typeid16, flags)
Exemplo n.º 16
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)
Exemplo n.º 17
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
Exemplo n.º 18
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)
Exemplo n.º 19
0
Arquivo: gc.py Projeto: enyst/plexnet
 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)