ghc-7.6.3: The GHC API

Safe Haskell | None

SMRep

Contents

- Words and bytes
- Closure repesentation
  - Construction
  - Predicates
  - Size-related things
  - RTS closure types
- Operations over [Word8] strings that don't belong here

Synopsis

- type StgWord = Word32
- type StgHalfWord = Word16
- hALF_WORD_SIZE :: ByteOff
- hALF_WORD_SIZE_IN_BITS :: Int
- type WordOff = Int
- type ByteOff = Int
- roundUpToWords :: ByteOff -> ByteOff
- data SMRep
  - = HeapRep IsStatic !WordOff !WordOff ClosureTypeInfo
  - | StackRep Liveness
  - | RTSRep StgHalfWord SMRep
- type IsStatic = Bool
- data ClosureTypeInfo
  - = Constr ConstrTag ConstrDescription
  - | Fun FunArity ArgDescr
  - | Thunk
  - | ThunkSelector SelectorOffset
  - | BlackHole
- data ArgDescr
  - = ArgSpec !StgHalfWord
  - | ArgGen Liveness
- type Liveness = [Bool]
- type ConstrDescription = [Word8]
- mkHeapRep :: IsStatic -> WordOff -> WordOff -> ClosureTypeInfo -> SMRep
- blackHoleRep :: SMRep
- mkStackRep :: [Bool] -> SMRep
- mkRTSRep :: StgHalfWord -> SMRep -> SMRep
- isStaticRep :: SMRep -> IsStatic
- isConRep :: SMRep -> Bool
- isThunkRep :: SMRep -> Bool
- isFunRep :: SMRep -> Bool
- isStaticNoCafCon :: SMRep -> Bool
- heapClosureSize :: SMRep -> WordOff
- fixedHdrSize :: WordOff
- arrWordsHdrSize :: ByteOff
- arrPtrsHdrSize :: ByteOff
- profHdrSize :: WordOff
- thunkHdrSize :: WordOff
- nonHdrSize :: SMRep -> WordOff
- rtsClosureType :: SMRep -> StgHalfWord
- rET_SMALL :: StgHalfWord
- rET_BIG :: StgHalfWord
- aRG_GEN :: StgHalfWord
- aRG_GEN_BIG :: StgHalfWord
- pprWord8String :: [Word8] -> SDoc
- stringToWord8s :: String -> [Word8]

# Words and bytes

type StgWord = Word32

type StgHalfWord = Word16

hALF_WORD_SIZE :: ByteOff

hALF_WORD_SIZE_IN_BITS :: Int

type WordOff = Int

type ByteOff = Int

roundUpToWords :: ByteOff -> ByteOff

# Closure repesentation

data SMRep

A description of the layout of a closure. Corresponds directly to the closure types in includesrtsstorage/ClosureTypes.h.

Constructors

HeapRep IsStatic !WordOff !WordOff ClosureTypeInfo |
StackRep Liveness |
RTSRep StgHalfWord SMRep |

Instances

Outputable SMRep |

type IsStatic = Bool

True = This is a static closure. Affects how we garbage-collect it. Static closure have an extra static link field at the end.

data ClosureTypeInfo

Constructors

Constr ConstrTag ConstrDescription |
Fun FunArity ArgDescr |
Thunk |
ThunkSelector SelectorOffset |
BlackHole |

Instances

Outputable ClosureTypeInfo |

data ArgDescr

Constructors

ArgSpec !StgHalfWord |
ArgGen Liveness |

Instances

Outputable ArgDescr |

type Liveness = [Bool]

type ConstrDescription = [Word8]

## Construction

mkHeapRep :: IsStatic -> WordOff -> WordOff -> ClosureTypeInfo -> SMRep

blackHoleRep :: SMRep

mkStackRep :: [Bool] -> SMRep

mkRTSRep :: StgHalfWord -> SMRep -> SMRep

## Predicates

isStaticRep :: SMRep -> IsStatic

isConRep :: SMRep -> Bool

isThunkRep :: SMRep -> Bool

isFunRep :: SMRep -> Bool

isStaticNoCafCon :: SMRep -> Bool

## Size-related things

heapClosureSize :: SMRep -> WordOff

fixedHdrSize :: WordOff

Size of a closure header (StgHeader in includesrtsstorage/Closures.h)

arrWordsHdrSize :: ByteOff

arrPtrsHdrSize :: ByteOff

profHdrSize :: WordOff

Size of the profiling part of a closure header (StgProfHeader in includesrtsstorage/Closures.h)

thunkHdrSize :: WordOff

nonHdrSize :: SMRep -> WordOff

## RTS closure types

rtsClosureType :: SMRep -> StgHalfWord

Derives the RTS closure type from an `SMRep`

rET_SMALL :: StgHalfWord

rET_BIG :: StgHalfWord

aRG_GEN :: StgHalfWord

aRG_GEN_BIG :: StgHalfWord

# Operations over [Word8] strings that don't belong here

pprWord8String :: [Word8] -> SDoc

stringToWord8s :: String -> [Word8]