[pypy-svn] r60531 - in pypy/branch/oo-jit/pypy/jit: rainbow/test tl tl/test
antocuni at codespeak.net
antocuni at codespeak.net
Wed Dec 17 11:01:41 CET 2008
Author: antocuni
Date: Wed Dec 17 11:01:40 2008
New Revision: 60531
Added:
pypy/branch/oo-jit/pypy/jit/tl/accumulator.tlc (contents, props changed)
pypy/branch/oo-jit/pypy/jit/tl/accumulator.tlc.src
Modified:
pypy/branch/oo-jit/pypy/jit/rainbow/test/test_0tlc.py
pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py
pypy/branch/oo-jit/pypy/jit/tl/tlc.py
Log:
a new oo benchmark for tlc, and two failing tests
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 Wed Dec 17 11:01:40 2008
@@ -74,7 +74,7 @@
code = """
NEW foo,meth=meth
PICK 0
- PUSH 40
+ PUSHARG
SETATTR foo
PUSH 2
SEND meth/1
@@ -86,8 +86,39 @@
ADD
RETURN
"""
- res = self.exec_code(code, 0)
+ res = self.exec_code(code, 40)
assert res == 42
+ self.check_insns(malloc=1)
+
+ def test_method_loop(self):
+ path = py.path.local(__file__).join('../../../tl/accumulator.tlc.src')
+ code = path.read()
+ res = self.exec_code(code, 10)
+ assert res == sum(range(10))
+ self.check_insns(malloc=1)
+
+ def test_binarytree(self):
+ py.test.skip('fix me')
+ path = py.path.local(__file__).join('../../../tl/binarytree.tlc.src')
+ code = path.read()
+ res = self.exec_code(code, 15)
+ assert res == 1
+ #self.check_insns(...)
+
+ def test_bug(self):
+ py.test.skip('fix me')
+ code = """
+ NEW foo,meth=meth
+ PUSHARG # if we use PUSH <constant> it works
+ SEND meth/1
+ RETURN
+ meth:
+ PUSH 1
+ RETURN
+ """
+ res = self.exec_code(code, -1)
+ assert res == 1
+ self.check_insns(malloc=1)
class TestLLType(BaseTestTLC):
type_system = "lltype"
Added: pypy/branch/oo-jit/pypy/jit/tl/accumulator.tlc
==============================================================================
Binary file. No diff available.
Added: pypy/branch/oo-jit/pypy/jit/tl/accumulator.tlc.src
==============================================================================
--- (empty file)
+++ pypy/branch/oo-jit/pypy/jit/tl/accumulator.tlc.src Wed Dec 17 11:01:40 2008
@@ -0,0 +1,33 @@
+main:
+ NEW value,add=add
+ PICK 0
+ PUSH 0
+ SETATTR value
+ PUSHARG # [obj, n]
+
+loop: # [obj, n]
+ PICK 0 # [obj, n, n]
+ BR_COND continue
+
+exit: # [obj, n]
+ POP
+ GETATTR value
+ RETURN
+
+continue: # [obj, n]
+ PUSH 1
+ SUB # [obj, n-1]
+ PICK 1 # [obj, n-1, obj]
+ PICK 1 # [obj, n-1, obj, n-1]
+ SEND add/1 # [obj, n-1]
+ PUSH 1
+ BR_COND loop
+
+add: # (x)
+ PUSHARG # [self]
+ PUSHARG # [self, self]
+ GETATTR value # [self, self.value]
+ PUSHARGN 1 # [self, self.value, x]
+ ADD # [self, self.value+x]
+ SETATTR value # []
+ RETURN
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 Wed Dec 17 11:01:40 2008
@@ -286,3 +286,9 @@
assert fibo(2) == 1
assert fibo(3) == 2
assert fibo(7) == 13
+
+ def test_accumulator(self):
+ acc = self.compile('../../accumulator.tlc.src')
+ assert acc(1) == 0
+ assert acc(10) == sum(range(10))
+ assert acc(20) == sum(range(20))
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 Wed Dec 17 11:01:40 2008
@@ -471,6 +471,7 @@
if not we_are_translated():
a = stack.pop()
hint(a, promote_class=True)
+ print a.to_string()
elif opcode == DUMP:
if not we_are_translated():
More information about the Pypy-commit
mailing list