本文整理匯總了Python中rpython.jit.metainterp.history.TreeLoop.inputargs方法的典型用法代碼示例。如果您正苦於以下問題:Python TreeLoop.inputargs方法的具體用法?Python TreeLoop.inputargs怎麽用?Python TreeLoop.inputargs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rpython.jit.metainterp.history.TreeLoop
的用法示例。
在下文中一共展示了TreeLoop.inputargs方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: unroll_and_optimize
# 需要導入模塊: from rpython.jit.metainterp.history import TreeLoop [as 別名]
# 或者: from rpython.jit.metainterp.history.TreeLoop import inputargs [as 別名]
def unroll_and_optimize(self, loop, call_pure_results=None,
jump_values=None):
self.add_guard_future_condition(loop)
jump_op = loop.operations[-1]
assert jump_op.getopnum() == rop.JUMP
celltoken = JitCellToken()
runtime_boxes = self.pack_into_boxes(jump_op, jump_values)
jump_op.setdescr(celltoken)
#start_label = ResOperation(rop.LABEL, loop.inputargs,
# descr=jump_op.getdescr())
#end_label = jump_op.copy_and_change(opnum=rop.LABEL)
call_pure_results = self._convert_call_pure_results(call_pure_results)
t = convert_loop_to_trace(loop, FakeMetaInterpStaticData(self.cpu))
preamble_data = compile.LoopCompileData(t, runtime_boxes,
call_pure_results)
start_state, preamble_ops = self._do_optimize_loop(preamble_data)
preamble_data.forget_optimization_info()
loop_data = compile.UnrolledLoopData(preamble_data.trace,
celltoken, start_state, call_pure_results)
loop_info, ops = self._do_optimize_loop(loop_data)
preamble = TreeLoop('preamble')
preamble.inputargs = start_state.renamed_inputargs
start_label = ResOperation(rop.LABEL, start_state.renamed_inputargs)
preamble.operations = ([start_label] + preamble_ops +
loop_info.extra_same_as + [loop_info.label_op])
loop.inputargs = loop_info.label_op.getarglist()[:]
loop.operations = [loop_info.label_op] + ops
return Info(preamble, loop_info.target_token.short_preamble,
start_state.virtual_state)
示例2: unroll_and_optimize
# 需要導入模塊: from rpython.jit.metainterp.history import TreeLoop [as 別名]
# 或者: from rpython.jit.metainterp.history.TreeLoop import inputargs [as 別名]
def unroll_and_optimize(self, loop, call_pure_results=None):
self.add_guard_future_condition(loop)
jump_op = loop.operations[-1]
assert jump_op.getopnum() == rop.JUMP
ops = loop.operations[:-1]
jump_op.setdescr(JitCellToken())
start_label = ResOperation(rop.LABEL, loop.inputargs,
jump_op.getdescr())
end_label = jump_op.copy_and_change(opnum=rop.LABEL)
call_pure_results = self._convert_call_pure_results(call_pure_results)
preamble_data = compile.LoopCompileData(start_label, end_label, ops,
call_pure_results)
start_state, preamble_ops = self._do_optimize_loop(preamble_data)
preamble_data.forget_optimization_info()
loop_data = compile.UnrolledLoopData(start_label, jump_op,
ops, start_state,
call_pure_results)
loop_info, ops = self._do_optimize_loop(loop_data)
preamble = TreeLoop('preamble')
preamble.inputargs = start_state.renamed_inputargs
start_label = ResOperation(rop.LABEL, start_state.renamed_inputargs)
preamble.operations = ([start_label] + preamble_ops +
loop_info.extra_same_as + [loop_info.label_op])
loop.inputargs = loop_info.label_op.getarglist()[:]
loop.operations = [loop_info.label_op] + ops
return Info(preamble, loop_info.target_token.short_preamble,
start_state.virtual_state)
示例3: convert_old_style_to_targets
# 需要導入模塊: from rpython.jit.metainterp.history import TreeLoop [as 別名]
# 或者: from rpython.jit.metainterp.history.TreeLoop import inputargs [as 別名]
def convert_old_style_to_targets(loop, jump):
newloop = TreeLoop(loop.name)
newloop.inputargs = loop.inputargs
newloop.operations = [ResOperation(rop.LABEL, loop.inputargs, None, descr=FakeDescr())] + \
loop.operations
if not jump:
assert newloop.operations[-1].getopnum() == rop.JUMP
newloop.operations[-1] = ResOperation(rop.LABEL, newloop.operations[-1].getarglist(), None, descr=FakeDescr())
return newloop
示例4: xxx_test_random_snapshot
# 需要導入模塊: from rpython.jit.metainterp.history import TreeLoop [as 別名]
# 或者: from rpython.jit.metainterp.history.TreeLoop import inputargs [as 別名]
def xxx_test_random_snapshot(self, lst):
inputargs, ops = lst
t = Trace(inputargs, metainterp_sd)
for op in ops:
newop = FakeOp(t.record_op(op.getopnum(), op.getarglist()))
newop.orig_op = op
if newop.is_guard():
resume.capture_resumedata(op.framestack,
None, [], t)
op.position = newop.get_position()
inpargs, l, iter = self.unpack(t)
loop1 = TreeLoop("loop1")
loop1.inputargs = inputargs
loop1.operations = ops
loop2 = TreeLoop("loop2")
loop2.inputargs = inpargs
loop2.operations = l
BaseTest.assert_equal(loop1, loop2)
示例5: unroll_and_optimize
# 需要導入模塊: from rpython.jit.metainterp.history import TreeLoop [as 別名]
# 或者: from rpython.jit.metainterp.history.TreeLoop import inputargs [as 別名]
def unroll_and_optimize(self, loop, call_pure_results=None):
self.add_guard_future_condition(loop)
operations = loop.operations
jumpop = operations[-1]
assert jumpop.getopnum() == rop.JUMP
inputargs = loop.inputargs
jump_args = jumpop.getarglist()[:]
operations = operations[:-1]
cloned_operations = [op.clone() for op in operations]
preamble = TreeLoop('preamble')
preamble.inputargs = inputargs
token = JitCellToken()
preamble.operations = [ResOperation(rop.LABEL, inputargs, None, descr=TargetToken(token))] + \
operations + \
[ResOperation(rop.LABEL, jump_args, None, descr=token)]
start_state = self._do_optimize_loop(preamble, call_pure_results,
export_state=True)
assert preamble.operations[-1].getopnum() == rop.LABEL
inliner = Inliner(inputargs, jump_args)
loop.operations = [preamble.operations[-1]] + \
[inliner.inline_op(op, clone=False) for op in cloned_operations] + \
[ResOperation(rop.JUMP, [inliner.inline_arg(a) for a in jump_args],
None, descr=token)]
#[inliner.inline_op(jumpop)]
assert loop.operations[-1].getopnum() == rop.JUMP
assert loop.operations[0].getopnum() == rop.LABEL
loop.inputargs = loop.operations[0].getarglist()
self._do_optimize_loop(loop, call_pure_results, start_state,
export_state=False)
extra_same_as = []
while loop.operations[0].getopnum() != rop.LABEL:
extra_same_as.append(loop.operations[0])
del loop.operations[0]
# Hack to prevent random order of same_as ops
extra_same_as.sort(key=lambda op: str(preamble.operations).find(str(op.getarg(0))))
for op in extra_same_as:
preamble.operations.insert(-1, op)
return preamble
示例6: build_random_loop
# 需要導入模塊: from rpython.jit.metainterp.history import TreeLoop [as 別名]
# 或者: from rpython.jit.metainterp.history.TreeLoop import inputargs [as 別名]
def build_random_loop(self, cpu, builder_factory, r, startvars,
allow_delay):
loop = TreeLoop('test_random_function')
loop.inputargs = startvars[:]
loop.operations = []
loop._jitcelltoken = JitCellToken()
builder = builder_factory(cpu, loop, startvars[:])
if allow_delay:
needs_a_label = True
else:
self.insert_label(loop, 0, r)
needs_a_label = False
self.generate_ops(builder, r, loop, startvars, needs_a_label=needs_a_label)
self.builder = builder
self.loop = loop
dump(loop)
cpu.compile_loop(loop.inputargs, loop.operations, loop._jitcelltoken)
if self.output:
builder.print_loop(self.output)
示例7: optimize
# 需要導入模塊: from rpython.jit.metainterp.history import TreeLoop [as 別名]
# 或者: from rpython.jit.metainterp.history.TreeLoop import inputargs [as 別名]
def optimize(self, ops):
loop = self.parse(ops)
self.add_guard_future_condition(loop)
operations = loop.operations
jumpop = operations[-1]
assert jumpop.getopnum() == rop.JUMP
inputargs = loop.inputargs
jump_args = jumpop.getarglist()[:]
operations = operations[:-1]
preamble = TreeLoop('preamble')
token = JitCellToken()
trace = oparser.convert_loop_to_trace(loop, FakeMetaInterpStaticData(self.cpu))
compile_data = LoopCompileData(trace, inputargs)
start_state, newops = self._do_optimize_loop(compile_data)
preamble.operations = newops
preamble.inputargs = start_state.renamed_inputargs
return start_state, loop, preamble
示例8: optimize
# 需要導入模塊: from rpython.jit.metainterp.history import TreeLoop [as 別名]
# 或者: from rpython.jit.metainterp.history.TreeLoop import inputargs [as 別名]
def optimize(self, ops):
loop = self.parse(ops, postprocess=self.postprocess)
self.add_guard_future_condition(loop)
operations = loop.operations
jumpop = operations[-1]
assert jumpop.getopnum() == rop.JUMP
inputargs = loop.inputargs
jump_args = jumpop.getarglist()[:]
operations = operations[:-1]
preamble = TreeLoop('preamble')
token = JitCellToken()
start_label = ResOperation(rop.LABEL, inputargs, descr=TargetToken(token))
stop_label = ResOperation(rop.LABEL, jump_args, descr=token)
compile_data = LoopCompileData(start_label, stop_label, operations)
start_state, newops = self._do_optimize_loop(compile_data)
preamble.operations = newops
preamble.inputargs = start_state.renamed_inputargs
return start_state, loop, preamble
示例9: optimize_loop
# 需要導入模塊: from rpython.jit.metainterp.history import TreeLoop [as 別名]
# 或者: from rpython.jit.metainterp.history.TreeLoop import inputargs [as 別名]
def optimize_loop(self, ops, expected, expected_shorts=None):
loop = self.parse(ops)
if expected != "crash!":
expected = self.parse(expected)
part = TreeLoop('part')
part.inputargs = loop.inputargs
token = loop.original_jitcell_token
optimized = TreeLoop('optimized')
optimized.inputargs = loop.inputargs
optimized.operations = []
labels = [i for i, op in enumerate(loop.operations) \
if op.getopnum()==rop.LABEL]
prv = 0
last_label = []
state = None
for nxt in labels + [len(loop.operations)]:
assert prv != nxt
operations = last_label + loop.operations[prv:nxt]
if nxt < len(loop.operations):
label = loop.operations[nxt]
assert label.getopnum() == rop.LABEL
if label.getdescr() is None:
label.setdescr(token)
operations.append(label)
part.operations = operations
self.add_guard_future_condition(part)
state = self._do_optimize_loop(part, None, state,
export_state=True)
if part.operations[-1].getopnum() == rop.LABEL:
last_label = [part.operations.pop()]
else:
last_label = []
optimized.operations.extend(part.operations)
prv = nxt + 1
#
print
print "Optimized:"
if optimized.operations:
print '\n'.join([str(o) for o in optimized.operations])
else:
print 'Failed!'
print
shorts = [op.getdescr().short_preamble
for op in optimized.operations
if op.getopnum() == rop.LABEL]
if expected_shorts:
for short in shorts:
print
print "Short preamble:"
print '\n'.join([str(o) for o in short])
assert expected != "crash!", "should have raised an exception"
self.assert_equal(optimized, expected)
if expected_shorts:
assert len(shorts) == len(expected_shorts)
for short, expected_short in zip(shorts, expected_shorts):
expected_short = self.parse(expected_short)
short_preamble = TreeLoop('short preamble')
assert short[0].getopnum() == rop.LABEL
short_preamble.inputargs = short[0].getarglist()
short_preamble.operations = short
self.assert_equal(short_preamble, expected_short,
text_right='expected short preamble')
return optimized