Hakan Ardo avatar Hakan Ardo committed 59a84d9

only skipp peeling if the optimized peeled trace have more than max_retrace_guards guards

Comments (0)

Files changed (2)

pypy/jit/metainterp/optimizeopt/unroll.py

             short = self.inline(inputargs, self.cloned_operations,
                                 loop.inputargs, short_inputargs,
                                 virtual_state)
-            if not virtual_state.contains_virtuals():
+
+            maxguards = self.optimizer.metainterp_sd.warmrunnerdesc.memory_manager.max_retrace_guards
+            if not virtual_state.contains_virtuals() and self.optimizer.emitted_guards > maxguards:
                 ops_in_loop = len(self.optimizer.newoperations)
                 ops_in_preamble = len(loop.preamble.operations) + 1
                 amount_saved = ((ops_in_preamble - ops_in_loop) * 100) / ops_in_preamble
             loop.preamble.operations.append(jmp)
 
             loop.operations = self.optimizer.newoperations
-            maxguards = self.optimizer.metainterp_sd.warmrunnerdesc.memory_manager.max_retrace_guards
             
             if self.optimizer.emitted_guards > maxguards:
                 loop.preamble.token.retraced_count = sys.maxint

pypy/jit/metainterp/test/test_ajit.py

         myjitdriver = JitDriver(greens = [], reds = ['n', 'i', 'sa', 'a'])
 
         def f(n, limit):
+            myjitdriver.set_param('limit_peeling', -1)
             myjitdriver.set_param('retrace_limit', 3)
             myjitdriver.set_param('max_retrace_guards', limit)
             sa = i = a = 0
     def test_limit_peeling(self):
         myjitdriver = JitDriver(greens = [], reds = ['n', 'i', 'sa', 'a'])
 
-        def f(n, limit):
+        def f(n, limit, maxguards):
             myjitdriver.set_param('limit_peeling', limit)
+            myjitdriver.set_param('max_retrace_guards', maxguards)
             sa = i = 0
             a = n + 1
             while i < n:
                 sa += a * a
                 i += 1
             return sa
-        assert self.meta_interp(f, [20, 0]) == f(20, 0)
+        assert self.meta_interp(f, [20, 0, 0]) == f(20, 0, 0)
         self.check_tree_loop_count(2)
-        assert self.meta_interp(f, [20, 10]) == f(20, 10)
+        assert self.meta_interp(f, [20, 10, 0]) == f(20, 10, 0)
         self.check_tree_loop_count(2)
-        assert self.meta_interp(f, [20, 20]) == f(20, 20)
+        assert self.meta_interp(f, [20, 20, 0]) == f(20, 20, 0)
         self.check_tree_loop_count(1)
+        assert self.meta_interp(f, [20, 20, 10]) == f(20, 20, 10)
+        self.check_tree_loop_count(2)
 
 
     def test_retrace_limit_with_extra_guards(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.