[pypy-svn] r51431 - in pypy/dist/pypy/translator/c: . src
arigo at codespeak.net
arigo at codespeak.net
Wed Feb 13 13:25:40 CET 2008
Author: arigo
Date: Wed Feb 13 13:25:39 2008
New Revision: 51431
Modified:
pypy/dist/pypy/translator/c/gc.py
pypy/dist/pypy/translator/c/src/mem.h
Log:
Attempt to avoid a stack overflow situation with Boehm,
by replacing recursive calls to finalizers with calls
from a flat loop.
Modified: pypy/dist/pypy/translator/c/gc.py
==============================================================================
--- pypy/dist/pypy/translator/c/gc.py (original)
+++ pypy/dist/pypy/translator/c/gc.py Wed Feb 13 13:25:39 2008
@@ -199,7 +199,7 @@
pass # yield 'assert(GC_all_interior_pointers == 0);'
else:
yield 'GC_all_interior_pointers = 0;'
- yield 'GC_init();'
+ yield 'boehm_gc_startup_code();'
def get_real_weakref_type(self):
return boehm.WEAKLINK
Modified: pypy/dist/pypy/translator/c/src/mem.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/mem.h (original)
+++ pypy/dist/pypy/translator/c/src/mem.h Wed Feb 13 13:25:39 2008
@@ -128,6 +128,29 @@
else \
GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj)
+void boehm_gc_startup_code(void);
+
+#ifndef PYPY_NOT_MAIN_FILE
+static void boehm_gc_finalizer_notifier(void)
+{
+ static int recursing = 0;
+ if (recursing)
+ return; /* GC_invoke_finalizers() will be done by the
+ boehm_gc_finalizer_notifier() that is
+ currently in the C stack, when we return there */
+ recursing = 1;
+ while (GC_should_invoke_finalizers())
+ GC_invoke_finalizers();
+ recursing = 0;
+}
+void boehm_gc_startup_code(void)
+{
+ GC_init();
+ GC_finalizer_notifier = &boehm_gc_finalizer_notifier;
+ GC_finalize_on_demand = 1;
+}
+#endif /* PYPY_NOT_MAIN_FILE */
+
#endif /* USING_BOEHM_GC */
/************************************************************/
More information about the Pypy-commit
mailing list