[pypy-svn] r65971 - in pypy/branch/pyjitpl5/pypy/jit/metainterp: . test
fijal at codespeak.net
fijal at codespeak.net
Thu Jun 25 22:51:23 CEST 2009
Author: fijal
Date: Thu Jun 25 22:51:22 2009
New Revision: 65971
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_recursive.py
Log:
Basic inlining seems to work without any trouble. This is wrong so far, but
passes test.
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py Thu Jun 25 22:51:22 2009
@@ -676,9 +676,10 @@
# ----------------------------------------------------------------
class Options:
- def __init__(self, specialize=True, listops=False):
+ def __init__(self, specialize=True, listops=False, inline=False):
self.specialize = specialize
self.listops = listops
+ self.inline = inline
def _freeze_(self):
return True
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py Thu Jun 25 22:51:22 2009
@@ -581,6 +581,9 @@
@arguments("descr", "varargs")
def opimpl_recursive_call(self, calldescr, varargs):
+ if self.metainterp.staticdata.options.inline:
+ portal_code = self.metainterp.staticdata.portal_code
+ return self.perform_call(portal_code, varargs[1:])
return self.execute_with_exc(rop.CALL, varargs, descr=calldescr)
@arguments("descr", "varargs")
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_recursive.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_recursive.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_recursive.py Thu Jun 25 22:51:22 2009
@@ -95,6 +95,42 @@
policy=StopAtXPolicy(opaque))
assert res == 1
+ def test_inline(self):
+ ADD = "0"
+ JUMP_BACK = "1"
+ CALL = "2"
+
+ code = "021"
+ subcode = "0"
+
+ jitdriver = JitDriver(greens = ['code', 'i'], reds = ['n'])
+
+ codes = [code, subcode]
+
+ def f(codenum, n):
+ i = 0
+ code = codes[codenum]
+ while i < len(code):
+ jitdriver.jit_merge_point(n=n, i=i, code=code)
+ op = code[i]
+ if op == ADD:
+ n += 1
+ i += 1
+ elif op == CALL:
+ n = f(1, n)
+ i += 1
+ elif op == JUMP_BACK:
+ if n > 20:
+ return 42
+ i -= 2
+ jitdriver.can_enter_jit(n=n, i=i, code=code)
+ else:
+ raise NotImplementedError
+ return n
+
+ assert self.meta_interp(f, [0, 0], optimizer=Optimizer) == 42
+ assert self.meta_interp(f, [0, 0], optimizer=Optimizer,
+ inline=True) == 42
class TestLLtype(RecursiveTests, LLJitMixin):
pass
More information about the Pypy-commit
mailing list