diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-03-13 19:42:47 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-03-17 05:05:10 -0400 |
commit | cb61371e3260e07be724a04b72a935133f66b514 (patch) | |
tree | 456e4f3fa84ab7f8fa94ed66f717f6ea949899f8 /libraries/ghc-heap/GHC/Exts | |
parent | 3f2291e47b8e00f1312c9be31484ceddd1289212 (diff) | |
download | haskell-cb61371e3260e07be724a04b72a935133f66b514.tar.gz |
ghc-heap: Introduce closureSize
This function allows the user to compute the (non-transitive) size of a
heap object in words. The "closure" in the name is admittedly confusing
but we are stuck with this nomenclature at this point.
Diffstat (limited to 'libraries/ghc-heap/GHC/Exts')
-rw-r--r-- | libraries/ghc-heap/GHC/Exts/Heap/Closures.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs b/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs index e624a17b78..2465014e48 100644 --- a/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs +++ b/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs @@ -13,6 +13,12 @@ module GHC.Exts.Heap.Closures ( , GenClosure(..) , PrimType(..) , allClosures +#if __GLASGOW_HASKELL__ >= 809 + -- The closureSize# primop is unsupported on earlier GHC releases but we + -- build ghc-heap as a boot library so it must be buildable. Drop this once + -- we are guaranteed to bootstsrap with GHC >= 8.9. + , closureSize +#endif -- * Boxes , Box(..) @@ -321,3 +327,11 @@ allClosures (FunClosure {..}) = ptrArgs allClosures (BlockingQueueClosure {..}) = [link, blackHole, owner, queue] allClosures (OtherClosure {..}) = hvalues allClosures _ = [] + +#if __GLASGOW_HASKELL__ >= 809 +-- | Get the size of a closure in words. +-- +-- @since 8.10.1 +closureSize :: Box -> Int +closureSize (Box x) = I# (closureSize# x) +#endif |