[pypy-commit] pypy jit-short_from_state: short_inputargs can contain the same keybox twice. The virtual_state check will ensure that any jump using the short preamble as target will have the exact same duplicated keyboxes. This is maybe not so nice a property...
hakanardo
noreply at buildbot.pypy.org
Wed Jul 20 10:19:35 CEST 2011
Author: Hakan Ardo <hakan at debian.org>
Branch: jit-short_from_state
Changeset: r45761:2729c61219e4
Date: 2011-07-17 16:50 +0200
http://bitbucket.org/pypy/pypy/changeset/2729c61219e4/
Log: short_inputargs can contain the same keybox twice. The virtual_state
check will ensure that any jump using the short preamble as target
will have the exact same duplicated keyboxes. This is maybe not so
nice a property...
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -6467,6 +6467,18 @@
"""
self.optimize_loop(ops, expected)
+ def test_duplicated_virtual(self):
+ ops = """
+ [p1, p2]
+ p3 = new_with_vtable(ConstClass(node_vtable))
+ jump(p3, p3)
+ """
+ expected = """
+ []
+ jump()
+ """
+ self.optimize_loop(ops, expected)
+
class TestLLtype(OptimizeOptTest, LLtypeMixin):
pass
diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -84,6 +84,9 @@
assert len(inputargs) == len(jump_args)
self.argmap = {}
for i in range(len(inputargs)):
+ if inputargs[i] in self.argmap:
+ assert self.argmap[inputargs[i]] == jump_args[i]
+ else:
self.argmap[inputargs[i]] = jump_args[i]
self.snapshot_map = {None: None}
@@ -220,7 +223,11 @@
# in the peeled loop
inputarg_setup_ops = []
preamble_optimizer.newoperations = []
+ seen = {}
for box in short_inputargs:
+ if box in seen:
+ continue
+ seen[box] = True
value = preamble_optimizer.getvalue(box)
if value.is_virtual():
value.force_box()
@@ -284,7 +291,15 @@
short_loop.operations = short
# Clone ops and boxes to get private versions and
- newargs = [a.clonebox() for a in short_loop.inputargs]
+ boxmap = {}
+ newargs = [None] * len(short_loop.inputargs)
+ for i in range(len(short_loop.inputargs)):
+ a = short_loop.inputargs[i]
+ if a in boxmap:
+ newargs[i] = boxmap[a]
+ else:
+ newargs[i] = a.clonebox()
+ boxmap[a] = newargs[i]
inliner = Inliner(short_loop.inputargs, newargs)
for box, const in self.constant_inputargs.items():
inliner.argmap[box] = const
More information about the pypy-commit
mailing list