예제 #1
0
 def __init__(self, gcdescr, translator=None, rtyper=None):
     GcCache.__init__(self, translator is not None, rtyper)
     self.gcdescr = gcdescr
     if translator and translator.config.translation.gcremovetypeptr:
         self.fielddescr_vtable = None
     else:
         self.fielddescr_vtable = get_field_descr(self, rclass.OBJECT, "typeptr")
     self._generated_functions = []
예제 #2
0
 def __init__(self, gcdescr, translator=None, rtyper=None):
     GcCache.__init__(self, translator is not None, rtyper)
     self.gcdescr = gcdescr
     if translator and translator.config.translation.gcremovetypeptr:
         self.fielddescr_vtable = None
     else:
         self.fielddescr_vtable = get_field_descr(self, rclass.OBJECT,
                                                  'typeptr')
     self._generated_functions = []
예제 #3
0
파일: gc.py 프로젝트: alkorzt/pypy
 def __init__(self, gc_ll_descr):
     self.llop1 = gc_ll_descr.llop1
     self.WB_FUNCPTR = gc_ll_descr.WB_FUNCPTR
     self.fielddescr_tid = get_field_descr(gc_ll_descr,
                                           gc_ll_descr.GCClass.HDR, 'tid')
     self.jit_wb_if_flag = gc_ll_descr.GCClass.JIT_WB_IF_FLAG
     # if convenient for the backend, we also compute the info about
     # the flag as (byte-offset, single-byte-flag).
     import struct
     value = struct.pack("i", self.jit_wb_if_flag)
     assert value.count('\x00') == len(value) - 1    # only one byte is != 0
     i = 0
     while value[i] == '\x00': i += 1
     self.jit_wb_if_flag_byteofs = i
     self.jit_wb_if_flag_singlebyte = struct.unpack('b', value[i])[0]
예제 #4
0
파일: gc.py 프로젝트: xx312022850/pypy
 def __init__(self, gc_ll_descr):
     self.llop1 = gc_ll_descr.llop1
     self.WB_FUNCPTR = gc_ll_descr.WB_FUNCPTR
     self.fielddescr_tid = get_field_descr(gc_ll_descr,
                                           gc_ll_descr.GCClass.HDR, 'tid')
     self.jit_wb_if_flag = gc_ll_descr.GCClass.JIT_WB_IF_FLAG
     # if convenient for the backend, we also compute the info about
     # the flag as (byte-offset, single-byte-flag).
     import struct
     value = struct.pack("i", self.jit_wb_if_flag)
     assert value.count('\x00') == len(value) - 1  # only one byte is != 0
     i = 0
     while value[i] == '\x00':
         i += 1
     self.jit_wb_if_flag_byteofs = i
     self.jit_wb_if_flag_singlebyte = struct.unpack('b', value[i])[0]
예제 #5
0
파일: gc.py 프로젝트: craigkerstiens/pypy
 def __init__(self, gc_ll_descr):
     GCClass = gc_ll_descr.GCClass
     self.llop1 = gc_ll_descr.llop1
     self.WB_FUNCPTR = gc_ll_descr.WB_FUNCPTR
     self.WB_ARRAY_FUNCPTR = gc_ll_descr.WB_ARRAY_FUNCPTR
     self.fielddescr_tid = get_field_descr(gc_ll_descr, GCClass.HDR, 'tid')
     #
     self.jit_wb_if_flag = GCClass.JIT_WB_IF_FLAG
     self.jit_wb_if_flag_byteofs, self.jit_wb_if_flag_singlebyte = (
         self.extract_flag_byte(self.jit_wb_if_flag))
     #
     if hasattr(GCClass, 'JIT_WB_CARDS_SET'):
         self.jit_wb_cards_set = GCClass.JIT_WB_CARDS_SET
         self.jit_wb_card_page_shift = GCClass.JIT_WB_CARD_PAGE_SHIFT
         self.jit_wb_cards_set_byteofs, self.jit_wb_cards_set_singlebyte = (
             self.extract_flag_byte(self.jit_wb_cards_set))
     else:
         self.jit_wb_cards_set = 0
