[pypy-svn] r63699 - in pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86: . test
fijal at codespeak.net
fijal at codespeak.net
Mon Apr 6 02:03:32 CEST 2009
Author: fijal
Date: Mon Apr 6 02:03:29 2009
New Revision: 63699
Modified:
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/regalloc.py
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py
Log:
* implement optimizations on guard's preceded by ooisnull/oononnull
* reimplement loggin
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py Mon Apr 6 02:03:29 2009
@@ -119,14 +119,13 @@
if self.malloc_func_addr == 0:
self.malloc_func_addr = gc_malloc_fnaddr()
- def eventually_log_operations(self, operations):
+ def eventually_log_operations(self, inputargs, operations, memo=None):
if self._log_fd == -1:
return
- return # XXX
- memo = {}
- os.write(self._log_fd, "<<<<<<<<<<\n")
- if guard_op is not None:
- os.write(self._log_fd, "GO(%d)\n" % guard_op._jmp_from)
+ if memo is None:
+ memo = {}
+ args = ",".join([repr_of_arg(memo, arg) for arg in inputargs])
+ os.write(self._log_fd, "LOOP %s\n" % args)
for op in operations:
args = ",".join([repr_of_arg(memo, arg) for arg in op.args])
os.write(self._log_fd, "%s %s\n" % (op.getopname(), args))
@@ -134,10 +133,10 @@
os.write(self._log_fd, " => %s\n" % repr_of_arg(memo,
op.result))
if op.is_guard():
- liveboxes_s = ",".join([repr_of_arg(memo, arg) for arg in
- op.liveboxes])
- os.write(self._log_fd, " .. %s\n" % liveboxes_s)
- os.write(self._log_fd, ">>>>>>>>>>\n")
+ os.write(self._log_fd, "BEGIN\n")
+ self.eventually_log_operations(inputargs, operations, memo)
+ os.write(self._log_fd, "END\n")
+ os.write(self._log_fd, "LOOP END\n")
def log_failure_recovery(self, gf, guard_index):
if self._log_fd == -1:
@@ -181,7 +180,7 @@
self._compute_longest_fail_op(tree.operations)
self.make_sure_mc_exists()
inputargs = tree.inputargs
- self.eventually_log_operations(tree)
+ self.eventually_log_operations(tree.inputargs, tree.operations)
regalloc = RegAlloc(self, tree, self.cpu.translate_support_code)
if not we_are_translated():
self._regalloc = regalloc # for debugging
@@ -417,6 +416,22 @@
self.mc.MOV(resloc, imm8(0))
self.mc.SETNZ(lower_byte(resloc))
+ def genop_guard_oononnull(self, op, guard_op, addr, arglocs, resloc):
+ loc = arglocs[0]
+ self.mc.TEST(loc, loc)
+ if guard_op.opnum == rop.GUARD_TRUE:
+ self.implement_guard(addr, guard_op, self.mc.JZ)
+ else:
+ self.implement_guard(addr, guard_op, self.mc.JNZ)
+
+ def genop_guard_ooisnull(self, op, guard_op, addr, arglocs, resloc):
+ loc = arglocs[0]
+ self.mc.TEST(loc, loc)
+ if guard_op.opnum == rop.GUARD_TRUE:
+ self.implement_guard(addr, guard_op, self.mc.JNZ)
+ else:
+ self.implement_guard(addr, guard_op, self.mc.JZ)
+
def genop_oononnull(self, op, arglocs, resloc):
self.mc.CMP(arglocs[0], imm8(0))
self.mc.MOV(resloc, imm8(0))
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/regalloc.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/regalloc.py Mon Apr 6 02:03:29 2009
@@ -227,7 +227,8 @@
self.assembler.regalloc_perform_discard(op, arglocs)
def can_optimize_cmp_op(self, op, i, operations):
- if not op.is_comparison():
+ if not (op.is_comparison() or op.opnum == rop.OOISNULL or
+ op.opnum == rop.OONONNULL):
return False
if (operations[i + 1].opnum != rop.GUARD_TRUE and
operations[i + 1].opnum != rop.GUARD_FALSE):
@@ -983,12 +984,21 @@
resloc = self.force_allocate_reg(op.result, [])
self.Perform(op, [argloc], resloc)
- def _consider_nullity(self, op, ignored):
+ def _consider_nullity(self, op, guard_op):
# doesn't need a register in arg
- argloc = self.loc(op.args[0])
- self.eventually_free_var(op.args[0])
- resloc = self.force_allocate_reg(op.result, [])
- self.Perform(op, [argloc], resloc)
+ if guard_op is not None:
+ argloc = self.make_sure_var_in_reg(op.args[0], [])
+ self.eventually_free_var(op.args[0])
+ regalloc = self.regalloc_for_guard(guard_op)
+ self.position += 1
+ self.perform_with_guard(op, guard_op, regalloc, [argloc], None)
+ self.eventually_free_var(op.result)
+ self.eventually_free_vars(guard_op.inputargs)
+ else:
+ argloc = self.loc(op.args[0])
+ self.eventually_free_var(op.args[0])
+ resloc = self.force_allocate_reg(op.result, [])
+ self.Perform(op, [argloc], resloc)
consider_ooisnull = _consider_nullity
consider_oononnull = _consider_nullity
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py Mon Apr 6 02:03:29 2009
@@ -466,3 +466,23 @@
def test_lshift(self):
py.test.skip("XXX")
+
+ def test_oononnull_with_guard(self):
+ p = lltype.cast_opaque_ptr(llmemory.GCREF,
+ lltype.malloc(lltype.GcStruct('x')))
+ p = BoxPtr(p)
+ f = BoxInt()
+ ops = [
+ ResOperation(rop.OONONNULL, [p], f),
+ ResOperation(rop.GUARD_FALSE, [f], None),
+ ResOperation(rop.FAIL, [ConstInt(0)], None),
+ ]
+ ops[1].suboperations = [ResOperation(rop.FAIL, [ConstInt(1)], None)]
+ ops[-1].ovf = False
+ ops[-1].exc = False
+ loop = TreeLoop('name')
+ loop.operations = ops
+ loop.inputargs = [p]
+ self.cpu.compile_operations(loop)
+ op = self.cpu.execute_operations(loop, [p])
+ assert op.args[0].value == 1
More information about the Pypy-commit
mailing list