本文整理汇总了Python中pypy.rlib.jit.we_are_jitted函数的典型用法代码示例。如果您正苦于以下问题:Python we_are_jitted函数的具体用法?Python we_are_jitted怎么用?Python we_are_jitted使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了we_are_jitted函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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)
示例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)
示例4: f
def f(x):
try:
if we_are_jitted():
return x
return x + 1
except Exception:
return 5
示例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
示例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)
示例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
示例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
示例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)
示例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
示例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)
示例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)
示例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)
示例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)
示例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)