本文整理汇总了Python中pypy.rlib.jit.we_are_jitted函数的典型用法代码示例。如果您正苦于以下问题:Python we_are_jitted函数的具体用法?Python we_are_jitted怎么用?Python we_are_jitted使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了we_are_jitted函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: execute_frame
def execute_frame(self):
"""Execute this frame. Main entry point to the interpreter."""
from pypy.rlib import rstack
# the following 'assert' is an annotation hint: it hides from
# the annotator all methods that are defined in PyFrame but
# overridden in the FrameClass subclass of PyFrame.
assert isinstance(self, self.space.FrameClass)
executioncontext = self.space.getexecutioncontext()
executioncontext.enter(self)
try:
if not we_are_jitted():
executioncontext.call_trace(self)
# Execution starts just after the last_instr. Initially,
# last_instr is -1. After a generator suspends it points to
# the YIELD_VALUE instruction.
next_instr = self.last_instr + 1
try:
w_exitvalue = self.dispatch(self.pycode, next_instr,
executioncontext)
rstack.resume_point("execute_frame", self, executioncontext,
returns=w_exitvalue)
except Exception:
if not we_are_jitted():
executioncontext.return_trace(self, self.space.w_None)
raise
if not we_are_jitted():
executioncontext.return_trace(self, w_exitvalue)
# on exit, we try to release self.last_exception -- breaks an
# obvious reference cycle, so it helps refcounting implementations
self.last_exception = None
finally:
executioncontext.leave(self)
return w_exitvalue
开发者ID:enyst,项目名称:plexnet,代码行数:33,代码来源:pyframe.py
示例2: call_valuestack
def call_valuestack(self, w_func, nargs, frame):
from pypy.interpreter.function import Function, Method, is_builtin_code
if (not we_are_jitted() and frame.is_being_profiled and
is_builtin_code(w_func)):
# XXX: this code is copied&pasted :-( from the slow path below
# call_valuestack().
args = frame.make_arguments(nargs)
return self.call_args_and_c_profile(frame, w_func, args)
if not self.config.objspace.disable_call_speedhacks:
# XXX start of hack for performance
if isinstance(w_func, Method):
w_inst = w_func.w_instance
if w_inst is not None:
w_func = w_func.w_function
# reuse callable stack place for w_inst
frame.settopvalue(w_inst, nargs)
nargs += 1
elif nargs > 0 and (
self.abstract_isinstance_w(frame.peekvalue(nargs-1), # :-(
w_func.w_class)):
w_func = w_func.w_function
if isinstance(w_func, Function):
return w_func.funccall_valuestack(nargs, frame)
# XXX end of hack for performance
args = frame.make_arguments(nargs)
return self.call_args(w_func, args)
开发者ID:enyst,项目名称:plexnet,代码行数:29,代码来源:baseobjspace.py
示例3: getcell
def getcell(self, key, makenew):
if makenew or jit.we_are_jitted():
# when we are jitting, we always go through the pure function
# below, to ensure that we have no residual dict lookup
self = jit.hint(self, promote=True)
return self._getcell_makenew(key)
return self.content.get(key, None)
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:celldict.py
示例4: f
def f(x):
try:
if we_are_jitted():
return x
return x + 1
except Exception:
return 5
开发者ID:ieure,项目名称:pypy,代码行数:7,代码来源:test_jit.py
示例5: JUMP_ABSOLUTE
def JUMP_ABSOLUTE(f, jumpto, _, ec=None):
if we_are_jitted():
f.last_instr = intmask(jumpto)
ec.bytecode_trace(f)
jumpto = r_uint(f.last_instr)
pypyjitdriver.can_enter_jit(frame=f, ec=ec, next_instr=jumpto,
pycode=f.getcode())
return jumpto
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:interp_jit.py
示例6: index
def index(self, selector):
if jit.we_are_jitted():
# hack for the jit:
# the _index method is pure too, but its argument is never
# constant, because it is always a new tuple
return self._index_jit_pure(selector[0], selector[1])
else:
return self._index_indirection(selector)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:mapdict.py
示例7: get_next_structure
def get_next_structure(self, key):
# jit helper
self = hint(self, promote=True)
key = hint(key, promote=True)
newstruct = _get_next_structure_shared(self, key)
if not we_are_jitted():
self._size_estimate -= self.size_estimate()
self._size_estimate += newstruct.size_estimate()
return newstruct
开发者ID:enyst,项目名称:plexnet,代码行数:9,代码来源:sharingdict.py
示例8: f
def f(y):
while y >= 0:
myjitdriver.can_enter_jit(y=y)
myjitdriver.jit_merge_point(y=y)
if we_are_jitted():
x = 1
else:
x = 10
y -= x
return y
开发者ID:enyst,项目名称:plexnet,代码行数:10,代码来源:test_basic.py
示例9: ll_stringslice_startstop
def ll_stringslice_startstop(s1, start, stop):
if jit.we_are_jitted():
if stop > len(s1.chars):
stop = len(s1.chars)
else:
if stop >= len(s1.chars):
if start == 0:
return s1
stop = len(s1.chars)
return LLHelpers._ll_stringslice(s1, start, stop)
开发者ID:craigkerstiens,项目名称:pypy,代码行数:10,代码来源:rstr.py
示例10: call__Type
def call__Type(space, w_type, __args__):
w_type = hint(w_type, promote=True)
# special case for type(x)
if space.is_w(w_type, space.w_type):
try:
w_obj, = __args__.fixedunpack(1)
except ValueError:
pass
else:
return space.type(w_obj)
# invoke the __new__ of the type
if not we_are_jitted():
# note that the annotator will figure out that w_type.w_bltin_new can
# only be None if the newshortcut config option is not set
w_bltin_new = w_type.w_bltin_new
else:
# for the JIT it is better to take the slow path because normal lookup
# is nicely optimized, but the w_type.w_bltin_new attribute is not
# known to the JIT
w_bltin_new = None
call_init = True
if w_bltin_new is not None:
w_newobject = space.call_obj_args(w_bltin_new, w_type, __args__)
else:
w_newtype, w_newdescr = w_type.lookup_where('__new__')
w_newfunc = space.get(w_newdescr, w_type)
if (space.config.objspace.std.newshortcut and
not we_are_jitted() and
isinstance(w_newtype, W_TypeObject) and
not w_newtype.is_heaptype() and
not space.is_w(w_newtype, space.w_type)):
w_type.w_bltin_new = w_newfunc
w_newobject = space.call_obj_args(w_newfunc, w_type, __args__)
call_init = space.is_true(space.isinstance(w_newobject, w_type))
# maybe invoke the __init__ of the type
if call_init:
w_descr = space.lookup(w_newobject, '__init__')
w_result = space.get_and_call_args(w_descr, w_newobject, __args__)
if not space.is_w(w_result, space.w_None):
raise OperationError(space.w_TypeError,
space.wrap("__init__() should return None"))
return w_newobject
开发者ID:alkorzt,项目名称:pypy,代码行数:43,代码来源:typeobject.py
示例11: 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
示例12: issubtype__Type_Type
def issubtype__Type_Type(space, w_type1, w_type2):
w_type1 = hint(w_type1, promote=True)
w_type2 = hint(w_type2, promote=True)
if space.config.objspace.std.withtypeversion and we_are_jitted():
version_tag1 = w_type1.version_tag()
version_tag2 = w_type2.version_tag()
if version_tag1 is not None and version_tag2 is not None:
res = _pure_issubtype(w_type1, w_type2, version_tag1, version_tag2)
return space.newbool(res)
res = _issubtype(w_type1, w_type2)
return space.newbool(res)
开发者ID:alkorzt,项目名称:pypy,代码行数:11,代码来源:typeobject.py
示例13: wrapchar
def wrapchar(space, c):
from pypy.objspace.std.stringobject import W_StringObject
from pypy.objspace.std.ropeobject import rope, W_RopeObject
if space.config.objspace.std.withprebuiltchar and not we_are_jitted():
if space.config.objspace.std.withrope:
return W_RopeObject.PREBUILT[ord(c)]
return W_StringObject.PREBUILT[ord(c)]
else:
if space.config.objspace.std.withrope:
return W_RopeObject(rope.LiteralStringNode(c))
return W_StringObject(c)
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:12,代码来源:stringtype.py
示例14: try_rule
def try_rule(self, rule, query, continuation=DONOTHING, choice_point=True,
inline=False):
if not choice_point:
return (TRY_RULE, query, continuation, rule)
if not we_are_jitted():
return self.portal_try_rule(rule, query, continuation, choice_point)
if inline:
return self.main_loop(TRY_RULE, query, continuation, rule)
#if _is_early_constant(rule):
# rule = hint(rule, promote=True)
# return self.portal_try_rule(rule, query, continuation, choice_point)
return self._opaque_try_rule(rule, query, continuation, choice_point)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:12,代码来源:engine.py
示例15: _match_signature
def _match_signature(self, w_firstarg, scope_w, signature, defaults_w=None,
blindargs=0):
"""Parse args and kwargs according to the signature of a code object,
or raise an ArgErr in case of failure.
Return the number of arguments filled in.
"""
if jit.we_are_jitted() and self._dont_jit:
return self._match_signature_jit_opaque(w_firstarg, scope_w,
signature, defaults_w,
blindargs)
return self._really_match_signature(w_firstarg, scope_w, signature,
defaults_w, blindargs)
开发者ID:cshen,项目名称:pypy,代码行数:12,代码来源:argument.py
示例16: eval_arithmetic
def eval_arithmetic(self, engine):
from pypy.lang.prolog.interpreter.arithmetic import arithmetic_functions
from pypy.lang.prolog.interpreter.arithmetic import arithmetic_functions_list
if we_are_jitted():
signature = hint(self.signature, promote=True)
func = None
for sig, func in arithmetic_functions_list:
if sig == signature:
break
else:
func = arithmetic_functions.get(self.signature, None)
if func is None:
error.throw_type_error("evaluable", self.get_prolog_signature())
return func(engine, self)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:14,代码来源:term.py
示例17: f
def f(self, code):
pc = 0
while pc < len(code):
myjitdriver.jit_merge_point(self=self, code=code, pc=pc)
op = code[pc]
if op == "-":
self.n -= 1
elif op == "c":
frame = Frame(self.n)
self.n = frame.f("---i---")
if we_are_jitted():
if frame.hookcalled:
raise UnexpectedHook
elif op == "C":
frame = Frame(self.n)
self.n = frame.f("cL")
if we_are_jitted():
if not frame.hookcalled:
raise ExpectedHook
elif op == "i":
if self.n % 5 == 1:
return self.n
elif op == "l":
if self.n > 0:
myjitdriver.can_enter_jit(self=self, code=code, pc=0)
pc = 0
continue
elif op == "L":
if self.n > 50:
myjitdriver.can_enter_jit(self=self, code=code, pc=0)
pc = 0
continue
else:
assert 0
pc += 1
return self.n
开发者ID:enyst,项目名称:plexnet,代码行数:37,代码来源:test_recursive.py
示例18: funccall_valuestack
def funccall_valuestack(self, nargs, frame): # speed hack
from pypy.interpreter import gateway
from pypy.interpreter.pycode import PyCode
code = self.getcode() # hook for the jit
#
if (jit.we_are_jitted() and code is self.space._code_of_sys_exc_info
and nargs == 0):
from pypy.module.sys.vm import exc_info_direct
return exc_info_direct(self.space, frame)
#
fast_natural_arity = code.fast_natural_arity
if nargs == fast_natural_arity:
if nargs == 0:
assert isinstance(code, gateway.BuiltinCode0)
return code.fastcall_0(self.space, self)
elif nargs == 1:
assert isinstance(code, gateway.BuiltinCode1)
return code.fastcall_1(self.space, self, frame.peekvalue(0))
elif nargs == 2:
assert isinstance(code, gateway.BuiltinCode2)
return code.fastcall_2(self.space, self, frame.peekvalue(1),
frame.peekvalue(0))
elif nargs == 3:
assert isinstance(code, gateway.BuiltinCode3)
return code.fastcall_3(self.space, self, frame.peekvalue(2),
frame.peekvalue(1), frame.peekvalue(0))
elif nargs == 4:
assert isinstance(code, gateway.BuiltinCode4)
return code.fastcall_4(self.space, self, frame.peekvalue(3),
frame.peekvalue(2), frame.peekvalue(1),
frame.peekvalue(0))
elif (nargs | Code.FLATPYCALL) == fast_natural_arity:
assert isinstance(code, PyCode)
return self._flat_pycall(code, nargs, frame)
elif fast_natural_arity & Code.FLATPYCALL:
natural_arity = fast_natural_arity & 0xff
if natural_arity > nargs >= natural_arity - len(self.defs_w):
assert isinstance(code, PyCode)
return self._flat_pycall_defaults(code, nargs, frame,
natural_arity - nargs)
elif fast_natural_arity == Code.PASSTHROUGHARGS1 and nargs >= 1:
assert isinstance(code, gateway.BuiltinCodePassThroughArguments1)
w_obj = frame.peekvalue(nargs-1)
args = frame.make_arguments(nargs-1)
return code.funcrun_obj(self, w_obj, args)
args = frame.make_arguments(nargs)
return self.call_args(args)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:49,代码来源:function.py
示例19: lookup_where_with_method_cache
def lookup_where_with_method_cache(w_self, name):
space = w_self.space
w_self = hint(w_self, promote=True)
assert space.config.objspace.std.withmethodcache
if (space.config.objspace.std.immutable_builtintypes and
we_are_jitted() and not w_self.is_heaptype()):
w_self = hint(w_self, promote=True)
name = hint(name, promote=True)
return w_self._pure_lookup_where_builtin_type(name)
version_tag = w_self.version_tag
version_tag = hint(version_tag, promote=True)
if version_tag is None:
tup = w_self._lookup_where(name)
return tup
name = hint(name, promote=True)
return w_self._pure_lookup_where_with_method_cache(name, version_tag)
开发者ID:enyst,项目名称:plexnet,代码行数:16,代码来源:typeobject.py
示例20: jump_absolute
def jump_absolute(self, jumpto, _, ec=None):
if we_are_jitted():
#
# assume that only threads are using the bytecode counter
decr_by = 0
if self.space.actionflag.has_bytecode_counter: # constant-folded
if self.space.threadlocals.gil_ready: # quasi-immutable field
decr_by = _get_adapted_tick_counter()
#
self.last_instr = intmask(jumpto)
ec.bytecode_trace(self, decr_by)
jumpto = r_uint(self.last_instr)
#
pypyjitdriver.can_enter_jit(frame=self, ec=ec, next_instr=jumpto,
pycode=self.getcode(),
is_being_profiled=self.is_being_profiled)
return jumpto
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:17,代码来源:interp_jit.py
注:本文中的pypy.rlib.jit.we_are_jitted函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论