Note [Weak pointer processing and the non-moving GC]

rts/sm/MarkWeak.c:86 rts

When using the non-moving GC we defer weak pointer processing
until the concurrent marking phase as weaks in the non-moving heap may be
keyed on objects living in the non-moving generation. To accomplish this
initWeakForGC keeps all weak pointers on oldest_gen->weak_ptr_list, where
nonmovingCollect will find them. From there they will be moved to
nonmoving_old_weak_ptr_list. During the mark loop we will move weaks with
reachable keys to nonmoving_weak_ptr_list. At the end of concurrent marking
we tidy the weak list (in nonmovingTidyWeakList) and perform another set of
marking as necessary, just as is done in tidyWeakList.

Note that this treatment takes advantage of the fact that we usually need
not worry about Weak#s living in the non-moving heap but being keyed on an
object in the moving heap since the Weak# must be strictly older than the
key. Such objects would otherwise pose a problem since the non-moving
collector would be unable to safely determine the liveness of the key.
In the rare case that we *do* see such a key (e.g. in the case of a
pinned ByteArray# living in a partially-filled accumulator block)
the nonmoving collector assumes that it is live.

References 0

This Note does not link to any other.

Referenced by 4