本文整理汇总了Python中pypy.rlib.objectmodel.we_are_translated函数的典型用法代码示例。如果您正苦于以下问题:Python we_are_translated函数的具体用法?Python we_are_translated怎么用?Python we_are_translated使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了we_are_translated函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_loop_to_backend
def send_loop_to_backend(greenkey, jitdriver_sd, metainterp_sd, loop, type):
jitdriver_sd.on_compile(metainterp_sd.logger_ops, loop.token, loop.operations, type, greenkey)
loopname = jitdriver_sd.warmstate.get_location_str(greenkey)
globaldata = metainterp_sd.globaldata
loop_token = loop.token
loop_token.number = n = globaldata.loopnumbering
globaldata.loopnumbering += 1
if not we_are_translated():
show_loop(metainterp_sd, loop)
loop.check_consistency()
operations = get_deep_immutable_oplist(loop.operations)
metainterp_sd.profiler.start_backend()
debug_start("jit-backend")
try:
ops_offset = metainterp_sd.cpu.compile_loop(loop.inputargs, operations, loop.token, name=loopname)
finally:
debug_stop("jit-backend")
metainterp_sd.profiler.end_backend()
metainterp_sd.stats.add_new_loop(loop)
if not we_are_translated():
if type != "entry bridge":
metainterp_sd.stats.compiled()
else:
loop._ignore_during_counting = True
metainterp_sd.log("compiled new " + type)
#
metainterp_sd.logger_ops.log_loop(loop.inputargs, loop.operations, n, type, ops_offset)
short = loop.token.short_preamble
if short:
metainterp_sd.logger_ops.log_short_preamble(short[-1].inputargs, short[-1].operations)
#
if metainterp_sd.warmrunnerdesc is not None: # for tests
metainterp_sd.warmrunnerdesc.memory_manager.keep_loop_alive(loop.token)
示例2: send_bridge_to_backend
def send_bridge_to_backend(jitdriver_sd, metainterp_sd, faildescr, inputargs, operations, original_loop_token):
n = metainterp_sd.cpu.get_fail_descr_number(faildescr)
if not we_are_translated():
show_procedures(metainterp_sd)
seen = dict.fromkeys(inputargs)
TreeLoop.check_consistency_of_branch(operations, seen)
if metainterp_sd.warmrunnerdesc is not None:
hooks = metainterp_sd.warmrunnerdesc.hooks
debug_info = JitDebugInfo(
jitdriver_sd, metainterp_sd.logger_ops, original_loop_token, operations, "bridge", fail_descr_no=n
)
hooks.before_compile_bridge(debug_info)
else:
hooks = None
debug_info = None
operations = get_deep_immutable_oplist(operations)
metainterp_sd.profiler.start_backend()
debug_start("jit-backend")
try:
asminfo = do_compile_bridge(metainterp_sd, faildescr, inputargs, operations, original_loop_token)
finally:
debug_stop("jit-backend")
metainterp_sd.profiler.end_backend()
if hooks is not None:
debug_info.asminfo = asminfo
hooks.after_compile_bridge(debug_info)
if not we_are_translated():
metainterp_sd.stats.compiled()
metainterp_sd.log("compiled new bridge")
#
if asminfo is not None:
ops_offset = asminfo.ops_offset
else:
ops_offset = None
metainterp_sd.logger_ops.log_bridge(inputargs, operations, n, ops_offset)
示例3: generate_operations
def generate_operations(self, mc):
if not we_are_translated():
print
# reserve locations for the inputvars
for i in range(len(self.inputvars_gv)):
v = self.inputvars_gv[i]
if v in self.lifetime: # else: input argument is not used
loc = self.inputlocations[i]
if v in self.var2loc: # duplicate inputvars_gv, which is ok
assert self.var2loc[v] == loc
else:
self.var2loc[v] = loc
self.vars_in_use[v] = self.lifetime[v]
self.force_loc_used(v, loc)
if not we_are_translated():
print 'in %20s: %s' % (loc, short(v))
self._check()
self.mc = mc
# Generate all operations.
# Actual registers or stack locations are allocated as we go.
for i in range(len(self.operations)):
self.registers_pinned = 0 # bitmask
op = self.operations[i]
if op.clobbers_cc:
self.clobber_cc()
self._check()
op.generate(self)
if not we_are_translated():
self._showprogress()
self.operationindex = i + 1
示例4: f
def f():
state.gil = allocate_ll_lock()
acquire_NOAUTO(state.gil, True)
state.bootstrapping = allocate_lock()
state.answers = []
state.finished = 0
# the next line installs before_extcall() and after_extcall()
# to be called automatically around external function calls.
# When not translated it does not work around time.sleep(),
# so we have to call them manually for this test.
invoke_around_extcall(before_extcall, after_extcall)
g(10, 1)
done = False
willing_to_wait_more = 2000
while not done:
if not willing_to_wait_more:
break
willing_to_wait_more -= 1
done = len(state.answers) == expected
if not we_are_translated(): before_extcall()
time.sleep(0.01)
if not we_are_translated(): after_extcall()
if not we_are_translated(): before_extcall()
time.sleep(0.1)
if not we_are_translated(): after_extcall()
return len(state.answers)
示例5: _really_force
def _really_force(self):
op = self.source_op
assert op is not None
# ^^^ This case should not occur any more (see test_bug_3).
#
if not we_are_translated():
op.name = 'FORCE ' + self.source_op.name
if self._is_immutable_and_filled_with_constants():
box = self.optimizer.constant_fold(op)
self.make_constant(box)
for ofs, value in self._fields.iteritems():
subbox = value.force_box()
assert isinstance(subbox, Const)
execute(self.optimizer.cpu, None, rop.SETFIELD_GC,
ofs, box, subbox)
# keep self._fields, because it's all immutable anyway
else:
newoperations = self.optimizer.newoperations
newoperations.append(op)
self.box = box = op.result
#
iteritems = self._fields.iteritems()
if not we_are_translated(): #random order is fine, except for tests
iteritems = list(iteritems)
iteritems.sort(key = lambda (x,y): x.sort_key())
for ofs, value in iteritems:
if value.is_null():
continue
subbox = value.force_box()
op = ResOperation(rop.SETFIELD_GC, [box, subbox], None,
descr=ofs)
newoperations.append(op)
self._fields = None
示例6: send_loop_to_backend
def send_loop_to_backend(metainterp_sd, loop, type):
globaldata = metainterp_sd.globaldata
loop_token = loop.token
loop_token.number = n = globaldata.loopnumbering
globaldata.loopnumbering += 1
metainterp_sd.logger_ops.log_loop(loop.inputargs, loop.operations, n, type)
if not we_are_translated():
show_loop(metainterp_sd, loop)
loop.check_consistency()
metainterp_sd.profiler.start_backend()
debug_start("jit-backend")
try:
metainterp_sd.cpu.compile_loop(loop.inputargs, loop.operations,
loop.token)
finally:
debug_stop("jit-backend")
metainterp_sd.profiler.end_backend()
metainterp_sd.stats.add_new_loop(loop)
if not we_are_translated():
if type != "entry bridge":
metainterp_sd.stats.compiled()
else:
loop._ignore_during_counting = True
metainterp_sd.log("compiled new " + type)
示例7: f
def f():
state.data = []
state.threadlocals = gil.GILThreadLocals()
state.threadlocals.setup_threads(space)
thread.gc_thread_prepare()
subident = thread.start_new_thread(bootstrap, ())
mainident = thread.get_ident()
runme()
still_waiting = 3000
while len(state.data) < 2*N:
if not still_waiting:
raise ValueError("time out")
still_waiting -= 1
if not we_are_translated(): gil.before_external_call()
time.sleep(0.01)
if not we_are_translated(): gil.after_external_call()
i1 = i2 = 0
for tid, i in state.data:
if tid == mainident:
assert i == i1; i1 += 1
elif tid == subident:
assert i == i2; i2 += 1
else:
assert 0
assert i1 == N
assert i2 == N
return len(state.data)
示例8: send_bridge_to_backend
def send_bridge_to_backend(metainterp_sd, faildescr, inputargs, operations):
n = faildescr.get_index()
metainterp_sd.logger_ops.log_bridge(inputargs, operations, n)
metainterp_sd.profiler.start_backend()
if not we_are_translated():
show_loop(metainterp_sd)
TreeLoop.check_consistency_of(inputargs, operations)
pass
metainterp_sd.cpu.compile_bridge(faildescr, inputargs, operations)
metainterp_sd.profiler.end_backend()
if not we_are_translated():
metainterp_sd.stats.compiled()
metainterp_sd.log("compiled new bridge")
示例9: returns_bool_result
def returns_bool_result(self):
opnum = self.getopnum()
if we_are_translated():
assert opnum >= 0
elif opnum < 0:
return False # for tests
return opboolresult[opnum]
示例10: gc_thread_after_fork
def gc_thread_after_fork(result_of_fork, opaqueaddr):
"""To call just after fork().
"""
if we_are_translated():
llop.gc_thread_after_fork(lltype.Void, result_of_fork, opaqueaddr)
else:
assert opaqueaddr == llmemory.NULL
示例11: gc_thread_die
def gc_thread_die():
"""To call just before the final GIL release done by a dying
thread. After a thread_die(), no more gc operation should
occur in this thread.
"""
if we_are_translated():
llop.gc_thread_die(lltype.Void)
示例12: call
def call(self):
space = self.space
coro = AppCoroutine.w_getcurrent(space)
assert isinstance(coro, AppCoroutine)
cspace = coro._cspace
w("-- initial DISTRIBUTOR thunk CALL in", str(id(coro)))
sched.uler.trace_vars(coro, logic_args(self.args.unpack()))
try:
try:
try:
_AppThunk.call(self)
finally:
coro = AppCoroutine.w_getcurrent(space)
assert isinstance(coro, AppCoroutine)
cspace = coro._cspace
except FailedSpace, exc:
w("-- EXIT of DISTRIBUTOR %s, space is FAILED with %s" % (id(coro),
str(exc)))
failed_value = W_FailedValue(exc)
interp_bind(cspace._solution, failed_value)
except Exception, exc:
# maybe app_level let something buble up ...
w("-- exceptional EXIT of DISTRIBUTOR %s with %s" % (id(coro),
str(exc)))
if not we_are_translated():
import traceback
traceback.print_exc()
failed_value = W_FailedValue(exc)
sched.uler.dirty_traced_vars(coro, failed_value)
interp_bind(cspace._solution, failed_value)
cspace.fail()
示例13: __init__
def __init__(self, value=0):
if not we_are_translated():
if isinstance(value, int):
value = int(value) # bool -> int
else:
assert isinstance(value, Symbolic)
self.value = value
示例14: __init__
def __init__(self, w_type, w_value, tb=None):
if not we_are_translated() and w_type is None:
from pypy.tool.error import FlowingError
raise FlowingError(w_value)
self.setup(w_type)
self._w_value = w_value
self._application_traceback = tb
示例15: ll_arraycopy
def ll_arraycopy(source, dest, source_start, dest_start, length):
from pypy.rpython.lltypesystem.lloperation import llop
from pypy.rlib.objectmodel import keepalive_until_here
# supports non-overlapping copies only
if not we_are_translated():
if source == dest:
assert (source_start + length <= dest_start or
dest_start + length <= source_start)
TP = lltype.typeOf(source).TO
assert TP == lltype.typeOf(dest).TO
if isinstance(TP.OF, lltype.Ptr) and TP.OF.TO._gckind == 'gc':
# perform a write barrier that copies necessary flags from
# source to dest
if not llop.gc_writebarrier_before_copy(lltype.Bool, source, dest):
# if the write barrier is not supported, copy by hand
for i in range(length):
dest[i + dest_start] = source[i + source_start]
return
source_addr = llmemory.cast_ptr_to_adr(source)
dest_addr = llmemory.cast_ptr_to_adr(dest)
cp_source_addr = (source_addr + llmemory.itemoffsetof(TP, 0) +
llmemory.sizeof(TP.OF) * source_start)
cp_dest_addr = (dest_addr + llmemory.itemoffsetof(TP, 0) +
llmemory.sizeof(TP.OF) * dest_start)
llmemory.raw_memcopy(cp_source_addr, cp_dest_addr,
llmemory.sizeof(TP.OF) * length)
keepalive_until_here(source)
keepalive_until_here(dest)