コード例 #1
0
ファイル: gc.py プロジェクト: weijiwei/pypy
 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
ファイル: gc.py プロジェクト: mozillazg/pypy
 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 プロジェクト: xen0n/pypy
 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 = []
     self.memcpy_fn = memcpy_fn
     self.memcpy_descr = get_call_descr(self,
         [lltype.Signed, lltype.Signed, lltype.Signed], lltype.Void,
         EffectInfo([], [], [], [], [], [], EffectInfo.EF_CANNOT_RAISE,
             can_collect=False))
コード例 #4
0
ファイル: heaptracker.py プロジェクト: Darriall/pypy
def gc_fielddescrs(gccache, STRUCT, res=None):
    from rpython.jit.backend.llsupport import descr

    if res is None:
        res = []
    # order is not relevant, except for tests
    for name in STRUCT._names:
        FIELD = getattr(STRUCT, name)
        if FIELD is lltype.Void:
            continue
        elif isinstance(FIELD, lltype.Struct):
            gc_fielddescrs(gccache, FIELD, res)
        elif isinstance(FIELD, lltype.Ptr) and FIELD._needsgc():
            res.append(descr.get_field_descr(gccache, STRUCT, name))
    return res
コード例 #5
0
def gc_fielddescrs(gccache, STRUCT, res=None):
    from rpython.jit.backend.llsupport import descr

    if res is None:
        res = []
    # order is not relevant, except for tests
    for name in STRUCT._names:
        FIELD = getattr(STRUCT, name)
        if FIELD is lltype.Void:
            continue
        elif isinstance(FIELD, lltype.Struct):
            gc_fielddescrs(gccache, FIELD, res)
        elif isinstance(FIELD, lltype.Ptr) and FIELD._needsgc():
            res.append(descr.get_field_descr(gccache, STRUCT, name))
    return res
コード例 #6
0
    def check_rewrite(self, frm_operations, to_operations, **namespace):
        # objects to use inside the test
        A = lltype.GcArray(lltype.Signed)
        adescr = get_array_descr(self.gc_ll_descr, A)
        adescr.tid = 4321
        alendescr = adescr.lendescr
        #
        pinned_obj_type = lltype.GcStruct('PINNED_STRUCT', ('my_int', lltype.Signed))
        pinned_obj_my_int_descr = get_field_descr(self.gc_ll_descr, pinned_obj_type, 'my_int')
        pinned_obj_ptr = lltype.malloc(pinned_obj_type)
        pinned_obj_gcref = lltype.cast_opaque_ptr(llmemory.GCREF, pinned_obj_ptr)
        assert rgc.pin(pinned_obj_gcref)
        #
        notpinned_obj_type = lltype.GcStruct('NOT_PINNED_STRUCT', ('my_int', lltype.Signed))
        notpinned_obj_my_int_descr = get_field_descr(self.gc_ll_descr, notpinned_obj_type, 'my_int')
        notpinned_obj_ptr = lltype.malloc(notpinned_obj_type)
        notpinned_obj_gcref = lltype.cast_opaque_ptr(llmemory.GCREF, notpinned_obj_ptr)
        #
        ptr_array_descr = self.cpu.arraydescrof(MovableObjectTracker.ptr_array_type)
        #
        vtable_descr = self.gc_ll_descr.fielddescr_vtable
        O = lltype.GcStruct('O', ('parent', rclass.OBJECT),
                                 ('x', lltype.Signed))
        o_vtable = lltype.malloc(rclass.OBJECT_VTABLE, immortal=True)
        #
        tiddescr = self.gc_ll_descr.fielddescr_tid
        wbdescr = self.gc_ll_descr.write_barrier_descr
        WORD = globals()['WORD']
        #
        strdescr     = self.gc_ll_descr.str_descr
        unicodedescr = self.gc_ll_descr.unicode_descr
        strlendescr     = strdescr.lendescr
        unicodelendescr = unicodedescr.lendescr

        casmdescr = JitCellToken()
        clt = FakeLoopToken()
        clt._ll_initial_locs = [0, 8]
        frame_info = lltype.malloc(jitframe.JITFRAMEINFO, flavor='raw')
        clt.frame_info = frame_info
        frame_info.jfi_frame_depth = 13
        frame_info.jfi_frame_size = 255
        framedescrs = self.gc_ll_descr.getframedescrs(self.cpu)
        framelendescr = framedescrs.arraydescr.lendescr
        jfi_frame_depth = framedescrs.jfi_frame_depth
        jfi_frame_size = framedescrs.jfi_frame_size
        jf_frame_info = framedescrs.jf_frame_info
        signedframedescr = self.cpu.signedframedescr
        floatframedescr = self.cpu.floatframedescr
        casmdescr.compiled_loop_token = clt
        tzdescr = None # noone cares
        #
        namespace.update(locals())
        #
        for funcname in self.gc_ll_descr._generated_functions:
            namespace[funcname] = self.gc_ll_descr.get_malloc_fn(funcname)
            namespace[funcname + '_descr'] = getattr(self.gc_ll_descr,
                                                     '%s_descr' % funcname)
        #
        ops = parse(frm_operations, namespace=namespace)
        operations = self.gc_ll_descr.rewrite_assembler(self.cpu,
                                                        ops.operations,
                                                        [])
        # make the array containing the GCREF's accessible inside the tests.
        # This must be done after we call 'rewrite_assembler'. Before that
        # call 'last_moving_obj_tracker' is None or filled with some old
        # value.
        namespace['ptr_array_gcref'] = self.gc_ll_descr.last_moving_obj_tracker.ptr_array_gcref
        expected = parse(to_operations % Evaluator(namespace),
                         namespace=namespace)
        equaloplists(operations, expected.operations)
        lltype.free(frame_info, flavor='raw')
