[pypy-commit] pypy default: Rework a bit the "--help" format, and split the JIT-related help

arigo noreply at buildbot.pypy.org
Fri Mar 2 21:24:45 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r53124:935c947b80cf
Date: 2012-03-02 20:14 +0100
http://bitbucket.org/pypy/pypy/changeset/935c947b80cf/

Log:	Rework a bit the "--help" format, and split the JIT-related help in
	its own subpage obtained from "--jit help".

diff --git a/pypy/jit/metainterp/optimizeopt/__init__.py b/pypy/jit/metainterp/optimizeopt/__init__.py
--- a/pypy/jit/metainterp/optimizeopt/__init__.py
+++ b/pypy/jit/metainterp/optimizeopt/__init__.py
@@ -9,7 +9,7 @@
 from pypy.jit.metainterp.optimizeopt.simplify import OptSimplify
 from pypy.jit.metainterp.optimizeopt.pure import OptPure
 from pypy.jit.metainterp.optimizeopt.earlyforce import OptEarlyForce
-from pypy.rlib.jit import PARAMETERS
+from pypy.rlib.jit import PARAMETERS, ENABLE_ALL_OPTS
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.rlib.debug import debug_start, debug_stop, debug_print
 
@@ -30,6 +30,9 @@
 ALL_OPTS_LIST = [name for name, _ in ALL_OPTS]
 ALL_OPTS_NAMES = ':'.join([name for name, _ in ALL_OPTS])
 
+assert ENABLE_ALL_OPTS == ALL_OPTS_NAMES, (
+    'please fix rlib/jit.py to say ENABLE_ALL_OPTS = %r' % (ALL_OPTS_NAMES,))
+
 def build_opt_chain(metainterp_sd, enable_opts):
     config = metainterp_sd.config
     optimizations = []
diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py
--- a/pypy/rlib/jit.py
+++ b/pypy/rlib/jit.py
@@ -392,6 +392,9 @@
 class JitHintError(Exception):
     """Inconsistency in the JIT hints."""
 
+ENABLE_ALL_OPTS = (
+    'intbounds:rewrite:virtualize:string:earlyforce:pure:heap:ffi:unroll')
+
 PARAMETER_DOCS = {
     'threshold': 'number of times a loop has to run for it to become hot',
     'function_threshold': 'number of times a function must run for it to become traced from start',
@@ -402,7 +405,8 @@
     'retrace_limit': 'how many times we can try retracing before giving up',
     'max_retrace_guards': 'number of extra guards a retrace can cause',
     'max_unroll_loops': 'number of extra unrollings a loop can cause',
-    'enable_opts': 'optimizations to enable or all, INTERNAL USE ONLY'
+    'enable_opts': 'INTERNAL USE ONLY: optimizations to enable, or all = %s' %
+                       ENABLE_ALL_OPTS,
     }
 
 PARAMETERS = {'threshold': 1039, # just above 1024, prime
diff --git a/pypy/translator/goal/app_main.py b/pypy/translator/goal/app_main.py
--- a/pypy/translator/goal/app_main.py
+++ b/pypy/translator/goal/app_main.py
@@ -130,30 +130,46 @@
         sys.executable,)
     print __doc__.rstrip()
     if 'pypyjit' in sys.builtin_module_names:
-        _print_jit_help()
+        print "  --jit OPTIONS  advanced JIT options: try 'off' or 'help'"
     print
     raise SystemExit
 
 def _print_jit_help():
-    import pypyjit
+    try:
+        import pypyjit
+    except ImportError:
+        print >> sys.stderr, "No jit support in %s" % (sys.executable,)
+        return
     items = pypyjit.defaults.items()
     items.sort()
+    print 'Advanced JIT options: a comma-separated list of OPTION=VALUE:'
     for key, value in items:
-        prefix = '  --jit %s=N %s' % (key, ' '*(18-len(key)))
+        print
+        print ' %s=N' % (key,)
         doc = '%s (default %s)' % (pypyjit.PARAMETER_DOCS[key], value)
-        while len(doc) > 51:
-            i = doc[:51].rfind(' ')
-            print prefix + doc[:i]
+        while len(doc) > 72:
+            i = doc[:74].rfind(' ')
+            if i < 0:
+                i = doc.find(' ')
+                if i < 0:
+                    i = len(doc)
+            print '    ' + doc[:i]
             doc = doc[i+1:]
-            prefix = ' '*len(prefix)
-        print prefix + doc
-    print '  --jit off                  turn off the JIT'
+        print '    ' + doc
+    print
+    print ' off'
+    print '    turn off the JIT'
+    print ' help'
+    print '    print this page'
 
 def print_version(*args):
     print >> sys.stderr, "Python", sys.version
     raise SystemExit
 
 def set_jit_option(options, jitparam, *args):
+    if jitparam == 'help':
+        _print_jit_help()
+        raise SystemExit
     if 'pypyjit' not in sys.builtin_module_names:
         print >> sys.stderr, ("Warning: No jit support in %s" %
                               (sys.executable,))


More information about the pypy-commit mailing list