[pypy-svn] pypy out-of-line-guards: Move out of line tests out of test_basic

fijal commits-noreply at bitbucket.org
Tue Dec 21 13:24:16 CET 2010


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: out-of-line-guards
Changeset: r40159:a3422281e05e
Date: 2010-12-21 12:59 +0200
http://bitbucket.org/pypy/pypy/changeset/a3422281e05e/

Log:	Move out of line tests out of test_basic

diff --git a/pypy/jit/metainterp/test/test_basic.py b/pypy/jit/metainterp/test/test_basic.py
--- a/pypy/jit/metainterp/test/test_basic.py
+++ b/pypy/jit/metainterp/test/test_basic.py
@@ -120,7 +120,7 @@
         raise Exception("FAILED")
 
 
-class JitMixin:
+class JitMixin(object):
     basic = True
     def check_loops(self, expected=None, everywhere=False, **check):
         get_stats().check_loops(expected=expected, everywhere=everywhere,
@@ -235,7 +235,7 @@
         return NODE
 
 
-class BasicTests:    
+class BasicTests(object):    
 
     def test_basic(self):
         def f(x, y):
@@ -721,116 +721,6 @@
         assert res == 210
         self.check_operations_history(getfield_gc=0)
 
-    def test_getfield_jit_invariant(self):
-        class A(object):
-            _jit_invariant_fields_ = ['x']
-
-        a1 = A()
-        a1.x = 5
-        a2 = A()
-        a2.x = 8
-
-        def f(x):
-            if x:
-                a = a1
-            else:
-                a = a2
-            return a.x
-        res = self.interp_operations(f, [-3])
-        self.check_operations_history(getfield_gc = 0)
-
-    def test_setfield_jit_invariant(self):
-        class A(object):
-            _jit_invariant_fields_ = ['x']
-
-        myjitdriver = JitDriver(greens = [], reds = ['i', 'total'])
-        
-        a = A()
-
-        @dont_look_inside
-        def g(i):
-            if i == 5:
-                a.x = 2
-
-        def f():
-            a.x = 1
-            i = 0
-            total = 0
-            while i < 20:
-                myjitdriver.can_enter_jit(i=i, total=total)
-                myjitdriver.jit_merge_point(i=i, total=total)
-                g(i)
-                i += a.x
-                total += i
-            return total
-
-        assert self.meta_interp(f, []) == f()
-        self.check_loop_count(2)
-        self.check_history(getfield_gc=0, getfield_gc_pure=0)
-
-    def test_jit_invariant_bridge(self):
-        class A(object):
-            _jit_invariant_fields_ = ['x']
-
-        myjitdriver = JitDriver(greens = [], reds = ['i', 'total'])
-        
-        a = A()
-
-        @dont_look_inside
-        def g(i):
-            if i == 5:
-                a.x = 2
-
-        def f():
-            a.x = 1
-            i = 0
-            total = 0
-            while i < 40:
-                myjitdriver.can_enter_jit(i=i, total=total)
-                myjitdriver.jit_merge_point(i=i, total=total)
-                g(i)
-                i += a.x
-                if i > 18:
-                    i += 1
-                total += i
-            return total
-
-        assert self.meta_interp(f, []) == f()
-        self.check_loop_count(3)
-        self.check_history(getfield_gc=0, getfield_gc_pure=0)        
-
-    def test_jit_invariant_entry_bridge(self):
-        class A(object):
-            _jit_invariant_fields_ = ['x']
-
-        myjitdriver = JitDriver(greens = [], reds = ['i', 'total', 'a'])
-        
-        def f(a):
-            i = 0
-            total = 0
-            while i < 30:
-                myjitdriver.can_enter_jit(i=i, total=total, a=a)
-                myjitdriver.jit_merge_point(i=i, total=total, a=a)
-                a = hint(a, promote=True)
-                total += a.x
-                if i > 11:
-                    i += 1
-                i += 1
-            return total
-
-        def main():
-            total = 0
-            a = A()
-            a.x = 1
-            total += f(a)
-            a.x = 2
-            total += f(a)
-            return total
-
-        assert self.meta_interp(main, []) == main()
-        self.check_loop_count(4)
-        self.check_history(getfield_gc=0, getfield_gc_pure=0)        
-
     def test_setfield_bool(self):
         class A:
             def __init__(self):

diff --git a/pypy/jit/metainterp/test_outofline.py b/pypy/jit/metainterp/test_outofline.py
new file mode 100644
--- /dev/null
+++ b/pypy/jit/metainterp/test_outofline.py
@@ -0,0 +1,117 @@
+
+from pypy.rlib.jit import JitDriver, dont_look_inside, hint
+from pypy.jit.metainterp.test.test_basic import LLJitMixin
+
+class OutOfLineTests(object):
+    def test_getfield_jit_invariant(self):
+        class A(object):
+            _jit_invariant_fields_ = ['x']
+
+        a1 = A()
+        a1.x = 5
+        a2 = A()
+        a2.x = 8
+
+        def f(x):
+            if x:
+                a = a1
+            else:
+                a = a2
+            return a.x
+        res = self.interp_operations(f, [-3])
+        self.check_operations_history(getfield_gc = 0)
+
+    def test_setfield_jit_invariant(self):
+        class A(object):
+            _jit_invariant_fields_ = ['x']
+
+        myjitdriver = JitDriver(greens = [], reds = ['i', 'total'])
+        
+        a = A()
+
+        @dont_look_inside
+        def g(i):
+            if i == 5:
+                a.x = 2
+
+        def f():
+            a.x = 1
+            i = 0
+            total = 0
+            while i < 20:
+                myjitdriver.can_enter_jit(i=i, total=total)
+                myjitdriver.jit_merge_point(i=i, total=total)
+                g(i)
+                i += a.x
+                total += i
+            return total
+
+        assert self.meta_interp(f, []) == f()
+        self.check_loop_count(2)
+        self.check_history(getfield_gc=0, getfield_gc_pure=0)
+
+    def test_jit_invariant_bridge(self):
+        class A(object):
+            _jit_invariant_fields_ = ['x']
+
+        myjitdriver = JitDriver(greens = [], reds = ['i', 'total'])
+        
+        a = A()
+
+        @dont_look_inside
+        def g(i):
+            if i == 5:
+                a.x = 2
+
+        def f():
+            a.x = 1
+            i = 0
+            total = 0
+            while i < 40:
+                myjitdriver.can_enter_jit(i=i, total=total)
+                myjitdriver.jit_merge_point(i=i, total=total)
+                g(i)
+                i += a.x
+                if i > 18:
+                    i += 1
+                total += i
+            return total
+
+        assert self.meta_interp(f, []) == f()
+        self.check_loop_count(3)
+        self.check_history(getfield_gc=0, getfield_gc_pure=0)        
+
+    def test_jit_invariant_entry_bridge(self):
+        class A(object):
+            _jit_invariant_fields_ = ['x']
+
+        myjitdriver = JitDriver(greens = [], reds = ['i', 'total', 'a'])
+        
+        def f(a):
+            i = 0
+            total = 0
+            while i < 30:
+                myjitdriver.can_enter_jit(i=i, total=total, a=a)
+                myjitdriver.jit_merge_point(i=i, total=total, a=a)
+                a = hint(a, promote=True)
+                total += a.x
+                if i > 11:
+                    i += 1
+                i += 1
+            return total
+
+        def main():
+            total = 0
+            a = A()
+            a.x = 1
+            total += f(a)
+            a.x = 2
+            total += f(a)
+            return total
+
+        assert self.meta_interp(main, []) == main()
+        self.check_loop_count(4)
+        self.check_history(getfield_gc=0, getfield_gc_pure=0)        
+
+class TestLLtype(OutOfLineTests, LLJitMixin):
+    pass


More information about the Pypy-commit mailing list