コード例 #7
0
ファイル: gc.py プロジェクト: weijiwei/pypy
 def _setup_str(self):
     self.str_descr = get_array_descr(self, rstr.STR)
     self.unicode_descr = get_array_descr(self, rstr.UNICODE)
     self.str_hash_descr = get_field_descr(self, rstr.STR, 'hash')
     self.unicode_hash_descr = get_field_descr(self, rstr.UNICODE, 'hash')
コード例 #8
0
ファイル: gc.py プロジェクト: weijiwei/pypy
 def _setup_tid(self):
     self.fielddescr_tid = get_field_descr(self, self.GCClass.HDR, 'tid')
     frame_tid = self.layoutbuilder.get_type_id(jitframe.JITFRAME)
     self.translator._jit2gc['frame_tid'] = frame_tid
コード例 #9
0
ファイル: llmodel.py プロジェクト: Mu-L/pypy
 def fielddescrof(self, STRUCT, fieldname):
     return get_field_descr(self.gc_ll_descr, STRUCT, fieldname)
コード例 #10
0
ファイル: gc.py プロジェクト: mozillazg/pypy
 def _setup_tid(self):
     self.fielddescr_tid = get_field_descr(self, self.GCClass.HDR, 'tid')
     frame_tid = self.layoutbuilder.get_type_id(jitframe.JITFRAME)
     self.translator._jit2gc['frame_tid'] = frame_tid
コード例 #11
0
ファイル: gc.py プロジェクト: mozillazg/pypy
 def _setup_str(self):
     self.str_descr     = get_array_descr(self, rstr.STR)
     self.unicode_descr = get_array_descr(self, rstr.UNICODE)
     self.str_hash_descr     = get_field_descr(self, rstr.STR,     'hash')
     self.unicode_hash_descr = get_field_descr(self, rstr.UNICODE, 'hash')
