[pypy-svn] r78187 - pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test

hakanardo at codespeak.net hakanardo at codespeak.net
Thu Oct 21 21:31:19 CEST 2010


Author: hakanardo
Date: Thu Oct 21 21:31:17 2010
New Revision: 78187

Modified:
   pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_basic.py
   pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_compile.py
   pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_exception.py
   pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_jitdriver.py
Log:
Some tests ajusted to reflect the new optimization

Modified: pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_basic.py	Thu Oct 21 21:31:17 2010
@@ -1453,7 +1453,8 @@
             return x
         res = self.meta_interp(f, [299], listops=True)
         assert res == f(299)
-        self.check_loops(guard_class=0, guard_value=3)
+        self.check_loops(guard_class=0, guard_value=1)        
+        self.check_loops(guard_class=0, guard_value=4, everywhere=True)
 
     def test_merge_guardnonnull_guardclass(self):
         from pypy.rlib.objectmodel import instantiate
@@ -1482,7 +1483,10 @@
         res = self.meta_interp(f, [299], listops=True)
         assert res == f(299)
         self.check_loops(guard_class=0, guard_nonnull=0,
-                         guard_nonnull_class=2, guard_isnull=1)
+                         guard_nonnull_class=1, guard_isnull=0)
+        self.check_loops(guard_class=0, guard_nonnull=0,
+                         guard_nonnull_class=3, guard_isnull=1,
+                         everywhere=True)
 
     def test_merge_guardnonnull_guardvalue(self):
         from pypy.rlib.objectmodel import instantiate
@@ -1509,8 +1513,11 @@
             return x
         res = self.meta_interp(f, [299], listops=True)
         assert res == f(299)
-        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=2,
-                         guard_nonnull_class=0, guard_isnull=1)
+        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=1,
+                         guard_nonnull_class=0, guard_isnull=0)
+        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=3,
+                         guard_nonnull_class=0, guard_isnull=1,
+                         everywhere=True)
 
     def test_merge_guardnonnull_guardvalue_2(self):
         from pypy.rlib.objectmodel import instantiate
@@ -1537,8 +1544,11 @@
             return x
         res = self.meta_interp(f, [299], listops=True)
         assert res == f(299)
-        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=2,
-                         guard_nonnull_class=0, guard_isnull=1)
+        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=1,
+                         guard_nonnull_class=0, guard_isnull=0)
+        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=3,
+                         guard_nonnull_class=0, guard_isnull=1,
+                         everywhere=True)
 
     def test_merge_guardnonnull_guardclass_guardvalue(self):
         from pypy.rlib.objectmodel import instantiate
@@ -1568,8 +1578,11 @@
             return x
         res = self.meta_interp(f, [399], listops=True)
         assert res == f(399)
-        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=3,
-                         guard_nonnull_class=0, guard_isnull=1)
+        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=1,
+                         guard_nonnull_class=0, guard_isnull=0)
+        self.check_loops(guard_class=0, guard_nonnull=0, guard_value=4,
+                         guard_nonnull_class=0, guard_isnull=1,
+                         everywhere=True)
 
     def test_residual_call_doesnt_lose_info(self):
         myjitdriver = JitDriver(greens = [], reds = ['x', 'y', 'l'])
@@ -1595,7 +1608,8 @@
                 y.v = g(y.v) - y.v/y.v + lc/l[0] - 1
             return y.v
         res = self.meta_interp(f, [20], listops=True)
-        self.check_loops(getfield_gc=1, getarrayitem_gc=0)
+        self.check_loops(getfield_gc=0, getarrayitem_gc=0)
+        self.check_loops(getfield_gc=1, getarrayitem_gc=0, everywhere=True)
 
     def test_guard_isnull_nonnull(self):
         myjitdriver = JitDriver(greens = [], reds = ['x', 'res'])
@@ -1625,7 +1639,7 @@
         assert res == 42
         self.check_loops(guard_nonnull=1, guard_isnull=1)
 
