summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Tennie <sven.tennie@gmail.com>2023-04-23 08:45:10 +0000
committerSven Tennie <sven.tennie@gmail.com>2023-05-05 19:59:53 +0000
commite83bba0d830ac18ed9df6f98979b5da6d20bf992 (patch)
tree515bd36579bb3ce170dec7ec9850bf30f5c51e31
parent0a77b36407d9b32e5233bb6ea3c7b4dbc4aacc34 (diff)
downloadhaskell-e83bba0d830ac18ed9df6f98979b5da6d20bf992.tar.gz
Haddock
-rw-r--r--libraries/ghc-heap/GHC/Exts/Stack.hs3
-rw-r--r--libraries/ghc-heap/GHC/Exts/Stack/Decode.hs10
2 files changed, 11 insertions, 2 deletions
diff --git a/libraries/ghc-heap/GHC/Exts/Stack.hs b/libraries/ghc-heap/GHC/Exts/Stack.hs
index 1405c69e06..90081a522a 100644
--- a/libraries/ghc-heap/GHC/Exts/Stack.hs
+++ b/libraries/ghc-heap/GHC/Exts/Stack.hs
@@ -14,6 +14,9 @@ import GHC.Exts.Stack.Constants
import GHC.Exts.Stack.Decode
import Prelude
+-- | Get the size of the `StackFrame` in words.
+--
+-- Includes header and payload. Does not follow pointers.
stackFrameSize :: StackFrame -> Int
stackFrameSize (UpdateFrame {}) = sizeStgUpdateFrame
stackFrameSize (CatchFrame {}) = sizeStgCatchFrame
diff --git a/libraries/ghc-heap/GHC/Exts/Stack/Decode.hs b/libraries/ghc-heap/GHC/Exts/Stack/Decode.hs
index 9c175fe17c..13d89f8bc8 100644
--- a/libraries/ghc-heap/GHC/Exts/Stack/Decode.hs
+++ b/libraries/ghc-heap/GHC/Exts/Stack/Decode.hs
@@ -427,19 +427,25 @@ intToWord# i = int2Word# (toInt# i)
wordOffsetToWord# :: WordOffset -> Word#
wordOffsetToWord# wo = intToWord# (fromIntegral wo)
+-- | Location of a stackframe on the stack
+--
+-- It's defined by the `StackSnapshot` (@StgStack@) and the offset to the bottom
+-- of the stack.
type StackFrameLocation = (StackSnapshot, WordOffset)
-- | Decode `StackSnapshot` to a `StgStackClosure`
--
-- The return value is the representation of the @StgStack@ itself.
+--
+-- See /Note [Decoding the stack]/.
decodeStack :: StackSnapshot -> IO StgStackClosure
decodeStack (StackSnapshot stack#) = do
info <- getInfoTableForStack stack#
(stack_size', stack_dirty', stack_marking') <- getStackFields stack#
case tipe info of
STACK -> do
- let sfis = stackFrameLocations (StackSnapshot stack#)
- stack' <- mapM unpackStackFrame sfis
+ let sfls = stackFrameLocations (StackSnapshot stack#)
+ stack' <- mapM unpackStackFrame sfls
pure $
StgStackClosure
{ ssc_info = info,