[pypy-svn] r79894 - in pypy/branch/gc-debug/pypy/rpython/memory: gc gctransform
arigo at codespeak.net
arigo at codespeak.net
Wed Dec 8 15:38:29 CET 2010
Author: arigo
Date: Wed Dec 8 15:38:28 2010
New Revision: 79894
Modified:
pypy/branch/gc-debug/pypy/rpython/memory/gc/base.py
pypy/branch/gc-debug/pypy/rpython/memory/gc/minimark.py
pypy/branch/gc-debug/pypy/rpython/memory/gctransform/framework.py
Log:
Unless I'm mistaken, making gc.DEBUG settable at run-time is
actually very easy and has no performance overhead.
Modified: pypy/branch/gc-debug/pypy/rpython/memory/gc/base.py
==============================================================================
--- pypy/branch/gc-debug/pypy/rpython/memory/gc/base.py (original)
+++ pypy/branch/gc-debug/pypy/rpython/memory/gc/base.py Wed Dec 8 15:38:28 2010
@@ -36,6 +36,13 @@
self.finalizer_lock_count = 0
self.run_finalizers = self.AddressDeque()
+ def post_setup(self):
+ # More stuff that needs to be initialized when the GC is already
+ # fully working. (Only called by gctransform/framework for now.)
+ from pypy.rpython.memory.gc import env
+ if env.read_from_env('PYPY_GC_DEBUG') > 0:
+ self.DEBUG = True
+
def _teardown(self):
pass
@@ -48,7 +55,8 @@
# The following flag enables costly consistency checks after each
# collection. It is automatically set to True by test_gc.py. The
# checking logic is translatable, so the flag can be set to True
- # here before translation.
+ # here before translation. At run-time, if PYPY_GC_DEBUG is set,
+ # then it is also set to True.
DEBUG = False
def set_query_functions(self, is_varsize, has_gcptr_in_varsize,
Modified: pypy/branch/gc-debug/pypy/rpython/memory/gc/minimark.py
==============================================================================
--- pypy/branch/gc-debug/pypy/rpython/memory/gc/minimark.py (original)
+++ pypy/branch/gc-debug/pypy/rpython/memory/gc/minimark.py Wed Dec 8 15:38:28 2010
@@ -32,6 +32,9 @@
limit. Useful to avoid spending all the time in
the GC in very small programs. Defaults to 8
times the nursery.
+
+ PYPY_GC_DEBUG Enable extra checks around collections that are
+ too slow for normal use.
"""
# XXX Should find a way to bound the major collection threshold by the
# XXX total addressable size. Maybe by keeping some minimarkpage arenas
@@ -841,7 +844,7 @@
def remember_young_pointer(addr_struct, newvalue):
# 'addr_struct' is the address of the object in which we write.
# 'newvalue' is the address that we are going to write in there.
- if DEBUG:
+ if DEBUG: # note: PYPY_GC_DEBUG=1 does not enable this
ll_assert(not self.is_in_nursery(addr_struct),
"nursery object with GCFLAG_NO_YOUNG_PTRS")
#
@@ -878,7 +881,7 @@
# 'addr_array' is the address of the object in which we write,
# which must have an array part; 'index' is the index of the
# item that is (or contains) the pointer that we write.
- if DEBUG:
+ if DEBUG: # note: PYPY_GC_DEBUG=1 does not enable this
ll_assert(not self.is_in_nursery(addr_array),
"nursery array with GCFLAG_NO_YOUNG_PTRS")
objhdr = self.header(addr_array)
Modified: pypy/branch/gc-debug/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/branch/gc-debug/pypy/rpython/memory/gctransform/framework.py (original)
+++ pypy/branch/gc-debug/pypy/rpython/memory/gctransform/framework.py Wed Dec 8 15:38:28 2010
@@ -189,6 +189,7 @@
# run-time initialization code
root_walker.setup_root_walker()
gcdata.gc.setup()
+ gcdata.gc.post_setup()
def frameworkgc__teardown():
# run-time teardown code for tests!
More information about the Pypy-commit
mailing list