GHC.Exts.Heap

ghc-heap-8.8.1: Functions for walking GHC's heap

Copyright | (c) 2012 Joachim Breitner
License | BSD3
Maintainer | Joachim Breitner <mail@joachim-breitner.de>
Safe Haskell | None
Language | Haskell2010

GHC.Exts.Heap

Contents

- Closure types
- Info Table types
- Closure inspection
- Boxes

Description

With this module, you can investigate the heap representation of Haskell values, i.e. to investigate sharing and lazy evaluation.

Synopsis

- type Closure = GenClosure Box
- data GenClosure b
  - = ConstrClosure {
    - info :: !StgInfoTable
    - ptrArgs :: ![b]
    - dataArgs :: ![Word]
    - pkg :: !String
    - modl :: !String
    - name :: !String
    }
  - | FunClosure {
    - info :: !StgInfoTable
    - ptrArgs :: ![b]
    - dataArgs :: ![Word]
    }
  - | ThunkClosure {
    - info :: !StgInfoTable
    - ptrArgs :: ![b]
    - dataArgs :: ![Word]
    }
  - | SelectorClosure {
    - info :: !StgInfoTable
    - selectee :: !b
    }
  - | PAPClosure {
    - info :: !StgInfoTable
    - arity :: !HalfWord
    - n_args :: !HalfWord
    - fun :: !b
    - payload :: ![b]
    }
  - | APClosure {
    - info :: !StgInfoTable
    - arity :: !HalfWord
    - n_args :: !HalfWord
    - fun :: !b
    - payload :: ![b]
    }
  - | APStackClosure {
    - info :: !StgInfoTable
    - fun :: !b
    - payload :: ![b]
    }
  - | IndClosure {
    - info :: !StgInfoTable
    - indirectee :: !b
    }
  - | BCOClosure {
    - info :: !StgInfoTable
    - instrs :: !b
    - literals :: !b
    - bcoptrs :: !b
    - arity :: !HalfWord
    - size :: !HalfWord
    - bitmap :: ![Word]
    }
  - | BlackholeClosure {
    - info :: !StgInfoTable
    - indirectee :: !b
    }
  - | ArrWordsClosure {
    - info :: !StgInfoTable
    - bytes :: !Word
    - arrWords :: ![Word]
    }
  - | MutArrClosure {
    - info :: !StgInfoTable
    - mccPtrs :: !Word
    - mccSize :: !Word
    - mccPayload :: ![b]
    }
  - | MVarClosure {
    - info :: !StgInfoTable
    - queueHead :: !b
    - queueTail :: !b
    - value :: !b
    }
  - | MutVarClosure {
    - info :: !StgInfoTable
    - var :: !b
    }
  - | BlockingQueueClosure {
    - info :: !StgInfoTable
    - link :: !b
    - blackHole :: !b
    - owner :: !b
    - queue :: !b
    }
  - | IntClosure {
    - ptipe :: PrimType
    - intVal :: !Int
    }
  - | WordClosure {
    - ptipe :: PrimType
    - wordVal :: !Word
    }
  - | Int64Closure {
    - ptipe :: PrimType
    - int64Val :: !Int64
    }
  - | Word64Closure {
    - ptipe :: PrimType
    - word64Val :: !Word64
    }
  - | AddrClosure {
    - ptipe :: PrimType
    - addrVal :: !Int
    }
  - | FloatClosure {
    - ptipe :: PrimType
    - floatVal :: !Float
    }
  - | DoubleClosure {
    - ptipe :: PrimType
    - doubleVal :: !Double
    }
  - | OtherClosure {
    - info :: !StgInfoTable
    - hvalues :: ![b]
    - rawWords :: ![Word]
    }
  - | UnsupportedClosure {
    - info :: !StgInfoTable
    }
