[pypy-svn] r49995 - in pypy/dist/pypy/translator: . backendopt/test
arigo at codespeak.net
arigo at codespeak.net
Sat Dec 22 09:11:48 CET 2007
Author: arigo
Date: Sat Dec 22 09:11:47 2007
New Revision: 49995
Modified:
pypy/dist/pypy/translator/backendopt/test/test_inline.py
pypy/dist/pypy/translator/simplify.py
Log:
How hard do we want to enforce the condition that indirect_call()
is never done with a Constant target?
Modified: pypy/dist/pypy/translator/backendopt/test/test_inline.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_inline.py (original)
+++ pypy/dist/pypy/translator/backendopt/test/test_inline.py Sat Dec 22 09:11:47 2007
@@ -718,3 +718,16 @@
eval_func, t = self.check_auto_inlining(fn5, [], checkvirtual=True)
res = eval_func([])
assert res == 42
+
+ def test_indirect_call_becomes_direct(self):
+ def h1(n):
+ return n+1
+ def h2(n):
+ return n+2
+ def g(myfunc, n):
+ return myfunc(n*5)
+ def f(x, y):
+ return g(h1, x) + g(h2, y)
+ eval_func = self.check_inline(g, f, [int, int])
+ res = eval_func([10, 173])
+ assert res == f(10, 173)
Modified: pypy/dist/pypy/translator/simplify.py
==============================================================================
--- pypy/dist/pypy/translator/simplify.py (original)
+++ pypy/dist/pypy/translator/simplify.py Sat Dec 22 09:11:47 2007
@@ -366,7 +366,12 @@
def rename_op(op):
args = [rename(a) for a in op.args]
op = SpaceOperation(op.opname, args, rename(op.result), op.offset)
- #op = SpaceOperation(op.opname, args, rename(op.result))
+ # special case...
+ if op.opname == 'indirect_call':
+ if isinstance(op.args[0], Constant):
+ assert isinstance(op.args[-1], Constant)
+ del op.args[-1]
+ op.opname = 'direct_call'
return op
for op in link.target.operations:
link.prevblock.operations.append(rename_op(op))
More information about the Pypy-commit
mailing list