コード例 #12
0
ファイル: test_rewrite.py プロジェクト: yuyichao/pypy
    def check_rewrite(self, frm_operations, to_operations, **namespace):
        S = lltype.GcStruct('S', ('x', lltype.Signed),
                                 ('y', lltype.Signed))
        sdescr = get_size_descr(self.gc_ll_descr, S)
        sdescr.tid = 1234
        #
        T = lltype.GcStruct('T', ('y', lltype.Signed),
                                 ('z', lltype.Ptr(S)),
                                 ('t', lltype.Signed))
        tdescr = get_size_descr(self.gc_ll_descr, T)
        tdescr.tid = 5678
        tzdescr = get_field_descr(self.gc_ll_descr, T, 'z')
        #
        A = lltype.GcArray(lltype.Signed)
        adescr = get_array_descr(self.gc_ll_descr, A)
        adescr.tid = 4321
        alendescr = adescr.lendescr
        #
        B = lltype.GcArray(lltype.Char)
        bdescr = get_array_descr(self.gc_ll_descr, B)
        bdescr.tid = 8765
        blendescr = bdescr.lendescr
        #
        C = lltype.GcArray(lltype.Ptr(S))
        cdescr = get_array_descr(self.gc_ll_descr, C)
        cdescr.tid = 8111
        clendescr = cdescr.lendescr
        #
        E = lltype.GcStruct('Empty')
        edescr = get_size_descr(self.gc_ll_descr, E)
        edescr.tid = 9000
        #
        vtable_descr = self.gc_ll_descr.fielddescr_vtable
        O = lltype.GcStruct('O', ('parent', rclass.OBJECT),
                                 ('x', lltype.Signed))
        o_vtable = lltype.malloc(rclass.OBJECT_VTABLE, immortal=True)
        register_known_gctype(self.cpu, o_vtable, O)
        #
        tiddescr = self.gc_ll_descr.fielddescr_tid
        wbdescr = self.gc_ll_descr.write_barrier_descr
        WORD = globals()['WORD']
        #
        strdescr     = self.gc_ll_descr.str_descr
        unicodedescr = self.gc_ll_descr.unicode_descr
        strlendescr     = strdescr.lendescr
        unicodelendescr = unicodedescr.lendescr

        casmdescr = JitCellToken()
        clt = FakeLoopToken()
        clt._ll_initial_locs = [0, 8]
        frame_info = lltype.malloc(jitframe.JITFRAMEINFO, flavor='raw')
        clt.frame_info = frame_info
        frame_info.jfi_frame_depth = 13
        frame_info.jfi_frame_size = 255
        framedescrs = self.gc_ll_descr.getframedescrs(self.cpu)
        framelendescr = framedescrs.arraydescr.lendescr
        jfi_frame_depth = framedescrs.jfi_frame_depth
        jfi_frame_size = framedescrs.jfi_frame_size
        jf_frame_info = framedescrs.jf_frame_info
        signedframedescr = self.cpu.signedframedescr
        floatframedescr = self.cpu.floatframedescr
        casmdescr.compiled_loop_token = clt
        tzdescr = None # noone cares
        #
        namespace.update(locals())
        #
        for funcname in self.gc_ll_descr._generated_functions:
            namespace[funcname] = self.gc_ll_descr.get_malloc_fn(funcname)
            namespace[funcname + '_descr'] = getattr(self.gc_ll_descr,
                                                     '%s_descr' % funcname)
        #
        ops = parse(frm_operations, namespace=namespace)
        expected = parse(to_operations % Evaluator(namespace),
                         namespace=namespace)
        operations = self.gc_ll_descr.rewrite_assembler(self.cpu,
                                                        ops.operations,
                                                        [])
        equaloplists(operations, expected.operations)
        lltype.free(frame_info, flavor='raw')
