never executed always true always false
    1 {-# LANGUAGE RecordWildCards, DeriveGeneric, GeneralizedNewtypeDeriving,
    2     BangPatterns, CPP #-}
    3 module GHCi.ResolvedBCO
    4   ( ResolvedBCO(..)
    5   , ResolvedBCOPtr(..)
    6   , isLittleEndian
    7   ) where
    8 
    9 import Prelude -- See note [Why do we import Prelude here?]
   10 import GHC.Data.SizedSeq
   11 import GHCi.RemoteTypes
   12 import GHCi.BreakArray
   13 
   14 import Data.Array.Unboxed
   15 import Data.Binary
   16 import GHC.Generics
   17 import GHCi.BinaryArray
   18 
   19 
   20 #include "MachDeps.h"
   21 
   22 isLittleEndian :: Bool
   23 #if defined(WORDS_BIGENDIAN)
   24 isLittleEndian = False
   25 #else
   26 isLittleEndian = True
   27 #endif
   28 
   29 -- -----------------------------------------------------------------------------
   30 -- ResolvedBCO
   31 
   32 -- | A 'ResolvedBCO' is one in which all the 'Name' references have been
   33 -- resolved to actual addresses or 'RemoteHValues'.
   34 --
   35 -- Note, all arrays are zero-indexed (we assume this when
   36 -- serializing/deserializing)
   37 data ResolvedBCO
   38    = ResolvedBCO {
   39         resolvedBCOIsLE   :: Bool,
   40         resolvedBCOArity  :: {-# UNPACK #-} !Int,
   41         resolvedBCOInstrs :: UArray Int Word16,         -- insns
   42         resolvedBCOBitmap :: UArray Int Word64,         -- bitmap
   43         resolvedBCOLits   :: UArray Int Word64,         -- non-ptrs
   44         resolvedBCOPtrs   :: (SizedSeq ResolvedBCOPtr)  -- ptrs
   45    }
   46    deriving (Generic, Show)
   47 
   48 -- | The Binary instance for ResolvedBCOs.
   49 --
   50 -- Note, that we do encode the endianness, however there is no support for mixed
   51 -- endianness setups.  This is primarily to ensure that ghc and iserv share the
   52 -- same endianness.
   53 instance Binary ResolvedBCO where
   54   put ResolvedBCO{..} = do
   55     put resolvedBCOIsLE
   56     put resolvedBCOArity
   57     putArray resolvedBCOInstrs
   58     putArray resolvedBCOBitmap
   59     putArray resolvedBCOLits
   60     put resolvedBCOPtrs
   61   get = ResolvedBCO
   62         <$> get <*> get <*> getArray <*> getArray <*> getArray <*> get
   63 
   64 data ResolvedBCOPtr
   65   = ResolvedBCORef {-# UNPACK #-} !Int
   66       -- ^ reference to the Nth BCO in the current set
   67   | ResolvedBCOPtr {-# UNPACK #-} !(RemoteRef HValue)
   68       -- ^ reference to a previously created BCO
   69   | ResolvedBCOStaticPtr {-# UNPACK #-} !(RemotePtr ())
   70       -- ^ reference to a static ptr
   71   | ResolvedBCOPtrBCO ResolvedBCO
   72       -- ^ a nested BCO
   73   | ResolvedBCOPtrBreakArray {-# UNPACK #-} !(RemoteRef BreakArray)
   74       -- ^ Resolves to the MutableArray# inside the BreakArray
   75   deriving (Generic, Show)
   76 
   77 instance Binary ResolvedBCOPtr