当前位置: 首页>>代码示例>>Python>>正文


Python history.getkind函数代码示例

本文整理汇总了Python中pypy.jit.metainterp.history.getkind函数的典型用法代码示例。如果您正苦于以下问题:Python getkind函数的具体用法?Python getkind怎么用?Python getkind使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getkind函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: indirect_residual_call_test

def indirect_residual_call_test(argtypes, restype, expectedkind):
    # an indirect call that is residual in all cases is very similar to
    # a residual direct call
    op = get_direct_call_op(argtypes, restype)
    op.opname = 'indirect_call'
    op.args[0] = varoftype(op.args[0].concretetype)
    op.args.append(Constant(['somegraph1', 'somegraph2'], lltype.Void))
    tr = Transformer(FakeCPU(), FakeResidualIndirectCallControl())
    tr.graph = 'someinitialgraph'
    oplist = tr.rewrite_operation(op)
    op0, op1 = oplist
    reskind = getkind(restype)[0]
    assert op0.opname == 'residual_call_%s_%s' % (expectedkind, reskind)
    assert op0.result == op.result
    assert op0.args[0] == op.args[0]
    assert op0.args[1] == 'calldescr'
    assert len(op0.args) == 2 + len(expectedkind)
    for sublist, kind1 in zip(op0.args[2:], expectedkind):
        assert sublist.kind.startswith(kind1)
        assert list(sublist) == [v for v in op.args[1:]
                                 if getkind(v.concretetype)==sublist.kind]
    for v in op.args[1:]:
        kind = getkind(v.concretetype)
        assert kind == 'void' or kind[0] in expectedkind
    assert op1.opname == '-live-'
    assert op1.args == []
开发者ID:gorakhargosh,项目名称:pypy,代码行数:26,代码来源:test_jtransform.py

示例2: make_dependencies

 def make_dependencies(self):
     dg = DependencyGraph()
     for block in self.graph.iterblocks():
         # Compute die_at = {Variable: index_of_operation_with_last_usage}
         die_at = dict.fromkeys(block.inputargs, 0)
         for i, op in enumerate(block.operations):
             for v in op.args:
                 if isinstance(v, Variable):
                     die_at[v] = i
                 elif isinstance(v, ListOfKind):
                     for v1 in v:
                         if isinstance(v1, Variable):
                             die_at[v1] = i
             if op.result is not None:
                 die_at[op.result] = i + 1
         if isinstance(block.exitswitch, tuple):
             for x in block.exitswitch:
                 die_at.pop(x, None)
         else:
             die_at.pop(block.exitswitch, None)
         for link in block.exits:
             for v in link.args:
                 die_at.pop(v, None)
         die_at = [(value, key) for (key, value) in die_at.items()]
         die_at.sort()
         die_at.append((sys.maxint,))
         # Done.  XXX the code above this line runs 3 times
         # (for kind in KINDS) to produce the same result...
         livevars = [v for v in block.inputargs
                       if getkind(v.concretetype) == self.kind]
         # Add the variables of this block to the dependency graph
         for i, v in enumerate(livevars):
             dg.add_node(v)
             for j in range(i):
                 dg.add_edge(livevars[j], v)
         livevars = set(livevars)
         die_index = 0
         for i, op in enumerate(block.operations):
             while die_at[die_index][0] == i:
                 try:
                     livevars.remove(die_at[die_index][1])
                 except KeyError:
                     pass
                 die_index += 1
             if (op.result is not None and
                 getkind(op.result.concretetype) == self.kind):
                 dg.add_node(op.result)
                 for v in livevars:
                     if getkind(v.concretetype) == self.kind:
                         dg.add_edge(v, op.result)
                 livevars.add(op.result)
     self._depgraph = dg
开发者ID:ieure,项目名称:pypy,代码行数:52,代码来源:regalloc.py

