[pypy-dev] [pypy-commit] pypy default: TEMPORARY: put a limit (4 by default) on the number of "cancelled,

Carl Friedrich Bolz cfbolz at gmx.de
Fri Jan 13 13:01:53 CET 2012


Yes, this breaks Pyrolog. That's fine, I can probably just increase the number. Could you write a test for this commit, though? 

Cheers, 

Carl Friedrich

----- Reply message -----
From: "arigo" <noreply at buildbot.pypy.org>
To: <pypy-commit at python.org>
Subject: [pypy-commit] pypy default: TEMPORARY: put a limit (4 by default) on the number of "cancelled,
Date: Thu, Jan 12, 2012 17:29


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r51285:b09a9354d977
Date: 2012-01-12 17:28 +0100
http://bitbucket.org/pypy/pypy/changeset/b09a9354d977/

Log:	TEMPORARY: put a limit (4 by default) on the number of "cancelled,
	tracing more" that can occur during one tracing. I think this will
	again fail in some non-PyPy interpreters like Pyrolog. Sorry about
	that, but it's the quickest way to fix issue985...

diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -1553,6 +1553,7 @@
 
 class MetaInterp(object):
     in_recursion = 0
+    cancel_count = 0
 
     def __init__(self, staticdata, jitdriver_sd):
         self.staticdata = staticdata
@@ -1975,6 +1976,13 @@
                         raise SwitchToBlackhole(ABORT_BAD_LOOP) # For now
                 self.compile_loop(original_boxes, live_arg_boxes, start, resumedescr)
                 # creation of the loop was cancelled!
+                self.cancel_count += 1
+                if self.staticdata.warmrunnerdesc:
+                    memmgr = self.staticdata.warmrunnerdesc.memory_manager
+                    if memmgr:
+                        if self.cancel_count > memmgr.max_unroll_loops:
+                            self.staticdata.log('cancelled too many times!')
+                            raise SwitchToBlackhole(ABORT_BAD_LOOP)
                 self.staticdata.log('cancelled, tracing more...')
 
         # Otherwise, no loop found so far, so continue tracing.
diff --git a/pypy/jit/metainterp/warmstate.py b/pypy/jit/metainterp/warmstate.py
--- a/pypy/jit/metainterp/warmstate.py
+++ b/pypy/jit/metainterp/warmstate.py
@@ -244,6 +244,11 @@
             if self.warmrunnerdesc.memory_manager:
                 self.warmrunnerdesc.memory_manager.max_retrace_guards = value
 
+    def set_param_max_unroll_loops(self, value):
+        if self.warmrunnerdesc:
+            if self.warmrunnerdesc.memory_manager:
+                self.warmrunnerdesc.memory_manager.max_unroll_loops = value
+
     def disable_noninlinable_function(self, greenkey):
         cell = self.jit_cell_at_key(greenkey)
         cell.dont_trace_here = True
diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py
--- a/pypy/rlib/jit.py
+++ b/pypy/rlib/jit.py
@@ -401,6 +401,7 @@
     'loop_longevity': 'a parameter controlling how long loops will be kept before being freed, an estimate',
     'retrace_limit': 'how many times we can try retracing before giving up',
     'max_retrace_guards': 'number of extra guards a retrace can cause',
+    'max_unroll_loops': 'number of extra unrollings a loop can cause',
     'enable_opts': 'optimizations to enable or all, INTERNAL USE ONLY'
     }
 
@@ -412,6 +413,7 @@
               'loop_longevity': 1000,
               'retrace_limit': 5,
               'max_retrace_guards': 15,
+              'max_unroll_loops': 4,
               'enable_opts': 'all',
               }
 unroll_parameters = unrolling_iterable(PARAMETERS.items())
_______________________________________________
pypy-commit mailing list
pypy-commit at python.org
http://mail.python.org/mailman/listinfo/pypy-commit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20120113/12dfe213/attachment.html>


More information about the pypy-dev mailing list