[pypy-commit] pypy const-fold-we-are-jitted: replace we_are_jitted with False when doing the normal backendopt optimization,

cfbolz pypy.commits at gmail.com
Sat Aug 20 10:31:41 EDT 2016


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: const-fold-we-are-jitted
Changeset: r86348:b2dbc4e9bdea
Date: 2016-08-20 14:50 +0200
http://bitbucket.org/pypy/pypy/changeset/b2dbc4e9bdea/

Log:	replace we_are_jitted with False when doing the normal backendopt
	optimization, but leave it alone when running the backend
	optimizations from the JIT

diff --git a/rpython/jit/metainterp/warmspot.py b/rpython/jit/metainterp/warmspot.py
--- a/rpython/jit/metainterp/warmspot.py
+++ b/rpython/jit/metainterp/warmspot.py
@@ -452,7 +452,8 @@
                               merge_if_blocks=True,
                               constfold=True,
                               remove_asserts=True,
-                              really_remove_asserts=True)
+                              really_remove_asserts=True,
+                              replace_we_are_jitted=False)
 
     def prejit_optimizations_minimal_inline(self, policy, graphs):
         from rpython.translator.backendopt.inline import auto_inline_graphs
diff --git a/rpython/translator/driver.py b/rpython/translator/driver.py
--- a/rpython/translator/driver.py
+++ b/rpython/translator/driver.py
@@ -381,7 +381,7 @@
         """ Run all backend optimizations - lltype version
         """
         from rpython.translator.backendopt.all import backend_optimizations
-        backend_optimizations(self.translator)
+        backend_optimizations(self.translator, replace_we_are_jitted=True)
 
 
     STACKCHECKINSERTION = 'stackcheckinsertion_lltype'
diff --git a/rpython/translator/test/test_interactive.py b/rpython/translator/test/test_interactive.py
--- a/rpython/translator/test/test_interactive.py
+++ b/rpython/translator/test/test_interactive.py
@@ -78,3 +78,15 @@
     dll = ctypes.CDLL(str(t.driver.c_entryp))
     f = dll.pypy_g_f
     assert f(2, 3) == 5
+
+def test_check_that_driver_uses_replace_we_are_jitted():
+    from rpython.rlib import jit
+    def f():
+        if jit.we_are_jitted():
+            return 1
+        return 2 + jit.we_are_jitted()
+
+    t = Translation(f, [])
+    t.backendopt()
+    graph = t.driver.translator.graphs[0]
+    assert graph.startblock.exits[0].args[0].value == 2


More information about the pypy-commit mailing list