[pypy-commit] pypy stm-gc: Comments and asserts.
noreply at buildbot.pypy.org
Wed Apr 18 18:07:43 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Date: 2012-04-18 17:24 +0200
Log: Comments and asserts.
diff --git a/pypy/rpython/memory/gc/stmtls.py b/pypy/rpython/memory/gc/stmtls.py
@@ -203,6 +203,13 @@
# visited above, and reset GCFLAG_VISITED on the others.
+ # Note that the last step guarantees the invariant that between
+ # collections, all the objects linked within 'self.sharedarea_tls'
+ # don't have GCFLAG_VISITED. As the newly allocated nursery
+ # objects don't have it either, at the start of the next
+ # collection, the only LOCAL objects that have it are the ones
+ # in 'copied_local_objects'.
# All live nursery objects are out, and the rest dies. Fill
# the whole nursery with zero and reset the current nursery pointer.
ll_assert(bool(self.nursery_free), "nursery_free is NULL")
@@ -464,24 +471,27 @@
obj = old.pop()
hdr = self.gc.header(obj)
+ ll_assert(hdr.tid & (GCFLAG_GLOBAL|GCFLAG_WAS_COPIED) == 0,
+ "local weakref: bad flags")
if hdr.tid & GCFLAG_VISITED == 0:
continue # weakref itself dies
obj = hdr.version
- hdr = self.gc.header(obj)
+ #hdr = self.gc.header(obj) --- not needed any more
offset = self.gc.weakpointer_offset(self.gc.get_type_id(obj))
pointing_to = (obj + offset).address
+ ll_assert(bool(pointing_to), "weakref to NULL in local_weakrefs")
cat = self.categorize_object(pointing_to, can_be_in_nursery=True)
if cat == 0:
# the weakref points to a dying object; no need to rememeber it
(obj + offset).address = llmemory.NULL
# the weakref points to an object that stays alive
- if cat == 2:
+ if cat == 2: # update the pointer if needed
pointing_hdr = self.gc.header(pointing_to)
(obj + offset).address = pointing_hdr.version
- new.append(obj) # stays alive
+ new.append(obj) # re-register in the new local_weakrefs list
self.local_weakrefs = new
More information about the pypy-commit