[pypy-svn] r61955 - in pypy/branch/oo-jit/pypy/jit/tl: . test
antocuni at codespeak.net
antocuni at codespeak.net
Mon Feb 16 23:52:43 CET 2009
Author: antocuni
Date: Mon Feb 16 23:52:41 2009
New Revision: 61955
Modified:
pypy/branch/oo-jit/pypy/jit/tl/test/test_tl.py
pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py
pypy/branch/oo-jit/pypy/jit/tl/tlc.py
pypy/branch/oo-jit/pypy/jit/tl/tlopcode.py
Log:
a new opcode for tlc, to pass arguments to functions
Modified: pypy/branch/oo-jit/pypy/jit/tl/test/test_tl.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/tl/test/test_tl.py (original)
+++ pypy/branch/oo-jit/pypy/jit/tl/test/test_tl.py Mon Feb 16 23:52:41 2009
@@ -37,6 +37,7 @@
py.test.raises(RuntimeError, self.interp, list2bytecode([INVALID]))
def test_tl_translatable(self):
+ py.test.skip('fixme, broken by r60900 :-(')
code = list2bytecode([PUSH,42, PUSH,100, ADD])
fn = self.getcompiled(self.interp, [str, int, int])
assert self.interp(code, 0, 0) == fn(code, 0, 0)
Modified: pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py (original)
+++ pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py Mon Feb 16 23:52:41 2009
@@ -270,6 +270,22 @@
res = interp_eval(bytecode, 0, [nil], pool)
assert res.int_o() == 42
+ def test_call_with_arguments(self):
+ from pypy.jit.tl.tlc import interp_eval, nil
+ pool = ConstantPool()
+ bytecode = compile("""
+ PUSH 41
+ CALLARGS foo/1
+ RETURN
+ foo:
+ PUSHARG
+ PUSH 1
+ ADD
+ RETURN
+ """, pool)
+ res = interp_eval(bytecode, 0, [nil], pool)
+ assert res.int_o() == 42
+
def compile(self, filename):
from pypy.jit.tl.tlc import interp_eval, IntObj
pool = ConstantPool()
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 Mon Feb 16 23:52:41 2009
@@ -473,6 +473,20 @@
args = meth_args
stack = []
+ elif supports_call and opcode == CALLARGS:
+ offset = char2int(code[pc])
+ pc += 1
+ num_args = char2int(code[pc])
+ call_args = [None] * num_args
+ while num_args > 0:
+ num_args -= 1
+ call_args[num_args] = stack.pop()
+ hint(num_args, concrete=True)
+ framestack.push(pc, args, stack)
+ pc = pc + offset
+ args = call_args
+ stack = []
+
elif opcode == PRINT:
if not we_are_translated():
a = stack.pop()
Modified: pypy/branch/oo-jit/pypy/jit/tl/tlopcode.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/tl/tlopcode.py (original)
+++ pypy/branch/oo-jit/pypy/jit/tl/tlopcode.py Mon Feb 16 23:52:41 2009
@@ -54,6 +54,7 @@
opcode(33, "PRINT")
opcode(34, "DUMP")
opcode(35, "BR")
+opcode(36, "CALLARGS")
del opcode
@@ -106,6 +107,12 @@
idx = pool.add_string(methname)
bytecode.append(idx)
bytecode.append(int(num_args))
+ elif t[0] == 'CALLARGS':
+ # 'label/num_args'
+ fnname, num_args = arg.split('/')
+ label_usage.append( (fnname, len(bytecode)) )
+ bytecode.append( 0 )
+ bytecode.append(int(num_args))
else:
# it's a label
label_usage.append( (arg, len(bytecode)) )
More information about the Pypy-commit
mailing list