[pypy-svn] r60533 - in pypy/branch/oo-jit/pypy/jit/tl: . test

antocuni at codespeak.net antocuni at codespeak.net
Wed Dec 17 11:47:39 CET 2008


Author: antocuni
Date: Wed Dec 17 11:47:38 2008
New Revision: 60533

Modified:
   pypy/branch/oo-jit/pypy/jit/tl/accumulator.tlc
   pypy/branch/oo-jit/pypy/jit/tl/accumulator.tlc.src
   pypy/branch/oo-jit/pypy/jit/tl/test/test_tlc.py
Log:
add another "class" to the benchmark, thanks cfbolz for the suggestion



Modified: pypy/branch/oo-jit/pypy/jit/tl/accumulator.tlc
==============================================================================
Binary files. No diff available.

Modified: pypy/branch/oo-jit/pypy/jit/tl/accumulator.tlc.src
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/tl/accumulator.tlc.src	(original)
+++ pypy/branch/oo-jit/pypy/jit/tl/accumulator.tlc.src	Wed Dec 17 11:47:38 2008
@@ -1,9 +1,27 @@
 main:
-    NEW value,add=add
+    PUSHARG
+    PUSH 0              # [n, 0]
+    LT
+    BR_COND negative
+
+positive:
+
+    NEW value,accumulate=add
     PICK 0
     PUSH 0
     SETATTR value
     PUSHARG             # [obj, n]
+    PUSH 1
+    BR_COND loop
+
+negative:
+    NEW value,accumulate=count
+    PICK 0
+    PUSH 0
+    SETATTR value       # [obj]
+    PUSH 0              # [obj, 0]
+    PUSHARG             # [obj, 0, n]
+    SUB                 # [obj, -n]
 
 loop:                   # [obj, n]
     PICK 0              # [obj, n, n]
@@ -19,7 +37,7 @@
     SUB                 # [obj, n-1]
     PICK 1              # [obj, n-1, obj]
     PICK 1              # [obj, n-1, obj, n-1]
-    SEND add/1          # [obj, n-1]
+    SEND accumulate/1   # [obj, n-1]
     PUSH 1
     BR_COND loop
 
@@ -31,3 +49,12 @@
     ADD                 # [self, self.value+x]
     SETATTR value       # []
     RETURN
+
+count: # (x)
+    PUSHARG             # [self]
+    PUSHARG             # [self, self]
+    GETATTR value       # [self, self.value]
+    PUSH 1
+    ADD                 # [self, self.value+1]
+    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:47:38 2008
@@ -289,6 +289,10 @@
 
     def test_accumulator(self):
         acc = self.compile('../../accumulator.tlc.src')
+        assert acc(0) == 0
         assert acc(1) == 0
         assert acc(10) == sum(range(10))
         assert acc(20) == sum(range(20))
+        assert acc(-1) == 1
+        assert acc(-2) == 2
+        assert acc(-10) == 10



More information about the Pypy-commit mailing list