{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE RecordWildCards            #-}
{-# LANGUAGE TypeApplications           #-}
--
--  (c) The University of Glasgow 2002-2006
--

-- | Bytecode assembler types
module GHC.ByteCode.Types
  ( CompiledByteCode(..), seqCompiledByteCode
  , FFIInfo(..)
  , RegBitmap(..)
  , TupleInfo(..), voidTupleInfo
  , ByteOff(..), WordOff(..)
  , UnlinkedBCO(..), BCOPtr(..), BCONPtr(..)
  , ItblEnv, ItblPtr(..)
  , CgBreakInfo(..)
  , ModBreaks (..), BreakIndex, emptyModBreaks
  , CCostCentre
  ) where

import GHC.Prelude

import GHC.Data.FastString
import GHC.Data.SizedSeq
import GHC.Types.Id
import GHC.Types.Name
import GHC.Types.Name.Env
import GHC.Utils.Outputable
import GHC.Builtin.PrimOps
import GHC.Core.Type
import GHC.Types.SrcLoc
import GHCi.BreakArray
import GHCi.RemoteTypes
import GHCi.FFI
import Control.DeepSeq

import Foreign
import Data.Array
import Data.Array.Base  ( UArray(..) )
import Data.ByteString (ByteString)
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap
import Data.Maybe (catMaybes)
import qualified GHC.Exts.Heap as Heap
import GHC.Stack.CCS
import GHC.Cmm.Expr ( GlobalRegSet, emptyRegSet, regSetToList )

-- -----------------------------------------------------------------------------
-- Compiled Byte Code

data CompiledByteCode = CompiledByteCode
  { CompiledByteCode -> [UnlinkedBCO]
bc_bcos   :: [UnlinkedBCO]  -- Bunch of interpretable bindings
  , CompiledByteCode -> ItblEnv
bc_itbls  :: ItblEnv        -- A mapping from DataCons to their itbls
  , CompiledByteCode -> [FFIInfo]
bc_ffis   :: [FFIInfo]      -- ffi blocks we allocated
  , CompiledByteCode -> [RemotePtr ()]
bc_strs   :: [RemotePtr ()] -- malloc'd strings
  , CompiledByteCode -> Maybe ModBreaks
bc_breaks :: Maybe ModBreaks -- breakpoint info (Nothing if we're not
                                 -- creating breakpoints, for some reason)
  }
                -- ToDo: we're not tracking strings that we malloc'd
newtype FFIInfo = FFIInfo (RemotePtr C_ffi_cif)
  deriving (BreakIndex -> FFIInfo -> ShowS
[FFIInfo] -> ShowS
FFIInfo -> String
(BreakIndex -> FFIInfo -> ShowS)
-> (FFIInfo -> String) -> ([FFIInfo] -> ShowS) -> Show FFIInfo
forall a.
(BreakIndex -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: BreakIndex -> FFIInfo -> ShowS
showsPrec :: BreakIndex -> FFIInfo -> ShowS
$cshow :: FFIInfo -> String
show :: FFIInfo -> String
$cshowList :: [FFIInfo] -> ShowS
showList :: [FFIInfo] -> ShowS
Show, FFIInfo -> ()
(FFIInfo -> ()) -> NFData FFIInfo
forall a. (a -> ()) -> NFData a
$crnf :: FFIInfo -> ()
rnf :: FFIInfo -> ()
NFData)

instance Outputable CompiledByteCode where
  ppr :: CompiledByteCode -> SDoc
ppr CompiledByteCode{[RemotePtr ()]
[UnlinkedBCO]
[FFIInfo]
Maybe ModBreaks
ItblEnv
bc_bcos :: CompiledByteCode -> [UnlinkedBCO]
bc_itbls :: CompiledByteCode -> ItblEnv
bc_ffis :: CompiledByteCode -> [FFIInfo]
bc_strs :: CompiledByteCode -> [RemotePtr ()]
bc_breaks :: CompiledByteCode -> Maybe ModBreaks
bc_bcos :: [UnlinkedBCO]
bc_itbls :: ItblEnv
bc_ffis :: [FFIInfo]
bc_strs :: [RemotePtr ()]
bc_breaks :: Maybe ModBreaks
..} = [UnlinkedBCO] -> SDoc
forall a. Outputable a => a -> SDoc
ppr [UnlinkedBCO]
bc_bcos

-- Not a real NFData instance, because ModBreaks contains some things
-- we can't rnf
seqCompiledByteCode :: CompiledByteCode -> ()
seqCompiledByteCode :: CompiledByteCode -> ()
seqCompiledByteCode CompiledByteCode{[RemotePtr ()]
[UnlinkedBCO]
[FFIInfo]
Maybe ModBreaks
ItblEnv
bc_bcos :: CompiledByteCode -> [UnlinkedBCO]
bc_itbls :: CompiledByteCode -> ItblEnv
bc_ffis :: CompiledByteCode -> [FFIInfo]
bc_strs :: CompiledByteCode -> [RemotePtr ()]
bc_breaks :: CompiledByteCode -> Maybe ModBreaks
bc_bcos :: [UnlinkedBCO]
bc_itbls :: ItblEnv
bc_ffis :: [FFIInfo]
bc_strs :: [RemotePtr ()]
bc_breaks :: Maybe ModBreaks
..} =
  [UnlinkedBCO] -> ()
forall a. NFData a => a -> ()
rnf [UnlinkedBCO]
bc_bcos () -> () -> ()
forall a b. a -> b -> b
`seq`
  ((Name, ItblPtr) -> ()) -> ItblEnv -> ()
forall elt. (elt -> ()) -> NameEnv elt -> ()
seqEltsNameEnv (Name, ItblPtr) -> ()
forall a. NFData a => a -> ()
rnf ItblEnv
bc_itbls () -> () -> ()
forall a b. a -> b -> b
`seq`
  [FFIInfo] -> ()
forall a. NFData a => a -> ()
rnf [FFIInfo]
bc_ffis () -> () -> ()
forall a b. a -> b -> b
`seq`
  [RemotePtr ()] -> ()
forall a. NFData a => a -> ()
rnf [RemotePtr ()]
bc_strs () -> () -> ()
forall a b. a -> b -> b
`seq`
  Maybe () -> ()
forall a. NFData a => a -> ()
rnf ((ModBreaks -> ()) -> Maybe ModBreaks -> Maybe ()
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ModBreaks -> ()
seqModBreaks Maybe ModBreaks
bc_breaks)

newtype ByteOff = ByteOff Int
    deriving (BreakIndex -> ByteOff
ByteOff -> BreakIndex
ByteOff -> [ByteOff]
ByteOff -> ByteOff
ByteOff -> ByteOff -> [ByteOff]
ByteOff -> ByteOff -> ByteOff -> [ByteOff]
(ByteOff -> ByteOff)
-> (ByteOff -> ByteOff)
-> (BreakIndex -> ByteOff)
-> (ByteOff -> BreakIndex)
-> (ByteOff -> [ByteOff])
-> (ByteOff -> ByteOff -> [ByteOff])
-> (ByteOff -> ByteOff -> [ByteOff])
-> (ByteOff -> ByteOff -> ByteOff -> [ByteOff])
-> Enum ByteOff
forall a.
(a -> a)
-> (a -> a)
-> (BreakIndex -> a)
-> (a -> BreakIndex)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: ByteOff -> ByteOff
succ :: ByteOff -> ByteOff
$cpred :: ByteOff -> ByteOff
pred :: ByteOff -> ByteOff
$ctoEnum :: BreakIndex -> ByteOff
toEnum :: BreakIndex -> ByteOff
$cfromEnum :: ByteOff -> BreakIndex
fromEnum :: ByteOff -> BreakIndex
$cenumFrom :: ByteOff -> [ByteOff]
enumFrom :: ByteOff -> [ByteOff]
$cenumFromThen :: ByteOff -> ByteOff -> [ByteOff]
enumFromThen :: ByteOff -> ByteOff -> [ByteOff]
$cenumFromTo :: ByteOff -> ByteOff -> [ByteOff]
enumFromTo :: ByteOff -> ByteOff -> [ByteOff]
$cenumFromThenTo :: ByteOff -> ByteOff -> ByteOff -> [ByteOff]
enumFromThenTo :: ByteOff -> ByteOff -> ByteOff -> [ByteOff]
Enum, ByteOff -> ByteOff -> Bool
(ByteOff -> ByteOff -> Bool)
-> (ByteOff -> ByteOff -> Bool) -> Eq ByteOff
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ByteOff -> ByteOff -> Bool
== :: ByteOff -> ByteOff -> Bool
$c/= :: ByteOff -> ByteOff -> Bool
/= :: ByteOff -> ByteOff -> Bool
Eq, BreakIndex -> ByteOff -> ShowS
[ByteOff] -> ShowS
ByteOff -> String
(BreakIndex -> ByteOff -> ShowS)
-> (ByteOff -> String) -> ([ByteOff] -> ShowS) -> Show ByteOff
forall a.
(BreakIndex -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: BreakIndex -> ByteOff -> ShowS
showsPrec :: BreakIndex -> ByteOff -> ShowS
$cshow :: ByteOff -> String
show :: ByteOff -> String
$cshowList :: [ByteOff] -> ShowS
showList :: [ByteOff] -> ShowS
Show, Enum ByteOff
Real ByteOff
(Real ByteOff, Enum ByteOff) =>
(ByteOff -> ByteOff -> ByteOff)
-> (ByteOff -> ByteOff -> ByteOff)
-> (ByteOff -> ByteOff -> ByteOff)
-> (ByteOff -> ByteOff -> ByteOff)
-> (ByteOff -> ByteOff -> (ByteOff, ByteOff))
-> (ByteOff -> ByteOff -> (ByteOff, ByteOff))
-> (ByteOff -> Integer)
-> Integral ByteOff
ByteOff -> Integer
ByteOff -> ByteOff -> (ByteOff, ByteOff)
ByteOff -> ByteOff -> ByteOff
forall a.
(Real a, Enum a) =>
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
$cquot :: ByteOff -> ByteOff -> ByteOff
quot :: ByteOff -> ByteOff -> ByteOff
$crem :: ByteOff -> ByteOff -> ByteOff
rem :: ByteOff -> ByteOff -> ByteOff
$cdiv :: ByteOff -> ByteOff -> ByteOff
div :: ByteOff -> ByteOff -> ByteOff
$cmod :: ByteOff -> ByteOff -> ByteOff
mod :: ByteOff -> ByteOff -> ByteOff
$cquotRem :: ByteOff -> ByteOff -> (ByteOff, ByteOff)
quotRem :: ByteOff -> ByteOff -> (ByteOff, ByteOff)
$cdivMod :: ByteOff -> ByteOff -> (ByteOff, ByteOff)
divMod :: ByteOff -> ByteOff -> (ByteOff, ByteOff)
$ctoInteger :: ByteOff -> Integer
toInteger :: ByteOff -> Integer
Integral, Integer -> ByteOff
ByteOff -> ByteOff
ByteOff -> ByteOff -> ByteOff
(ByteOff -> ByteOff -> ByteOff)
-> (ByteOff -> ByteOff -> ByteOff)
-> (ByteOff -> ByteOff -> ByteOff)
-> (ByteOff -> ByteOff)
-> (ByteOff -> ByteOff)
-> (ByteOff -> ByteOff)
-> (Integer -> ByteOff)
-> Num ByteOff
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: ByteOff -> ByteOff -> ByteOff
+ :: ByteOff -> ByteOff -> ByteOff
$c- :: ByteOff -> ByteOff -> ByteOff
- :: ByteOff -> ByteOff -> ByteOff
$c* :: ByteOff -> ByteOff -> ByteOff
* :: ByteOff -> ByteOff -> ByteOff
$cnegate :: ByteOff -> ByteOff
negate :: ByteOff -> ByteOff
$cabs :: ByteOff -> ByteOff
abs :: ByteOff -> ByteOff
$csignum :: ByteOff -> ByteOff
signum :: ByteOff -> ByteOff
$cfromInteger :: Integer -> ByteOff
fromInteger :: Integer -> ByteOff
Num, Eq ByteOff
Eq ByteOff =>
(ByteOff -> ByteOff -> Ordering)
-> (ByteOff -> ByteOff -> Bool)
-> (ByteOff -> ByteOff -> Bool)
-> (ByteOff -> ByteOff -> Bool)
-> (ByteOff -> ByteOff -> Bool)
-> (ByteOff -> ByteOff -> ByteOff)
-> (ByteOff -> ByteOff -> ByteOff)
-> Ord ByteOff
ByteOff -> ByteOff -> Bool
ByteOff -> ByteOff -> Ordering
ByteOff -> ByteOff -> ByteOff
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ByteOff -> ByteOff -> Ordering
compare :: ByteOff -> ByteOff -> Ordering
$c< :: ByteOff -> ByteOff -> Bool
< :: ByteOff -> ByteOff -> Bool
$c<= :: ByteOff -> ByteOff -> Bool
<= :: ByteOff -> ByteOff -> Bool
$c> :: ByteOff -> ByteOff -> Bool
> :: ByteOff -> ByteOff -> Bool
$c>= :: ByteOff -> ByteOff -> Bool
>= :: ByteOff -> ByteOff -> Bool
$cmax :: ByteOff -> ByteOff -> ByteOff
max :: ByteOff -> ByteOff -> ByteOff
$cmin :: ByteOff -> ByteOff -> ByteOff
min :: ByteOff -> ByteOff -> ByteOff
Ord, Num ByteOff
Ord ByteOff
(Num ByteOff, Ord ByteOff) => (ByteOff -> Rational) -> Real ByteOff
ByteOff -> Rational
forall a. (Num a, Ord a) => (a -> Rational) -> Real a
$ctoRational :: ByteOff -> Rational
toRational :: ByteOff -> Rational
Real, ByteOff -> SDoc
(ByteOff -> SDoc) -> Outputable ByteOff
forall a. (a -> SDoc) -> Outputable a
$cppr :: ByteOff -> SDoc
ppr :: ByteOff -> SDoc
Outputable)

newtype WordOff = WordOff Int
    deriving (BreakIndex -> WordOff
WordOff -> BreakIndex
WordOff -> [WordOff]
WordOff -> WordOff
WordOff -> WordOff -> [WordOff]
WordOff -> WordOff -> WordOff -> [WordOff]
(WordOff -> WordOff)
-> (WordOff -> WordOff)
-> (BreakIndex -> WordOff)
-> (WordOff -> BreakIndex)
-> (WordOff -> [WordOff])
-> (WordOff -> WordOff -> [WordOff])
-> (WordOff -> WordOff -> [WordOff])
-> (WordOff -> WordOff -> WordOff -> [WordOff])
-> Enum WordOff
forall a.
(a -> a)
-> (a -> a)
-> (BreakIndex -> a)
-> (a -> BreakIndex)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: WordOff -> WordOff
succ :: WordOff -> WordOff
$cpred :: WordOff -> WordOff
pred :: WordOff -> WordOff
$ctoEnum :: BreakIndex -> WordOff
toEnum :: BreakIndex -> WordOff
$cfromEnum :: WordOff -> BreakIndex
fromEnum :: WordOff -> BreakIndex
$cenumFrom :: WordOff -> [WordOff]
enumFrom :: WordOff -> [WordOff]
$cenumFromThen :: WordOff -> WordOff -> [WordOff]
enumFromThen :: WordOff -> WordOff -> [WordOff]
$cenumFromTo :: WordOff -> WordOff -> [WordOff]
enumFromTo :: WordOff -> WordOff -> [WordOff]
$cenumFromThenTo :: WordOff -> WordOff -> WordOff -> [WordOff]
enumFromThenTo :: WordOff -> WordOff -> WordOff -> [WordOff]
Enum, WordOff -> WordOff -> Bool
(WordOff -> WordOff -> Bool)
-> (WordOff -> WordOff -> Bool) -> Eq WordOff
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: WordOff -> WordOff -> Bool
== :: WordOff -> WordOff -> Bool
$c/= :: WordOff -> WordOff -> Bool
/= :: WordOff -> WordOff -> Bool
Eq, BreakIndex -> WordOff -> ShowS
[WordOff] -> ShowS
WordOff -> String
(BreakIndex -> WordOff -> ShowS)
-> (WordOff -> String) -> ([WordOff] -> ShowS) -> Show WordOff
forall a.
(BreakIndex -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: BreakIndex -> WordOff -> ShowS
showsPrec :: BreakIndex -> WordOff -> ShowS
$cshow :: WordOff -> String
show :: WordOff -> String
$cshowList :: [WordOff] -> ShowS
showList :: [WordOff] -> ShowS
Show, Enum WordOff
Real WordOff
(Real WordOff, Enum WordOff) =>
(WordOff -> WordOff -> WordOff)
-> (WordOff -> WordOff -> WordOff)
-> (WordOff -> WordOff -> WordOff)
-> (WordOff -> WordOff -> WordOff)
-> (WordOff -> WordOff -> (WordOff, WordOff))
-> (WordOff -> WordOff -> (WordOff, WordOff))
-> (WordOff -> Integer)
-> Integral WordOff
WordOff -> Integer
WordOff -> WordOff -> (WordOff, WordOff)
WordOff -> WordOff -> WordOff
forall a.
(Real a, Enum a) =>
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
$cquot :: WordOff -> WordOff -> WordOff
quot :: WordOff -> WordOff -> WordOff
$crem :: WordOff -> WordOff -> WordOff
rem :: WordOff -> WordOff -> WordOff
$cdiv :: WordOff -> WordOff -> WordOff
div :: WordOff -> WordOff -> WordOff
$cmod :: WordOff -> WordOff -> WordOff
mod :: WordOff -> WordOff -> WordOff
$cquotRem :: WordOff -> WordOff -> (WordOff, WordOff)
quotRem :: WordOff -> WordOff -> (WordOff, WordOff)
$cdivMod :: WordOff -> WordOff -> (WordOff, WordOff)
divMod :: WordOff -> WordOff -> (WordOff, WordOff)
$ctoInteger :: WordOff -> Integer
toInteger :: WordOff -> Integer
Integral, Integer -> WordOff
WordOff -> WordOff
WordOff -> WordOff -> WordOff
(WordOff -> WordOff -> WordOff)
-> (WordOff -> WordOff -> WordOff)
-> (WordOff -> WordOff -> WordOff)
-> (WordOff -> WordOff)
-> (WordOff -> WordOff)
-> (WordOff -> WordOff)
-> (Integer -> WordOff)
-> Num WordOff
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: WordOff -> WordOff -> WordOff
+ :: WordOff -> WordOff -> WordOff
$c- :: WordOff -> WordOff -> WordOff
- :: WordOff -> WordOff -> WordOff
$c* :: WordOff -> WordOff -> WordOff
* :: WordOff -> WordOff -> WordOff
$cnegate :: WordOff -> WordOff
negate :: WordOff -> WordOff
$cabs :: WordOff -> WordOff
abs :: WordOff -> WordOff
$csignum :: WordOff -> WordOff
signum :: WordOff -> WordOff
$cfromInteger :: Integer -> WordOff
fromInteger :: Integer -> WordOff
Num, Eq WordOff
Eq WordOff =>
(WordOff -> WordOff -> Ordering)
-> (WordOff -> WordOff -> Bool)
-> (WordOff -> WordOff -> Bool)
-> (WordOff -> WordOff -> Bool)
-> (WordOff -> WordOff -> Bool)
-> (WordOff -> WordOff -> WordOff)
-> (WordOff -> WordOff -> WordOff)
-> Ord WordOff
WordOff -> WordOff -> Bool
WordOff -> WordOff -> Ordering
WordOff -> WordOff -> WordOff
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: WordOff -> WordOff -> Ordering
compare :: WordOff -> WordOff -> Ordering
$c< :: WordOff -> WordOff -> Bool
< :: WordOff -> WordOff -> Bool
$c<= :: WordOff -> WordOff -> Bool
<= :: WordOff -> WordOff -> Bool
$c> :: WordOff -> WordOff -> Bool
> :: WordOff -> WordOff -> Bool
$c>= :: WordOff -> WordOff -> Bool
>= :: WordOff -> WordOff -> Bool
$cmax :: WordOff -> WordOff -> WordOff
max :: WordOff -> WordOff -> WordOff
$cmin :: WordOff -> WordOff -> WordOff
min :: WordOff -> WordOff -> WordOff
Ord, Num WordOff
Ord WordOff
(Num WordOff, Ord WordOff) => (WordOff -> Rational) -> Real WordOff
WordOff -> Rational
forall a. (Num a, Ord a) => (a -> Rational) -> Real a
$ctoRational :: WordOff -> Rational
toRational :: WordOff -> Rational
Real, WordOff -> SDoc
(WordOff -> SDoc) -> Outputable WordOff
forall a. (a -> SDoc) -> Outputable a
$cppr :: WordOff -> SDoc
ppr :: WordOff -> SDoc
Outputable)

newtype RegBitmap = RegBitmap { RegBitmap -> Word32
unRegBitmap :: Word32 }
    deriving (BreakIndex -> RegBitmap
RegBitmap -> BreakIndex
RegBitmap -> [RegBitmap]
RegBitmap -> RegBitmap
RegBitmap -> RegBitmap -> [RegBitmap]
RegBitmap -> RegBitmap -> RegBitmap -> [RegBitmap]
(RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap)
-> (BreakIndex -> RegBitmap)
-> (RegBitmap -> BreakIndex)
-> (RegBitmap -> [RegBitmap])
-> (RegBitmap -> RegBitmap -> [RegBitmap])
-> (RegBitmap -> RegBitmap -> [RegBitmap])
-> (RegBitmap -> RegBitmap -> RegBitmap -> [RegBitmap])
-> Enum RegBitmap
forall a.
(a -> a)
-> (a -> a)
-> (BreakIndex -> a)
-> (a -> BreakIndex)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: RegBitmap -> RegBitmap
succ :: RegBitmap -> RegBitmap
$cpred :: RegBitmap -> RegBitmap
pred :: RegBitmap -> RegBitmap
$ctoEnum :: BreakIndex -> RegBitmap
toEnum :: BreakIndex -> RegBitmap
$cfromEnum :: RegBitmap -> BreakIndex
fromEnum :: RegBitmap -> BreakIndex
$cenumFrom :: RegBitmap -> [RegBitmap]
enumFrom :: RegBitmap -> [RegBitmap]
$cenumFromThen :: RegBitmap -> RegBitmap -> [RegBitmap]
enumFromThen :: RegBitmap -> RegBitmap -> [RegBitmap]
$cenumFromTo :: RegBitmap -> RegBitmap -> [RegBitmap]
enumFromTo :: RegBitmap -> RegBitmap -> [RegBitmap]
$cenumFromThenTo :: RegBitmap -> RegBitmap -> RegBitmap -> [RegBitmap]
enumFromThenTo :: RegBitmap -> RegBitmap -> RegBitmap -> [RegBitmap]
Enum, RegBitmap -> RegBitmap -> Bool
(RegBitmap -> RegBitmap -> Bool)
-> (RegBitmap -> RegBitmap -> Bool) -> Eq RegBitmap
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RegBitmap -> RegBitmap -> Bool
== :: RegBitmap -> RegBitmap -> Bool
$c/= :: RegBitmap -> RegBitmap -> Bool
/= :: RegBitmap -> RegBitmap -> Bool
Eq, BreakIndex -> RegBitmap -> ShowS
[RegBitmap] -> ShowS
RegBitmap -> String
(BreakIndex -> RegBitmap -> ShowS)
-> (RegBitmap -> String)
-> ([RegBitmap] -> ShowS)
-> Show RegBitmap
forall a.
(BreakIndex -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: BreakIndex -> RegBitmap -> ShowS
showsPrec :: BreakIndex -> RegBitmap -> ShowS
$cshow :: RegBitmap -> String
show :: RegBitmap -> String
$cshowList :: [RegBitmap] -> ShowS
showList :: [RegBitmap] -> ShowS
Show, Enum RegBitmap
Real RegBitmap
(Real RegBitmap, Enum RegBitmap) =>
(RegBitmap -> RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap -> (RegBitmap, RegBitmap))
-> (RegBitmap -> RegBitmap -> (RegBitmap, RegBitmap))
-> (RegBitmap -> Integer)
-> Integral RegBitmap
RegBitmap -> Integer
RegBitmap -> RegBitmap -> (RegBitmap, RegBitmap)
RegBitmap -> RegBitmap -> RegBitmap
forall a.
(Real a, Enum a) =>
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
$cquot :: RegBitmap -> RegBitmap -> RegBitmap
quot :: RegBitmap -> RegBitmap -> RegBitmap
$crem :: RegBitmap -> RegBitmap -> RegBitmap
rem :: RegBitmap -> RegBitmap -> RegBitmap
$cdiv :: RegBitmap -> RegBitmap -> RegBitmap
div :: RegBitmap -> RegBitmap -> RegBitmap
$cmod :: RegBitmap -> RegBitmap -> RegBitmap
mod :: RegBitmap -> RegBitmap -> RegBitmap
$cquotRem :: RegBitmap -> RegBitmap -> (RegBitmap, RegBitmap)
quotRem :: RegBitmap -> RegBitmap -> (RegBitmap, RegBitmap)
$cdivMod :: RegBitmap -> RegBitmap -> (RegBitmap, RegBitmap)
divMod :: RegBitmap -> RegBitmap -> (RegBitmap, RegBitmap)
$ctoInteger :: RegBitmap -> Integer
toInteger :: RegBitmap -> Integer
Integral, Integer -> RegBitmap
RegBitmap -> RegBitmap
RegBitmap -> RegBitmap -> RegBitmap
(RegBitmap -> RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap)
-> (Integer -> RegBitmap)
-> Num RegBitmap
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: RegBitmap -> RegBitmap -> RegBitmap
+ :: RegBitmap -> RegBitmap -> RegBitmap
$c- :: RegBitmap -> RegBitmap -> RegBitmap
- :: RegBitmap -> RegBitmap -> RegBitmap
$c* :: RegBitmap -> RegBitmap -> RegBitmap
* :: RegBitmap -> RegBitmap -> RegBitmap
$cnegate :: RegBitmap -> RegBitmap
negate :: RegBitmap -> RegBitmap
$cabs :: RegBitmap -> RegBitmap
abs :: RegBitmap -> RegBitmap
$csignum :: RegBitmap -> RegBitmap
signum :: RegBitmap -> RegBitmap
$cfromInteger :: Integer -> RegBitmap
fromInteger :: Integer -> RegBitmap
Num, Eq RegBitmap
Eq RegBitmap =>
(RegBitmap -> RegBitmap -> Ordering)
-> (RegBitmap -> RegBitmap -> Bool)
-> (RegBitmap -> RegBitmap -> Bool)
-> (RegBitmap -> RegBitmap -> Bool)
-> (RegBitmap -> RegBitmap -> Bool)
-> (RegBitmap -> RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap -> RegBitmap)
-> Ord RegBitmap
RegBitmap -> RegBitmap -> Bool
RegBitmap -> RegBitmap -> Ordering
RegBitmap -> RegBitmap -> RegBitmap
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: RegBitmap -> RegBitmap -> Ordering
compare :: RegBitmap -> RegBitmap -> Ordering
$c< :: RegBitmap -> RegBitmap -> Bool
< :: RegBitmap -> RegBitmap -> Bool
$c<= :: RegBitmap -> RegBitmap -> Bool
<= :: RegBitmap -> RegBitmap -> Bool
$c> :: RegBitmap -> RegBitmap -> Bool
> :: RegBitmap -> RegBitmap -> Bool
$c>= :: RegBitmap -> RegBitmap -> Bool
>= :: RegBitmap -> RegBitmap -> Bool
$cmax :: RegBitmap -> RegBitmap -> RegBitmap
max :: RegBitmap -> RegBitmap -> RegBitmap
$cmin :: RegBitmap -> RegBitmap -> RegBitmap
min :: RegBitmap -> RegBitmap -> RegBitmap
Ord, Num RegBitmap
Ord RegBitmap
(Num RegBitmap, Ord RegBitmap) =>
(RegBitmap -> Rational) -> Real RegBitmap
RegBitmap -> Rational
forall a. (Num a, Ord a) => (a -> Rational) -> Real a
$ctoRational :: RegBitmap -> Rational
toRational :: RegBitmap -> Rational
Real, Eq RegBitmap
RegBitmap
Eq RegBitmap =>
(RegBitmap -> RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap -> RegBitmap)
-> (RegBitmap -> RegBitmap)
-> (RegBitmap -> BreakIndex -> RegBitmap)
-> (RegBitmap -> BreakIndex -> RegBitmap)
-> RegBitmap
-> (BreakIndex -> RegBitmap)
-> (RegBitmap -> BreakIndex -> RegBitmap)
-> (RegBitmap -> BreakIndex -> RegBitmap)
-> (RegBitmap -> BreakIndex -> RegBitmap)
-> (RegBitmap -> BreakIndex -> Bool)
-> (RegBitmap -> Maybe BreakIndex)
-> (RegBitmap -> BreakIndex)
-> (RegBitmap -> Bool)
-> (RegBitmap -> BreakIndex -> RegBitmap)
-> (RegBitmap -> BreakIndex -> RegBitmap)
-> (RegBitmap -> BreakIndex -> RegBitmap)
-> (RegBitmap -> BreakIndex -> RegBitmap)
-> (RegBitmap -> BreakIndex -> RegBitmap)
-> (RegBitmap -> BreakIndex -> RegBitmap)
-> (RegBitmap -> BreakIndex)
-> Bits RegBitmap
BreakIndex -> RegBitmap
RegBitmap -> Bool
RegBitmap -> BreakIndex
RegBitmap -> Maybe BreakIndex
RegBitmap -> RegBitmap
RegBitmap -> BreakIndex -> Bool
RegBitmap -> BreakIndex -> RegBitmap
RegBitmap -> RegBitmap -> RegBitmap
forall a.
Eq a =>
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> BreakIndex -> a)
-> (a -> BreakIndex -> a)
-> a
-> (BreakIndex -> a)
-> (a -> BreakIndex -> a)
-> (a -> BreakIndex -> a)
-> (a -> BreakIndex -> a)
-> (a -> BreakIndex -> Bool)
-> (a -> Maybe BreakIndex)
-> (a -> BreakIndex)
-> (a -> Bool)
-> (a -> BreakIndex -> a)
-> (a -> BreakIndex -> a)
-> (a -> BreakIndex -> a)
-> (a -> BreakIndex -> a)
-> (a -> BreakIndex -> a)
-> (a -> BreakIndex -> a)
-> (a -> BreakIndex)
-> Bits a
$c.&. :: RegBitmap -> RegBitmap -> RegBitmap
.&. :: RegBitmap -> RegBitmap -> RegBitmap
$c.|. :: RegBitmap -> RegBitmap -> RegBitmap
.|. :: RegBitmap -> RegBitmap -> RegBitmap
$cxor :: RegBitmap -> RegBitmap -> RegBitmap
xor :: RegBitmap -> RegBitmap -> RegBitmap
$ccomplement :: RegBitmap -> RegBitmap
complement :: RegBitmap -> RegBitmap
$cshift :: RegBitmap -> BreakIndex -> RegBitmap
shift :: RegBitmap -> BreakIndex -> RegBitmap
$crotate :: RegBitmap -> BreakIndex -> RegBitmap
rotate :: RegBitmap -> BreakIndex -> RegBitmap
$czeroBits :: RegBitmap
zeroBits :: RegBitmap
$cbit :: BreakIndex -> RegBitmap
bit :: BreakIndex -> RegBitmap
$csetBit :: RegBitmap -> BreakIndex -> RegBitmap
setBit :: RegBitmap -> BreakIndex -> RegBitmap
$cclearBit :: RegBitmap -> BreakIndex -> RegBitmap
clearBit :: RegBitmap -> BreakIndex -> RegBitmap
$ccomplementBit :: RegBitmap -> BreakIndex -> RegBitmap
complementBit :: RegBitmap -> BreakIndex -> RegBitmap
$ctestBit :: RegBitmap -> BreakIndex -> Bool
testBit :: RegBitmap -> BreakIndex -> Bool
$cbitSizeMaybe :: RegBitmap -> Maybe BreakIndex
bitSizeMaybe :: RegBitmap -> Maybe BreakIndex
$cbitSize :: RegBitmap -> BreakIndex
bitSize :: RegBitmap -> BreakIndex
$cisSigned :: RegBitmap -> Bool
isSigned :: RegBitmap -> Bool
$cshiftL :: RegBitmap -> BreakIndex -> RegBitmap
shiftL :: RegBitmap -> BreakIndex -> RegBitmap
$cunsafeShiftL :: RegBitmap -> BreakIndex -> RegBitmap
unsafeShiftL :: RegBitmap -> BreakIndex -> RegBitmap
$cshiftR :: RegBitmap -> BreakIndex -> RegBitmap
shiftR :: RegBitmap -> BreakIndex -> RegBitmap
$cunsafeShiftR :: RegBitmap -> BreakIndex -> RegBitmap
unsafeShiftR :: RegBitmap -> BreakIndex -> RegBitmap
$crotateL :: RegBitmap -> BreakIndex -> RegBitmap
rotateL :: RegBitmap -> BreakIndex -> RegBitmap
$crotateR :: RegBitmap -> BreakIndex -> RegBitmap
rotateR :: RegBitmap -> BreakIndex -> RegBitmap
$cpopCount :: RegBitmap -> BreakIndex
popCount :: RegBitmap -> BreakIndex
Bits, Bits RegBitmap
Bits RegBitmap =>
(RegBitmap -> BreakIndex)
-> (RegBitmap -> BreakIndex)
-> (RegBitmap -> BreakIndex)
-> FiniteBits RegBitmap
RegBitmap -> BreakIndex
forall b.
Bits b =>
(b -> BreakIndex)
-> (b -> BreakIndex) -> (b -> BreakIndex) -> FiniteBits b
$cfiniteBitSize :: RegBitmap -> BreakIndex
finiteBitSize :: RegBitmap -> BreakIndex
$ccountLeadingZeros :: RegBitmap -> BreakIndex
countLeadingZeros :: RegBitmap -> BreakIndex
$ccountTrailingZeros :: RegBitmap -> BreakIndex
countTrailingZeros :: RegBitmap -> BreakIndex
FiniteBits, RegBitmap -> SDoc
(RegBitmap -> SDoc) -> Outputable RegBitmap
forall a. (a -> SDoc) -> Outputable a
$cppr :: RegBitmap -> SDoc
ppr :: RegBitmap -> SDoc
Outputable)

{- Note [GHCi TupleInfo]
~~~~~~~~~~~~~~~~~~~~~~~~
   This contains the data we need for passing unboxed tuples between
   bytecode and native code

   In general we closely follow the native calling convention that
   GHC uses for unboxed tuples, but we don't use any registers in
   bytecode. All tuple elements are expanded to use a full register
   or a full word on the stack.

   The position of tuple elements that are returned on the stack in
   the native calling convention is unchanged when returning the same
   tuple in bytecode.

   The order of the remaining elements is determined by the register in
   which they would have been returned, rather than by their position in
   the tuple in the Haskell source code. This makes jumping between bytecode
   and native code easier: A map of live registers is enough to convert the
   tuple.

   See GHC.StgToByteCode.layoutTuple for more details.
-}
data TupleInfo = TupleInfo
  { TupleInfo -> WordOff
tupleSize            :: !WordOff   -- total size of tuple in words
  , TupleInfo -> GlobalRegSet
tupleRegs            :: !GlobalRegSet
  , TupleInfo -> WordOff
tupleNativeStackSize :: !WordOff {- words spilled on the stack by
                                        GHCs native calling convention -}
  } deriving (BreakIndex -> TupleInfo -> ShowS
[TupleInfo] -> ShowS
TupleInfo -> String
(BreakIndex -> TupleInfo -> ShowS)
-> (TupleInfo -> String)
-> ([TupleInfo] -> ShowS)
-> Show TupleInfo
forall a.
(BreakIndex -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: BreakIndex -> TupleInfo -> ShowS
showsPrec :: BreakIndex -> TupleInfo -> ShowS
$cshow :: TupleInfo -> String
show :: TupleInfo -> String
$cshowList :: [TupleInfo] -> ShowS
showList :: [TupleInfo] -> ShowS
Show)

instance Outputable TupleInfo where
  ppr :: TupleInfo -> SDoc
ppr TupleInfo{GlobalRegSet
WordOff
tupleSize :: TupleInfo -> WordOff
tupleRegs :: TupleInfo -> GlobalRegSet
tupleNativeStackSize :: TupleInfo -> WordOff
tupleSize :: WordOff
tupleRegs :: GlobalRegSet
tupleNativeStackSize :: WordOff
..} = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"<size" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> WordOff -> SDoc
forall a. Outputable a => a -> SDoc
ppr WordOff
tupleSize SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
                      String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"stack" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+> WordOff -> SDoc
forall a. Outputable a => a -> SDoc
ppr WordOff
tupleNativeStackSize SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
                      String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"regs"  SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
                      [SDoc] -> SDoc
forall a. Outputable a => a -> SDoc
ppr ((GlobalReg -> SDoc) -> [GlobalReg] -> [SDoc]
forall a b. (a -> b) -> [a] -> [b]
map (forall doc. IsLine doc => String -> doc
text @SDoc (String -> SDoc) -> (GlobalReg -> String) -> GlobalReg -> SDoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GlobalReg -> String
forall a. Show a => a -> String
show) ([GlobalReg] -> [SDoc]) -> [GlobalReg] -> [SDoc]
forall a b. (a -> b) -> a -> b
$ GlobalRegSet -> [GlobalReg]
forall r. RegSet r -> [r]
regSetToList GlobalRegSet
tupleRegs) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<>
                      Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'>'

voidTupleInfo :: TupleInfo
voidTupleInfo :: TupleInfo
voidTupleInfo = WordOff -> GlobalRegSet -> WordOff -> TupleInfo
TupleInfo WordOff
0 GlobalRegSet
forall r. RegSet r
emptyRegSet WordOff
0

type ItblEnv = NameEnv (Name, ItblPtr)
        -- We need the Name in the range so we know which
        -- elements to filter out when unloading a module

newtype ItblPtr = ItblPtr (RemotePtr Heap.StgInfoTable)
  deriving (BreakIndex -> ItblPtr -> ShowS
[ItblPtr] -> ShowS
ItblPtr -> String
(BreakIndex -> ItblPtr -> ShowS)
-> (ItblPtr -> String) -> ([ItblPtr] -> ShowS) -> Show ItblPtr
forall a.
(BreakIndex -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: BreakIndex -> ItblPtr -> ShowS
showsPrec :: BreakIndex -> ItblPtr -> ShowS
$cshow :: ItblPtr -> String
show :: ItblPtr -> String
$cshowList :: [ItblPtr] -> ShowS
showList :: [ItblPtr] -> ShowS
Show, ItblPtr -> ()
(ItblPtr -> ()) -> NFData ItblPtr
forall a. (a -> ()) -> NFData a
$crnf :: ItblPtr -> ()
rnf :: ItblPtr -> ()
NFData)

data UnlinkedBCO
   = UnlinkedBCO {
        UnlinkedBCO -> Name
unlinkedBCOName   :: !Name,
        UnlinkedBCO -> BreakIndex
unlinkedBCOArity  :: {-# UNPACK #-} !Int,
        UnlinkedBCO -> UArray BreakIndex Word16
unlinkedBCOInstrs :: !(UArray Int Word16),      -- insns
        UnlinkedBCO -> UArray BreakIndex Word64
unlinkedBCOBitmap :: !(UArray Int Word64),      -- bitmap
        UnlinkedBCO -> SizedSeq BCONPtr
unlinkedBCOLits   :: !(SizedSeq BCONPtr),       -- non-ptrs
        UnlinkedBCO -> SizedSeq BCOPtr
unlinkedBCOPtrs   :: !(SizedSeq BCOPtr)         -- ptrs
   }

instance NFData UnlinkedBCO where
  rnf :: UnlinkedBCO -> ()
rnf UnlinkedBCO{BreakIndex
UArray BreakIndex Word16
UArray BreakIndex Word64
SizedSeq BCONPtr
SizedSeq BCOPtr
Name
unlinkedBCOName :: UnlinkedBCO -> Name
unlinkedBCOArity :: UnlinkedBCO -> BreakIndex
unlinkedBCOInstrs :: UnlinkedBCO -> UArray BreakIndex Word16
unlinkedBCOBitmap :: UnlinkedBCO -> UArray BreakIndex Word64
unlinkedBCOLits :: UnlinkedBCO -> SizedSeq BCONPtr
unlinkedBCOPtrs :: UnlinkedBCO -> SizedSeq BCOPtr
unlinkedBCOName :: Name
unlinkedBCOArity :: BreakIndex
unlinkedBCOInstrs :: UArray BreakIndex Word16
unlinkedBCOBitmap :: UArray BreakIndex Word64
unlinkedBCOLits :: SizedSeq BCONPtr
unlinkedBCOPtrs :: SizedSeq BCOPtr
..} =
    SizedSeq BCONPtr -> ()
forall a. NFData a => a -> ()
rnf SizedSeq BCONPtr
unlinkedBCOLits () -> () -> ()
forall a b. a -> b -> b
`seq`
    SizedSeq BCOPtr -> ()
forall a. NFData a => a -> ()
rnf SizedSeq BCOPtr
unlinkedBCOPtrs

data BCOPtr
  = BCOPtrName   !Name
  | BCOPtrPrimOp !PrimOp
  | BCOPtrBCO    !UnlinkedBCO
  | BCOPtrBreakArray  -- a pointer to this module's BreakArray

instance NFData BCOPtr where
  rnf :: BCOPtr -> ()
rnf (BCOPtrBCO UnlinkedBCO
bco) = UnlinkedBCO -> ()
forall a. NFData a => a -> ()
rnf UnlinkedBCO
bco
  rnf BCOPtr
x = BCOPtr
x BCOPtr -> () -> ()
forall a b. a -> b -> b
`seq` ()

data BCONPtr
  = BCONPtrWord  {-# UNPACK #-} !Word
  | BCONPtrLbl   !FastString
  | BCONPtrItbl  !Name
  | BCONPtrStr   !ByteString

instance NFData BCONPtr where
  rnf :: BCONPtr -> ()
rnf BCONPtr
x = BCONPtr
x BCONPtr -> () -> ()
forall a b. a -> b -> b
`seq` ()

-- | Information about a breakpoint that we know at code-generation time
data CgBreakInfo
   = CgBreakInfo
   { CgBreakInfo -> [Maybe (Id, Word16)]
cgb_vars   :: [Maybe (Id,Word16)]
   , CgBreakInfo -> Type
cgb_resty  :: Type
   }
-- See Note [Syncing breakpoint info] in GHC.Runtime.Eval

-- Not a real NFData instance because we can't rnf Id or Type
seqCgBreakInfo :: CgBreakInfo -> ()
seqCgBreakInfo :: CgBreakInfo -> ()
seqCgBreakInfo CgBreakInfo{[Maybe (Id, Word16)]
Type
cgb_vars :: CgBreakInfo -> [Maybe (Id, Word16)]
cgb_resty :: CgBreakInfo -> Type
cgb_vars :: [Maybe (Id, Word16)]
cgb_resty :: Type
..} =
  [Word16] -> ()
forall a. NFData a => a -> ()
rnf (((Id, Word16) -> Word16) -> [(Id, Word16)] -> [Word16]
forall a b. (a -> b) -> [a] -> [b]
map (Id, Word16) -> Word16
forall a b. (a, b) -> b
snd ([Maybe (Id, Word16)] -> [(Id, Word16)]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe (Id, Word16)]
cgb_vars))) () -> () -> ()
forall a b. a -> b -> b
`seq`
  Type -> ()
seqType Type
cgb_resty

instance Outputable UnlinkedBCO where
   ppr :: UnlinkedBCO -> SDoc
ppr (UnlinkedBCO Name
nm BreakIndex
_arity UArray BreakIndex Word16
_insns UArray BreakIndex Word64
_bitmap SizedSeq BCONPtr
lits SizedSeq BCOPtr
ptrs)
      = [SDoc] -> SDoc
forall doc. IsLine doc => [doc] -> doc
sep [String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"BCO", Name -> SDoc
forall a. Outputable a => a -> SDoc
ppr Name
nm, String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"with",
             Word -> SDoc
forall a. Outputable a => a -> SDoc
ppr (SizedSeq BCONPtr -> Word
forall a. SizedSeq a -> Word
sizeSS SizedSeq BCONPtr
lits), String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"lits",
             Word -> SDoc
forall a. Outputable a => a -> SDoc
ppr (SizedSeq BCOPtr -> Word
forall a. SizedSeq a -> Word
sizeSS SizedSeq BCOPtr
ptrs), String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"ptrs" ]

instance Outputable CgBreakInfo where
   ppr :: CgBreakInfo -> SDoc
ppr CgBreakInfo
info = String -> SDoc
forall doc. IsLine doc => String -> doc
text String
"CgBreakInfo" SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
              SDoc -> SDoc
forall doc. IsLine doc => doc -> doc
parens ([Maybe (Id, Word16)] -> SDoc
forall a. Outputable a => a -> SDoc
ppr (CgBreakInfo -> [Maybe (Id, Word16)]
cgb_vars CgBreakInfo
info) SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<+>
                      Type -> SDoc
forall a. Outputable a => a -> SDoc
ppr (CgBreakInfo -> Type
cgb_resty CgBreakInfo
info))

-- -----------------------------------------------------------------------------
-- Breakpoints

-- | Breakpoint index
type BreakIndex = Int

-- | C CostCentre type
data CCostCentre

-- | All the information about the breakpoints for a module
data ModBreaks
   = ModBreaks
   { ModBreaks -> ForeignRef BreakArray
modBreaks_flags :: ForeignRef BreakArray
        -- ^ The array of flags, one per breakpoint,
        -- indicating which breakpoints are enabled.
   , ModBreaks -> Array BreakIndex SrcSpan
modBreaks_locs :: !(Array BreakIndex SrcSpan)
        -- ^ An array giving the source span of each breakpoint.
   , ModBreaks -> Array BreakIndex [OccName]
modBreaks_vars :: !(Array BreakIndex [OccName])
        -- ^ An array giving the names of the free variables at each breakpoint.
   , ModBreaks -> Array BreakIndex [String]
modBreaks_decls :: !(Array BreakIndex [String])
        -- ^ An array giving the names of the declarations enclosing each breakpoint.
        -- See Note [Field modBreaks_decls]
   , ModBreaks -> Array BreakIndex (RemotePtr CostCentre)
modBreaks_ccs :: !(Array BreakIndex (RemotePtr CostCentre))
        -- ^ Array pointing to cost centre for each breakpoint
   , ModBreaks -> IntMap CgBreakInfo
modBreaks_breakInfo :: IntMap CgBreakInfo
        -- ^ info about each breakpoint from the bytecode generator
   }

seqModBreaks :: ModBreaks -> ()
seqModBreaks :: ModBreaks -> ()
seqModBreaks ModBreaks{Array BreakIndex [String]
Array BreakIndex [OccName]
Array BreakIndex (RemotePtr CostCentre)
Array BreakIndex SrcSpan
IntMap CgBreakInfo
ForeignRef BreakArray
modBreaks_flags :: ModBreaks -> ForeignRef BreakArray
modBreaks_locs :: ModBreaks -> Array BreakIndex SrcSpan
modBreaks_vars :: ModBreaks -> Array BreakIndex [OccName]
modBreaks_decls :: ModBreaks -> Array BreakIndex [String]
modBreaks_ccs :: ModBreaks -> Array BreakIndex (RemotePtr CostCentre)
modBreaks_breakInfo :: ModBreaks -> IntMap CgBreakInfo
modBreaks_flags :: ForeignRef BreakArray
modBreaks_locs :: Array BreakIndex SrcSpan
modBreaks_vars :: Array BreakIndex [OccName]
modBreaks_decls :: Array BreakIndex [String]
modBreaks_ccs :: Array BreakIndex (RemotePtr CostCentre)
modBreaks_breakInfo :: IntMap CgBreakInfo
..} =
  ForeignRef BreakArray -> ()
forall a. NFData a => a -> ()
rnf ForeignRef BreakArray
modBreaks_flags () -> () -> ()
forall a b. a -> b -> b
`seq`
  Array BreakIndex SrcSpan -> ()
forall a. NFData a => a -> ()
rnf Array BreakIndex SrcSpan
modBreaks_locs () -> () -> ()
forall a b. a -> b -> b
`seq`
  Array BreakIndex [OccName] -> ()
forall a. NFData a => a -> ()
rnf Array BreakIndex [OccName]
modBreaks_vars () -> () -> ()
forall a b. a -> b -> b
`seq`
  Array BreakIndex [String] -> ()
forall a. NFData a => a -> ()
rnf Array BreakIndex [String]
modBreaks_decls () -> () -> ()
forall a b. a -> b -> b
`seq`
  Array BreakIndex (RemotePtr CostCentre) -> ()
forall a. NFData a => a -> ()
rnf Array BreakIndex (RemotePtr CostCentre)
modBreaks_ccs () -> () -> ()
forall a b. a -> b -> b
`seq`
  IntMap () -> ()
forall a. NFData a => a -> ()
rnf ((CgBreakInfo -> ()) -> IntMap CgBreakInfo -> IntMap ()
forall a b. (a -> b) -> IntMap a -> IntMap b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CgBreakInfo -> ()
seqCgBreakInfo IntMap CgBreakInfo
modBreaks_breakInfo)

-- | Construct an empty ModBreaks
emptyModBreaks :: ModBreaks
emptyModBreaks :: ModBreaks
emptyModBreaks = ModBreaks
   { modBreaks_flags :: ForeignRef BreakArray
modBreaks_flags = String -> ForeignRef BreakArray
forall a. HasCallStack => String -> a
error String
"ModBreaks.modBreaks_array not initialised"
         -- ToDo: can we avoid this?
   , modBreaks_locs :: Array BreakIndex SrcSpan
modBreaks_locs  = (BreakIndex, BreakIndex)
-> [(BreakIndex, SrcSpan)] -> Array BreakIndex SrcSpan
forall i e. Ix i => (i, i) -> [(i, e)] -> Array i e
array (BreakIndex
0,-BreakIndex
1) []
   , modBreaks_vars :: Array BreakIndex [OccName]
modBreaks_vars  = (BreakIndex, BreakIndex)
-> [(BreakIndex, [OccName])] -> Array BreakIndex [OccName]
forall i e. Ix i => (i, i) -> [(i, e)] -> Array i e
array (BreakIndex
0,-BreakIndex
1) []
   , modBreaks_decls :: Array BreakIndex [String]
modBreaks_decls = (BreakIndex, BreakIndex)
-> [(BreakIndex, [String])] -> Array BreakIndex [String]
forall i e. Ix i => (i, i) -> [(i, e)] -> Array i e
array (BreakIndex
0,-BreakIndex
1) []
   , modBreaks_ccs :: Array BreakIndex (RemotePtr CostCentre)
modBreaks_ccs = (BreakIndex, BreakIndex)
-> [(BreakIndex, RemotePtr CostCentre)]
-> Array BreakIndex (RemotePtr CostCentre)
forall i e. Ix i => (i, i) -> [(i, e)] -> Array i e
array (BreakIndex
0,-BreakIndex
1) []
   , modBreaks_breakInfo :: IntMap CgBreakInfo
modBreaks_breakInfo = IntMap CgBreakInfo
forall a. IntMap a
IntMap.empty
   }

{-
Note [Field modBreaks_decls]
~~~~~~~~~~~~~~~~~~~~~~
A value of eg ["foo", "bar", "baz"] in a `modBreaks_decls` field means:
The breakpoint is in the function called "baz" that is declared in a `let`
or `where` clause of a declaration called "bar", which itself is declared
in a `let` or `where` clause of the top-level function called "foo".
-}