• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python jit.promote函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _apply

 def _apply(self, funDef):
     msg = assertClosureV(funDef, self.body)
     if msg != "True":
         return FinalBounce(ErrorV(msg))
     newEnv = funDef.env
     promote(newEnv)
     funDef.env = newEnv.add_attribute(self.funName, funDef)
     return KeepBouncing(self.expr, funDef.env, self.k) 
开发者ID:leodh,项目名称:RPython-internship,代码行数:8,代码来源:interpretTramp.py


示例2: get_attr

 def get_attr(self, name):
     map = self.map
     promote(map)
     index = map.getindex(name)
     if index != -1:
         return self.storage[index]
     else:
         print("Free variable : " + name)
         return 2
开发者ID:leodh,项目名称:RPython-internship,代码行数:9,代码来源:treeClass.py


示例3: Interpret

def Interpret(tree):
    """Interpret the tree, iteratively."""

    set_param(jitdriver, "trace_limit", 25000)

    register = ReturnType()
    tree = tree
    env = Map()
    k = EndK()

    while 1:
        jitdriver.jit_merge_point(tree=tree, env=env, k=k, register=register)

        if isinstance(k, FinalK):
            break

        if isinstance(tree, parser.Num):
            register, tree, env, k = k._apply(NumV(tree.val), tree, env, k)

        elif isinstance(tree, parser.Op):
            k = Op1K(tree.op, tree.lhs, tree.rhs, env, k)
            tree = tree.lhs

        elif isinstance(tree, parser.Id):
            promote(env)
            register = env.getvalue(tree.name)
            if isinstance(register, ErrorV):
                k = FinalK()
            else:
                register, tree, env, k = k._apply(register, tree, env, k)

        elif isinstance(tree, parser.If):
            k = If0K(tree.nul, tree.true, tree.false, env, k)
            tree = tree.nul

        elif isinstance(tree, parser.Func):
            assert isinstance(tree.arg, parser.Id)
            register, tree, env, k = k._apply(ClosureV(tree.arg, tree.body, env), tree, env, k)

        elif isinstance(tree, parser.App):
            k = App1K(tree.fun, env, k)
            tree = tree.arg
            jitdriver.can_enter_jit(tree=tree, env=env, k=k, register=register)

        elif isinstance(tree, parser.Rec):
            k = RecK(tree.funName, tree.body, tree.expr, k)
            dummy = NumV(42)
            promote(env)
            env = env.add_attribute(tree.funName, dummy)
            tree = tree.body

        else:
            msg = "Parsing error, tree %s is not valid" % tree.__str__()
            register = ErrorV(msg)
            k = FinalK()

    return register
开发者ID:ldharo,项目名称:Internship2012,代码行数:57,代码来源:interpretIterBoth.py


示例4: stack_get_slice

 def stack_get_slice(self, i, j):
     assert i >= 0 and j >= i
     l = [None] * (j - i)
     a = 0
     jit.promote(i)
     for k in range(i, j):
         l[a] = self.stack[k]
         a += 1
     return l
开发者ID:cfbolz,项目名称:converge,代码行数:9,代码来源:VM.py


示例5: _apply

 def _apply(self, reg, tree, env, k):
     # reg is suppose to be te interpretation of fun
     funDef = reg
     msg = assertClosureV(funDef, self.body)
     if msg != "True":
         return ErrorV(msg), tree, env, FinalK()
     newEnv = funDef.env
     promote(newEnv)
     funDef.env = newEnv.add_attribute(self.funName, funDef)
     return funDef, self.expr, funDef.env, self.k
开发者ID:ldharo,项目名称:Internship2012,代码行数:10,代码来源:interpretIterNoElidable.py


示例6: issubtype

 def issubtype(w_self, w_type):
     promote(w_self)
     promote(w_type)
     if w_self.space.config.objspace.std.withtypeversion and we_are_jitted():
         version_tag1 = w_self.version_tag()
         version_tag2 = w_type.version_tag()
         if version_tag1 is not None and version_tag2 is not None:
             res = _pure_issubtype(w_self, w_type, version_tag1, version_tag2)
             return res
     return _issubtype(w_self, w_type)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:10,代码来源:typeobject.py


示例7: lookup_where_with_method_cache

 def lookup_where_with_method_cache(w_self, name):
     space = w_self.space
     promote(w_self)
     assert space.config.objspace.std.withmethodcache
     version_tag = promote(w_self.version_tag())
     if version_tag is None:
         tup = w_self._lookup_where(name)
         return tup
     w_class, w_value = w_self._pure_lookup_where_with_method_cache(name, version_tag)
     return w_class, unwrap_cell(space, w_value)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:10,代码来源:typeobject.py


