[pypy-svn] r79835 - in pypy/trunk: . pypy pypy/interpreter pypy/jit/metainterp/optimizeopt pypy/module/_stackless pypy/module/array/benchmark pypy/module/array/test pypy/module/sys pypy/rlib pypy/rlib/test pypy/translator/goal

fijal at codespeak.net fijal at codespeak.net
Sun Dec 5 09:36:47 CET 2010


Author: fijal
Date: Sun Dec  5 09:36:45 2010
New Revision: 79835

Modified:
   pypy/trunk/   (props changed)
   pypy/trunk/pypy/   (props changed)
   pypy/trunk/pypy/interpreter/executioncontext.py
   pypy/trunk/pypy/jit/metainterp/optimizeopt/optimizer.py   (props changed)
   pypy/trunk/pypy/module/_stackless/interp_coroutine.py
   pypy/trunk/pypy/module/array/benchmark/Makefile   (props changed)
   pypy/trunk/pypy/module/array/benchmark/intimg.c   (props changed)
   pypy/trunk/pypy/module/array/benchmark/intimgtst.c   (props changed)
   pypy/trunk/pypy/module/array/benchmark/intimgtst.py   (props changed)
   pypy/trunk/pypy/module/array/benchmark/loop.c   (props changed)
   pypy/trunk/pypy/module/array/benchmark/sum.c   (props changed)
   pypy/trunk/pypy/module/array/benchmark/sumtst.c   (props changed)
   pypy/trunk/pypy/module/array/benchmark/sumtst.py   (props changed)
   pypy/trunk/pypy/module/array/test/test_array_old.py   (props changed)
   pypy/trunk/pypy/module/sys/vm.py
   pypy/trunk/pypy/rlib/rerased.py   (props changed)
   pypy/trunk/pypy/rlib/test/test_rerased.py   (props changed)
   pypy/trunk/pypy/translator/goal/app_main.py
Log:
Remove sys.setrecursionlimit functionality. It still works and you can get/set
it, but it won't cause RuntimeError to be raised.

The reason behind that is that we have better mechanism in place already
that prevents this from happening (and does not have impact on JIT).


Modified: pypy/trunk/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/trunk/pypy/interpreter/executioncontext.py	(original)
+++ pypy/trunk/pypy/interpreter/executioncontext.py	Sun Dec  5 09:36:45 2010
@@ -27,7 +27,6 @@
     def __init__(self, space):
         self.space = space
         self.topframeref = jit.vref_None
-        self.framestackdepth = 0
         # tracing: space.frame_trace_action.fire() must be called to ensure
         # that tracing occurs whenever self.w_tracefunc or self.is_tracing
         # is modified.
@@ -54,9 +53,6 @@
         return frame
 
     def enter(self, frame):
-        if self.framestackdepth > self.space.sys.recursionlimit:
-            raise self.space.prebuilt_recursion_error
-        self.framestackdepth += 1
         frame.f_backref = self.topframeref
         self.topframeref = jit.virtual_ref(frame)
 
@@ -66,7 +62,6 @@
                 self._trace(frame, 'leaveframe', self.space.w_None)
         finally:
             self.topframeref = frame.f_backref
-            self.framestackdepth -= 1
             jit.virtual_ref_finish(frame)
 
         if self.w_tracefunc is not None and not frame.hide():
@@ -80,7 +75,6 @@
 
         def __init__(self):
             self.topframe = None
-            self.framestackdepth = 0
             self.w_tracefunc = None
             self.profilefunc = None
             self.w_profilefuncarg = None
@@ -88,7 +82,6 @@
 
         def enter(self, ec):
             ec.topframeref = jit.non_virtual_ref(self.topframe)
-            ec.framestackdepth = self.framestackdepth
             ec.w_tracefunc = self.w_tracefunc
             ec.profilefunc = self.profilefunc
             ec.w_profilefuncarg = self.w_profilefuncarg
@@ -97,7 +90,6 @@
 
         def leave(self, ec):
             self.topframe = ec.gettopframe()
-            self.framestackdepth = ec.framestackdepth
             self.w_tracefunc = ec.w_tracefunc
             self.profilefunc = ec.profilefunc
             self.w_profilefuncarg = ec.w_profilefuncarg 
