[pypy-svn] r60486 - in pypy/branch/oo-jit/pypy/jit: rainbow/test tl
antocuni at codespeak.net
antocuni at codespeak.net
Sat Dec 13 10:16:11 CET 2008
Author: antocuni
Date: Sat Dec 13 10:16:09 2008
New Revision: 60486
Modified:
pypy/branch/oo-jit/pypy/jit/rainbow/test/test_0tlc.py
pypy/branch/oo-jit/pypy/jit/tl/tlc.py
Log:
make test_0tlc using the 'with call' version of interp_eval, and some rpython
fixes needed for it
Modified: pypy/branch/oo-jit/pypy/jit/rainbow/test/test_0tlc.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/test/test_0tlc.py (original)
+++ pypy/branch/oo-jit/pypy/jit/rainbow/test/test_0tlc.py Sat Dec 13 10:16:09 2008
@@ -63,10 +63,10 @@
bytecode = hlstr(llbytecode)
encpool = hlstr(llencpool)
pool = decode_pool(encpool)
- obj = tlc.interp_eval_without_call(bytecode,
- pc,
- tlc.IntObj(inputarg),
- pool)
+ obj = tlc.interp_eval(bytecode,
+ pc,
+ [tlc.IntObj(inputarg)],
+ pool)
return obj.int_o()
to_rstr = self.to_rstr
@@ -78,18 +78,20 @@
interp.convert_arguments = [build_bytecode, int, int, build_pool]
return interp
- def test_factorial(self):
- code = tlc.compile(FACTORIAL_SOURCE)
+ def exec_code(self, code, inputarg, pool=None):
bytecode = ','.join([str(ord(c)) for c in code])
+ interp = self._get_interp()
+ res = self.timeshift_from_portal(interp,
+ tlc.interp_eval,
+ [bytecode, 0, inputarg, pool],
+ policy=P_OOPSPEC)
+ return res
+ def test_factorial(self):
+ code = tlc.compile(FACTORIAL_SOURCE)
n = 5
expected = 120
-
- interp = self._get_interp()
- res = self.timeshift_from_portal(interp,
- tlc.interp_eval_without_call,
- [bytecode, 0, n, None],
- policy=P_OOPSPEC)#, backendoptimize=True)
+ res = self.exec_code(code, n)
assert res == expected
self.check_insns(malloc=1)
@@ -106,18 +108,11 @@
PUSHARG
DIV
""")
- bytecode = ','.join([str(ord(c)) for c in code])
-
- interp = self._get_interp()
- res = self.timeshift_from_portal(interp,
- tlc.interp_eval_without_call,
- [bytecode, 0, 1, None],
- policy=P_OOPSPEC)#, backendoptimize=True)
+ res = self.exec_code(code, 1)
assert res == 20
def test_getattr(self):
- from pypy.jit.tl.tlc import interp_eval, nil, ConstantPool
- pool = ConstantPool()
+ pool = tlc.ConstantPool()
code = tlc.compile("""
NEW foo,bar
PICK 0
@@ -125,12 +120,7 @@
SETATTR bar,
GETATTR bar,
""", pool)
- bytecode = ','.join([str(ord(c)) for c in code])
- interp = self._get_interp()
- res = self.timeshift_from_portal(interp,
- tlc.interp_eval_without_call,
- [bytecode, 0, 0, pool],
- policy=P_OOPSPEC)
+ res = self.exec_code(code, 0, pool)
assert res == 42
self.check_insns(malloc=1, direct_call=0)
Modified: pypy/branch/oo-jit/pypy/jit/tl/tlc.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/tl/tlc.py (original)
+++ pypy/branch/oo-jit/pypy/jit/tl/tlc.py Sat Dec 13 10:16:09 2008
@@ -220,6 +220,14 @@
args = [IntObj(inputarg)]
return interp_eval(code, pc, args, pool).int_o()
+ def call_interp_eval(code2, pc2, args2, pool2):
+ # recursive calls to portal need to go through an helper
+ code = hint(code2, promote=True)
+ pc = hint(pc2, promote=True)
+ args = hint(args2, promote=True)
+ return interp_eval(code, pc, args, pool2)
+
+
def interp_eval(code, pc, args, pool2):
code_len = len(code)
stack = []
@@ -357,7 +365,7 @@
elif supports_call and opcode == CALL:
offset = char2int(code[pc])
pc += 1
- res = interp_eval(code, pc + offset, [zero], pool2)
+ res = call_interp_eval(code, pc + offset, [zero], pool2)
stack.append( res )
elif opcode == RETURN:
@@ -402,12 +410,17 @@
pc += 1
num_args += 1 # include self
name = pool.strings[idx]
- meth_args = stack[-num_args:]
- del stack[-num_args:]
+ start = len(stack)-num_args
+ assert start >= 0
+ meth_args = stack[start:]
+ # we can't use del because vlist.py doesn't support list_method_resize_le
+ #del stack[start:]
+ for i in range(num_args):
+ stack.pop()
a = meth_args[0]
hint(a, promote_class=True)
meth_pc = a.send(name)
- res = interp_eval(code, meth_pc, meth_args, pool2)
+ res = call_interp_eval(code, meth_pc, meth_args, pool2)
stack.append( res )
else:
More information about the Pypy-commit
mailing list