[pypy-svn] pypy enable-opts: Progress on fixing tests

fijal commits-noreply at bitbucket.org
Sun Mar 13 19:42:31 CET 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: enable-opts
Changeset: r42566:5f532ba0133f
Date: 2011-03-12 22:40 -0500
http://bitbucket.org/pypy/pypy/changeset/5f532ba0133f/

Log:	Progress on fixing tests

diff --git a/pypy/jit/metainterp/test/test_warmspot.py b/pypy/jit/metainterp/test/test_warmspot.py
--- a/pypy/jit/metainterp/test/test_warmspot.py
+++ b/pypy/jit/metainterp/test/test_warmspot.py
@@ -7,6 +7,7 @@
 from pypy.jit.metainterp.history import BoxInt
 
 from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
+from pypy.jit.metainterp.optimizeopt import ALL_OPTS_NAMES
 
 
 class Exit(Exception):
@@ -81,7 +82,9 @@
         for loc in get_stats().locations:
             assert loc == 'GREEN IS 123.'
 
-    def test_set_param_optimizer(self):
+    def test_set_param_enable_opts(self):
+        from pypy.rpython.annlowlevel import llstr, hlstr
+        
         myjitdriver = JitDriver(greens = [], reds = ['n'])
         class A(object):
             def m(self, n):
@@ -93,45 +96,20 @@
                 myjitdriver.jit_merge_point(n=n)
                 n = A().m(n)
             return n
-        def f(n, optimizer):
-            myjitdriver.set_param('optimizer', optimizer)
+        def f(n, enable_opts):
+            myjitdriver.set_param('enable_opts', hlstr(enable_opts))
             return g(n)
 
         # check that the set_param will override the default
-        res = self.meta_interp(f, [10, OPTIMIZER_SIMPLE],
-                               optimizer=OPTIMIZER_FULL)
+        res = self.meta_interp(f, [10, llstr('')])
         assert res == 0
         self.check_loops(new_with_vtable=1)
 
-        res = self.meta_interp(f, [10, OPTIMIZER_FULL],
-                               optimizer=OPTIMIZER_SIMPLE)
+        res = self.meta_interp(f, [10, llstr(ALL_OPTS_NAMES)],
+                               enable_opts='')
         assert res == 0
         self.check_loops(new_with_vtable=0)
 
-    def test_optimizer_default_choice(self):
-        myjitdriver = JitDriver(greens = [], reds = ['n'])
-        def f(n):
-            while n > 0:
-                myjitdriver.can_enter_jit(n=n)
-                myjitdriver.jit_merge_point(n=n)
-                n -= 1
-            return n
-
-        from pypy.rpython.test.test_llinterp import gengraph
-        t, rtyper, graph = gengraph(f, [int], type_system=self.type_system,
-                                    **{'translation.gc': 'boehm'})
-        
-        from pypy.jit.metainterp.warmspot import WarmRunnerDesc
-
-        warmrunnerdescr = WarmRunnerDesc(t, CPUClass=self.CPUClass,
-                                         optimizer=None) # pick default
-
-        from pypy.jit.metainterp import optimize
-
-        state = warmrunnerdescr.jitdrivers_sd[0].warmstate
-        assert state.optimize_loop is optimize.optimize_loop
-        assert state.optimize_bridge is optimize.optimize_bridge
-
     def test_unwanted_loops(self):
         mydriver = JitDriver(reds = ['n', 'total', 'm'], greens = [])
 

diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py
--- a/pypy/rlib/jit.py
+++ b/pypy/rlib/jit.py
@@ -538,18 +538,24 @@
     def compute_result_annotation(self, s_name, s_value):
         from pypy.annotation import model as annmodel
         assert s_name.is_constant()
-        if annmodel.SomeInteger().contains(s_value):
-            pass
+        if s_name.const == 'enable_opts':
+            assert annmodel.SomeString(can_be_None=True).contains(s_value)
         else:
-            assert annmodel.SomeString().contains(s_value)
+            assert annmodel.SomeInteger().contains(s_value)
         return annmodel.s_None
 
     def specialize_call(self, hop):
         from pypy.rpython.lltypesystem import lltype
+        from pypy.rpython.lltypesystem.rstr import string_repr
+        
         hop.exception_cannot_occur()
         driver = self.instance.im_self
         name = hop.args_s[0].const
-        v_value = hop.inputarg(hop.args_r[1], arg=1)
+        if name == 'enable_opts':
+            repr = string_repr
+        else:
+            repr = lltype.Signed
+        v_value = hop.inputarg(repr, arg=1)
         vlist = [hop.inputconst(lltype.Void, "set_param"),
                  hop.inputconst(lltype.Void, driver),
                  hop.inputconst(lltype.Void, name),

diff --git a/pypy/jit/metainterp/warmstate.py b/pypy/jit/metainterp/warmstate.py
--- a/pypy/jit/metainterp/warmstate.py
+++ b/pypy/jit/metainterp/warmstate.py
@@ -224,9 +224,11 @@
         self.inlining = value
 
     def set_param_enable_opts(self, value):
-        from pypy.jit.metainterp.optimizeopt import ALL_OPTS_DICT
+        from pypy.jit.metainterp.optimizeopt import ALL_OPTS_DICT, ALL_OPTS_NAMES
 
         d = {}
+        if value is None:
+            value = ALL_OPTS_NAMES
         for name in value.split(":"):
             if name:
                 if name not in ALL_OPTS_DICT:

diff --git a/pypy/jit/metainterp/test/test_ztranslation.py b/pypy/jit/metainterp/test/test_ztranslation.py
--- a/pypy/jit/metainterp/test/test_ztranslation.py
+++ b/pypy/jit/metainterp/test/test_ztranslation.py
@@ -89,7 +89,6 @@
         res = rpython_ll_meta_interp(main, [40, 5],
                                      CPUClass=self.CPUClass,
                                      type_system=self.type_system,
-                                     optimizer=OPTIMIZER_FULL,
                                      ProfilerClass=Profiler)
         assert res == main(40, 5)
 


More information about the Pypy-commit mailing list