-staticClosureNeedsLink (MkClosureInfo _ info _) =
- case info of
- LFThunk _ _ _ _ _ _ NoSRT -> False
- LFReEntrant _ _ _ _ _ NoSRT -> False
- LFCon _ True -> False -- zero arity constructors
- _ -> True
-
-getSRTInfo :: ClosureInfo -> (CLabel, SRT)
-getSRTInfo (MkClosureInfo _ info _) =
- case info of
- LFThunk _ _ _ _ _ lbl srt -> (lbl,srt)
- LFReEntrant _ _ _ _ lbl srt -> (lbl,srt)
- _ -> panic "getSRTInfo"
+-- A static closure needs a link field to aid the GC when traversing
+-- the static closure graph. But it only needs such a field if either
+-- a) it has an SRT
+-- b) it's a non-nullary constructor
+-- In case (b), the constructor's fields themselves play the role
+-- of the SRT.
+staticClosureNeedsLink (MkClosureInfo { closureName = name, closureSRT = srt, closureLFInfo = info })
+ = needsSRT srt || constructor_srt
+ where
+ constructor_srt
+ = case info of
+ LFThunk _ _ _ _ _ -> False
+ LFReEntrant _ _ _ _ -> False
+ LFCon _ is_nullary -> not is_nullary
+ LFTuple _ is_nullary -> not is_nullary
+ other -> pprPanic "staticClosureNeedsLink" (ppr name)