[pypy-svn] r52240 - in pypy/branch/jit-refactoring/pypy: jit/rainbow jit/rainbow/test translator

arigo at codespeak.net arigo at codespeak.net
Fri Mar 7 10:58:28 CET 2008


Author: arigo
Date: Fri Mar  7 10:58:28 2008
New Revision: 52240

Modified:
   pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_frontend.py
   pypy/branch/jit-refactoring/pypy/translator/driver.py
Log:
Can't use constant_fold_graph() here because it doesn't preserve
annotations.  The original problem was that hannotator.simplify() was
not done any more when using the translator driver.



Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py	Fri Mar  7 10:58:28 2008
@@ -1320,13 +1320,8 @@
         self.hannotator = hannotator
 
     def transform_graph(self, graph):
-        from pypy.translator.backendopt.constfold import constant_fold_graph
         self.graph = graph
         remove_same_as(graph)
-        # to get rid of the usages of the we_are_jitted constant
-        # (turned to '1' by the hintannotator)
-        # XXX is this the best way to deal with it?
-        constant_fold_graph(graph)
         self.insert_splits()
 
     def insert_splits(self):

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_frontend.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_frontend.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_frontend.py	Fri Mar  7 10:58:28 2008
@@ -7,16 +7,20 @@
     type_system = "lltype"
 
     def test_we_are_jitted(self):
-        def f():
+        def g(n):
+            return n + 5
+        def f(m):
             if we_are_jitted():
                 return 42
-            return 0
-
-        assert f() == 0
-        res = interpret(f, [])
-        assert res == 0
+            # the following path should not be seen by the hint-annotator
+            # and killed from the red-green graphs by 'hannotator.simplify()'
+            return g(m)
+
+        assert f(5) == 10
+        res = interpret(f, [5])
+        assert res == 10
 
-        res = self.interpret(f, [])
+        res = self.interpret(f, [5])
         assert res == 42
 
     def test_is_early_constant(self):

Modified: pypy/branch/jit-refactoring/pypy/translator/driver.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/translator/driver.py	(original)
+++ pypy/branch/jit-refactoring/pypy/translator/driver.py	Fri Mar  7 10:58:28 2008
@@ -394,6 +394,7 @@
                                     [SomeLLAbstractConstant(v.concretetype,
                                                             {OriginFlags(): True})
                                      for v in self.orig_portal_graph.getargs()])
+        hannotator.simplify()
         count = hannotator.bookkeeper.nonstuboriggraphcount
         stubcount = hannotator.bookkeeper.stuboriggraphcount
         self.log.info("The hint-annotator saw %d graphs"


More information about the pypy-svn mailing list