Commits

Maciej Fijalkowski committed 6376527

(fijal, hodgestar) make the test pass

Comments (0)

Files changed (3)

pypy/jit/metainterp/pyjitpl.py

         any_operation = len(self.metainterp.history.operations) > 0
         jitdriver_sd = self.metainterp.staticdata.jitdrivers_sd[jdindex]
         self.verify_green_args(jitdriver_sd, greenboxes)
-        import pdb; pdb.set_trace()
         self.debug_merge_point(jitdriver_sd, jdindex, self.metainterp.in_recursion,
                                greenboxes)
 
             # close the loop.  We have to put the possibly-modified list
             # 'redboxes' back into the registers where it comes from.
             put_back_list_of_boxes3(self, jcposition, redboxes)
+        elif jitdriver_sd.warmstate.should_unroll_one_iteration(greenboxes):
+            return
         else:
             # warning! careful here.  We have to return from the current
             # frame containing the jit_merge_point, and then use

pypy/jit/metainterp/test/test_ajit.py

         assert res == 84 - 61 - 62
         self.check_history(call=1)   # because the trace starts immediately
 
-    def test_unroll_one_loop(self):
+    def test_unroll_one_loop_iteration(self):
         def unroll(x):
             return x == 0
         myjitdriver = JitDriver(greens = ['x'], reds = ['y'], should_unroll_one_iteration=unroll)

pypy/jit/metainterp/warmstate.py

             return can_inline_greenargs(*greenargs)
         self.can_inline_greenargs = can_inline_greenargs
         self.can_inline_callable = can_inline_callable
+
+        if jd._should_unroll_one_iteration_ptr is None:
+            def should_unroll_one_iteration(greenkey):
+                return False
+        else:
+            rtyper = self.warmrunnerdesc.rtyper
+            inline_ptr = jd._should_unroll_one_iteration_ptr
+            def should_unroll_one_iteration(greenkey):
+                greenargs = unwrap_greenkey(greenkey)
+                fn = support.maybe_on_top_of_llinterp(rtyper, inline_ptr)
+                return fn(*greenargs)
+        self.should_unroll_one_iteration = should_unroll_one_iteration
+        
         if hasattr(jd.jitdriver, 'on_compile'):
             def on_compile(logger, token, operations, type, greenkey):
                 greenargs = unwrap_greenkey(greenkey)