Note [STATIC_LINK fields]
The low 2 bits of the static link field have the following meaning:
00 we haven't seen this static object before
01/10 if it equals static_flag, then we saw it in this GC, otherwise
we saw it in the previous GC.
11 ignore during GC. This value is used in two ways
- When we put CAFs on a list (see Note [CAF lists])
- a static constructor that was determined to have no CAF
references at compile time is given this value, so we
don't traverse it during GC
This choice of values is quite deliberate, because it means we can
decide whether a static object should be traversed during GC using a
single test:
bits = link_field & 3;
if ((bits | prev_static_flag) != 3) { ... }
However, this mechanism for tracking liveness has an important implication:
once a static object becomes unreachable it must never become reachable again.
One would think that this can by definition never happen but in the past SRT
generation bugs have caused precisely this behavior with disasterous results.
See Note [No static object resurrection] in GHC.Cmm.Info.Build for details. References 2
- No static object resurrection GHC.Cmm.Info.Build
- CAF lists
Referenced by 6
- No static object resurrection GHC.Cmm.Info.Build
- SRTs GHC.Cmm.Info.Build
- GHC.StgToCmm.Heap call site
- rts/sm/Evac.c call site
- Static objects under the nonmoving collector
- rts/Sparks.c call site