ghc-8.0.2: The GHC API

Safe Haskell | None
Language | Haskell2010

SMRep

Contents

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

Synopsis

- type WordOff = Int
- type ByteOff = Int
- wordsToBytes :: Num a => DynFlags -> a -> a
- bytesToWordsRoundUp :: DynFlags -> ByteOff -> WordOff
- roundUpToWords :: DynFlags -> ByteOff -> ByteOff
- data StgWord
- fromStgWord :: StgWord -> Integer
- toStgWord :: DynFlags -> Integer -> StgWord
- data StgHalfWord
- fromStgHalfWord :: StgHalfWord -> Integer
- toStgHalfWord :: DynFlags -> Integer -> StgHalfWord
- hALF_WORD_SIZE :: DynFlags -> ByteOff
- hALF_WORD_SIZE_IN_BITS :: DynFlags -> Int
- data SMRep
  - = HeapRep IsStatic !WordOff !WordOff ClosureTypeInfo
  - | ArrayPtrsRep !WordOff !WordOff
  - | SmallArrayPtrsRep !WordOff
  - | ArrayWordsRep !WordOff
  - | StackRep Liveness
  - | RTSRep Int SMRep
- type IsStatic = Bool
- data ClosureTypeInfo
  - = Constr ConstrTag ConstrDescription
  - | Fun FunArity ArgDescr
  - | Thunk
  - | ThunkSelector SelectorOffset
  - | BlackHole
  - | IndStatic
- data ArgDescr
  - = ArgSpec !Int
  - | ArgGen Liveness
- type Liveness = [Bool]
- type ConstrDescription = [Word8]
- mkHeapRep :: DynFlags -> IsStatic -> WordOff -> WordOff -> ClosureTypeInfo -> SMRep
- blackHoleRep :: SMRep
- indStaticRep :: SMRep
- mkStackRep :: [Bool] -> SMRep
- mkRTSRep :: Int -> SMRep -> SMRep
- arrPtrsRep :: DynFlags -> WordOff -> SMRep
- smallArrPtrsRep :: WordOff -> SMRep
- arrWordsRep :: DynFlags -> ByteOff -> SMRep
- isStaticRep :: SMRep -> IsStatic
- isConRep :: SMRep -> Bool
- isThunkRep :: SMRep -> Bool
- isFunRep :: SMRep -> Bool
- isStaticNoCafCon :: SMRep -> Bool
- isStackRep :: SMRep -> Bool
- heapClosureSizeW :: DynFlags -> SMRep -> WordOff
- fixedHdrSizeW :: DynFlags -> WordOff
- arrWordsHdrSize :: DynFlags -> ByteOff
- arrWordsHdrSizeW :: DynFlags -> WordOff
- arrPtrsHdrSize :: DynFlags -> ByteOff
- arrPtrsHdrSizeW :: DynFlags -> WordOff
- profHdrSize :: DynFlags -> WordOff
- thunkHdrSize :: DynFlags -> WordOff
- nonHdrSize :: DynFlags -> SMRep -> ByteOff
- nonHdrSizeW :: SMRep -> WordOff
- smallArrPtrsHdrSize :: DynFlags -> ByteOff
- smallArrPtrsHdrSizeW :: DynFlags -> WordOff
- hdrSize :: DynFlags -> SMRep -> ByteOff
- hdrSizeW :: DynFlags -> SMRep -> WordOff
- fixedHdrSize :: DynFlags -> ByteOff
- rtsClosureType :: SMRep -> Int
- rET_SMALL :: Int
- rET_BIG :: Int
- aRG_GEN :: Int
- aRG_GEN_BIG :: Int
- card :: DynFlags -> Int -> Int
- cardRoundUp :: DynFlags -> Int -> Int
- cardTableSizeB :: DynFlags -> Int -> ByteOff
- cardTableSizeW :: DynFlags -> Int -> WordOff
- pprWord8String :: [Word8] -> SDoc
- stringToWord8s :: String -> [Word8]

# Words and bytes

type WordOff = Int Source #

Word offset, or word count

type ByteOff = Int Source #

Byte offset, or byte count

wordsToBytes :: Num a => DynFlags -> a -> a Source #

Convert the given number of words to a number of bytes.

This function morally has type `WordOff -> ByteOff`, but uses `Num a` to allow for overloading.

bytesToWordsRoundUp :: DynFlags -> ByteOff -> WordOff Source #

First round the given byte count up to a multiple of the machine's word size and then convert the result to words.

roundUpToWords :: DynFlags -> ByteOff -> ByteOff Source #

Round up the given byte count to the next byte count that's a multiple of the machine's word size.

data StgWord Source #

Instances

Eq StgWord # |
Methods (==) :: StgWord -> StgWord -> Bool # (/=) :: StgWord -> StgWord -> Bool #
Bits StgWord # |
Methods (.&.) :: StgWord -> StgWord -> StgWord Source # (.|.) :: StgWord -> StgWord -> StgWord Source # xor :: StgWord -> StgWord -> StgWord Source # complement :: StgWord -> StgWord Source # shift :: StgWord -> Int -> StgWord Source # rotate :: StgWord -> Int -> StgWord Source # zeroBits :: StgWord Source # bit :: Int -> StgWord Source # setBit :: StgWord -> Int -> StgWord Source # clearBit :: StgWord -> Int -> StgWord Source # complementBit :: StgWord -> Int -> StgWord Source # testBit :: StgWord -> Int -> Bool Source # bitSizeMaybe :: StgWord -> Maybe Int Source # bitSize :: StgWord -> Int Source # isSigned :: StgWord -> Bool Source # shiftL :: StgWord -> Int -> StgWord Source # unsafeShiftL :: StgWord -> Int -> StgWord Source # shiftR :: StgWord -> Int -> StgWord Source # unsafeShiftR :: StgWord -> Int -> StgWord Source # rotateL :: StgWord -> Int -> StgWord Source # rotateR :: StgWord -> Int -> StgWord Source # popCount :: StgWord -> Int Source #
Outputable StgWord # |
Methods ppr :: StgWord -> SDoc Source # pprPrec :: Rational -> StgWord -> SDoc Source #