コード例 #13
0
    def check_rewrite(self, frm_operations, to_operations, **namespace):
        # objects to use inside the test
        A = lltype.GcArray(lltype.Signed)
        adescr = get_array_descr(self.gc_ll_descr, A)
        adescr.tid = 4321
        alendescr = adescr.lendescr
        #
        pinned_obj_type = lltype.GcStruct('PINNED_STRUCT', ('my_int', lltype.Signed))
        pinned_obj_my_int_descr = get_field_descr(self.gc_ll_descr, pinned_obj_type, 'my_int')
        pinned_obj_ptr = lltype.malloc(pinned_obj_type)
        pinned_obj_gcref = lltype.cast_opaque_ptr(llmemory.GCREF, pinned_obj_ptr)
        assert rgc.pin(pinned_obj_gcref)
        #
        notpinned_obj_type = lltype.GcStruct('NOT_PINNED_STRUCT', ('my_int', lltype.Signed))
        notpinned_obj_my_int_descr = get_field_descr(self.gc_ll_descr, notpinned_obj_type, 'my_int')
        notpinned_obj_ptr = lltype.malloc(notpinned_obj_type)
        notpinned_obj_gcref = lltype.cast_opaque_ptr(llmemory.GCREF, notpinned_obj_ptr)
        #
        ptr_array_descr = self.cpu.arraydescrof(MovableObjectTracker.ptr_array_type)
        #
        vtable_descr = self.gc_ll_descr.fielddescr_vtable
        O = lltype.GcStruct('O', ('parent', rclass.OBJECT),
                                 ('x', lltype.Signed))
        o_vtable = lltype.malloc(rclass.OBJECT_VTABLE, immortal=True)
        register_known_gctype(self.cpu, o_vtable, O)
        #
        tiddescr = self.gc_ll_descr.fielddescr_tid
        wbdescr = self.gc_ll_descr.write_barrier_descr
        WORD = globals()['WORD']
        #
        strdescr     = self.gc_ll_descr.str_descr
        unicodedescr = self.gc_ll_descr.unicode_descr
        strlendescr     = strdescr.lendescr
        unicodelendescr = unicodedescr.lendescr

        casmdescr = JitCellToken()
        clt = FakeLoopToken()
        clt._ll_initial_locs = [0, 8]
        frame_info = lltype.malloc(jitframe.JITFRAMEINFO, flavor='raw')
        clt.frame_info = frame_info
        frame_info.jfi_frame_depth = 13
        frame_info.jfi_frame_size = 255
        framedescrs = self.gc_ll_descr.getframedescrs(self.cpu)
        framelendescr = framedescrs.arraydescr.lendescr
        jfi_frame_depth = framedescrs.jfi_frame_depth
        jfi_frame_size = framedescrs.jfi_frame_size
        jf_frame_info = framedescrs.jf_frame_info
        signedframedescr = self.cpu.signedframedescr
        floatframedescr = self.cpu.floatframedescr
        casmdescr.compiled_loop_token = clt
        tzdescr = None # noone cares
        #
        namespace.update(locals())
        #
        for funcname in self.gc_ll_descr._generated_functions:
            namespace[funcname] = self.gc_ll_descr.get_malloc_fn(funcname)
            namespace[funcname + '_descr'] = getattr(self.gc_ll_descr,
                                                     '%s_descr' % funcname)
        #
        ops = parse(frm_operations, namespace=namespace)
        operations = self.gc_ll_descr.rewrite_assembler(self.cpu,
                                                        ops.operations,
                                                        [])
        # make the array containing the GCREF's accessible inside the tests.
        # This must be done after we call 'rewrite_assembler'. Before that
        # call 'last_moving_obj_tracker' is None or filled with some old
        # value.
        namespace['ptr_array_gcref'] = self.gc_ll_descr.last_moving_obj_tracker.ptr_array_gcref
        expected = parse(to_operations % Evaluator(namespace),
                         namespace=namespace)
        equaloplists(operations, expected.operations)
        lltype.free(frame_info, flavor='raw')
