Types.hsc 1.08 KB
Newer Older
1
{-# LANGUAGE DeriveGeneric #-}
patrickdoc's avatar
patrickdoc committed
2 3 4 5 6 7 8 9 10
module GHC.Exts.Heap.InfoTable.Types
    ( StgInfoTable(..)
    , EntryFunPtr
    , HalfWord
    , ItblCodes
    ) where

#include "Rts.h"

11
import Prelude -- See note [Why do we import Prelude here?]
12
import GHC.Generics
patrickdoc's avatar
patrickdoc committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
import GHC.Exts.Heap.ClosureTypes
import Foreign

type ItblCodes = Either [Word8] [Word32]

#include "ghcautoconf.h"
-- Ultra-minimalist version specially for constructors
#if SIZEOF_VOID_P == 8
type HalfWord = Word32
#elif SIZEOF_VOID_P == 4
type HalfWord = Word16
#else
#error Unknown SIZEOF_VOID_P
#endif

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

-- | This is a somewhat faithful representation of an info table. See
31
-- <https://gitlab.haskell.org/ghc/ghc/blob/master/includes/rts/storage/InfoTables.h>
patrickdoc's avatar
patrickdoc committed
32 33 34 35 36 37 38 39
-- for more details on this data structure.
data StgInfoTable = StgInfoTable {
   entry  :: Maybe EntryFunPtr, -- Just <=> not ghciTablesNextToCode
   ptrs   :: HalfWord,
   nptrs  :: HalfWord,
   tipe   :: ClosureType,
   srtlen :: HalfWord,
   code   :: Maybe ItblCodes -- Just <=> ghciTablesNextToCode
40
  } deriving (Show, Generic)