[pypy-commit] pypy share-guard-info: whack a bit until we can share more
fijal
noreply at buildbot.pypy.org
Sun Sep 13 17:12:50 CEST 2015
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: share-guard-info
Changeset: r79608:986e925ea183
Date: 2015-09-13 17:12 +0200
http://bitbucket.org/pypy/pypy/changeset/986e925ea183/
Log: whack a bit until we can share more
diff --git a/rpython/jit/codewriter/flatten.py b/rpython/jit/codewriter/flatten.py
--- a/rpython/jit/codewriter/flatten.py
+++ b/rpython/jit/codewriter/flatten.py
@@ -216,24 +216,21 @@
if linkfalse.llexitcase == True:
linkfalse, linktrue = linktrue, linkfalse
opname = 'goto_if_not'
- livebefore = False
if isinstance(block.exitswitch, tuple):
# special case produced by jtransform.optimize_goto_if_not()
opname = 'goto_if_not_' + block.exitswitch[0]
opargs = block.exitswitch[1:]
if opargs[-1] == '-live-before':
- livebefore = True
opargs = opargs[:-1]
else:
assert block.exitswitch.concretetype == lltype.Bool
opargs = [block.exitswitch]
#
lst = self.flatten_list(opargs) + [TLabel(linkfalse)]
- if livebefore:
- self.emitline('-live-')
+ self.emitline('-live-')
self.emitline(opname, *lst)
- if not livebefore:
- self.emitline('-live-', TLabel(linkfalse))
+ #if not livebefore:
+ # self.emitline('-live-', TLabel(linkfalse))
# true path:
self.make_link(linktrue)
# false path:
diff --git a/rpython/jit/codewriter/jtransform.py b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -211,8 +211,8 @@
# ok! optimize this case
block.operations.remove(op)
block.exitswitch = (op.opname,) + tuple(op.args)
- if op.opname in ('ptr_iszero', 'ptr_nonzero'):
- block.exitswitch += ('-live-before',)
+ #if op.opname in ('ptr_iszero', 'ptr_nonzero'):
+ block.exitswitch += ('-live-before',)
# if the variable escape to the next block along a link,
# replace it with a constant, because we know its value
for link in block.exits:
diff --git a/rpython/jit/metainterp/blackhole.py b/rpython/jit/metainterp/blackhole.py
--- a/rpython/jit/metainterp/blackhole.py
+++ b/rpython/jit/metainterp/blackhole.py
@@ -1473,7 +1473,7 @@
elif opnum == rop.GUARD_TRUE:
# Produced directly by some goto_if_not_xxx() opcode that did not
# jump, but which must now jump. The pc is just after the opcode.
- self.position = self.jitcode.follow_jump(self.position)
+ pass # self.position = self.jitcode.follow_jump(self.position)
#
elif opnum == rop.GUARD_FALSE:
# Produced directly by some goto_if_not_xxx() opcode that jumped,
diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -599,6 +599,8 @@
descr.copy_all_attributes_from(last_guard_op.getdescr())
guard_op.setdescr(descr)
guard_op.setfailargs(last_guard_op.getfailargs())
+ if guard_op.getopnum() == rop.GUARD_VALUE:
+ guard_op = self._maybe_replace_guard_value(guard_op, descr)
return guard_op
def getlastop(self):
@@ -641,24 +643,28 @@
descr.store_final_boxes(op, newboxes, self.metainterp_sd)
#
if op.getopnum() == rop.GUARD_VALUE:
- if op.getarg(0).type == 'i':
- b = self.getintbound(op.getarg(0))
- if b.is_bool():
- # Hack: turn guard_value(bool) into guard_true/guard_false.
- # This is done after the operation is emitted to let
- # store_final_boxes_in_guard set the guard_opnum field of
- # the descr to the original rop.GUARD_VALUE.
- constvalue = op.getarg(1).getint()
- if constvalue == 0:
- opnum = rop.GUARD_FALSE
- elif constvalue == 1:
- opnum = rop.GUARD_TRUE
- else:
- raise AssertionError("uh?")
- newop = self.replace_op_with(op, opnum, [op.getarg(0)], descr)
- return newop
- # a real GUARD_VALUE. Make it use one counter per value.
- descr.make_a_counter_per_value(op)
+ op = self._maybe_replace_guard_value(op, descr)
+ return op
+
+ def _maybe_replace_guard_value(self, op, descr):
+ if op.getarg(0).type == 'i':
+ b = self.getintbound(op.getarg(0))
+ if b.is_bool():
+ # Hack: turn guard_value(bool) into guard_true/guard_false.
+ # This is done after the operation is emitted to let
+ # store_final_boxes_in_guard set the guard_opnum field of
+ # the descr to the original rop.GUARD_VALUE.
+ constvalue = op.getarg(1).getint()
+ if constvalue == 0:
+ opnum = rop.GUARD_FALSE
+ elif constvalue == 1:
+ opnum = rop.GUARD_TRUE
+ else:
+ raise AssertionError("uh?")
+ newop = self.replace_op_with(op, opnum, [op.getarg(0)], descr)
+ return newop
+ # a real GUARD_VALUE. Make it use one counter per value.
+ descr.make_a_counter_per_value(op)
return op
def optimize_default(self, op):
diff --git a/rpython/jit/metainterp/pyjitpl.py b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -329,37 +329,37 @@
def opimpl_goto(self, target):
self.pc = target
- @arguments("box", "label")
- def opimpl_goto_if_not(self, box, target):
+ @arguments("box", "label", "orgpc")
+ def opimpl_goto_if_not(self, box, target, orgpc):
switchcase = box.getint()
if switchcase:
opnum = rop.GUARD_TRUE
else:
opnum = rop.GUARD_FALSE
- self.metainterp.generate_guard(opnum, box)
+ self.metainterp.generate_guard(opnum, box, resumepc=orgpc)
if not switchcase:
self.pc = target
- @arguments("box", "label")
- def opimpl_goto_if_not_int_is_true(self, box, target):
+ @arguments("box", "label", "orgpc")
+ def opimpl_goto_if_not_int_is_true(self, box, target, orgpc):
condbox = self.execute(rop.INT_IS_TRUE, box)
- self.opimpl_goto_if_not(condbox, target)
+ self.opimpl_goto_if_not(condbox, target, orgpc)
- @arguments("box", "label")
- def opimpl_goto_if_not_int_is_zero(self, box, target):
+ @arguments("box", "label", "orgpc")
+ def opimpl_goto_if_not_int_is_zero(self, box, target, orgpc):
condbox = self.execute(rop.INT_IS_ZERO, box)
- self.opimpl_goto_if_not(condbox, target)
+ self.opimpl_goto_if_not(condbox, target, orgpc)
for _opimpl in ['int_lt', 'int_le', 'int_eq', 'int_ne', 'int_gt', 'int_ge',
'ptr_eq', 'ptr_ne']:
exec py.code.Source('''
- @arguments("box", "box", "label")
- def opimpl_goto_if_not_%s(self, b1, b2, target):
+ @arguments("box", "box", "label", "orgpc")
+ def opimpl_goto_if_not_%s(self, b1, b2, target, orgpc):
if b1 is b2:
condbox = %s
else:
condbox = self.execute(rop.%s, b1, b2)
- self.opimpl_goto_if_not(condbox, target)
+ self.opimpl_goto_if_not(condbox, target, orgpc)
''' % (_opimpl, FASTPATHS_SAME_BOXES[_opimpl.split("_")[-1]], _opimpl.upper())
).compile()
@@ -2456,7 +2456,7 @@
if opnum == rop.GUARD_FUTURE_CONDITION:
pass
elif opnum == rop.GUARD_TRUE: # a goto_if_not that jumps only now
- frame.pc = frame.jitcode.follow_jump(frame.pc)
+ pass # frame.pc = frame.jitcode.follow_jump(frame.pc)
elif opnum == rop.GUARD_FALSE: # a goto_if_not that stops jumping;
pass # or a switch that was in its "default" case
elif opnum == rop.GUARD_VALUE or opnum == rop.GUARD_CLASS:
More information about the pypy-commit
mailing list