示例8: f

 def f(n, a, i):
     stufflist = StuffList()
     stufflist.lst = [Stuff(a), Stuff(3)]
     while n > 0:
         myjitdriver.can_enter_jit(n=n, i=i, stufflist=stufflist)
         myjitdriver.jit_merge_point(n=n, i=i, stufflist=stufflist)
         promote(i)
         v = Stuff(i)
         n -= stufflist.lst[v.x].x
     return n
开发者ID:gorakhargosh,项目名称:pypy,代码行数:10,代码来源:test_virtual.py


示例9: fn

 def fn(n, i):
     res = 0
     obj = A()
     while i > 0:
         myjitdriver.can_enter_jit(i=i, obj=obj)
         myjitdriver.jit_merge_point(i=i, obj=obj)
         promote(obj)
         res = obj.foo()
         i-=1
     return res
开发者ID:craigkerstiens,项目名称:pypy,代码行数:10,代码来源:test_send.py


示例10: write_attribute

 def write_attribute(self, name, value):
     assert isinstance(name, str)
     assert isinstance(value, int)
     map = self.map
     promote(map)
     index = map.getindex(name)
     if index != -1:
         self.storage[index] = value
         return
     self.map = map.add_attribute(name)
     self.storage.append(value)
开发者ID:leodh,项目名称:RPython-internship,代码行数:11,代码来源:treeClass.py


示例11: stack_get_slice_del

 def stack_get_slice_del(self, i):
     assert i >= 0
     l = [None] * (self.stackpe - i)
     a = 0
     jit.promote(i)
     for k in range(i, self.stackpe):
         l[a] = self.stack[k]
         self.stack[k] = None
         a += 1
     self.stackpe = i
     return l
开发者ID:cfbolz,项目名称:converge,代码行数:11,代码来源:VM.py


示例12: libffi_stuff

 def libffi_stuff(i, j):
     lib = CDLL(libm_name)
     func = lib.getpointer('fabs', [types.double], types.double)
     res = 0.0
     x = float(j)
     while i > 0:
         jitdriver2.jit_merge_point(i=i, res=res, func=func, x=x)
         promote(func)
         argchain = ArgChain()
         argchain.arg(x)
         res = func.call(argchain, rffi.DOUBLE)
         i -= 1
     return res
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:13,代码来源:test_ztranslation.py


示例13: do_fast_call

 def do_fast_call(self, cppthis, args_w, call_local):
     jit.promote(self)
     argchain = libffi.ArgChain()
     argchain.arg(cppthis)
     i = len(self.arg_defs)
     for i in range(len(args_w)):
         conv = self.converters[i]
         w_arg = args_w[i]
         conv.convert_argument_libffi(self.space, w_arg, argchain, call_local)
     for j in range(i + 1, len(self.arg_defs)):
         conv = self.converters[j]
         conv.default_argument_libffi(self.space, argchain)
     return self.executor.execute_libffi(self.space, self._libffifunc, argchain)
开发者ID:MichaelBlume,项目名称:pypy,代码行数:13,代码来源:interp_cppyy.py


示例14: pop

 def pop(self):
     stackpos = jit.promote(self.stackpos) - 1
     assert stackpos >= 0
     w_res = self.stack_w[stackpos]
     self.stack_w[stackpos] = None
     self.stackpos = stackpos
     return w_res
开发者ID:gnprice,项目名称:rupypy,代码行数:7,代码来源:frame.py


示例15: on_enter_jit

 def on_enter_jit(self, invariants, reds, bytecode, pos):
     # Now some strange code that makes a copy of the 'args' list in
     # a complicated way...  this is a workaround forcing the whole 'args'
     # list to be virtual.  It is a way to tell the JIT compiler that it
     # doesn't have to worry about the 'args' list being unpredictably
     # modified.
     oldloops = invariants
     oldargs = reds.args
     argcount = promote(len(oldargs))
     args = []
     n = 0
     while n < argcount:
         hint(n, concrete=True)
         args.append(oldargs[n])
         n += 1
     reds.args = args
     # turn the green 'loops' from 'invariants' into a virtual list
     oldloops = hint(oldloops, deepfreeze=True)
     argcount = len(oldloops)
     loops = []
     n = 0
     while n < argcount:
         hint(n, concrete=True)
         loops.append(oldloops[n])
         n += 1
     reds.loops = loops
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:26,代码来源:tiny2_hotpath.py


