1. Pypy
  2. Untitled project
  3. pypy

Commits

Simon Cross  committed 2e3ca4c

(fijal, hodgestar) Start adding should_unroll_one_iteration.

  • Participants
  • Parent commits ea1d8b0
  • Branches inline-simple-generators

Comments (0)

Files changed (5)

File pypy/jit/metainterp/pyjitpl.py

View file
         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)
 

File pypy/jit/metainterp/test/test_ajit.py

View file
         assert res == 84 - 61 - 62
         self.check_history(call=1)   # because the trace starts immediately
 
+    def test_unroll_one_loop(self):
+        def unroll(x):
+            return x == 0
+        myjitdriver = JitDriver(greens = ['x'], reds = ['y'], should_unroll_one_iteration=unroll)
+
+        def f(x, y):
+            while y > 0:
+                myjitdriver.jit_merge_point(x=x, y=y)
+                if x == 0:
+                    return y
+                f(0, 4)
+                y -= 1
+            return 0
+
+        res = self.meta_interp(f, [1, 4], enable_opts="", inline=True)
+        self.check_history(call_assembler=0)
+
     def test_format(self):
         def f(n):
             return len("<%d>" % n)

File pypy/jit/metainterp/warmspot.py

View file
                 onlygreens=False)
             jd._can_never_inline_ptr = self._make_hook_graph(jd,
                 annhelper, jd.jitdriver.can_never_inline, annmodel.s_Bool)
+            jd._should_unroll_one_iteration_ptr = self._make_hook_graph(jd,
+                annhelper, jd.jitdriver.should_unroll_one_iteration,
+                annmodel.s_Bool)
         annhelper.finish()
 
     def _make_hook_graph(self, jitdriver_sd, annhelper, func,

File pypy/module/pypyjit/interp_jit.py

View file
             ec.w_tracefunc is None)
 
 def can_never_inline(next_instr, is_being_profiled, bytecode):
-    return (bytecode.co_flags & CO_GENERATOR) != 0
-
+    #return (bytecode.co_flags & CO_GENERATOR) != 0
+    return False
 
 def wrap_oplist(space, logops, operations):
     list_w = []

File pypy/rlib/jit.py

View file
     def __init__(self, greens=None, reds=None, virtualizables=None,
                  get_jitcell_at=None, set_jitcell_at=None,
                  get_printable_location=None, confirm_enter_jit=None,
-                 can_never_inline=None):
+                 can_never_inline=None, should_unroll_one_iteration=None):
         if greens is not None:
             self.greens = greens
         if reds is not None:
         self.get_printable_location = get_printable_location
         self.confirm_enter_jit = confirm_enter_jit
         self.can_never_inline = can_never_inline
+        self.should_unroll_one_iteration = should_unroll_one_iteration
 
     def _freeze_(self):
         return True