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


Python jit.promote函数代码示例

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


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


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