示例3: calldescrof

 def calldescrof(self, FUNC, ARGS, RESULT, extrainfo=None):
     arg_types = []
     for ARG in ARGS:
         token = history.getkind(ARG)
         if token != 'void':
             if token == 'float' and longlong.is_longlong(ARG):
                 token = 'L'
             arg_types.append(token[0])
     token = history.getkind(RESULT)
     if token == 'float' and longlong.is_longlong(RESULT):
         token = 'L'
     return self.getdescr(0, token[0], extrainfo=extrainfo,
                          arg_types=''.join(arg_types))
开发者ID:ieure,项目名称:pypy,代码行数:13,代码来源:runner.py

示例4: get_call_descr

def get_call_descr(gccache, ARGS, RESULT, extrainfo=None):
    arg_classes = []
    for ARG in ARGS:
        kind = getkind(ARG)
        if   kind == 'int':
            if ARG is lltype.SingleFloat:
                arg_classes.append('S')
            else:
                arg_classes.append('i')
        elif kind == 'ref': arg_classes.append('r')
        elif kind == 'float':
            if is_longlong(ARG):
                arg_classes.append('L')
            else:
                arg_classes.append('f')
        else:
            raise NotImplementedError('ARG = %r' % (ARG,))
    arg_classes = ''.join(arg_classes)
    cls = getCallDescrClass(RESULT)
    key = (cls, arg_classes, extrainfo)
    cache = gccache._cache_call
    try:
        return cache[key]
    except KeyError:
        calldescr = cls(arg_classes, extrainfo)
        calldescr.create_call_stub(gccache.rtyper, RESULT)
        cache[key] = calldescr
        return calldescr
开发者ID:gorakhargosh,项目名称:pypy,代码行数:28,代码来源:descr.py

示例5: make_args_specification

 def make_args_specification(self, jd):
     graph, op = jd._jit_merge_point_pos
     greens_v, reds_v = support.decode_hp_hint_args(op)
     ALLARGS = [v.concretetype for v in (greens_v + reds_v)]
     jd._green_args_spec = [v.concretetype for v in greens_v]
     jd._red_args_types = [history.getkind(v.concretetype) for v in reds_v]
     jd.num_green_args = len(jd._green_args_spec)
     jd.num_red_args = len(jd._red_args_types)
     RESTYPE = graph.getreturnvar().concretetype
     (jd._JIT_ENTER_FUNCTYPE,
      jd._PTR_JIT_ENTER_FUNCTYPE) = self.cpu.ts.get_FuncType(ALLARGS, lltype.Void)
     (jd._PORTAL_FUNCTYPE,
      jd._PTR_PORTAL_FUNCTYPE) = self.cpu.ts.get_FuncType(ALLARGS, RESTYPE)
     #
     if jd.result_type == 'v':
         ASMRESTYPE = lltype.Void
     elif jd.result_type == history.INT:
         ASMRESTYPE = lltype.Signed
     elif jd.result_type == history.REF:
         ASMRESTYPE = llmemory.GCREF
     elif jd.result_type == history.FLOAT:
         ASMRESTYPE = lltype.Float
     else:
         assert False
     (_, jd._PTR_ASSEMBLER_HELPER_FUNCTYPE) = self.cpu.ts.get_FuncType(
         [lltype.Signed, llmemory.GCREF], ASMRESTYPE)
开发者ID:ieure,项目名称:pypy,代码行数:26,代码来源:warmspot.py

示例6: split_graph_and_record_jitdriver

 def split_graph_and_record_jitdriver(self, graph, block, pos):
     op = block.operations[pos]
     jd = JitDriverStaticData()
     jd._jit_merge_point_pos = (graph, op)
     args = op.args[2:]
     s_binding = self.translator.annotator.binding
     jd._portal_args_s = [s_binding(v) for v in args]
     graph = copygraph(graph)
     graph.startblock.isstartblock = False
     [jmpp] = find_jit_merge_points([graph])
     graph.startblock = support.split_before_jit_merge_point(*jmpp)
     graph.startblock.isstartblock = True
     # a crash in the following checkgraph() means that you forgot
     # to list some variable in greens=[] or reds=[] in JitDriver.
     checkgraph(graph)
     for v in graph.getargs():
         assert isinstance(v, Variable)
     assert len(dict.fromkeys(graph.getargs())) == len(graph.getargs())
     self.translator.graphs.append(graph)
     jd.portal_graph = graph
     # it's a bit unbelievable to have a portal without func
     assert hasattr(graph, "func")
     graph.func._dont_inline_ = True
     graph.func._jit_unroll_safe_ = True
     jd.jitdriver = block.operations[pos].args[1].value
     jd.portal_runner_ptr = "<not set so far>"
     jd.result_type = history.getkind(jd.portal_graph.getreturnvar()
                                      .concretetype)[0]
     self.jitdrivers_sd.append(jd)
