本文整理汇总了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)
示例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
示例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
示例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
示例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
示例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)
示例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)
示例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
示例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
示例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)
示例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
示例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
示例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)
示例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
示例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