コード例 #14
0
ファイル: test_rewrite.py プロジェクト: weijiwei/pypy
    def check_rewrite(self, frm_operations, to_operations, **namespace):
        S = lltype.GcStruct('S', ('x', lltype.Signed), ('y', lltype.Signed))
        sdescr = get_size_descr(self.gc_ll_descr, S)
        sdescr.tid = 1234
        #
        T = lltype.GcStruct('T', ('y', lltype.Signed), ('z', lltype.Ptr(S)),
                            ('t', lltype.Signed))
        tdescr = get_size_descr(self.gc_ll_descr, T)
        tdescr.tid = 5678
        tzdescr = get_field_descr(self.gc_ll_descr, T, 'z')
        #
        A = lltype.GcArray(lltype.Signed)
        adescr = get_array_descr(self.gc_ll_descr, A)
        adescr.tid = 4321
        alendescr = adescr.lendescr
        #
        B = lltype.GcArray(lltype.Char)
        bdescr = get_array_descr(self.gc_ll_descr, B)
        bdescr.tid = 8765
        blendescr = bdescr.lendescr
        #
        C = lltype.GcArray(lltype.Ptr(S))
        cdescr = get_array_descr(self.gc_ll_descr, C)
        cdescr.tid = 8111
        clendescr = cdescr.lendescr
        #
        E = lltype.GcStruct('Empty')
        edescr = get_size_descr(self.gc_ll_descr, E)
        edescr.tid = 9000
        #
        vtable_descr = self.gc_ll_descr.fielddescr_vtable
        O = lltype.GcStruct('O', ('parent', rclass.OBJECT),
                            ('x', lltype.Signed))
        o_vtable = lltype.malloc(rclass.OBJECT_VTABLE, immortal=True)
        register_known_gctype(self.cpu, o_vtable, O)
        #
        tiddescr = self.gc_ll_descr.fielddescr_tid
        wbdescr = self.gc_ll_descr.write_barrier_descr
        WORD = globals()['WORD']
        #
        strdescr = self.gc_ll_descr.str_descr
        unicodedescr = self.gc_ll_descr.unicode_descr
        strlendescr = strdescr.lendescr
        unicodelendescr = unicodedescr.lendescr
        strhashdescr = self.gc_ll_descr.str_hash_descr
        unicodehashdescr = self.gc_ll_descr.unicode_hash_descr

        casmdescr = JitCellToken()
        clt = FakeLoopToken()
        clt._ll_initial_locs = [0, 8]
        frame_info = lltype.malloc(jitframe.JITFRAMEINFO, flavor='raw')
        clt.frame_info = frame_info
        frame_info.jfi_frame_depth = 13
        frame_info.jfi_frame_size = 255
        framedescrs = self.gc_ll_descr.getframedescrs(self.cpu)
        framelendescr = framedescrs.arraydescr.lendescr
        jfi_frame_depth = framedescrs.jfi_frame_depth
        jfi_frame_size = framedescrs.jfi_frame_size
        jf_frame_info = framedescrs.jf_frame_info
        jf_savedata = framedescrs.jf_savedata
        jf_force_descr = framedescrs.jf_force_descr
        jf_descr = framedescrs.jf_descr
        jf_guard_exc = framedescrs.jf_guard_exc
        jf_forward = framedescrs.jf_forward
        jf_extra_stack_depth = framedescrs.jf_extra_stack_depth
        signedframedescr = self.cpu.signedframedescr
        floatframedescr = self.cpu.floatframedescr
        casmdescr.compiled_loop_token = clt
        #
        guarddescr = AbstractFailDescr()
        #
        namespace.update(locals())
        #
        for funcname in self.gc_ll_descr._generated_functions:
            namespace[funcname] = self.gc_ll_descr.get_malloc_fn(funcname)
            namespace[funcname + '_descr'] = getattr(self.gc_ll_descr,
                                                     '%s_descr' % funcname)
        #
        ops = parse(frm_operations, namespace=namespace)
        expected = parse(to_operations % Evaluator(namespace),
                         namespace=namespace)
        operations = self.gc_ll_descr.rewrite_assembler(
            self.cpu, ops.operations, [])
        equaloplists(operations, expected.operations)
        lltype.free(frame_info, flavor='raw')
コード例 #15
0
ファイル: llmodel.py プロジェクト: mozillazg/pypy
 def fielddescrof(self, STRUCT, fieldname):
     return get_field_descr(self.gc_ll_descr, STRUCT, fieldname)