开发者ID:ieure,项目名称:pypy,代码行数:29,代码来源:warmspot.py

示例7: serialize_op

 def serialize_op(self, op):
     args = self.flatten_list(op.args)
     if op.result is not None:
         kind = getkind(op.result.concretetype)
         if kind != 'void':
             args.append("->")
             args.append(self.getcolor(op.result))
     self.emitline(op.opname, *args)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:flatten.py

示例8: __init__

    def __init__(self, TYPE, fieldname):
        self.TYPE = TYPE
        self.fieldname = fieldname

        _, T = TYPE._lookup_field(fieldname)
        def getfield(objbox):
            obj = objbox.getref(TYPE)
            value = getattr(obj, fieldname)
            return boxresult(T, value)
        def setfield(objbox, valuebox):
            obj = objbox.getref(TYPE)
            value = unwrap(T, valuebox)
            setattr(obj, fieldname, value)

        self.getfield = getfield
        self.setfield = setfield
        self._is_pointer_field = (history.getkind(T) == 'ref')
        self._is_float_field = (history.getkind(T) == 'float')
开发者ID:ieure,项目名称:pypy,代码行数:18,代码来源:runner.py

示例9: getcolor

 def getcolor(self, v):
     if isinstance(v, Constant):
         return v
     kind = getkind(v.concretetype)
     col = self.regallocs[kind].getcolor(v)    # if kind=='void', fix caller
     try:
         r = self.registers[kind, col]
     except KeyError:
         r = self.registers[kind, col] = Register(kind, col)
     return r
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:10,代码来源:flatten.py

示例10: _sort

 def _sort(args_v):
     from pypy.jit.metainterp.history import getkind
     lst = [v for v in args_v if v.concretetype is not lltype.Void]
     _kind2count = {'int': 1, 'ref': 2, 'float': 3}
     lst2 = sorted(lst, key=lambda v: _kind2count[getkind(v.concretetype)])
     # a crash here means that you have to reorder the variable named in
     # the JitDriver.  Indeed, greens and reds must both be sorted: first
     # all INTs, followed by all REFs, followed by all FLOATs.
     assert lst == lst2
     return lst
开发者ID:ieure,项目名称:pypy,代码行数:10,代码来源:support.py

示例11: __init__

 def __init__(self, TYPE, fieldname):
     DescrWithKey.__init__(self, (TYPE, fieldname))
     from pypy.jit.backend.llgraph.runner import boxresult
     from pypy.jit.metainterp.warmstate import unwrap
     _, T = TYPE._lookup_field(fieldname)
     def getfield(objbox):
         obj = objbox.getref(TYPE)
         value = getattr(obj, fieldname)
         return boxresult(T, value)
     def setfield(objbox, valuebox):
         obj = objbox.getref(TYPE)
         value = unwrap(T, valuebox)
         setattr(obj, fieldname, value)
         
     self.getfield = getfield
     self.setfield = setfield
     self.selfclass = ootype.runtimeClass(TYPE)
     self.fieldname = fieldname
     self.key = key_manager.getkey((TYPE, fieldname))
     self._is_pointer_field = (history.getkind(T) == 'ref')
     self._is_float_field = (history.getkind(T) == 'float')
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:21,代码来源:runner.py

示例12: map_type_to_argclass