-    def test_loop_invariant(self):
+    def test_loop_invariant1(self):
         myjitdriver = JitDriver(greens = [], reds = ['x', 'res'])
         class A(object):
             pass
@@ -1650,7 +1664,8 @@
             return res
         res = self.meta_interp(g, [21])
         assert res == 3 * 21
-        self.check_loops(call=1)
+        self.check_loops(call=0)
+        self.check_loops(call=1, everywhere=True)
 
     def test_bug_optimizeopt_mutates_ops(self):
         myjitdriver = JitDriver(greens = [], reds = ['x', 'res', 'const', 'a'])

Modified: pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_compile.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_compile.py	(original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_compile.py	Thu Oct 21 21:31:17 2010
@@ -5,7 +5,7 @@
 from pypy.jit.metainterp.compile import ResumeGuardDescr
 from pypy.jit.metainterp.compile import ResumeGuardCountersInt
 from pypy.jit.metainterp.compile import compile_tmp_callback
-from pypy.jit.metainterp import optimize, jitprof, typesystem, compile
+from pypy.jit.metainterp import optimize_nopspec, jitprof, typesystem, compile
 from pypy.jit.metainterp.test.oparser import parse
 from pypy.jit.metainterp.test.test_optimizefindnode import LLtypeMixin
 
@@ -41,9 +41,12 @@
         pass
 
 class FakeState:
-    optimize_loop = staticmethod(optimize.optimize_loop)
+    optimize_loop = staticmethod(optimize_nopspec.optimize_loop)
     debug_level = 0
 
+    def attach_unoptimized_bridge_from_interp(*args):
+        pass
+
 class FakeGlobalData:
     loopnumbering = 0
 
@@ -87,11 +90,11 @@
     loop_tokens = []
     loop_token = compile_new_loop(metainterp, loop_tokens, [], 0)
     assert loop_tokens == [loop_token]
-    assert loop_token.number == 1
-    assert staticdata.globaldata.loopnumbering == 2
+    assert loop_token.number == 2
+    assert staticdata.globaldata.loopnumbering == 3
     #
-    assert len(cpu.seen) == 1
-    assert cpu.seen[0][2] == loop_token
+    assert len(cpu.seen) == 2
+    assert cpu.seen[1][2] == loop_token
     #
     del cpu.seen[:]
     metainterp = FakeMetaInterp()
@@ -105,7 +108,7 @@
     assert loop_token_2 is loop_token
     assert loop_tokens == [loop_token]
     assert len(cpu.seen) == 0
-    assert staticdata.globaldata.loopnumbering == 2    
+    assert staticdata.globaldata.loopnumbering == 3
 
 
 def test_resume_guard_counters():

Modified: pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_exception.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_exception.py	(original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_exception.py	Thu Oct 21 21:31:17 2010
@@ -516,10 +516,9 @@
         assert res == -1
         self.check_tree_loop_count(2)      # the loop and the entry path
         # we get:
-        #    ENTER    - compile the new loop
-        #    ENTER    - compile the entry bridge
+        #    ENTER    - compile the new loop and the entry bridge
         #    ENTER    - compile the leaving path (raising MyError)
-        self.check_enter_count(3)
+        self.check_enter_count(2)
 
 
     def test_bridge_from_interpreter_exc_2(self):

Modified: pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_jitdriver.py
==============================================================================
--- pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_jitdriver.py	(original)
+++ pypy/branch/jit-unroll-loops/pypy/jit/metainterp/test/test_jitdriver.py	Thu Oct 21 21:31:17 2010
@@ -42,7 +42,7 @@
         # at the generated machine code
         self.check_loop_count(5)
         self.check_tree_loop_count(4)    # 2 x loop, 2 x enter bridge
-        self.check_enter_count(7)
+        self.check_enter_count(5)
 
     def test_inline(self):
         # this is not an example of reasonable code: loop1() is unrolled



More information about the Pypy-commit mailing list