[pypy-commit] pypy resume-refactor: a bit of a mess in walk_operations, but otherwise pass more tests
fijal
noreply at buildbot.pypy.org
Wed Oct 16 16:59:37 CEST 2013
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: resume-refactor
Changeset: r67427:2bd1ba38dfcd
Date: 2013-10-16 16:58 +0200
http://bitbucket.org/pypy/pypy/changeset/2bd1ba38dfcd/
Log: a bit of a mess in walk_operations, but otherwise pass more tests
diff --git a/rpython/jit/backend/llsupport/regalloc.py b/rpython/jit/backend/llsupport/regalloc.py
--- a/rpython/jit/backend/llsupport/regalloc.py
+++ b/rpython/jit/backend/llsupport/regalloc.py
@@ -649,16 +649,21 @@
# for tests
looptoken.compiled_loop_token._ll_initial_locs = locs
+ def get_next_op(self, operations, i):
+ while operations[i].is_resume():
+ i += 1
+ return operations[i]
+
def can_merge_with_next_guard(self, op, i, operations):
if (op.getopnum() == rop.CALL_MAY_FORCE or
op.getopnum() == rop.CALL_ASSEMBLER or
op.getopnum() == rop.CALL_RELEASE_GIL):
- assert operations[i + 1].getopnum() == rop.GUARD_NOT_FORCED
+ assert self.get_next_op(operations, i + 1).getopnum() == rop.GUARD_NOT_FORCED
return True
if not op.is_comparison():
if op.is_ovf():
- if (operations[i + 1].getopnum() != rop.GUARD_NO_OVERFLOW and
- operations[i + 1].getopnum() != rop.GUARD_OVERFLOW):
+ if (self.get_next_op(operations, i + 1).getopnum() != rop.GUARD_NO_OVERFLOW and
+ self.get_next_op(operations, i + 1).getopnum() != rop.GUARD_OVERFLOW):
not_implemented("int_xxx_ovf not followed by "
"guard_(no)_overflow")
return True
diff --git a/rpython/jit/backend/test/runner_test.py b/rpython/jit/backend/test/runner_test.py
--- a/rpython/jit/backend/test/runner_test.py
+++ b/rpython/jit/backend/test/runner_test.py
@@ -65,14 +65,16 @@
deadframe = self.cpu.execute_token(looptoken, *args)
if self.cpu.get_latest_descr(deadframe) is operations[-1].getdescr():
self.guard_failed = False
+ locs = None
else:
self.guard_failed = True
+ xxxx
if result_type == 'int':
- return BoxInt(self.cpu.get_int_value(deadframe, 0))
+ return BoxInt(self.cpu.get_int_value(deadframe, locs, 0))
elif result_type == 'ref':
- return BoxPtr(self.cpu.get_ref_value(deadframe, 0))
+ return BoxPtr(self.cpu.get_ref_value(deadframe, locs, 0))
elif result_type == 'float':
- return BoxFloat(self.cpu.get_float_value(deadframe, 0))
+ return BoxFloat(self.cpu.get_float_value(deadframe, locs, 0))
elif result_type == 'void':
return None
else:
@@ -378,22 +380,29 @@
z = BoxInt(579)
t = BoxInt(455)
u = BoxInt(0) # False
+ jitcode = JitCode('jitcode')
+ jitcode.setup(num_regs_i=2, num_regs_r=0, num_regs_f=0)
looptoken = JitCellToken()
targettoken = TargetToken()
operations = [
ResOperation(rop.LABEL, [y, x], None, descr=targettoken),
+ ResOperation(rop.ENTER_FRAME, [ConstInt(-1)], None, descr=jitcode),
ResOperation(rop.INT_ADD, [x, y], z),
ResOperation(rop.INT_SUB, [y, ConstInt(1)], t),
ResOperation(rop.INT_EQ, [t, ConstInt(0)], u),
+ ResOperation(rop.RESUME_PUT, [t, ConstInt(0), ConstInt(0)], None),
+ ResOperation(rop.RESUME_PUT, [z, ConstInt(0), ConstInt(1)], None),
ResOperation(rop.GUARD_FALSE, [u], None,
descr=BasicFailDescr()),
+ ResOperation(rop.LEAVE_FRAME, [], None),
ResOperation(rop.JUMP, [t, z], None, descr=targettoken),
]
- operations[-2].setfailargs([t, z])
cpu.compile_loop(None, [x, y], operations, looptoken)
deadframe = self.cpu.execute_token(looptoken, 0, 10)
- assert self.cpu.get_int_value(deadframe, 0) == 0
- assert self.cpu.get_int_value(deadframe, 1) == 55
+ fail = self.cpu.get_latest_descr(deadframe)
+ locs = rebuild_locs_from_resumedata(fail)
+ assert self.cpu.get_int_value(deadframe, locs, 0) == 0
+ assert self.cpu.get_int_value(deadframe, locs, 1) == 55
def test_int_operations(self):
from rpython.jit.metainterp.test.test_executor import get_int_tests
@@ -429,24 +438,33 @@
v2 = BoxInt(testcases[0][1])
v_res = BoxInt()
#
+ jitcode = JitCode('jitcode')
+ jitcode.setup(num_regs_i=1, num_regs_f=0, num_regs_r=0)
if not reversed:
ops = [
+ ResOperation(rop.ENTER_FRAME, [ConstInt(-1)], None,
+ descr=jitcode),
ResOperation(opnum, [v1, v2], v_res),
+ ResOperation(rop.RESUME_PUT, [v_res, ConstInt(0),
+ ConstInt(0)], None),
ResOperation(rop.GUARD_NO_OVERFLOW, [], None,
descr=BasicFailDescr(1)),
+ ResOperation(rop.LEAVE_FRAME, [], None),
ResOperation(rop.FINISH, [v_res], None,
descr=BasicFinalDescr(2)),
]
- ops[1].setfailargs([])
else:
- v_exc = self.cpu.ts.BoxRef()
ops = [
+ ResOperation(rop.ENTER_FRAME, [ConstInt(-1)], None,
+ descr=jitcode),
ResOperation(opnum, [v1, v2], v_res),
+ ResOperation(rop.RESUME_PUT, [v_res, ConstInt(0),
+ ConstInt(0)], None),
ResOperation(rop.GUARD_OVERFLOW, [], None,
descr=BasicFailDescr(1)),
+ ResOperation(rop.LEAVE_FRAME, [], None),
ResOperation(rop.FINISH, [], None, descr=BasicFinalDescr(2)),
]
- ops[1].setfailargs([v_res])
#
looptoken = JitCellToken()
self.cpu.compile_loop(None, [v1, v2], ops, looptoken)
@@ -454,11 +472,13 @@
deadframe = self.cpu.execute_token(looptoken, x, y)
fail = self.cpu.get_latest_descr(deadframe)
if (z == boom) ^ reversed:
+ locs = rebuild_locs_from_resumedata(fail)
assert fail.identifier == 1
else:
+ locs = None
assert fail.identifier == 2
if z != boom:
- assert self.cpu.get_int_value(deadframe, 0) == z
+ assert self.cpu.get_int_value(deadframe, locs, 0) == z
excvalue = self.cpu.grab_exc_value(deadframe)
assert not excvalue
diff --git a/rpython/jit/backend/x86/regalloc.py b/rpython/jit/backend/x86/regalloc.py
--- a/rpython/jit/backend/x86/regalloc.py
+++ b/rpython/jit/backend/x86/regalloc.py
@@ -318,8 +318,20 @@
self.possibly_free_vars_for_op(op)
continue
if self.can_merge_with_next_guard(op, i, operations):
- oplist_with_guard[op.getopnum()](self, op, operations[i + 1])
+ # make sure we process all the operations between this and the
+ # next guard before executing it
+ guard_op = self.get_next_op(operations, i + 1)
i += 1
+ while operations[i].is_resume():
+ self.resumebuilder.process(operations[i])
+ i += 1
+ oplist_with_guard[op.getopnum()](self, op, guard_op)
+ self.rm.position = i
+ self.xrm.position = i
+ self.rm.free_unused_regs()
+ self.xrm.free_unused_regs()
+ i += 1
+ continue
elif not we_are_translated() and op.getopnum() == -124:
self._consider_force_spill(op)
else:
More information about the pypy-commit
mailing list