コード例 #16
0
    def check_rewrite(self, frm_operations, to_operations, **namespace):
        S = lltype.GcStruct('S', ('x', lltype.Signed),
                                 ('y', lltype.Signed))
        sdescr = get_size_descr(self.gc_ll_descr, S)
        sdescr.tid = 1234
        #
        T = lltype.GcStruct('T', ('y', lltype.Signed),
                                 ('z', lltype.Ptr(S)),
                                 ('t', lltype.Signed))
        tdescr = get_size_descr(self.gc_ll_descr, T)
        tdescr.tid = 5678
        tzdescr = get_field_descr(self.gc_ll_descr, T, 'z')
        #
        A = lltype.GcArray(lltype.Signed)
        adescr = get_array_descr(self.gc_ll_descr, A)
        adescr.tid = 4321
        alendescr = adescr.lendescr
        #
        B = lltype.GcArray(lltype.Char)
        bdescr = get_array_descr(self.gc_ll_descr, B)
        bdescr.tid = 8765
        blendescr = bdescr.lendescr
        #
        C = lltype.GcArray(lltype.Ptr(S))
        cdescr = get_array_descr(self.gc_ll_descr, C)
        cdescr.tid = 8111
        clendescr = cdescr.lendescr
        #
        E = lltype.GcStruct('Empty')
        edescr = get_size_descr(self.gc_ll_descr, E)
        edescr.tid = 9000
        #
        vtable_descr = self.gc_ll_descr.fielddescr_vtable
        O = lltype.GcStruct('O', ('parent', rclass.OBJECT),
                                 ('x', lltype.Signed))
        o_descr = self.cpu.sizeof(O, True)
        o_vtable = globals()['o_vtable']
        #
        tiddescr = self.gc_ll_descr.fielddescr_tid
        wbdescr = self.gc_ll_descr.write_barrier_descr
        WORD = globals()['WORD']
        #
        strdescr     = self.gc_ll_descr.str_descr
        unicodedescr = self.gc_ll_descr.unicode_descr
        strlendescr     = strdescr.lendescr
        unicodelendescr = unicodedescr.lendescr
        strhashdescr     = self.gc_ll_descr.str_hash_descr
        unicodehashdescr = self.gc_ll_descr.unicode_hash_descr

        casmdescr = JitCellToken()
        clt = FakeLoopToken()
        clt._ll_initial_locs = [0, 8]
        frame_info = lltype.malloc(jitframe.JITFRAMEINFO, flavor='raw')
        clt.frame_info = frame_info
        frame_info.jfi_frame_depth = 13
        frame_info.jfi_frame_size = 255
        framedescrs = self.gc_ll_descr.getframedescrs(self.cpu)
        framelendescr = framedescrs.arraydescr.lendescr
        jfi_frame_depth = framedescrs.jfi_frame_depth
        jfi_frame_size = framedescrs.jfi_frame_size
        jf_frame_info = framedescrs.jf_frame_info
        jf_savedata = framedescrs.jf_savedata
        jf_force_descr = framedescrs.jf_force_descr
        jf_descr = framedescrs.jf_descr
        jf_guard_exc = framedescrs.jf_guard_exc
        jf_forward = framedescrs.jf_forward
        jf_extra_stack_depth = framedescrs.jf_extra_stack_depth
        signedframedescr = self.cpu.signedframedescr
        floatframedescr = self.cpu.floatframedescr
        casmdescr.compiled_loop_token = clt
        #
        guarddescr = AbstractFailDescr()
        #
        namespace.update(locals())
        #
        for funcname in self.gc_ll_descr._generated_functions:
            namespace[funcname] = self.gc_ll_descr.get_malloc_fn(funcname)
            namespace[funcname + '_descr'] = getattr(self.gc_ll_descr,
                                                     '%s_descr' % funcname)
        #
        ops = parse(frm_operations, namespace=namespace)
        expected = parse(to_operations % Evaluator(namespace),
                         namespace=namespace)
        operations = self.gc_ll_descr.rewrite_assembler(self.cpu,
                                                        ops.operations,
                                                        [])
        remap = {}
        for a, b in zip(ops.inputargs, expected.inputargs):
            remap[b] = a
        equaloplists(operations, expected.operations, remap=remap)
        lltype.free(frame_info, flavor='raw')