예제 #6
0
 def fielddescrof(self, STRUCT, fieldname):
     return get_field_descr(self.gc_ll_descr, STRUCT, fieldname)
예제 #7
0
파일: llmodel.py 프로젝트: purepython/pypy
 def fielddescrof(self, STRUCT, fieldname):
     return get_field_descr(self.gc_ll_descr, STRUCT, fieldname)
예제 #8
0
 def _setup_tid(self):
     self.fielddescr_tid = get_field_descr(self, self.GCClass.HDR, 'tid')
예제 #9
0
 def _setup_tid(self):
     self.fielddescr_tid = get_field_descr(self, self.GCClass.HDR, 'tid')
예제 #10
0
파일: gc.py 프로젝트: neurobcn/plexnet
    def __init__(self, gcdescr, translator, llop1=llop):
        from pypy.rpython.memory.gctypelayout import _check_typeid
        from pypy.rpython.memory.gcheader import GCHeaderBuilder
        from pypy.rpython.memory.gctransform import framework
        GcLLDescription.__init__(self, gcdescr, translator)
        assert self.translate_support_code, "required with the framework GC"
        self.translator = translator
        self.llop1 = llop1

        # we need the hybrid GC for GcRefList.alloc_gcref_list() to work
        if gcdescr.config.translation.gc != 'hybrid':
            raise NotImplementedError("--gc=%s not implemented with the JIT" %
                                      (gcdescr.config.translation.gc, ))

        # to find roots in the assembler, make a GcRootMap
        name = gcdescr.config.translation.gcrootfinder
        try:
            cls = globals()['GcRootMap_' + name]
        except KeyError:
            raise NotImplementedError("--gcrootfinder=%s not implemented"
                                      " with the JIT" % (name, ))
        gcrootmap = cls()
        self.gcrootmap = gcrootmap
        self.gcrefs = GcRefList()
        self.single_gcref_descr = GcPtrFieldDescr(0)

        # make a TransformerLayoutBuilder and save it on the translator
        # where it can be fished and reused by the FrameworkGCTransformer
        self.layoutbuilder = framework.JITTransformerLayoutBuilder(
            gcdescr.config)
        self.layoutbuilder.delay_encoding()
        self.translator._jit2gc = {
            'layoutbuilder': self.layoutbuilder,
            'gcmapstart': lambda: gcrootmap.gcmapstart(),
            'gcmapend': lambda: gcrootmap.gcmapend(),
        }
        self.GCClass = self.layoutbuilder.GCClass
        self.moving_gc = self.GCClass.moving_gc
        self.HDRPTR = lltype.Ptr(self.GCClass.HDR)
        self.gcheaderbuilder = GCHeaderBuilder(self.HDRPTR.TO)
        self.fielddescr_tid = get_field_descr(self, self.GCClass.HDR, 'tid')
        self.c_jit_wb_if_flag = ConstInt(self.GCClass.JIT_WB_IF_FLAG)
        self.calldescr_jit_wb = get_call_descr(
            self, [llmemory.GCREF, llmemory.GCREF], lltype.Void)
        (self.array_basesize, _, self.array_length_ofs) = \
             symbolic.get_array_token(lltype.GcArray(lltype.Signed), True)
        min_ns = self.GCClass.TRANSLATION_PARAMS['min_nursery_size']
        self.max_size_of_young_obj = self.GCClass.get_young_fixedsize(min_ns)

        # make a malloc function, with three arguments
        def malloc_basic(size, tid):
            type_id = llop.extract_ushort(rffi.USHORT, tid)
            has_finalizer = bool(tid & (1 << 16))
            _check_typeid(type_id)
            res = llop1.do_malloc_fixedsize_clear(llmemory.GCREF, type_id,
                                                  size, True, has_finalizer,
                                                  False)
            #llop.debug_print(lltype.Void, "\tmalloc_basic", size, type_id,
            #                 "-->", res)
            return res

        self.malloc_basic = malloc_basic
        self.GC_MALLOC_BASIC = lltype.Ptr(
            lltype.FuncType([lltype.Signed, lltype.Signed], llmemory.GCREF))
        self.WB_FUNCPTR = lltype.Ptr(
            lltype.FuncType([llmemory.Address, llmemory.Address], lltype.Void))

        #
        def malloc_array(itemsize, tid, num_elem):
            type_id = llop.extract_ushort(rffi.USHORT, tid)
            _check_typeid(type_id)
            return llop1.do_malloc_varsize_clear(llmemory.GCREF, type_id,
                                                 num_elem, self.array_basesize,
                                                 itemsize,
                                                 self.array_length_ofs, True)

        self.malloc_array = malloc_array
        self.GC_MALLOC_ARRAY = lltype.Ptr(
            lltype.FuncType([lltype.Signed] * 3, llmemory.GCREF))
        #
        (str_basesize, str_itemsize,
         str_ofs_length) = symbolic.get_array_token(rstr.STR, True)
        (unicode_basesize, unicode_itemsize,
         unicode_ofs_length) = symbolic.get_array_token(rstr.UNICODE, True)
        str_type_id = self.layoutbuilder.get_type_id(rstr.STR)
        unicode_type_id = self.layoutbuilder.get_type_id(rstr.UNICODE)

        #
        def malloc_str(length):
            return llop1.do_malloc_varsize_clear(llmemory.GCREF, str_type_id,
                                                 length, str_basesize,
                                                 str_itemsize, str_ofs_length,
                                                 True)

        def malloc_unicode(length):
            return llop1.do_malloc_varsize_clear(llmemory.GCREF,
                                                 unicode_type_id, length,
                                                 unicode_basesize,
                                                 unicode_itemsize,
                                                 unicode_ofs_length, True)

        self.malloc_str = malloc_str
        self.malloc_unicode = malloc_unicode
        self.GC_MALLOC_STR_UNICODE = lltype.Ptr(
            lltype.FuncType([lltype.Signed], llmemory.GCREF))

        def malloc_fixedsize_slowpath(size):
            gcref = llop1.do_malloc_fixedsize_clear(llmemory.GCREF, 0, size,
                                                    True, False, False)
            res = rffi.cast(lltype.Signed, gcref)
            nurs_free = llop1.gc_adr_of_nursery_free(
                llmemory.Address).signed[0]
            return r_ulonglong(nurs_free) << 32 | r_ulonglong(r_uint(res))

        self.malloc_fixedsize_slowpath = malloc_fixedsize_slowpath
        self.MALLOC_FIXEDSIZE_SLOWPATH = lltype.FuncType(
            [lltype.Signed], lltype.UnsignedLongLong)