def map_type_to_argclass(ARG, accept_void=False):
    kind = getkind(ARG)
    if   kind == 'int':
        if ARG is lltype.SingleFloat: return 'S'
        else:                         return 'i'
    elif kind == 'ref':               return 'r'
    elif kind == 'float':
        if is_longlong(ARG):          return 'L'
        else:                         return 'f'
    elif kind == 'void':
        if accept_void:               return 'v'
    raise NotImplementedError('ARG = %r' % (ARG,))
开发者ID:Sherlockhlt,项目名称:pypy,代码行数:12,代码来源:descr.py

示例13: enforce_input_args

 def enforce_input_args(self):
     inputargs = self.graph.startblock.inputargs
     numkinds = {}
     for v in inputargs:
         kind = getkind(v.concretetype)
         if kind == 'void':
             continue
         curcol = self.regallocs[kind].getcolor(v)
         realcol = numkinds.get(kind, 0)
         numkinds[kind] = realcol + 1
         if curcol != realcol:
             assert curcol > realcol
             self.regallocs[kind].swapcolors(realcol, curcol)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:13,代码来源:flatten.py

示例14: indirect_regular_call_test

def indirect_regular_call_test(argtypes, restype, expectedkind):
    # a regular indirect call is preceded by a guard_value on the
    # function address, so that pyjitpl can know which jitcode to follow
    from pypy.jit.codewriter.flatten import IndirectCallTargets
    op = get_direct_call_op(argtypes, restype)
    op.opname = 'indirect_call'
    op.args[0] = varoftype(op.args[0].concretetype)
    op.args.append(Constant(['somegraph1', 'somegraph2'], lltype.Void))
    tr = Transformer(FakeCPU(), FakeRegularIndirectCallControl())
    tr.graph = 'someinitialgraph'
    oplist = tr.rewrite_operation(op)
    op0gv, op1gv, op0, op1 = oplist
    assert op0gv.opname == '-live-'
    assert op0gv.args == []
    assert op1gv.opname == 'int_guard_value'
    assert op1gv.args == [op.args[0]]
    assert op1gv.result is None
    #
    reskind = getkind(restype)[0]
    assert op0.opname == 'residual_call_%s_%s' % (expectedkind, reskind)
    assert op0.result == op.result
    assert op0.args[0] == op.args[0]
    assert op0.args[1] == 'calldescr'
    assert isinstance(op0.args[2], IndirectCallTargets)
    assert op0.args[2].lst == ['somejitcode1', 'somejitcode2']
    assert len(op0.args) == 3 + len(expectedkind)
    for sublist, kind1 in zip(op0.args[3:], expectedkind):
        assert sublist.kind.startswith(kind1)
        assert list(sublist) == [v for v in op.args[1:]
                                 if getkind(v.concretetype)==sublist.kind]
    for v in op.args[1:]:
        kind = getkind(v.concretetype)
        assert kind == 'void' or kind[0] in expectedkind
    # Note: we still expect a -live- here, even though canraise() returns
    # False, because this 'residual_call' will likely call further jitcodes
    # which can do e.g. guard_class or other stuff requiring anyway a -live-.
    assert op1.opname == '-live-'
    assert op1.args == []
开发者ID:gorakhargosh,项目名称:pypy,代码行数:38,代码来源:test_jtransform.py

示例15: _try_coalesce

 def _try_coalesce(self, v, w):
     if isinstance(v, Variable) and getkind(v.concretetype) == self.kind:
         dg = self._depgraph
         uf = self._unionfind
         v0 = uf.find_rep(v)
         w0 = uf.find_rep(w)
         if v0 is not w0 and v0 not in dg.neighbours[w0]:
             _, rep, _ = uf.union(v0, w0)
             assert uf.find_rep(v0) is uf.find_rep(w0) is rep
             if rep is v0:
                 dg.coalesce(w0, v0)
             else:
                 assert rep is w0
                 dg.coalesce(v0, w0)
开发者ID:ieure,项目名称:pypy,代码行数:14,代码来源:regalloc.py


注:本文中的pypy.jit.metainterp.history.getkind函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。