示例16: op2

def op2(stack, func_int, func_str):
    # Operate on the top two stack items.  The promotion hints force the
    # class of each arguments (IntBox or StrBox) to turn into a compile-time
    # constant if they weren't already.  The effect we seek is to make the
    # calls to as_int() direct calls at compile-time, instead of indirect
    # ones.  The JIT compiler cannot look into indirect calls, but it
    # can analyze and inline the code in directly-called functions.
    y = stack.pop()
    promote(y.__class__)
    x = stack.pop()
    promote(x.__class__)
    try:
        z = IntBox(func_int(x.as_int(), y.as_int()))
    except ValueError:
        z = StrBox(func_str(x.as_str(), y.as_str()))
    stack.append(z)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:16,代码来源:tiny2.py


示例17: next_skip_x

 def next_skip_x(self, shapelen, step):
     shapelen = jit.promote(len(self.res_shape))
     offset = self.offset
     indices = [0] * shapelen
     for i in range(shapelen):
         indices[i] = self.indices[i]
     done = False
     for i in range(shapelen - 1, -1, -1):
         if indices[i] < self.res_shape[i] - step:
             indices[i] += step
             offset += self.strides[i] * step
             break
         else:
             remaining_step = (indices[i] + step) // self.res_shape[i]
             this_i_step = step - remaining_step * self.res_shape[i]
             offset += self.strides[i] * this_i_step
             indices[i] = indices[i] +  this_i_step
             step = remaining_step
     else:
         done = True
     res = instantiate(ViewIterator)
     res.offset = offset
     res.indices = indices
     res.strides = self.strides
     res.backstrides = self.backstrides
     res.res_shape = self.res_shape
     res._done = done
     return res
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:28,代码来源:interp_iter.py


示例18: getsingletonclass

 def getsingletonclass(self, space):
     w_cls = jit.promote(self.map).get_class()
     if w_cls.is_singleton:
         return w_cls
     w_cls = space.newclass(w_cls.name, w_cls, is_singleton=True)
     self.map = self.map.change_class(space, w_cls)
     return w_cls
开发者ID:gnprice,项目名称:rupypy,代码行数:7,代码来源:objectobject.py


示例19: _add_continuation_frame

    def _add_continuation_frame(self, func, nargs):
        if not isinstance(func, Builtins.Con_Func):
            self.raise_helper("Apply_Exception", [func])
        func = jit.promote(func) # XXX this will promote lambdas, which will be inefficient

        pc = func.pc
        if isinstance(pc, BC_PC):
            bc_off = pc.off
        else:
            bc_off = -1 

        closure = Closure(func.container_closure, func.num_vars)

        if func.max_stack_size > nargs:
            max_stack_size = func.max_stack_size
        elif nargs == 0:
            # We make the stack size at least 1 so that RPython functions have room for 1 generator
            # frame. If they need more than that, they'll have to be clever.
            max_stack_size = 1
        else:
            max_stack_size = nargs

        cf = Stack_Continuation_Frame(self.cur_cf, func, pc, max_stack_size, nargs, bc_off,
          closure)
        self.cur_cf = cf
        
        return cf
开发者ID:cfbolz,项目名称:converge,代码行数:27,代码来源:VM.py


示例20: _dispatch_loop

 def _dispatch_loop(self):
     code = self.code.co_code
     instr_index = 0
     while True:
         jitdriver.jit_merge_point(code=code, instr_index=instr_index,
                                   frame=self)
         self.stack_depth = promote(self.stack_depth)
         op = ord(code[instr_index])
         instr_index += 1
         if op >= HAVE_ARGUMENT:
             low = ord(code[instr_index])
             hi = ord(code[instr_index + 1])
             oparg = (hi << 8) | low
             instr_index += 2
         else:
             oparg = 0
         if we_are_translated():
             for opdesc in unrolling_opcode_descs:
                 if op == opdesc.index:
                     meth = getattr(self, opdesc.methodname)
                     instr_index = meth(oparg, instr_index, code)
                     break
             else:
                 raise MissingOpcode(op)
         else:
             meth = getattr(self, opcode_method_names[op])
             instr_index = meth(oparg, instr_index, code)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:27,代码来源:interpreter.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python jit.virtual_ref函数代码示例发布时间:2022-05-27
下一篇:
Python jit.hint函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap