Maintainer | Joachim Breitner <mail@joachim-breitner.de> |
---|---|
Safe Haskell | Safe-Infered |
With this module, you can investigate the heap representation of Haskell values, i.e. to investigate sharing and lazy evaluation.
- data Closure
- = ConsClosure { }
- | ThunkClosure { }
- | SelectorClosure {
- info :: StgInfoTable
- selectee :: Box
- | IndClosure {
- info :: StgInfoTable
- indirectee :: Box
- | BlackholeClosure {
- info :: StgInfoTable
- indirectee :: Box
- | APClosure { }
- | PAPClosure { }
- | BCOClosure { }
- | ArrWordsClosure { }
- | MutArrClosure {
- info :: StgInfoTable
- mccPtrs :: Word
- mccSize :: Word
- mccPayload :: [Box]
- | MutVarClosure {
- info :: StgInfoTable
- var :: Box
- | MVarClosure { }
- | FunClosure { }
- | BlockingQueueClosure { }
- | OtherClosure { }
- allPtrs :: Closure -> [Box]
- data ClosureType
- = INVALID_OBJECT
- | CONSTR
- | CONSTR_1_0
- | CONSTR_0_1
- | CONSTR_2_0
- | CONSTR_1_1
- | CONSTR_0_2
- | CONSTR_STATIC
- | CONSTR_NOCAF_STATIC
- | FUN
- | FUN_1_0
- | FUN_0_1
- | FUN_2_0
- | FUN_1_1
- | FUN_0_2
- | FUN_STATIC
- | THUNK
- | THUNK_1_0
- | THUNK_0_1
- | THUNK_2_0
- | THUNK_1_1
- | THUNK_0_2
- | THUNK_STATIC
- | THUNK_SELECTOR
- | BCO
- | AP
- | PAP
- | AP_STACK
- | IND
- | IND_PERM
- | IND_STATIC
- | RET_BCO
- | RET_SMALL
- | RET_BIG
- | RET_DYN
- | RET_FUN
- | UPDATE_FRAME
- | CATCH_FRAME
- | UNDERFLOW_FRAME
- | STOP_FRAME
- | BLOCKING_QUEUE
- | BLACKHOLE
- | MVAR_CLEAN
- | MVAR_DIRTY
- | ARR_WORDS
- | MUT_ARR_PTRS_CLEAN
- | MUT_ARR_PTRS_DIRTY
- | MUT_ARR_PTRS_FROZEN0
- | MUT_ARR_PTRS_FROZEN
- | MUT_VAR_CLEAN
- | MUT_VAR_DIRTY
- | WEAK
- | PRIM
- | MUT_PRIM
- | TSO
- | STACK
- | TREC_CHUNK
- | ATOMICALLY_FRAME
- | CATCH_RETRY_FRAME
- | CATCH_STM_FRAME
- | WHITEHOLE
- data StgInfoTable = StgInfoTable {}
- type HalfWord = Word16
- getClosureData :: a -> IO Closure
- getBoxedClosureData :: Box -> IO Closure
- getClosureRaw :: a -> IO (Ptr StgInfoTable, [Word], [Box])
- data Box = Box Any
- asBox :: a -> Box
Heap data types
This is the main data type of this module, representing a Haskell value on the heap. This reflects http://hackage.haskell.org/trac/ghc/browser/includes/rts/storage/Closures.h
data ClosureType Source
A closure type enumeration, in order matching the actual value on the heap. Needs to be synchronized with http://hackage.haskell.org/trac/ghc/browser/includes/rts/storage/ClosureTypes.h
data StgInfoTable Source
This is a somewhat faithful representation of an info table. See
http://hackage.haskell.org/trac/ghc/browser/includes/rts/storage/InfoTables.h
for more details on this data structure. Note that the Storable
instance
provided here does _not_ support writing.
Reading from the heap
getClosureData :: a -> IO ClosureSource
This function returns parsed heap representation of the argument _at this
moment_, even if it is unevaluated or an indirection or other exotic stuff.
Beware when passing something to this function, the same caveats as for
asBox
apply.
getBoxedClosureData :: Box -> IO ClosureSource
Like getClosureData
, but taking a Box
, so it is easier to work with.
getClosureRaw :: a -> IO (Ptr StgInfoTable, [Word], [Box])Source
This returns the raw representation of the given argument. The second
component of the triple are the words on the heap, and the third component
are those words that are actually pointers. Once back in Haskell word, the
Word
may be outdated after a garbage collector run, but the corresponding
Box
will still point to the correct value.
Boxes
An arbitrarily Haskell value in a safe Box. The point is that even
unevaluated thunks can safely be moved around inside the Box, and when
required, e.g. in getBoxedClosureData
, the function knows how far it has
to evalue the argument.