- data ClosureType
  - = INVALID_OBJECT
  - | CONSTR
  - | CONSTR_1_0
  - | CONSTR_0_1
  - | CONSTR_2_0
  - | CONSTR_1_1
  - | CONSTR_0_2
  - | CONSTR_NOCAF
  - | 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_STATIC
  - | RET_BCO
  - | RET_SMALL
  - | RET_BIG
  - | RET_FUN
  - | UPDATE_FRAME
  - | CATCH_FRAME
  - | UNDERFLOW_FRAME
  - | STOP_FRAME
  - | BLOCKING_QUEUE
  - | BLACKHOLE
  - | MVAR_CLEAN
  - | MVAR_DIRTY
  - | TVAR
  - | ARR_WORDS
  - | MUT_ARR_PTRS_CLEAN
  - | MUT_ARR_PTRS_DIRTY
  - | MUT_ARR_PTRS_FROZEN_DIRTY
  - | MUT_ARR_PTRS_FROZEN_CLEAN
  - | MUT_VAR_CLEAN
  - | MUT_VAR_DIRTY
  - | WEAK
  - | PRIM
  - | MUT_PRIM
  - | TSO
  - | STACK
  - | TREC_CHUNK
  - | ATOMICALLY_FRAME
  - | CATCH_RETRY_FRAME
  - | CATCH_STM_FRAME
  - | WHITEHOLE
  - | SMALL_MUT_ARR_PTRS_CLEAN
  - | SMALL_MUT_ARR_PTRS_DIRTY
  - | SMALL_MUT_ARR_PTRS_FROZEN_DIRTY
  - | SMALL_MUT_ARR_PTRS_FROZEN_CLEAN
  - | COMPACT_NFDATA
  - | N_CLOSURE_TYPES
- data PrimType
  - = PInt
  - | PWord
  - | PInt64
  - | PWord64
  - | PAddr
  - | PFloat
  - | PDouble
- class HasHeapRep (a :: TYPE rep) where
  - getClosureData :: a -> IO Closure
- data StgInfoTable = StgInfoTable {
  - entry :: Maybe EntryFunPtr
  - ptrs :: HalfWord
  - nptrs :: HalfWord
  - tipe :: ClosureType
  - srtlen :: HalfWord
  - code :: Maybe ItblCodes
  }
- type EntryFunPtr = FunPtr (Ptr () -> IO (Ptr ()))
- type HalfWord = Word32
- type ItblCodes = Either [Word8] [Word32]
- itblSize :: Int
- peekItbl :: Ptr StgInfoTable -> IO StgInfoTable
- pokeItbl :: Ptr StgInfoTable -> StgInfoTable -> IO ()
- getBoxedClosureData :: Box -> IO Closure
- allClosures :: GenClosure b -> [b]
- data Box = Box Any
- asBox :: a -> Box
- areBoxesEqual :: Box -> Box -> IO Bool

# Closure types

type Closure = GenClosure Box Source #

data GenClosure b Source #

This is the representation of a Haskell value on the heap. It reflects http://ghc.haskell.org/trac/ghc/browser/includes/rts/storage/Closures.h

The data type is parametrized by the type to store references in. Usually this is a `Box` with the type synonym `Closure`.

All Heap objects have the same basic layout. A header containing a pointer to the info table and a payload with various fields. The `info` field below always refers to the info table pointed to by the header. The remaining fields are the payload.

See https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/HeapObjects for more information.

Constructors

ConstrClosure | A data constructor
Fields info :: !StgInfoTable ptrArgs :: ![b] Pointer arguments dataArgs :: ![Word] Non-pointer arguments pkg :: !String Package name modl :: !String Module name name :: !String Constructor name
FunClosure | A function
Fields info :: !StgInfoTable ptrArgs :: ![b] Pointer arguments dataArgs :: ![Word] Non-pointer arguments
ThunkClosure | A thunk, an expression not obviously in head normal form
Fields info :: !StgInfoTable ptrArgs :: ![b] Pointer arguments dataArgs :: ![Word] Non-pointer arguments
SelectorClosure | A thunk which performs a simple selection operation
Fields info :: !StgInfoTable selectee :: !b Pointer to the object being selected from
PAPClosure | An unsaturated function application
Fields info :: !StgInfoTable arity :: !HalfWord Arity of the partial application n_args :: !HalfWord Size of the payload in words fun :: !b Pointer to a `FunClosure` payload :: ![b] Sequence of already applied arguments
APClosure | A function application
Fields info :: !StgInfoTable arity :: !HalfWord Arity of the partial application n_args :: !HalfWord Size of the payload in words fun :: !b Pointer to a `FunClosure` payload :: ![b] Sequence of already applied arguments
APStackClosure | A suspended thunk evaluation
Fields info :: !StgInfoTable fun :: !b Pointer to a `FunClosure` payload :: ![b] Sequence of already applied arguments
IndClosure | A pointer to another closure, introduced when a thunk is updated to point at its value
Fields info :: !StgInfoTable indirectee :: !b Target closure
BCOClosure | A byte-code object (BCO) which can be interpreted by GHC's byte-code interpreter (e.g. as used by GHCi)
Fields info :: !StgInfoTable instrs :: !b A pointer to an ArrWords of instructions literals :: !b A pointer to an ArrWords of literals bcoptrs :: !b A pointer to an ArrWords of byte code objects arity :: !HalfWord Arity of the partial application size :: !HalfWord The size of this BCO in words bitmap :: ![Word] An StgLargeBitmap describing the pointerhood of its args/free vars
BlackholeClosure | A thunk under evaluation by another thread
Fields info :: !StgInfoTable indirectee :: !b Target closure
ArrWordsClosure | A `ByteArray#`
Fields info :: !StgInfoTable bytes :: !Word Size of array in bytes arrWords :: ![Word] Array payload
MutArrClosure | A `MutableByteArray#`
Fields info :: !StgInfoTable mccPtrs :: !Word Number of pointers mccSize :: !Word ?? Closures.h vs ClosureMacros.h mccPayload :: ![b] Array payload Card table ignored
MVarClosure | An `MVar#`, with a queue of thread state objects blocking on them
Fields info :: !StgInfoTable queueHead :: !b Pointer to head of queue queueTail :: !b Pointer to tail of queue value :: !b Pointer to closure
MutVarClosure | A `MutVar#`
Fields info :: !StgInfoTable var :: !b Pointer to contents
BlockingQueueClosure | An STM blocking queue.
Fields info :: !StgInfoTable link :: !b ?? Here so it looks like an IND blackHole :: !b The blackhole closure owner :: !b The owning thread state object queue :: !b ??
IntClosure | Primitive Int
Fields ptipe :: PrimType intVal :: !Int
WordClosure | Primitive Word
Fields ptipe :: PrimType wordVal :: !Word
Int64Closure | Primitive Int64
Fields ptipe :: PrimType int64Val :: !Int64
Word64Closure | Primitive Word64
Fields ptipe :: PrimType word64Val :: !Word64
AddrClosure | Primitive Addr
Fields ptipe :: PrimType addrVal :: !Int
FloatClosure | Primitive Float
Fields ptipe :: PrimType floatVal :: !Float
DoubleClosure | Primitive Double
Fields ptipe :: PrimType doubleVal :: !Double
OtherClosure | Another kind of closure
Fields info :: !StgInfoTable hvalues :: ![b] rawWords :: ![Word]
UnsupportedClosure |
Fields info :: !StgInfoTable

#### Instances

Instances details

