Commits

Armin Rigo committed 73c6c33

Reintroduce a test similar to the previous one, and fix broken code.

  • Participants
  • Parent commits 6ce8443

Comments (0)

Files changed (2)

pypy/jit/metainterp/test/test_warmspot.py

 import py
 from pypy.jit.metainterp.warmspot import get_stats
-from pypy.rlib.jit import JitDriver, set_param, unroll_safe
+from pypy.rlib.jit import JitDriver, set_param, unroll_safe, jit_callback
 from pypy.jit.backend.llgraph import runner
 
 from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
         self.check_trace_count(1)
 
 
+    def test_callback_jit_merge_point(self):
+        @jit_callback("testing")
+        def callback(a, b):
+            if a > b:
+                return 1
+            return -1
+
+        def main():
+            total = 0
+            for i in range(10):
+                total += callback(i, 2)
+            return total
+
+        res = self.meta_interp(main, [])
+        assert res == 7 - 3
+        self.check_trace_count(2)
+
+
 class TestLLWarmspot(WarmspotTests, LLJitMixin):
     CPUClass = runner.LLGraphCPU
     type_system = 'lltype'

pypy/jit/metainterp/warmspot.py

         jd._jit_merge_point_in = graph
         args = op.args[2:]
         s_binding = self.translator.annotator.binding
-        if op.args[1].value.autoreds:
-            # _portal_args_s is used only by _make_hook_graph, but for now we
-            # declare the various set_jitcell_at, get_printable_location,
-            # etc. as incompatible with autoreds
-            jd._portal_args_s = None
-        else:
-            jd._portal_args_s = [s_binding(v) for v in args]
+        jd._portal_args_s = [s_binding(v) for v in args]
         graph = copygraph(graph)
         [jmpp] = find_jit_merge_points([graph])
         graph.startblock = support.split_before_jit_merge_point(*jmpp)
         if func is None:
             return None
         #
-        assert not jitdriver_sd.jitdriver.autoreds, (
-            "reds='auto' is not compatible with JitDriver hooks such as "
-            "{get,set}_jitcell_at, get_printable_location, confirm_enter_jit, etc.")
+        if not onlygreens:
+            assert not jitdriver_sd.jitdriver.autoreds, (
+                "reds='auto' is not compatible with JitDriver hooks such as "
+                "confirm_enter_jit")
         extra_args_s = []
         if s_first_arg is not None:
             extra_args_s.append(s_first_arg)