예제 #11
0
파일: gc.py 프로젝트: enyst/plexnet
    def __init__(self, gcdescr, translator, llop1=llop):
        from pypy.rpython.memory.gctypelayout import _check_typeid
        from pypy.rpython.memory.gcheader import GCHeaderBuilder
        from pypy.rpython.memory.gctransform import framework
        GcLLDescription.__init__(self, gcdescr, translator)
        assert self.translate_support_code, "required with the framework GC"
        self.translator = translator
        self.llop1 = llop1

        # we need the hybrid GC for GcRefList.alloc_gcref_list() to work
        if gcdescr.config.translation.gc != 'hybrid':
            raise NotImplementedError("--gc=%s not implemented with the JIT" %
                                      (gcdescr.config.translation.gc,))

        # to find roots in the assembler, make a GcRootMap
        name = gcdescr.config.translation.gcrootfinder
        try:
            cls = globals()['GcRootMap_' + name]
        except KeyError:
            raise NotImplementedError("--gcrootfinder=%s not implemented"
                                      " with the JIT" % (name,))
        gcrootmap = cls()
        self.gcrootmap = gcrootmap
        self.gcrefs = GcRefList()
        self.single_gcref_descr = GcPtrFieldDescr(0)

        # make a TransformerLayoutBuilder and save it on the translator
        # where it can be fished and reused by the FrameworkGCTransformer
        self.layoutbuilder = framework.JITTransformerLayoutBuilder(
            gcdescr.config)
        self.layoutbuilder.delay_encoding()
        self.translator._jit2gc = {
            'layoutbuilder': self.layoutbuilder,
            'gcmapstart': lambda: gcrootmap.gcmapstart(),
            'gcmapend': lambda: gcrootmap.gcmapend(),
            }
        self.GCClass = self.layoutbuilder.GCClass
        self.moving_gc = self.GCClass.moving_gc
        self.HDRPTR = lltype.Ptr(self.GCClass.HDR)
        self.gcheaderbuilder = GCHeaderBuilder(self.HDRPTR.TO)
        self.fielddescr_tid = get_field_descr(self, self.GCClass.HDR, 'tid')
        self.c_jit_wb_if_flag = ConstInt(self.GCClass.JIT_WB_IF_FLAG)
        self.calldescr_jit_wb = get_call_descr(self, [llmemory.GCREF,
                                                      llmemory.GCREF],
                                               lltype.Void)
        (self.array_basesize, _, self.array_length_ofs) = \
             symbolic.get_array_token(lltype.GcArray(lltype.Signed), True)
        min_ns = self.GCClass.TRANSLATION_PARAMS['min_nursery_size']
        self.max_size_of_young_obj = self.GCClass.get_young_fixedsize(min_ns)

        # make a malloc function, with three arguments
        def malloc_basic(size, tid):
            type_id = llop.extract_ushort(rffi.USHORT, tid)
            has_finalizer = bool(tid & (1<<16))
            _check_typeid(type_id)
            res = llop1.do_malloc_fixedsize_clear(llmemory.GCREF,
                                                  type_id, size, True,
                                                  has_finalizer, False)
            #llop.debug_print(lltype.Void, "\tmalloc_basic", size, type_id,
            #                 "-->", res)
            return res
        self.malloc_basic = malloc_basic
        self.GC_MALLOC_BASIC = lltype.Ptr(lltype.FuncType(
            [lltype.Signed, lltype.Signed], llmemory.GCREF))
        self.WB_FUNCPTR = lltype.Ptr(lltype.FuncType(
            [llmemory.Address, llmemory.Address], lltype.Void))
        #
        def malloc_array(itemsize, tid, num_elem):
            type_id = llop.extract_ushort(rffi.USHORT, tid)
            _check_typeid(type_id)
            return llop1.do_malloc_varsize_clear(
                llmemory.GCREF,
                type_id, num_elem, self.array_basesize, itemsize,
                self.array_length_ofs, True)
        self.malloc_array = malloc_array
        self.GC_MALLOC_ARRAY = lltype.Ptr(lltype.FuncType(
            [lltype.Signed] * 3, llmemory.GCREF))
        #
        (str_basesize, str_itemsize, str_ofs_length
         ) = symbolic.get_array_token(rstr.STR, True)
        (unicode_basesize, unicode_itemsize, unicode_ofs_length
         ) = symbolic.get_array_token(rstr.UNICODE, True)
        str_type_id = self.layoutbuilder.get_type_id(rstr.STR)
        unicode_type_id = self.layoutbuilder.get_type_id(rstr.UNICODE)
        #
        def malloc_str(length):
            return llop1.do_malloc_varsize_clear(
                llmemory.GCREF,
                str_type_id, length, str_basesize, str_itemsize,
                str_ofs_length, True)
        def malloc_unicode(length):
            return llop1.do_malloc_varsize_clear(
                llmemory.GCREF,
                unicode_type_id, length, unicode_basesize, unicode_itemsize,
                unicode_ofs_length, True)
        self.malloc_str = malloc_str
        self.malloc_unicode = malloc_unicode
        self.GC_MALLOC_STR_UNICODE = lltype.Ptr(lltype.FuncType(
            [lltype.Signed], llmemory.GCREF))
        def malloc_fixedsize_slowpath(size):
            gcref = llop1.do_malloc_fixedsize_clear(llmemory.GCREF,
                                        0, size, True, False, False)
            res = rffi.cast(lltype.Signed, gcref)
            nurs_free = llop1.gc_adr_of_nursery_free(llmemory.Address).signed[0]
            return r_ulonglong(nurs_free) << 32 | r_ulonglong(r_uint(res))
        self.malloc_fixedsize_slowpath = malloc_fixedsize_slowpath
        self.MALLOC_FIXEDSIZE_SLOWPATH = lltype.FuncType([lltype.Signed],
                                                 lltype.UnsignedLongLong)