Functor GenClosure # |
Instance details Defined in GHC.Exts.Heap.Closures Methods fmap :: (a -> b) -> GenClosure a -> GenClosure b Source # (<$) :: a -> GenClosure b -> GenClosure a Source #
Foldable GenClosure # |
Instance details Defined in GHC.Exts.Heap.Closures Methods fold :: Monoid m => GenClosure m -> m Source # foldMap :: Monoid m => (a -> m) -> GenClosure a -> m Source # foldMap' :: Monoid m => (a -> m) -> GenClosure a -> m Source # foldr :: (a -> b -> b) -> b -> GenClosure a -> b Source # foldr' :: (a -> b -> b) -> b -> GenClosure a -> b Source # foldl :: (b -> a -> b) -> b -> GenClosure a -> b Source # foldl' :: (b -> a -> b) -> b -> GenClosure a -> b Source # foldr1 :: (a -> a -> a) -> GenClosure a -> a Source # foldl1 :: (a -> a -> a) -> GenClosure a -> a Source # toList :: GenClosure a -> [a] Source # null :: GenClosure a -> Bool Source # length :: GenClosure a -> Int Source # elem :: Eq a => a -> GenClosure a -> Bool Source # maximum :: Ord a => GenClosure a -> a Source # minimum :: Ord a => GenClosure a -> a Source # sum :: Num a => GenClosure a -> a Source # product :: Num a => GenClosure a -> a Source #
Traversable GenClosure # |
Instance details Defined in GHC.Exts.Heap.Closures Methods traverse :: Applicative f => (a -> f b) -> GenClosure a -> f (GenClosure b) Source # sequenceA :: Applicative f => GenClosure (f a) -> f (GenClosure a) Source # mapM :: Monad m => (a -> m b) -> GenClosure a -> m (GenClosure b) Source # sequence :: Monad m => GenClosure (m a) -> m (GenClosure a) Source #
Show b => Show (GenClosure b) # |
Instance details Defined in GHC.Exts.Heap.Closures Methods showsPrec :: Int -> GenClosure b -> ShowS Source # show :: GenClosure b -> String Source # showList :: [GenClosure b] -> ShowS Source #
Generic (GenClosure b) # |
Instance details Defined in GHC.Exts.Heap.Closures Associated Types type Rep (GenClosure b) :: Type -> Type Source # Methods from :: GenClosure b -> Rep (GenClosure b) x Source # to :: Rep (GenClosure b) x -> GenClosure b Source #
type Rep (GenClosure b) # |
Instance details Defined in GHC.Exts.Heap.Closures type Rep (GenClosure b) = D1 ('MetaData "GenClosure" "GHC.Exts.Heap.Closures" "ghc-heap-8.8.1" 'False) ((((C1 ('MetaCons "ConstrClosure" 'PrefixI 'True) ((S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: (S1 ('MetaSel ('Just "ptrArgs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [b]) :*: S1 ('MetaSel ('Just "dataArgs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Word]))) :*: (S1 ('MetaSel ('Just "pkg") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String) :*: (S1 ('MetaSel ('Just "modl") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String) :*: S1 ('MetaSel ('Just "name") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String)))) :+: (C1 ('MetaCons "FunClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: (S1 ('MetaSel ('Just "ptrArgs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [b]) :*: S1 ('MetaSel ('Just "dataArgs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Word]))) :+: C1 ('MetaCons "ThunkClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: (S1 ('MetaSel ('Just "ptrArgs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [b]) :*: S1 ('MetaSel ('Just "dataArgs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Word]))))) :+: (C1 ('MetaCons "SelectorClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: S1 ('MetaSel ('Just "selectee") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b)) :+: (C1 ('MetaCons "PAPClosure" 'PrefixI 'True) ((S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: S1 ('MetaSel ('Just "arity") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HalfWord)) :*: (S1 ('MetaSel ('Just "n_args") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HalfWord) :*: (S1 ('MetaSel ('Just "fun") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b) :*: S1 ('MetaSel ('Just "payload") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [b])))) :+: C1 ('MetaCons "APClosure" 'PrefixI 'True) ((S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: S1 ('MetaSel ('Just "arity") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HalfWord)) :*: (S1 ('MetaSel ('Just "n_args") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HalfWord) :*: (S1 ('MetaSel ('Just "fun") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b) :*: S1 ('MetaSel ('Just "payload") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [b]))))))) :+: ((C1 ('MetaCons "APStackClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: (S1 ('MetaSel ('Just "fun") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b) :*: S1 ('MetaSel ('Just "payload") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [b]))) :+: (C1 ('MetaCons "IndClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: S1 ('MetaSel ('Just "indirectee") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b)) :+: C1 ('MetaCons "BCOClosure" 'PrefixI 'True) ((S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: (S1 ('MetaSel ('Just "instrs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b) :*: S1 ('MetaSel ('Just "literals") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b))) :*: ((S1 ('MetaSel ('Just "bcoptrs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b) :*: S1 ('MetaSel ('Just "arity") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HalfWord)) :*: (S1 ('MetaSel ('Just "size") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HalfWord) :*: S1 ('MetaSel ('Just "bitmap") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Word])))))) :+: (C1 ('MetaCons "BlackholeClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: S1 ('MetaSel ('Just "indirectee") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b)) :+: (C1 ('MetaCons "ArrWordsClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: (S1 ('MetaSel ('Just "bytes") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word) :*: S1 ('MetaSel ('Just "arrWords") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Word]))) :+: C1 ('MetaCons "MutArrClosure" 'PrefixI 'True) ((S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: S1 ('MetaSel ('Just "mccPtrs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word)) :*: (S1 ('MetaSel ('Just "mccSize") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word) :*: S1 ('MetaSel ('Just "mccPayload") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [b]))))))) :+: (((C1 ('MetaCons "MVarClosure" 'PrefixI 'True) ((S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: S1 ('MetaSel ('Just "queueHead") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b)) :*: (S1 ('MetaSel ('Just "queueTail") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b) :*: S1 ('MetaSel ('Just "value") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b))) :+: (C1 ('MetaCons "MutVarClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: S1 ('MetaSel ('Just "var") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b)) :+: C1 ('MetaCons "BlockingQueueClosure" 'PrefixI 'True) ((S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: S1 ('MetaSel ('Just "link") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b)) :*: (S1 ('MetaSel ('Just "blackHole") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b) :*: (S1 ('MetaSel ('Just "owner") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b) :*: S1 ('MetaSel ('Just "queue") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 b)))))) :+: (C1 ('MetaCons "IntClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "ptipe") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PrimType) :*: S1 ('MetaSel ('Just "intVal") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :+: (C1 ('MetaCons "WordClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "ptipe") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PrimType) :*: S1 ('MetaSel ('Just "wordVal") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word)) :+: C1 ('MetaCons "Int64Closure" 'PrefixI 'True) (S1 ('MetaSel ('Just "ptipe") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PrimType) :*: S1 ('MetaSel ('Just "int64Val") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int64))))) :+: ((C1 ('MetaCons "Word64Closure" 'PrefixI 'True) (S1 ('MetaSel ('Just "ptipe") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PrimType) :*: S1 ('MetaSel ('Just "word64Val") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64)) :+: (C1 ('MetaCons "AddrClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "ptipe") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PrimType) :*: S1 ('MetaSel ('Just "addrVal") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :+: C1 ('MetaCons "FloatClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "ptipe") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PrimType) :*: S1 ('MetaSel ('Just "floatVal") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Float)))) :+: (C1 ('MetaCons "DoubleClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "ptipe") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PrimType) :*: S1 ('MetaSel ('Just "doubleVal") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Double)) :+: (C1 ('MetaCons "OtherClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable) :*: (S1 ('MetaSel ('Just "hvalues") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [b]) :*: S1 ('MetaSel ('Just "rawWords") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [Word]))) :+: C1 ('MetaCons "UnsupportedClosure" 'PrefixI 'True) (S1 ('MetaSel ('Just "info") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 StgInfoTable)))))))

data ClosureType Source #

Constructors

INVALID_OBJECT |
CONSTR |
CONSTR_1_0 |
CONSTR_0_1 |
CONSTR_2_0 |
CONSTR_1_1 |
CONSTR_0_2 |
CONSTR_NOCAF |
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_STATIC |
RET_BCO |
RET_SMALL |
RET_BIG |
RET_FUN |
UPDATE_FRAME |
CATCH_FRAME |
UNDERFLOW_FRAME |
STOP_FRAME |
BLOCKING_QUEUE |
BLACKHOLE |
MVAR_CLEAN |
MVAR_DIRTY |
TVAR |
ARR_WORDS |
MUT_ARR_PTRS_CLEAN |
MUT_ARR_PTRS_DIRTY |
MUT_ARR_PTRS_FROZEN_DIRTY |
MUT_ARR_PTRS_FROZEN_CLEAN |
MUT_VAR_CLEAN |
MUT_VAR_DIRTY |
WEAK |
PRIM |
MUT_PRIM |
TSO |
STACK |
TREC_CHUNK |
ATOMICALLY_FRAME |
CATCH_RETRY_FRAME |
CATCH_STM_FRAME |
WHITEHOLE |
SMALL_MUT_ARR_PTRS_CLEAN |
SMALL_MUT_ARR_PTRS_DIRTY |
SMALL_MUT_ARR_PTRS_FROZEN_DIRTY |
SMALL_MUT_ARR_PTRS_FROZEN_CLEAN |
COMPACT_NFDATA |
N_CLOSURE_TYPES |

#### Instances

Instances details

Enum ClosureType # |
Instance details Defined in GHC.Exts.Heap.ClosureTypes Methods succ :: ClosureType -> ClosureType Source # pred :: ClosureType -> ClosureType Source # toEnum :: Int -> ClosureType Source # fromEnum :: ClosureType -> Int Source # enumFrom :: ClosureType -> [ClosureType] Source # enumFromThen :: ClosureType -> ClosureType -> [ClosureType] Source # enumFromTo :: ClosureType -> ClosureType -> [ClosureType] Source # enumFromThenTo :: ClosureType -> ClosureType -> ClosureType -> [ClosureType] Source #
Eq ClosureType # |
Instance details Defined in GHC.Exts.Heap.ClosureTypes Methods (==) :: ClosureType -> ClosureType -> Bool Source # (/=) :: ClosureType -> ClosureType -> Bool Source #
Ord ClosureType # |
Instance details Defined in GHC.Exts.Heap.ClosureTypes Methods compare :: ClosureType -> ClosureType -> Ordering Source # (<) :: ClosureType -> ClosureType -> Bool Source # (<=) :: ClosureType -> ClosureType -> Bool Source # (>) :: ClosureType -> ClosureType -> Bool Source # (>=) :: ClosureType -> ClosureType -> Bool Source # max :: ClosureType -> ClosureType -> ClosureType Source # min :: ClosureType -> ClosureType -> ClosureType Source #
Show ClosureType # |
Instance details Defined in GHC.Exts.Heap.ClosureTypes Methods showsPrec :: Int -> ClosureType -> ShowS Source # show :: ClosureType -> String Source # showList :: [ClosureType] -> ShowS Source #
Generic ClosureType # |
Instance details Defined in GHC.Exts.Heap.ClosureTypes Associated Types type Rep ClosureType :: Type -> Type Source # Methods from :: ClosureType -> Rep ClosureType x Source # to :: Rep ClosureType x -> ClosureType Source #
type Rep ClosureType # |
Instance details Defined in GHC.Exts.Heap.ClosureTypes type Rep ClosureType = D1 ('MetaData "ClosureType" "GHC.Exts.Heap.ClosureTypes" "ghc-heap-8.8.1" 'False) ((((((C1 ('MetaCons "INVALID_OBJECT" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CONSTR" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "CONSTR_1_0" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CONSTR_0_1" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "CONSTR_2_0" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CONSTR_1_1" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "CONSTR_0_2" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CONSTR_NOCAF" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: (((C1 ('MetaCons "FUN" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FUN_1_0" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "FUN_0_1" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FUN_2_0" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "FUN_1_1" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FUN_0_2" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "FUN_STATIC" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "THUNK" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: ((((C1 ('MetaCons "THUNK_1_0" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "THUNK_0_1" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "THUNK_2_0" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "THUNK_1_1" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "THUNK_0_2" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "THUNK_STATIC" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "THUNK_SELECTOR" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BCO" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: (((C1 ('MetaCons "AP" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PAP" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "AP_STACK" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IND" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "IND_STATIC" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "RET_BCO" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "RET_SMALL" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "RET_BIG" 'PrefixI 'False) (U1 :: Type -> Type)))))) :+: (((((C1 ('MetaCons "RET_FUN" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "UPDATE_FRAME" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "CATCH_FRAME" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "UNDERFLOW_FRAME" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "STOP_FRAME" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BLOCKING_QUEUE" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "BLACKHOLE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MVAR_CLEAN" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: (((C1 ('MetaCons "MVAR_DIRTY" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TVAR" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "ARR_WORDS" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MUT_ARR_PTRS_CLEAN" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "MUT_ARR_PTRS_DIRTY" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MUT_ARR_PTRS_FROZEN_DIRTY" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MUT_ARR_PTRS_FROZEN_CLEAN" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MUT_VAR_CLEAN" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: ((((C1 ('MetaCons "MUT_VAR_DIRTY" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WEAK" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "PRIM" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MUT_PRIM" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "TSO" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "STACK" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TREC_CHUNK" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ATOMICALLY_FRAME" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: (((C1 ('MetaCons "CATCH_RETRY_FRAME" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CATCH_STM_FRAME" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "WHITEHOLE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SMALL_MUT_ARR_PTRS_CLEAN" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "SMALL_MUT_ARR_PTRS_DIRTY" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SMALL_MUT_ARR_PTRS_FROZEN_DIRTY" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "SMALL_MUT_ARR_PTRS_FROZEN_CLEAN" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "COMPACT_NFDATA" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "N_CLOSURE_TYPES" 'PrefixI 'False) (U1 :: Type -> Type))))))))

data PrimType Source #

Constructors

PInt |
PWord |
PInt64 |
PWord64 |
PAddr |
PFloat |
PDouble |

#### Instances

Instances details

Eq PrimType # |
Instance details Defined in GHC.Exts.Heap.Closures Methods (==) :: PrimType -> PrimType -> Bool Source # (/=) :: PrimType -> PrimType -> Bool Source #
Show PrimType # |
Instance details Defined in GHC.Exts.Heap.Closures Methods showsPrec :: Int -> PrimType -> ShowS Source # show :: PrimType -> String Source # showList :: [PrimType] -> ShowS Source #
Generic PrimType # |
Instance details Defined in GHC.Exts.Heap.Closures Associated Types type Rep PrimType :: Type -> Type Source # Methods from :: PrimType -> Rep PrimType x Source # to :: Rep PrimType x -> PrimType Source #
type Rep PrimType # |
Instance details Defined in GHC.Exts.Heap.Closures type Rep PrimType = D1 ('MetaData "PrimType" "GHC.Exts.Heap.Closures" "ghc-heap-8.8.1" 'False) ((C1 ('MetaCons "PInt" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PWord" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PInt64" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "PWord64" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PAddr" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "PFloat" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PDouble" 'PrefixI 'False) (U1 :: Type -> Type))))

class HasHeapRep (a :: TYPE rep) where Source #

Methods

getClosureData :: a -> IO Closure Source #

#### Instances

Instances details

HasHeapRep (a :: Type) # |
Instance details Defined in GHC.Exts.Heap Methods getClosureData :: a -> IO Closure Source #
HasHeapRep (a :: TYPE 'UnliftedRep) # |
Instance details Defined in GHC.Exts.Heap Methods getClosureData :: a -> IO Closure Source #
Int# ~ a => HasHeapRep (a :: TYPE 'IntRep) # |
Instance details Defined in GHC.Exts.Heap Methods getClosureData :: a -> IO Closure Source #
Word# ~ a => HasHeapRep (a :: TYPE 'WordRep) # |
Instance details Defined in GHC.Exts.Heap Methods getClosureData :: a -> IO Closure Source #
Int64# ~ a => HasHeapRep (a :: TYPE 'Int64Rep) # |
Instance details Defined in GHC.Exts.Heap Methods getClosureData :: a -> IO Closure Source #
Word64# ~ a => HasHeapRep (a :: TYPE 'Word64Rep) # |
Instance details Defined in GHC.Exts.Heap Methods getClosureData :: a -> IO Closure Source #
Addr# ~ a => HasHeapRep (a :: TYPE 'AddrRep) # |
Instance details Defined in GHC.Exts.Heap Methods getClosureData :: a -> IO Closure Source #
Float# ~ a => HasHeapRep (a :: TYPE 'FloatRep) # |
Instance details Defined in GHC.Exts.Heap Methods getClosureData :: a -> IO Closure Source #
Double# ~ a => HasHeapRep (a :: TYPE 'DoubleRep) # |
Instance details Defined in GHC.Exts.Heap Methods getClosureData :: a -> IO Closure Source #

# Info Table types

data StgInfoTable Source #

This is a somewhat faithful representation of an info table. See http://ghc.haskell.org/trac/ghc/browser/includes/rts/storage/InfoTables.h for more details on this data structure.

Constructors

StgInfoTable |
Fields entry :: Maybe EntryFunPtr ptrs :: HalfWord nptrs :: HalfWord tipe :: ClosureType srtlen :: HalfWord code :: Maybe ItblCodes

#### Instances

Instances details

Show StgInfoTable # |
Instance details Defined in GHC.Exts.Heap.InfoTable.Types Methods showsPrec :: Int -> StgInfoTable -> ShowS Source # show :: StgInfoTable -> String Source # showList :: [StgInfoTable] -> ShowS Source #
Generic StgInfoTable # |
Instance details Defined in GHC.Exts.Heap.InfoTable.Types Associated Types type Rep StgInfoTable :: Type -> Type Source # Methods from :: StgInfoTable -> Rep StgInfoTable x Source # to :: Rep StgInfoTable x -> StgInfoTable Source #
type Rep StgInfoTable # |
Instance details Defined in GHC.Exts.Heap.InfoTable.Types type Rep StgInfoTable = D1 ('MetaData "StgInfoTable" "GHC.Exts.Heap.InfoTable.Types" "ghc-heap-8.8.1" 'False) (C1 ('MetaCons "StgInfoTable" 'PrefixI 'True) ((S1 ('MetaSel ('Just "entry") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe EntryFunPtr)) :*: (S1 ('MetaSel ('Just "ptrs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HalfWord) :*: S1 ('MetaSel ('Just "nptrs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HalfWord))) :*: (S1 ('MetaSel ('Just "tipe") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ClosureType) :*: (S1 ('MetaSel ('Just "srtlen") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HalfWord) :*: S1 ('MetaSel ('Just "code") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ItblCodes))))))

type EntryFunPtr = FunPtr (Ptr () -> IO (Ptr ())) Source #

type HalfWord = Word32 Source #

type ItblCodes = Either [Word8] [Word32] Source #

itblSize :: Int Source #

Size in bytes of a standard InfoTable

peekItbl :: Ptr StgInfoTable -> IO StgInfoTable Source #

Read an InfoTable from the heap into a haskell type. WARNING: This code assumes it is passed a pointer to a "standard" info table. If tables_next_to_code is enabled, it will look 1 byte before the start for the entry field.

pokeItbl :: Ptr StgInfoTable -> StgInfoTable -> IO () Source #

# Closure inspection

getBoxedClosureData :: Box -> IO Closure Source #

Like `getClosureData`, but taking a `Box`, so it is easier to work with.

allClosures :: GenClosure b -> [b] Source #

For generic code, this function returns all referenced closures.

# Boxes

data Box Source #

An arbitrary 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 evaluate the argument.

Constructors

Box Any |

#### Instances

Instances details

Show Box # |
Instance details Defined in GHC.Exts.Heap.Closures Methods showsPrec :: Int -> Box -> ShowS Source # show :: Box -> String Source # showList :: [Box] -> ShowS Source #

asBox :: a -> Box Source #

This takes an arbitrary value and puts it into a box. Note that calls like

    asBox (head list)

will put the thunk "head list" into the box, not the element at the head of the list. For that, use careful case expressions:

    case list of x:_ -> asBox x

areBoxesEqual :: Box -> Box -> IO Bool Source #

Boxes can be compared, but this is not pure, as different heap objects can, after garbage collection, become the same object.