Commits

Armin Rigo committed 6ee99f7

A test and fix for jit.look_inside.

Comments (0)

Files changed (2)

rpython/jit/codewriter/policy.py

         return True # look into everything by default
 
     def _reject_function(self, func):
-        if hasattr(func, '_jit_look_inside_'):
-            return not func._jit_look_inside_
         # explicitly elidable functions are always opaque
         if getattr(func, '_elidable_function_', False):
             return True
         except AttributeError:
             see_function = True
         else:
-            see_function = (self.look_inside_function(func) and not
-                            self._reject_function(func))
+            if hasattr(func, '_jit_look_inside_'):
+                see_function = func._jit_look_inside_   # override guessing
+            else:
+                see_function = (self.look_inside_function(func) and not
+                                self._reject_function(func))
             contains_loop = contains_loop and not getattr(
                     func, '_jit_unroll_safe_', False)
 

rpython/jit/codewriter/test/test_policy.py

     graph = support.getgraph(h, [5])
     assert not JitPolicy().look_inside_graph(graph)
 
+def test_look_inside():
+    def h1(x):
+        return x + 1
+    @jit.look_inside    # force True, even if look_inside_function() thinks not
+    def h2(x):
+        return x + 2
+    class MyPolicy(JitPolicy):
+        def look_inside_function(self, func):
+            return False
+    graph1 = support.getgraph(h1, [5])
+    graph2 = support.getgraph(h2, [5])
+    assert not MyPolicy().look_inside_graph(graph1)
+    assert MyPolicy().look_inside_graph(graph2)
+
 def test_loops():
     def g(x):
         i = 0