[pypy-commit] pypy small-unroll-improvements: make generate_guards take an OptValue instead of a box
cfbolz
noreply at buildbot.pypy.org
Tue Apr 8 10:10:09 CEST 2014
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: small-unroll-improvements
Changeset: r70486:63d82c48f6f4
Date: 2014-04-08 10:09 +0200
http://bitbucket.org/pypy/pypy/changeset/63d82c48f6f4/
Log: make generate_guards take an OptValue instead of a box
(in theory, it is not necessary to make it take a second virtual
state now, but well)
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
@@ -144,10 +144,16 @@
class BaseTestGenerateGuards(BaseTest):
- def guards(self, info1, info2, box, expected):
+ def guards(self, info1, info2, box_or_value, expected):
+ if isinstance(box_or_value, OptValue):
+ value = box_or_value
+ box = value.box
+ else:
+ box = box_or_value
+ value = OptValue(box)
info1.position = info2.position = 0
guards = []
- info1.generate_guards(info2, box, self.cpu, guards, {})
+ info1.generate_guards(info2, value, self.cpu, guards, {})
self.compare(guards, expected, [box])
def compare(self, guards, expected, inputargs):
@@ -162,7 +168,7 @@
assert equaloplists(guards, loop.operations, False,
boxmap)
def test_intbounds(self):
- value1 = OptValue(BoxInt())
+ value1 = OptValue(BoxInt(15))
value1.intbound.make_ge(IntBound(0, 10))
value1.intbound.make_le(IntBound(20, 30))
info1 = NotVirtualStateInfo(value1)
@@ -174,7 +180,7 @@
i2 = int_le(i0, 30)
guard_true(i2) []
"""
- self.guards(info1, info2, BoxInt(15), expected)
+ self.guards(info1, info2, value1, expected)
py.test.raises(InvalidLoop, self.guards,
info1, info2, BoxInt(50), expected)
@@ -219,7 +225,7 @@
self.compare(guards, expected, [box])
def test_equal_inputargs(self):
- value = OptValue(self.nodebox)
+ value = OptValue(self.nodebox)
classbox = self.cpu.ts.cls_of_box(self.nodebox)
value.make_constant_class(classbox, -1)
knownclass_info = NotVirtualStateInfo(value)
@@ -242,20 +248,20 @@
expected = """
[p0]
- guard_nonnull(p0) []
+ guard_nonnull(p0) []
guard_class(p0, ConstClass(node_vtable)) []
"""
guards = []
- vstate1.generate_guards(vstate2, [self.nodebox, self.nodebox], self.cpu, guards)
+ vstate1.generate_guards(vstate2, [value, value], self.cpu, guards)
self.compare(guards, expected, [self.nodebox])
with py.test.raises(InvalidLoop):
guards = []
- vstate1.generate_guards(vstate3, [self.nodebox, self.nodebox],
+ vstate1.generate_guards(vstate3, [value, value],
self.cpu, guards)
with py.test.raises(InvalidLoop):
guards = []
- vstate2.generate_guards(vstate3, [self.nodebox, self.nodebox],
+ vstate2.generate_guards(vstate3, [value, value],
self.cpu, guards)
def test_known_value_virtualstate(self):
@@ -271,7 +277,7 @@
guard_value(i0, 1) []
"""
guards = []
- vstate1.generate_guards(vstate2, [box2], self.cpu, guards)
+ vstate1.generate_guards(vstate2, [value2], self.cpu, guards)
self.compare(guards, expected, [box2])
diff --git a/rpython/jit/metainterp/optimizeopt/unroll.py b/rpython/jit/metainterp/optimizeopt/unroll.py
--- a/rpython/jit/metainterp/optimizeopt/unroll.py
+++ b/rpython/jit/metainterp/optimizeopt/unroll.py
@@ -545,6 +545,8 @@
args = jumpop.getarglist()
modifier = VirtualStateAdder(self.optimizer)
virtual_state = modifier.get_virtual_state(args)
+ values = [self.getvalue(arg)
+ for arg in jumpop.getarglist()]
debug_start('jit-log-virtualstate')
virtual_state.debug_print("Looking for ")
@@ -563,15 +565,14 @@
try:
cpu = self.optimizer.cpu
target.virtual_state.generate_guards(virtual_state,
- args, cpu,
+ values,
+ cpu,
extra_guards)
ok = True
debugmsg = 'Guarded to match '
except InvalidLoop:
pass
- #else:
- # import pdb; pdb.set_trace()
if ok and not patchguardop:
# if we can't patch the guards to go to a good target, no use
# in jumping to this label
@@ -590,8 +591,6 @@
if ok:
debug_stop('jit-log-virtualstate')
- values = [self.getvalue(arg)
- for arg in jumpop.getarglist()]
args = target.virtual_state.make_inputargs(values, self.optimizer,
keyboxes=True)
short_inputargs = target.short_preamble[0].getarglist()
@@ -604,6 +603,7 @@
self.optimizer.send_extra_operation(guard)
try:
+ # NB: the short_preamble ends with a jump
for shop in target.short_preamble[1:]:
newop = inliner.inline_op(shop)
if newop.is_guard():
diff --git a/rpython/jit/metainterp/optimizeopt/virtualstate.py b/rpython/jit/metainterp/optimizeopt/virtualstate.py
--- a/rpython/jit/metainterp/optimizeopt/virtualstate.py
+++ b/rpython/jit/metainterp/optimizeopt/virtualstate.py
@@ -4,7 +4,7 @@
from rpython.jit.metainterp.optimizeopt import virtualize
from rpython.jit.metainterp.optimizeopt.intutils import IntUnbounded
from rpython.jit.metainterp.optimizeopt.optimizer import (LEVEL_CONSTANT,
- LEVEL_KNOWNCLASS, LEVEL_NONNULL, LEVEL_UNKNOWN)
+ LEVEL_KNOWNCLASS, LEVEL_NONNULL, LEVEL_UNKNOWN, OptValue)
from rpython.jit.metainterp.resoperation import rop, ResOperation
from rpython.rlib.debug import debug_start, debug_stop, debug_print
from rpython.rlib.objectmodel import we_are_translated
@@ -28,7 +28,8 @@
bad[self] = bad[other] = None
return result
- def generate_guards(self, other, box, cpu, extra_guards, renum):
+ def generate_guards(self, other, value, cpu, extra_guards, renum):
+ assert isinstance(value, OptValue)
if self.generalization_of(other, renum, {}):
return
if renum[self.position] != other.position:
@@ -36,9 +37,9 @@
'match. This means that two virtual fields ' +
'have been set to the same Box in one of the ' +
'virtual states but not in the other.')
- self._generate_guards(other, box, cpu, extra_guards)
+ self._generate_guards(other, value, cpu, extra_guards, renum)
- def _generate_guards(self, other, box, cpu, extra_guards):
+ def _generate_guards(self, other, value, cpu, extra_guards, renum):
raise InvalidLoop('Generating guards for making the VirtualStates ' +
'at hand match have not been implemented')
@@ -279,7 +280,8 @@
return False
return True
- def _generate_guards(self, other, box, cpu, extra_guards):
+ def _generate_guards(self, other, value, cpu, extra_guards, renum):
+ box = value.box
if not isinstance(other, NotVirtualStateInfo):
raise InvalidLoop('The VirtualStates does not match as a ' +
'virtual appears where a pointer is needed ' +
@@ -408,11 +410,11 @@
return False
return True
- def generate_guards(self, other, args, cpu, extra_guards):
- assert len(self.state) == len(other.state) == len(args)
+ def generate_guards(self, other, values, cpu, extra_guards):
+ assert len(self.state) == len(other.state) == len(values)
renum = {}
for i in range(len(self.state)):
- self.state[i].generate_guards(other.state[i], args[i],
+ self.state[i].generate_guards(other.state[i], values[i],
cpu, extra_guards, renum)
def make_inputargs(self, values, optimizer, keyboxes=False):
More information about the pypy-commit
mailing list