[pypy-svn] r70990 - in pypy/branch/multijit/pypy/jit: backend/llgraph metainterp metainterp/test

arigo at codespeak.net arigo at codespeak.net
Sat Jan 30 17:54:43 CET 2010


Author: arigo
Date: Sat Jan 30 17:54:42 2010
New Revision: 70990

Modified:
   pypy/branch/multijit/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/multijit/pypy/jit/backend/llgraph/runner.py
   pypy/branch/multijit/pypy/jit/metainterp/test/test_ztranslation.py
   pypy/branch/multijit/pypy/jit/metainterp/warmspot.py
Log:
- port r70989 from trunk.
- fix test_ztranslation to test two JITs.  (not working yet)


Modified: pypy/branch/multijit/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/multijit/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/multijit/pypy/jit/backend/llgraph/llimpl.py	Sat Jan 30 17:54:42 2010
@@ -20,7 +20,7 @@
 from pypy.jit.metainterp.resoperation import rop
 from pypy.jit.backend.llgraph import symbolic
 
-from pypy.rlib.objectmodel import ComputedIntSymbolic
+from pypy.rlib.objectmodel import ComputedIntSymbolic, we_are_translated
 from pypy.rlib.rarithmetic import ovfcheck
 
 import py
@@ -318,6 +318,8 @@
     op.descr = Descr(ofs, type)
 
 def compile_add_loop_token(loop, descr):
+    if we_are_translated():
+        raise ValueError("CALL_ASSEMBLER not supported")
     loop = _from_opaque(loop)
     op = loop.operations[-1]
     op.descr = descr

Modified: pypy/branch/multijit/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/multijit/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/multijit/pypy/jit/backend/llgraph/runner.py	Sat Jan 30 17:54:42 2010
@@ -149,7 +149,7 @@
             descr = op.descr
             if isinstance(descr, Descr):
                 llimpl.compile_add_descr(c, descr.ofs, descr.typeinfo)
-            if isinstance(descr, history.LoopToken):
+            if isinstance(descr, history.LoopToken) and op.opnum != rop.JUMP:
                 llimpl.compile_add_loop_token(c, descr)
             if self.is_oo and isinstance(descr, (OODescr, MethDescr)):
                 # hack hack, not rpython

Modified: pypy/branch/multijit/pypy/jit/metainterp/test/test_ztranslation.py
==============================================================================
--- pypy/branch/multijit/pypy/jit/metainterp/test/test_ztranslation.py	(original)
+++ pypy/branch/multijit/pypy/jit/metainterp/test/test_ztranslation.py	Sat Jan 30 17:54:42 2010
@@ -7,8 +7,6 @@
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.ootypesystem import ootype
 
-py.test.skip("Broken")
-
 class TranslationTest:
 
     CPUClass = None
@@ -23,6 +21,7 @@
         # - profiler
         # - full optimizer
         # - jitdriver hooks
+        # - two JITs
 
         class Frame(object):
             _virtualizable2_ = ['i']
@@ -64,14 +63,29 @@
                     frame.i -= 2
                 frame.i -= 1
             return total * 10
-        res = ll_meta_interp(f, [40], CPUClass=self.CPUClass,
-                             type_system=self.type_system)
-        assert res == f(40)
-        res = rpython_ll_meta_interp(f, [40], loops=2, CPUClass=self.CPUClass,
+        #
+        myjitdriver2 = JitDriver(greens = [], reds = ['m', 'x'])
+        def f2(m, x):
+            while m > 0:
+                myjitdriver2.can_enter_jit(m=m, x=x)
+                myjitdriver2.jit_merge_point(m=m, x=x)
+                m -= 1
+                x += 3
+            return x
+        #
+        def main(i, j):
+            return f(i) - f2(i, j)
+        res = ll_meta_interp(main, [40, 5], CPUClass=self.CPUClass,
+                             type_system=self.type_system,
+                             num_jit_drivers=2)
+        assert res == main(40, 5)
+        res = rpython_ll_meta_interp(main, [40, 5], loops=2,
+                                     CPUClass=self.CPUClass,
                                      type_system=self.type_system,
                                      optimizer=OPTIMIZER_FULL,
-                                     ProfilerClass=Profiler)
-        assert res == f(40)
+                                     ProfilerClass=Profiler,
+                                     num_jit_drivers=2)
+        assert res == main(40, 5)
 
     def test_external_exception_handling_translates(self):
         jitdriver = JitDriver(greens = [], reds = ['n', 'total'])

Modified: pypy/branch/multijit/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/multijit/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/branch/multijit/pypy/jit/metainterp/warmspot.py	Sat Jan 30 17:54:42 2010
@@ -66,13 +66,15 @@
 def jittify_and_run(interp, graph, args, repeat=1, CPUClass=None,
                     backendopt=False, trace_limit=sys.maxint,
                     debug_level=DEBUG_STEPS, inline=False,
+                    translate_support_code=False,
                     num_jit_drivers=1, **kwds):
     translator = interp.typer.annotator.translator
     translator.config.translation.gc = "boehm"
     translator.config.translation.list_comprehension_operations = True
     jmpps = find_jit_merge_points(translator.graphs)
     assert len(jmpps) == num_jit_drivers
-    cpu = build_cpu(translator, CPUClass)
+    cpu = build_cpu(translator, CPUClass, translate_support_code)
+    warmrunnerdescs = []
     for jmpp in jmpps:
         warmrunnerdesc = WarmRunnerDesc(translator, cpu, backendopt=backendopt,
                                         jit_merge_point_pos=jmpp, **kwds)
@@ -82,9 +84,11 @@
         warmrunnerdesc.state.set_param_inlining(inline)
         warmrunnerdesc.state.set_param_debug(debug_level)
         warmrunnerdesc.finish()
+        warmrunnerdescs.append(warmrunnerdesc)
     res = interp.eval_graph(graph, args)
-    if not kwds.get('translate_support_code', False):
-        warmrunnerdesc.metainterp_sd.profiler.finish()
+    if not translate_support_code:
+        for warmrunnerdesc in warmrunnerdescs:
+            warmrunnerdesc.metainterp_sd.profiler.finish()
     print '~~~ return value:', res
     while repeat > 1:
         print '~' * 79



More information about the Pypy-commit mailing list