@@ -105,7 +97,6 @@
 
         def clear_framestack(self):
             self.topframe = None
-            self.framestackdepth = 0
 
         # the following interface is for pickling and unpickling
         def getstate(self, space):
@@ -121,17 +112,14 @@
                 self.topframe = space.interp_w(PyFrame, frames_w[-1])
             else:
                 self.topframe = None
-            self.framestackdepth = len(frames_w)
 
         def getframestack(self):
-            index = self.framestackdepth
-            lst = [None] * index
+            lst = []
             f = self.topframe
-            while index > 0:
-                index -= 1
-                lst[index] = f
+            while f is not None:
+                lst.append(f)
                 f = f.f_backref()
-            assert f is None
+            lst.reverse()
             return lst
         # coroutine: I think this is all, folks!
 

Modified: pypy/trunk/pypy/module/_stackless/interp_coroutine.py
==============================================================================
--- pypy/trunk/pypy/module/_stackless/interp_coroutine.py	(original)
+++ pypy/trunk/pypy/module/_stackless/interp_coroutine.py	Sun Dec  5 09:36:45 2010
@@ -304,16 +304,14 @@
 
 def w_descr__framestack(space, self):
     assert isinstance(self, AppCoroutine)
-    index = self.subctx.framestackdepth
-    if not index:
-        return space.newtuple([])
-    items = [None] * index
     f = self.subctx.topframe
-    while index > 0:
-        index -= 1
-        items[index] = space.wrap(f)
+    items = []
+    if not f:
+        return space.newtuple([])
+    while f is not None:
+        items.append(space.wrap(f))
         f = f.f_backref()
-    assert f is None
+    items.reverse()
     return space.newtuple(items)
 
 def makeStaticMethod(module, classname, funcname):

Modified: pypy/trunk/pypy/module/sys/vm.py
==============================================================================
--- pypy/trunk/pypy/module/sys/vm.py	(original)
+++ pypy/trunk/pypy/module/sys/vm.py	Sun Dec  5 09:36:45 2010
@@ -41,27 +41,21 @@
         f = ec.getnextframe_nohidden(f)
     return space.wrap(f)
 
-# directly from the C code in ceval.c, might be moved somewhere else.
-
 def setrecursionlimit(space, w_new_limit):
-    """Set the maximum depth of the Python interpreter stack to n.  This
-limit prevents infinite recursion from causing an overflow of the C
-stack and crashing Python.  The highest possible limit is platform
-dependent."""
+    """DEPRECATED on PyPy. Will issue warning and not work
+    """
     new_limit = space.int_w(w_new_limit)
     if new_limit <= 0:
         raise OperationError(space.w_ValueError,
                              space.wrap("recursion limit must be positive"))
     # global recursion_limit
     # we need to do it without writing globals.
+    space.warn('setrecursionlimit deprecated', space.w_DeprecationWarning)
     space.sys.recursionlimit = new_limit
 
 def getrecursionlimit(space):
-    """Return the current value of the recursion limit, the maximum depth
-    of the Python interpreter stack.  This limit prevents infinite
-    recursion from causing an overflow of the C stack and crashing Python.
+    """DEPRECATED on PyPy. Will issue warning and not work
     """
-
     return space.wrap(space.sys.recursionlimit)
 
 def setcheckinterval(space, interval):

Modified: pypy/trunk/pypy/translator/goal/app_main.py
==============================================================================
--- pypy/trunk/pypy/translator/goal/app_main.py	(original)
+++ pypy/trunk/pypy/translator/goal/app_main.py	Sun Dec  5 09:36:45 2010
@@ -312,8 +312,9 @@
                      cmd=None,
                      **ignored):
     # with PyPy in top of CPython we can only have around 100 
-    # but we need more in the translated PyPy for the compiler package 
-    sys.setrecursionlimit(5000)
+    # but we need more in the translated PyPy for the compiler package
+    if '__pypy__' not in sys.builtin_module_names:
+        sys.setrecursionlimit(5000)
 
     if unbuffered:
         set_unbuffered_io()



More information about the Pypy-commit mailing list