summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Tennie <sven.tennie@gmail.com>2023-04-09 08:44:19 +0000
committerSven Tennie <sven.tennie@gmail.com>2023-05-05 19:59:53 +0000
commite85771bae705a4f167fff1270805461b38973d64 (patch)
tree9c2ff2e5223e0a39e6c768ffad8cdffd725b7f46
parent9006a2f1f018cc93544bd44a5a9f5d664c5d646f (diff)
downloadhaskell-e85771bae705a4f167fff1270805461b38973d64.tar.gz
Rename
-rw-r--r--libraries/ghc-heap/GHC/Exts/Stack/Decode.hs28
1 files changed, 14 insertions, 14 deletions
diff --git a/libraries/ghc-heap/GHC/Exts/Stack/Decode.hs b/libraries/ghc-heap/GHC/Exts/Stack/Decode.hs
index d775c369ce..3ce123a1a3 100644
--- a/libraries/ghc-heap/GHC/Exts/Stack/Decode.hs
+++ b/libraries/ghc-heap/GHC/Exts/Stack/Decode.hs
@@ -212,7 +212,6 @@ getClosure stackSnapshot# index relativeOffset =
(# s1, ptr #) ->
(# s1, Box ptr #)
--- TODO: Inline later
-- | Iterator state for stack decoding
data StackFrameIter =
-- | Represents a closure on the stack
@@ -287,6 +286,8 @@ decodeBitmaps stackSnapshot# index relativePayloadOffset bitmapWords size =
getIndex (SfiClosure _ i) = i
getIndex (SfiPrimitive _ i) = i
+-- TODO: (auto-) format the code
+-- TODO: Check all functions with two WordOffsets? Can't it be one?
decodeSmallBitmap :: SmallBitmapGetter -> StackSnapshot# -> WordOffset -> WordOffset -> IO [Closure]
decodeSmallBitmap getterFun# stackSnapshot# index relativePayloadOffset =
do
@@ -296,7 +297,7 @@ decodeSmallBitmap getterFun# stackSnapshot# index relativePayloadOffset =
let bitmapWords = [bitmap | size > 0]
decodeBitmaps stackSnapshot# index relativePayloadOffset bitmapWords size
-unpackStackFrame :: (StackSnapshot, WordOffset) -> IO StackFrame
+unpackStackFrame :: StackFrameLocation -> IO StackFrame
unpackStackFrame ((StackSnapshot stackSnapshot#), index) = do
info <- getInfoTableOnStack stackSnapshot# index
unpackStackFrame' info
@@ -390,6 +391,7 @@ unpackStackFrame ((StackSnapshot stackSnapshot#), index) = do
alt_code = alt_code'
}
CATCH_STM_FRAME -> do
+ -- TODO: Move `getBoxedClosureData =<<` to `getClosure`
catchFrameCode' <- getBoxedClosureData =<< getClosure stackSnapshot# index offsetStgCatchSTMFrameCode
handler' <- getBoxedClosureData =<< getClosure stackSnapshot# index offsetStgCatchSTMFrameHandler
pure $
@@ -400,6 +402,7 @@ unpackStackFrame ((StackSnapshot stackSnapshot#), index) = do
}
x -> error $ "Unexpected closure type on stack: " ++ show x
+-- TODO: Duplicate
getClosureDataFromHeapObject
:: a
-- ^ Heap object to decode.
@@ -435,21 +438,18 @@ intToWord# i = int2Word# (toInt# i)
wordOffsetToWord# :: WordOffset -> Word#
wordOffsetToWord# wo = intToWord# (fromIntegral wo)
--- | Decode `StackSnapshot` to a Closure
+type StackFrameLocation = (StackSnapshot, WordOffset)
+
+-- | Decode `StackSnapshot` to a `StgStackClosure`
--
--- Due to the use of `Box` this decoding is lazy. The first decoded closure is
--- the representation of the @StgStack@ itself.
+-- The return value is the representation of the @StgStack@ itself.
decodeStack :: StackSnapshot -> IO StgStackClosure
-decodeStack (StackSnapshot stack#) =
- unpackStack stack#
-
-unpackStack :: StackSnapshot# -> IO StgStackClosure
-unpackStack stack# = do
+decodeStack (StackSnapshot stack#) = do
info <- getInfoTableForStack stack#
(stack_size', stack_dirty', stack_marking') <- getStackFields stack#
case tipe info of
STACK -> do
- let sfis = decodeStackToBoxes (StackSnapshot stack#)
+ let sfis = stackFrameLocations (StackSnapshot stack#)
stack' <- mapM unpackStackFrame sfis
pure $
StgStackClosure
@@ -461,12 +461,12 @@ unpackStack stack# = do
}
_ -> error $ "Expected STACK closure, got " ++ show info
where
- decodeStackToBoxes :: StackSnapshot -> [(StackSnapshot, WordOffset)]
- decodeStackToBoxes s =
+ stackFrameLocations :: StackSnapshot -> [StackFrameLocation]
+ stackFrameLocations s =
(stackHead s)
: go (advanceStackFrameIter (fst (stackHead s)) (snd (stackHead s)))
where
- go :: Maybe (StackSnapshot, WordOffset) -> [(StackSnapshot, WordOffset)]
+ go :: Maybe StackFrameLocation -> [StackFrameLocation]
go Nothing = []
go (Just r) = r : go (advanceStackFrameIter (fst r) (snd r))