fromStgWord :: StgWord -> Integer Source #

toStgWord :: DynFlags -> Integer -> StgWord Source #

data StgHalfWord Source #

Instances

Eq StgHalfWord # |
Methods (==) :: StgHalfWord -> StgHalfWord -> Bool # (/=) :: StgHalfWord -> StgHalfWord -> Bool #
Outputable StgHalfWord # |
Methods ppr :: StgHalfWord -> SDoc Source # pprPrec :: Rational -> StgHalfWord -> SDoc Source #

fromStgHalfWord :: StgHalfWord -> Integer Source #

toStgHalfWord :: DynFlags -> Integer -> StgHalfWord Source #

hALF_WORD_SIZE :: DynFlags -> ByteOff Source #

hALF_WORD_SIZE_IN_BITS :: DynFlags -> Int Source #

# Closure repesentation

data SMRep Source #

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

Constructors

HeapRep IsStatic !WordOff !WordOff ClosureTypeInfo |
ArrayPtrsRep !WordOff !WordOff |
SmallArrayPtrsRep !WordOff |
ArrayWordsRep !WordOff |
StackRep Liveness |
RTSRep Int SMRep |

Instances

Outputable SMRep # |
Methods ppr :: SMRep -> SDoc Source # pprPrec :: Rational -> SMRep -> SDoc Source #

type IsStatic = Bool Source #

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 Source #

Constructors

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

Instances

Outputable ClosureTypeInfo # |
Methods ppr :: ClosureTypeInfo -> SDoc Source # pprPrec :: Rational -> ClosureTypeInfo -> SDoc Source #

data ArgDescr Source #

Constructors

ArgSpec !Int |
ArgGen Liveness |

Instances

Outputable ArgDescr # |
Methods ppr :: ArgDescr -> SDoc Source # pprPrec :: Rational -> ArgDescr -> SDoc Source #

type Liveness = [Bool] Source #

type ConstrDescription = [Word8] Source #

## Construction

mkHeapRep :: DynFlags -> IsStatic -> WordOff -> WordOff -> ClosureTypeInfo -> SMRep Source #

blackHoleRep :: SMRep Source #

indStaticRep :: SMRep Source #

mkStackRep :: [Bool] -> SMRep Source #

mkRTSRep :: Int -> SMRep -> SMRep Source #

arrPtrsRep :: DynFlags -> WordOff -> SMRep Source #

smallArrPtrsRep :: WordOff -> SMRep Source #

arrWordsRep :: DynFlags -> ByteOff -> SMRep Source #

## Predicates

isStaticRep :: SMRep -> IsStatic Source #

isConRep :: SMRep -> Bool Source #

isThunkRep :: SMRep -> Bool Source #

isFunRep :: SMRep -> Bool Source #

isStaticNoCafCon :: SMRep -> Bool Source #

isStackRep :: SMRep -> Bool Source #

## Size-related things

heapClosureSizeW :: DynFlags -> SMRep -> WordOff Source #

The total size of the closure, in words.

fixedHdrSizeW :: DynFlags -> WordOff Source #

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

arrWordsHdrSize :: DynFlags -> ByteOff Source #

arrWordsHdrSizeW :: DynFlags -> WordOff Source #

arrPtrsHdrSize :: DynFlags -> ByteOff Source #

arrPtrsHdrSizeW :: DynFlags -> WordOff Source #

profHdrSize :: DynFlags -> WordOff Source #

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

thunkHdrSize :: DynFlags -> WordOff Source #

nonHdrSize :: DynFlags -> SMRep -> ByteOff Source #

nonHdrSizeW :: SMRep -> WordOff Source #

smallArrPtrsHdrSize :: DynFlags -> ByteOff Source #

smallArrPtrsHdrSizeW :: DynFlags -> WordOff Source #

hdrSize :: DynFlags -> SMRep -> ByteOff Source #

hdrSizeW :: DynFlags -> SMRep -> WordOff Source #

fixedHdrSize :: DynFlags -> ByteOff Source #

## RTS closure types

rtsClosureType :: SMRep -> Int Source #

Derives the RTS closure type from an `SMRep`

rET_SMALL :: Int Source #

rET_BIG :: Int Source #

aRG_GEN :: Int Source #

aRG_GEN_BIG :: Int Source #

## Arrays

card :: DynFlags -> Int -> Int Source #

The byte offset into the card table of the card for a given element

cardRoundUp :: DynFlags -> Int -> Int Source #

Convert a number of elements to a number of cards, rounding up

cardTableSizeB :: DynFlags -> Int -> ByteOff Source #

The size of a card table, in bytes

cardTableSizeW :: DynFlags -> Int -> WordOff Source #

The size of a card table, in words

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

pprWord8String :: [Word8] -> SDoc Source #

stringToWord8s :: String -> [Word8] Source #