[pypy-svn] r77498 - in pypy/branch/jit-str-fix/pypy: jit/metainterp jit/tl translator translator/goal

arigo at codespeak.net arigo at codespeak.net
Thu Sep 30 17:05:07 CEST 2010


Author: arigo
Date: Thu Sep 30 17:05:05 2010
New Revision: 77498

Added:
   pypy/branch/jit-str-fix/pypy/jit/tl/jittest.py
Modified:
   pypy/branch/jit-str-fix/pypy/jit/metainterp/warmspot.py
   pypy/branch/jit-str-fix/pypy/translator/driver.py
   pypy/branch/jit-str-fix/pypy/translator/goal/translate.py
Log:
Add the target --jittest to translate.py.  Works like pypyjit.py,
but for any jit target.


Modified: pypy/branch/jit-str-fix/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/jit-str-fix/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/branch/jit-str-fix/pypy/jit/metainterp/warmspot.py	Thu Sep 30 17:05:05 2010
@@ -67,9 +67,16 @@
 def jittify_and_run(interp, graph, args, repeat=1,
                     backendopt=False, trace_limit=sys.maxint,
                     debug_level=DEBUG_STEPS, inline=False, **kwds):
+    from pypy.config.config import ConfigError
     translator = interp.typer.annotator.translator
-    translator.config.translation.gc = "boehm"
-    translator.config.translation.list_comprehension_operations = True
+    try:
+        translator.config.translation.gc = "boehm"
+    except ConfigError:
+        pass
+    try:
+        translator.config.translation.list_comprehension_operations = True
+    except ConfigError:
+        pass
     warmrunnerdesc = WarmRunnerDesc(translator, backendopt=backendopt, **kwds)
     for jd in warmrunnerdesc.jitdrivers_sd:
         jd.warmstate.set_param_threshold(3)          # for tests

Added: pypy/branch/jit-str-fix/pypy/jit/tl/jittest.py
==============================================================================
--- (empty file)
+++ pypy/branch/jit-str-fix/pypy/jit/tl/jittest.py	Thu Sep 30 17:05:05 2010
@@ -0,0 +1,43 @@
+"""
+This file is imported by pypy.translation.driver when running the
+target --jittest.  Feel free to hack it as needed; it is imported
+only after the '---> Checkpoint' fork.
+"""
+
+from pypy.conftest import option
+from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.llinterp import LLInterpreter
+from pypy.rpython.annlowlevel import llstr
+from pypy.jit.metainterp import warmspot
+from pypy.rlib.jit import OPTIMIZER_FULL
+
+
+ARGS = ["jittest", "10000"]
+
+
+def jittest(driver):
+    graph = driver.translator.graphs[0]
+    interp = LLInterpreter(driver.translator.rtyper, malloc_check=False)
+
+    def returns_null(T, *args, **kwds):
+        return lltype.nullptr(T)
+    interp.heap.malloc_nonmovable = returns_null     # XXX
+
+    get_policy = driver.extra['jitpolicy']
+    jitpolicy = get_policy(driver)
+
+    from pypy.jit.backend.llgraph.runner import LLtypeCPU
+    apply_jit(jitpolicy, interp, graph, LLtypeCPU)
+
+
+def apply_jit(policy, interp, graph, CPUClass):
+    print 'warmspot.jittify_and_run() started...'
+    option.view = True
+    LIST = graph.getargs()[0].concretetype
+    lst = LIST.TO.ll_newlist(len(ARGS))
+    for i, arg in enumerate(ARGS):
+        lst.ll_setitem_fast(i, llstr(arg))
+    warmspot.jittify_and_run(interp, graph, [lst], policy=policy,
+                             listops=True, CPUClass=CPUClass,
+                             backendopt=True, inline=True,
+                             optimizer=OPTIMIZER_FULL)

Modified: pypy/branch/jit-str-fix/pypy/translator/driver.py
==============================================================================
--- pypy/branch/jit-str-fix/pypy/translator/driver.py	(original)
+++ pypy/branch/jit-str-fix/pypy/translator/driver.py	Thu Sep 30 17:05:05 2010
@@ -426,6 +426,22 @@
                                   [OOTYPE],
                                   "JIT compiler generation")
 
+    def task_jittest_lltype(self):
+        """ Run with the JIT on top of the llgraph backend
+        """
+        # parent process loop: spawn a child, wait for the child to finish,
+        # print a message, and restart
+        from pypy.translator.goal import unixcheckpoint
+        unixcheckpoint.restartable_point(auto='run')
+        # load the module pypy/jit/tl/jittest.py, which you can hack at
+        # and restart without needing to restart the whole translation process
+        from pypy.jit.tl import jittest
+        jittest.jittest(self)
+    #
+    task_jittest_lltype = taskdef(task_jittest_lltype,
+                                  [RTYPE],
+                                  "test of the JIT on the llgraph backend")
+
     def task_backendopt_lltype(self):
         """ Run all backend optimizations - lltype version
         """
@@ -433,7 +449,8 @@
         backend_optimizations(self.translator)
     #
     task_backendopt_lltype = taskdef(task_backendopt_lltype,
-                                     [RTYPE, '??pyjitpl_lltype'],
+                                     [RTYPE, '??pyjitpl_lltype',
+                                             '??jittest_lltype'],
                                      "lltype back-end optimisations")
     BACKENDOPT = 'backendopt_lltype'
 

Modified: pypy/branch/jit-str-fix/pypy/translator/goal/translate.py
==============================================================================
--- pypy/branch/jit-str-fix/pypy/translator/goal/translate.py	(original)
+++ pypy/branch/jit-str-fix/pypy/translator/goal/translate.py	Thu Sep 30 17:05:05 2010
@@ -27,6 +27,7 @@
         ("annotate", "do type inference", "-a --annotate", ""),
         ("rtype", "do rtyping", "-t --rtype", ""),
         ("pyjitpl", "JIT generation step", "--pyjitpl", ""),
+        ("jittest", "JIT test with llgraph backend", "--jittest", ""),
         ("backendopt", "do backend optimizations", "--backendopt", ""),
         ("source", "create source", "-s --source", ""),
         ("compile", "compile", "-c --compile", " (default goal)"),



More information about the Pypy-commit mailing list