[pypy-svn] pypy jit-unroll-loops: Restored what (I think) is the original meaning of these tests: checking

arigo commits-noreply at bitbucket.org
Mon Jan 3 18:36:48 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: jit-unroll-loops
Changeset: r40343:15e7b6609970
Date: 2011-01-03 18:34 +0100
http://bitbucket.org/pypy/pypy/changeset/15e7b6609970/

Log:	Restored what (I think) is the original meaning of these tests:
	checking that we needed a two-levels blackhole interpreter.

diff --git a/pypy/jit/metainterp/test/test_blackhole.py b/pypy/jit/metainterp/test/test_blackhole.py
--- a/pypy/jit/metainterp/test/test_blackhole.py
+++ b/pypy/jit/metainterp/test/test_blackhole.py
@@ -156,23 +156,21 @@
         builder.release_interp(interp1)
         interp3 = builder.acquire_interp()
         assert builder.num_interpreters == 2
-        
-    def test_blackholeinterp_cache(self):
+
+    def test_blackholeinterp_cache_normal(self):
         myjitdriver = JitDriver(greens = [], reds = ['x', 'y'])
         def choices(x):
-            if x == 2: return 10
-            if x == 3: return 199
-            if x == 4: return 124
-            if x == 5: return -521
-            if x == 6: return 8917
-            if x == 7: return -387
+            if x == 0:
+                return 0
             return 34871
         def f(x):
             y = 0
-            while x > 0:
+            cont = 1
+            while cont:
                 myjitdriver.can_enter_jit(x=x, y=y)
                 myjitdriver.jit_merge_point(x=x, y=y)
-                y += choices(x)
+                cont = choices(x)
+                y += cont
                 x -= 1
             return y
         #
@@ -189,8 +187,8 @@
         #
         assert res == sum([choices(x) for x in range(1, 8)])
         builder = pyjitpl._warmrunnerdesc.metainterp_sd.blackholeinterpbuilder
-        assert builder.num_interpreters == 1
-        assert len(seen) == 1 * 3
+        assert builder.num_interpreters == 2
+        assert len(seen) == 2 * 3
 
     def test_blackholeinterp_cache_exc(self):
         myjitdriver = JitDriver(greens = [], reds = ['x', 'y'])
@@ -198,21 +196,19 @@
             def __init__(self, num):
                 self.num = num
         def choices(x):
-            if x == 2: raise FooError(10)
-            if x == 3: raise FooError(199)
-            if x == 4: raise FooError(124)
-            if x == 5: raise FooError(-521)
-            if x == 6: raise FooError(8917)
-            if x == 7: raise FooError(-387)
+            if x == 0:
+                raise FooError(0)
             raise FooError(34871)
         def f(x):
             y = 0
-            while x > 0:
+            while True:
                 myjitdriver.can_enter_jit(x=x, y=y)
                 myjitdriver.jit_merge_point(x=x, y=y)
                 try:
                     choices(x)
                 except FooError, e:
+                    if e.num == 0:
+                        break
                     y += e.num
                 x -= 1
             return y
@@ -220,4 +216,4 @@
         assert res == sum([py.test.raises(FooError, choices, x).value.num
                            for x in range(1, 8)])
         builder = pyjitpl._warmrunnerdesc.metainterp_sd.blackholeinterpbuilder
-        assert builder.num_interpreters == 1
+        assert builder.num_interpreters == 2


More information about the Pypy-commit mailing list