[pypy-svn] r52050 - in pypy/branch/jit-refactoring/pypy/jit/rainbow: . test

arigo at codespeak.net arigo at codespeak.net
Sun Mar 2 17:40:23 CET 2008


Author: arigo
Date: Sun Mar  2 17:40:21 2008
New Revision: 52050

Added:
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_llinterp.py   (contents, props changed)
Modified:
   pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py
Log:
Support for, and a test for, translating the JIT support code.
Many RPython fixes pending.


Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/portal.py	Sun Mar  2 17:40:21 2008
@@ -9,12 +9,14 @@
 
 # graph transformations for transforming the portal graph(s)
 class PortalRewriter(object):
-    def __init__(self, hintannotator, rtyper, RGenOp, codewriter):
+    def __init__(self, hintannotator, rtyper, RGenOp, codewriter,
+                 translate_support_code = True):
         self.hintannotator = hintannotator
         self.rtyper = rtyper
         self.interpreter = codewriter.interpreter
         self.codewriter = codewriter
         self.RGenOp = RGenOp
+        self.translate_support_code = translate_support_code
 
     def rewrite(self, origportalgraph, portalgraph, view=False):
         self.origportalgraph = origportalgraph
@@ -64,12 +66,26 @@
         self.interpreter.set_portalstate(state)
 
     def mutate_origportalgraph(self):
-        # XXX
-        # the following line should really be a call to a mixlevel annotator
-        # but for now the jit stuff should be run directly to make tests faster
-        # currently this makes it untranslatable
-        portal_entry_graph_ptr = llhelper(lltype.Ptr(self.PORTAL_FUNCTYPE),
-                                          self.portal_entry)
+        if not self.translate_support_code:
+            # this case is used for most tests: the jit stuff should be run
+            # directly to make these tests faster
+            portal_entry_graph_ptr = llhelper(lltype.Ptr(self.PORTAL_FUNCTYPE),
+                                              self.portal_entry)
+        else:
+            # this translates portal_entry into low-level graphs, recursively
+            # dragging the whole jit support code with it.  Depending on which
+            # descs are reachable from the portalbytecode, this will create
+            # the specialized versions of the support code as needed.
+            from pypy.rpython import annlowlevel
+            from pypy.annotation import model as annmodel
+            annhelper = annlowlevel.MixLevelHelperAnnotator(self.rtyper)
+            FUNC = self.PORTAL_FUNCTYPE
+            args_s = [annmodel.lltype_to_annotation(ARG) for ARG in FUNC.ARGS]
+            s_result = annmodel.lltype_to_annotation(FUNC.RESULT)
+            portal_entry_graph_ptr = annhelper.delayedfunction(
+                self.portal_entry, args_s, s_result)
+            annhelper.finish()
+
         # the following gives a pdb prompt when portal_entry raises an exception
         portal_entry_graph_ptr._obj.__dict__['_debugexc'] = True
         # XXX hack hack hack

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py	Sun Mar  2 17:40:21 2008
@@ -75,6 +75,7 @@
 
     RGenOp = LLRGenOp
     small = False
+    translate_support_code = False       # only works for portal tests for now
 
     def setup_class(cls):
         cls.on_llgraph = cls.RGenOp is LLRGenOp
@@ -115,7 +116,7 @@
         # rewire the original portal
 
         rewriter = PortalRewriter(self.hintannotator, self.rtyper, self.RGenOp,
-                                  writer)
+                                  writer, self.translate_support_code)
         self.rewriter = rewriter
         origportalgraph = graphof(self.rtyper.annotator.translator, portal)
         portalgraph = graphof(t, portal)

Added: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_llinterp.py
==============================================================================
--- (empty file)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_llinterp.py	Sun Mar  2 17:40:21 2008
@@ -0,0 +1,9 @@
+import py; py.test.skip("in-progress")
+from pypy.jit.rainbow.test import test_portal
+
+
+class TestLLInterpreted(test_portal.TestPortal):
+    translate_support_code = True
+
+    # for the individual tests see
+    # ====> test_portal.py


More information about the pypy-svn mailing list