Closure size functions will return incorrect for closures with static links
Not sure if this is a bug or not, but here goes.
Closure size functions like closureSize#
(primop) and closure_size
(C function) don't take static link fields into account, so they will return incorrect result for top-level constructors (e.g. SRTs, or CAFFY constructors).
It seems like the assumption here is they'll always be passed heap-allocated closures, but as far as I can see this fact is not documented, e.g. in ghc-heap
's closureSize
:
-- | Get the size of the top-level closure in words.
-- Includes header and payload. Does not follow pointers.
--
-- @since 8.10.1
closureSize :: Box -> Int
closureSize (Box x) = I# (closureSize# x)
Note that, confusingly, "top-level" here means that the function does not recursively visit payloads, not that the closure is actually top-level!