[pypy-svn] r35506 - in pypy/branch/jit-real-world/pypy/jit/timeshifter: . test
arigo at codespeak.net
arigo at codespeak.net
Fri Dec 8 19:22:48 CET 2006
Author: arigo
Date: Fri Dec 8 19:22:45 2006
New Revision: 35506
Modified:
pypy/branch/jit-real-world/pypy/jit/timeshifter/test/test_timeshift.py
pypy/branch/jit-real-world/pypy/jit/timeshifter/transform.py
Log:
(pedronis, arigo)
Fix the case of red calls whose return value is not used.
Modified: pypy/branch/jit-real-world/pypy/jit/timeshifter/test/test_timeshift.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/jit/timeshifter/test/test_timeshift.py (original)
+++ pypy/branch/jit-real-world/pypy/jit/timeshifter/test/test_timeshift.py Fri Dec 8 19:22:45 2006
@@ -1200,3 +1200,13 @@
res = self.timeshift(f, [-20], [], policy=stop_at_h)
assert res == 7
self.check_insns(int_add=0)
+
+ def test_red_call_ignored_result(self):
+ def g(n):
+ return n * 7
+ def f(n, m):
+ g(n) # ignore the result
+ return m
+
+ res = self.timeshift(f, [4, 212], [], policy=P_NOVIRTUAL)
+ assert res == 212
Modified: pypy/branch/jit-real-world/pypy/jit/timeshifter/transform.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/jit/timeshifter/transform.py (original)
+++ pypy/branch/jit-real-world/pypy/jit/timeshifter/transform.py Fri Dec 8 19:22:45 2006
@@ -547,18 +547,22 @@
if color == 'red':
assert not self.hannotator.binding(op.result).is_green()
-
- try:
- index = varsalive.index(op.result)
- except ValueError:
- uses_retval = False
+ # the result will be either passed as an extra local 0
+ # by the caller, or restored by a restore_local
+ try:
+ index = varsalive.index(op.result)
+ except ValueError:
+ linkargs.insert(0, op.result)
+ v_result = copyvar(self.hannotator, op.result)
+ nextblock.inputargs.insert(0, v_result)
+ else:
+ del varsalive[index]
+ old_v_result = linkargs.pop(index)
+ linkargs.insert(0, old_v_result)
+ v_result = nextblock.inputargs.pop(index)
+ nextblock.inputargs.insert(0, v_result)
else:
- uses_retval = True # it will be restored by a restore_local
- del varsalive[index]
- old_v_result = linkargs.pop(index)
- linkargs.insert(0, old_v_result)
- v_result = nextblock.inputargs.pop(index)
- nextblock.inputargs.insert(0, v_result)
+ assert op.result not in varsalive # XXX gray result used
reds, greens = self.sort_by_color(varsalive)
@@ -599,7 +603,7 @@
v_res = self.genop(nonconstantblock, 'residual_%s_call' % (color,),
[op.args[0]], result_like = op.result)
- if uses_retval:
+ if color == 'red':
linkargs[0] = v_res
nonconstantblock.closeblock(Link(linkargs, nextblock))
More information about the Pypy-commit
mailing list