[pypy-commit] pypy default: test that it is possible disable each of the optimization steps

hakanardo noreply at buildbot.pypy.org
Tue May 1 11:27:30 CEST 2012


Author: Hakan Ardo <hakan at debian.org>
Branch: 
Changeset: r54838:0778ff2df9df
Date: 2012-05-01 10:53 +0200
http://bitbucket.org/pypy/pypy/changeset/0778ff2df9df/

Log:	test that it is possible disable each of the optimization steps

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_disable_optimizations.py b/pypy/jit/metainterp/optimizeopt/test/test_disable_optimizations.py
new file mode 100644
--- /dev/null
+++ b/pypy/jit/metainterp/optimizeopt/test/test_disable_optimizations.py
@@ -0,0 +1,46 @@
+from pypy.jit.metainterp.optimizeopt.test.test_optimizeopt import OptimizeOptTest
+from pypy.jit.metainterp.optimizeopt.test.test_util import LLtypeMixin
+from pypy.jit.metainterp.resoperation import rop
+
+
+allopts = OptimizeOptTest.enable_opts.split(':')
+for optnum in range(len(allopts)):
+    myopts = allopts[:]
+    del myopts[optnum]
+
+    class TestLLtype(OptimizeOptTest, LLtypeMixin):
+        enable_opts = ':'.join(myopts)
+
+        def optimize_loop(self, ops, expected, expected_preamble=None,
+                          call_pure_results=None, expected_short=None):
+            loop = self.parse(ops)
+            if expected != "crash!":
+                expected = self.parse(expected)
+            if expected_preamble:
+                expected_preamble = self.parse(expected_preamble)
+            if expected_short:
+                expected_short = self.parse(expected_short)
+
+            preamble = self.unroll_and_optimize(loop, call_pure_results)
+
+            for op in preamble.operations + loop.operations:
+                assert op.getopnum() not in (rop.CALL_PURE,
+                                             rop.CALL_LOOPINVARIANT,
+                                             rop.VIRTUAL_REF_FINISH,
+                                             rop.VIRTUAL_REF,
+                                             rop.QUASIIMMUT_FIELD,
+                                             rop.MARK_OPAQUE_PTR,
+                                             rop.RECORD_KNOWN_CLASS)
+
+        def raises(self, e, fn, *args):
+            try:
+                fn(*args)
+            except e:
+                pass
+
+    opt = allopts[optnum]
+    exec "TestNo%sLLtype = TestLLtype" % (opt[0].upper() + opt[1:])
+
+del TestLLtype
+del TestNoUnrollLLtype
+        
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -105,6 +105,9 @@
 
         return loop
 
+    def raises(self, e, fn, *args):
+        py.test.raises(e, fn, *args)
+
 class OptimizeOptTest(BaseTestWithUnroll):
 
     def setup_method(self, meth=None):
@@ -2639,7 +2642,7 @@
         p2 = new_with_vtable(ConstClass(node_vtable))
         jump(p2)
         """
-        py.test.raises(InvalidLoop, self.optimize_loop,
+        self.raises(InvalidLoop, self.optimize_loop,
                        ops, ops)
 
     def test_invalid_loop_2(self):
@@ -2651,7 +2654,7 @@
         escape(p2)      # prevent it from staying Virtual
         jump(p2)
         """
-        py.test.raises(InvalidLoop, self.optimize_loop,
+        self.raises(InvalidLoop, self.optimize_loop,
                        ops, ops)
 
     def test_invalid_loop_3(self):
@@ -2665,7 +2668,7 @@
         setfield_gc(p3, p4, descr=nextdescr)
         jump(p3)
         """
-        py.test.raises(InvalidLoop, self.optimize_loop, ops, ops)
+        self.raises(InvalidLoop, self.optimize_loop, ops, ops)
 
 
     def test_merge_guard_class_guard_value(self):
@@ -4411,7 +4414,7 @@
         setfield_gc(p1, p3, descr=nextdescr)
         jump(p3)
         """
-        py.test.raises(BogusPureField, self.optimize_loop, ops, "crash!")
+        self.raises(BogusPureField, self.optimize_loop, ops, "crash!")
 
     def test_dont_complains_different_field(self):
         ops = """
@@ -5024,7 +5027,7 @@
         i2 = int_add(i0, 3)
         jump(i2)
         """
-        py.test.raises(InvalidLoop, self.optimize_loop, ops, ops)
+        self.raises(InvalidLoop, self.optimize_loop, ops, ops)
 
     def test_bound_ne_const_not(self):
         ops = """
@@ -5074,7 +5077,7 @@
         i3 = int_add(i0, 3)
         jump(i3)
         """
-        py.test.raises(InvalidLoop, self.optimize_loop, ops, ops)
+        self.raises(InvalidLoop, self.optimize_loop, ops, ops)
 
     def test_bound_lshift(self):
         ops = """


More information about the pypy-commit mailing list