ghc-7.10.2: The GHC API

Safe HaskellNone
LanguageHaskell2010

SMRep

Contents

Synopsis

Words and bytes

type WordOff = Int

Word offset, or word count

type ByteOff = Int

Byte offset, or byte count

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

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

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

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

Closure repesentation

data SMRep

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

Instances

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 
IndStatic 

data ArgDescr

Constructors

ArgSpec !Int 
ArgGen Liveness 

Instances

type Liveness = [Bool]

Construction

Predicates

Size-related things

heapClosureSizeW :: DynFlags -> SMRep -> WordOff

The total size of the closure, in words.

fixedHdrSizeW :: DynFlags -> WordOff

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

profHdrSize :: DynFlags -> WordOff

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

RTS closure types

rtsClosureType :: SMRep -> Int

Derives the RTS closure type from an SMRep

Arrays

card :: DynFlags -> Int -> Int

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

cardRoundUp :: DynFlags -> Int -> Int

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

cardTableSizeB :: DynFlags -> Int -> ByteOff

The size of a card table, in bytes

cardTableSizeW :: DynFlags -> Int -> WordOff

The size of a card table, in words

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