{-# LINE 1 "libraries/ghci/GHCi/InfoTable.hsc" #-}
{-# LANGUAGE CPP, MagicHash, ScopedTypeVariables #-}
module GHCi.InfoTable
(
mkConInfoTable
) where
import Prelude hiding (fail)
import Foreign
import Foreign.C
import GHC.Ptr
import GHC.Exts
import GHC.Exts.Heap
import Data.ByteString (ByteString)
import Control.Monad.Fail
import qualified Data.ByteString as BS
import GHC.Platform.Host (hostPlatformArch)
import GHC.Platform.ArchOS
mkConInfoTable
:: Bool
-> Int
-> Int
-> Int
-> Int
-> ByteString
-> IO (Ptr StgInfoTable)
mkConInfoTable :: Bool
-> Int -> Int -> Int -> Int -> ByteString -> IO (Ptr StgInfoTable)
mkConInfoTable Bool
tables_next_to_code Int
ptr_words Int
nonptr_words Int
tag Int
ptrtag ByteString
con_desc = do
let entry_addr :: EntryFunPtr
entry_addr = [EntryFunPtr]
interpConstrEntry forall a. [a] -> Int -> a
!! Int
ptrtag
Maybe ItblCodes
code' <- if Bool
tables_next_to_code
then forall a. a -> Maybe a
Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). MonadFail m => EntryFunPtr -> m ItblCodes
mkJumpToAddr EntryFunPtr
entry_addr
else forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing
let
itbl :: StgInfoTable
itbl = StgInfoTable {
entry :: Maybe EntryFunPtr
entry = if Bool
tables_next_to_code
then forall a. Maybe a
Nothing
else forall a. a -> Maybe a
Just EntryFunPtr
entry_addr,
ptrs :: HalfWord
ptrs = forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ptr_words,
nptrs :: HalfWord
nptrs = forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
nonptr_words,
tipe :: ClosureType
tipe = ClosureType
CONSTR,
srtlen :: HalfWord
srtlen = forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
tag,
code :: Maybe ItblCodes
code = Maybe ItblCodes
code'
}
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Bool -> StgInfoTable -> ByteString -> IO (FunPtr ())
newExecConItbl Bool
tables_next_to_code StgInfoTable
itbl ByteString
con_desc
funPtrToInt :: FunPtr a -> Int
funPtrToInt :: forall a. FunPtr a -> Int
funPtrToInt (FunPtr Addr#
a) = Int# -> Int
I# (Addr# -> Int#
addr2Int# Addr#
a)
mkJumpToAddr :: MonadFail m => EntryFunPtr-> m ItblCodes
mkJumpToAddr :: forall (m :: * -> *). MonadFail m => EntryFunPtr -> m ItblCodes
mkJumpToAddr EntryFunPtr
a = case Arch
hostPlatformArch of
Arch
ArchPPC -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
let w32 :: HalfWord
w32 = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. FunPtr a -> Int
funPtrToInt EntryFunPtr
a)
hi16 :: a -> a
hi16 a
x = (a
x forall a. Bits a => a -> Int -> a
`shiftR` Int
16) forall a. Bits a => a -> a -> a
.&. a
0xFFFF
lo16 :: a -> a
lo16 a
x = a
x forall a. Bits a => a -> a -> a
.&. a
0xFFFF
in forall a b. b -> Either a b
Right [ HalfWord
0x3D800000 forall a. Bits a => a -> a -> a
.|. forall {a}. (Bits a, Num a) => a -> a
hi16 HalfWord
w32,
HalfWord
0x618C0000 forall a. Bits a => a -> a -> a
.|. forall {a}. (Bits a, Num a) => a -> a
lo16 HalfWord
w32,
HalfWord
0x7D8903A6, HalfWord
0x4E800420 ]
Arch
ArchX86 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
let w32 :: HalfWord
w32 = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. FunPtr a -> Int
funPtrToInt EntryFunPtr
a) :: Word32
insnBytes :: [Word8]
insnBytes :: [Word8]
insnBytes
= [Word8
0xB8, forall w. Integral w => w -> Word8
byte0 HalfWord
w32, forall w. (Integral w, Bits w) => w -> Word8
byte1 HalfWord
w32,
forall w. (Integral w, Bits w) => w -> Word8
byte2 HalfWord
w32, forall w. (Integral w, Bits w) => w -> Word8
byte3 HalfWord
w32,
Word8
0xFF, Word8
0xE0]
in
forall a b. a -> Either a b
Left [Word8]
insnBytes
Arch
ArchX86_64 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
let w64 :: Word64
w64 = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. FunPtr a -> Int
funPtrToInt EntryFunPtr
a) :: Word64
insnBytes :: [Word8]
insnBytes :: [Word8]
insnBytes
= [Word8
0xff, Word8
0x25, Word8
0x02, Word8
0x00, Word8
0x00, Word8
0x00, Word8
0x00, Word8
0x00,
forall w. Integral w => w -> Word8
byte0 Word64
w64, forall w. (Integral w, Bits w) => w -> Word8
byte1 Word64
w64, forall w. (Integral w, Bits w) => w -> Word8
byte2 Word64
w64, forall w. (Integral w, Bits w) => w -> Word8
byte3 Word64
w64,
forall w. (Integral w, Bits w) => w -> Word8
byte4 Word64
w64, forall w. (Integral w, Bits w) => w -> Word8
byte5 Word64
w64, forall w. (Integral w, Bits w) => w -> Word8
byte6 Word64
w64, forall w. (Integral w, Bits w) => w -> Word8
byte7 Word64
w64]
in
forall a b. a -> Either a b
Left [Word8]
insnBytes
Arch
ArchAlpha -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
let w64 :: Word64
w64 = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. FunPtr a -> Int
funPtrToInt EntryFunPtr
a) :: Word64
in forall a b. b -> Either a b
Right [ HalfWord
0xc3800000
, HalfWord
0xa79c000c
, HalfWord
0x6bfc0000
, HalfWord
0x47ff041f
, forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64
w64 forall a. Bits a => a -> a -> a
.&. Word64
0x0000FFFF)
, forall a b. (Integral a, Num b) => a -> b
fromIntegral ((Word64
w64 forall a. Bits a => a -> Int -> a
`shiftR` Int
32) forall a. Bits a => a -> a -> a
.&. Word64
0x0000FFFF) ]
ArchARM {} -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
let w32 :: HalfWord
w32 = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. FunPtr a -> Int
funPtrToInt EntryFunPtr
a) :: Word32
in forall a b. a -> Either a b
Left [ Word8
0x00, Word8
0x10, Word8
0x9f, Word8
0xe5
, Word8
0x11, Word8
0xff, Word8
0x2f, Word8
0xe1
, forall w. Integral w => w -> Word8
byte0 HalfWord
w32, forall w. (Integral w, Bits w) => w -> Word8
byte1 HalfWord
w32, forall w. (Integral w, Bits w) => w -> Word8
byte2 HalfWord
w32, forall w. (Integral w, Bits w) => w -> Word8
byte3 HalfWord
w32]
ArchAArch64 {} -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
let w64 :: Word64
w64 = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. FunPtr a -> Int
funPtrToInt EntryFunPtr
a) :: Word64
in forall a b. b -> Either a b
Right [ HalfWord
0x58000041
, HalfWord
0xd61f0020
, forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
w64
, forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64
w64 forall a. Bits a => a -> Int -> a
`shiftR` Int
32) ]
ArchPPC_64 PPC_64ABI
ELF_V1 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
let w32 :: HalfWord
w32 = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. FunPtr a -> Int
funPtrToInt EntryFunPtr
a)
hi16 :: a -> a
hi16 a
x = (a
x forall a. Bits a => a -> Int -> a
`shiftR` Int
16) forall a. Bits a => a -> a -> a
.&. a
0xFFFF
lo16 :: a -> a
lo16 a
x = a
x forall a. Bits a => a -> a -> a
.&. a
0xFFFF
in forall a b. b -> Either a b
Right [ HalfWord
0x3D800000 forall a. Bits a => a -> a -> a
.|. forall {a}. (Bits a, Num a) => a -> a
hi16 HalfWord
w32,
HalfWord
0x618C0000 forall a. Bits a => a -> a -> a
.|. forall {a}. (Bits a, Num a) => a -> a
lo16 HalfWord
w32,
HalfWord
0xE96C0000,
HalfWord
0xE84C0008,
HalfWord
0x7D6903A6,
HalfWord
0xE96C0010,
HalfWord
0x4E800420]
ArchPPC_64 PPC_64ABI
ELF_V2 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
let w32 :: HalfWord
w32 = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. FunPtr a -> Int
funPtrToInt EntryFunPtr
a)
hi16 :: a -> a
hi16 a
x = (a
x forall a. Bits a => a -> Int -> a
`shiftR` Int
16) forall a. Bits a => a -> a -> a
.&. a
0xFFFF
lo16 :: a -> a
lo16 a
x = a
x forall a. Bits a => a -> a -> a
.&. a
0xFFFF
in forall a b. b -> Either a b
Right [ HalfWord
0x3D800000 forall a. Bits a => a -> a -> a
.|. forall {a}. (Bits a, Num a) => a -> a
hi16 HalfWord
w32,
HalfWord
0x618C0000 forall a. Bits a => a -> a -> a
.|. forall {a}. (Bits a, Num a) => a -> a
lo16 HalfWord
w32,
HalfWord
0x7D8903A6, HalfWord
0x4E800420 ]
Arch
ArchS390X -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
let w64 :: Word64
w64 = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. FunPtr a -> Int
funPtrToInt EntryFunPtr
a) :: Word64
in forall a b. a -> Either a b
Left [ Word8
0xC0, Word8
0x1E, forall w. (Integral w, Bits w) => w -> Word8
byte7 Word64
w64, forall w. (Integral w, Bits w) => w -> Word8
byte6 Word64
w64, forall w. (Integral w, Bits w) => w -> Word8
byte5 Word64
w64, forall w. (Integral w, Bits w) => w -> Word8
byte4 Word64
w64,
Word8
0xC0, Word8
0x19, forall w. (Integral w, Bits w) => w -> Word8
byte3 Word64
w64, forall w. (Integral w, Bits w) => w -> Word8
byte2 Word64
w64, forall w. (Integral w, Bits w) => w -> Word8
byte1 Word64
w64, forall w. Integral w => w -> Word8
byte0 Word64
w64,
Word8
0x07, Word8
0xF1 ]
Arch
ArchRISCV64 -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$
let w64 :: Word64
w64 = forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. FunPtr a -> Int
funPtrToInt EntryFunPtr
a) :: Word64
in forall a b. b -> Either a b
Right [ HalfWord
0x00000297
, HalfWord
0x01053283
, HalfWord
0x00028067
, HalfWord
0x00000013
, forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
w64
, forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64
w64 forall a. Bits a => a -> Int -> a
`shiftR` Int
32) ]
Arch
arch ->
forall (m :: * -> *) a. MonadFail m => String -> m a
fail forall a b. (a -> b) -> a -> b
$ String
"mkJumpToAddr: arch is not supported with TABLES_NEXT_TO_CODE ("
forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Arch
arch forall a. [a] -> [a] -> [a]
++ String
")"
byte0 :: (Integral w) => w -> Word8
byte0 :: forall w. Integral w => w -> Word8
byte0 w
w = forall a b. (Integral a, Num b) => a -> b
fromIntegral w
w
byte1, byte2, byte3, byte4, byte5, byte6, byte7
:: (Integral w, Bits w) => w -> Word8
byte1 :: forall w. (Integral w, Bits w) => w -> Word8
byte1 w
w = forall a b. (Integral a, Num b) => a -> b
fromIntegral (w
w forall a. Bits a => a -> Int -> a
`shiftR` Int
8)
byte2 :: forall w. (Integral w, Bits w) => w -> Word8
byte2 w
w = forall a b. (Integral a, Num b) => a -> b
fromIntegral (w
w forall a. Bits a => a -> Int -> a
`shiftR` Int
16)
byte3 :: forall w. (Integral w, Bits w) => w -> Word8
byte3 w
w = forall a b. (Integral a, Num b) => a -> b
fromIntegral (w
w forall a. Bits a => a -> Int -> a
`shiftR` Int
24)
byte4 :: forall w. (Integral w, Bits w) => w -> Word8
byte4 w
w = forall a b. (Integral a, Num b) => a -> b
fromIntegral (w
w forall a. Bits a => a -> Int -> a
`shiftR` Int
32)
byte5 :: forall w. (Integral w, Bits w) => w -> Word8
byte5 w
w = forall a b. (Integral a, Num b) => a -> b
fromIntegral (w
w forall a. Bits a => a -> Int -> a
`shiftR` Int
40)
byte6 :: forall w. (Integral w, Bits w) => w -> Word8
byte6 w
w = forall a b. (Integral a, Num b) => a -> b
fromIntegral (w
w forall a. Bits a => a -> Int -> a
`shiftR` Int
48)
byte7 :: forall w. (Integral w, Bits w) => w -> Word8
byte7 w
w = forall a b. (Integral a, Num b) => a -> b
fromIntegral (w
w forall a. Bits a => a -> Int -> a
`shiftR` Int
56)
foreign import ccall "&stg_interp_constr1_entry" stg_interp_constr1_entry :: EntryFunPtr
foreign import ccall "&stg_interp_constr2_entry" stg_interp_constr2_entry :: EntryFunPtr
foreign import ccall "&stg_interp_constr3_entry" stg_interp_constr3_entry :: EntryFunPtr
foreign import ccall "&stg_interp_constr4_entry" stg_interp_constr4_entry :: EntryFunPtr
foreign import ccall "&stg_interp_constr5_entry" stg_interp_constr5_entry :: EntryFunPtr
foreign import ccall "&stg_interp_constr6_entry" stg_interp_constr6_entry :: EntryFunPtr
foreign import ccall "&stg_interp_constr7_entry" stg_interp_constr7_entry :: EntryFunPtr
interpConstrEntry :: [EntryFunPtr]
interpConstrEntry :: [EntryFunPtr]
interpConstrEntry = [ forall a. HasCallStack => String -> a
error String
"pointer tag 0"
, EntryFunPtr
stg_interp_constr1_entry
, EntryFunPtr
stg_interp_constr2_entry
, EntryFunPtr
stg_interp_constr3_entry
, EntryFunPtr
stg_interp_constr4_entry
, EntryFunPtr
stg_interp_constr5_entry
, EntryFunPtr
stg_interp_constr6_entry
, EntryFunPtr
stg_interp_constr7_entry ]
data StgConInfoTable = StgConInfoTable {
StgConInfoTable -> Ptr Word8
conDesc :: Ptr Word8,
StgConInfoTable -> StgInfoTable
infoTable :: StgInfoTable
}
pokeConItbl
:: Bool -> Ptr StgConInfoTable -> Ptr StgConInfoTable -> StgConInfoTable
-> IO ()
pokeConItbl :: Bool
-> Ptr StgConInfoTable
-> Ptr StgConInfoTable
-> StgConInfoTable
-> IO ()
pokeConItbl Bool
tables_next_to_code Ptr StgConInfoTable
wr_ptr Ptr StgConInfoTable
_ex_ptr StgConInfoTable
itbl = do
if Bool
tables_next_to_code
then do
let con_desc_offset :: Int
con_desc_offset = StgConInfoTable -> Ptr Word8
conDesc StgConInfoTable
itbl forall a b. Ptr a -> Ptr b -> Int
`minusPtr` (Ptr StgConInfoTable
_ex_ptr forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
conInfoTableSizeB)
((\Ptr StgConInfoTable
hsc_ptr -> forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr StgConInfoTable
hsc_ptr Int
0)) Ptr StgConInfoTable
wr_ptr Int
con_desc_offset
{-# LINE 289 "libraries/ghci/GHCi/InfoTable.hsc" #-}
else do
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr StgConInfoTable
wr_ptr Int
itblSize (StgConInfoTable -> Ptr Word8
conDesc StgConInfoTable
itbl)
Ptr StgInfoTable -> StgInfoTable -> IO ()
pokeItbl (Ptr StgConInfoTable
wr_ptr forall a b. Ptr a -> Int -> Ptr b
`plusPtr` ((Int
8))) (StgConInfoTable -> StgInfoTable
infoTable StgConInfoTable
itbl)
{-# LINE 295 "libraries/ghci/GHCi/InfoTable.hsc" #-}
sizeOfEntryCode :: MonadFail m => Bool -> m Int
sizeOfEntryCode :: forall (m :: * -> *). MonadFail m => Bool -> m Int
sizeOfEntryCode Bool
tables_next_to_code
| Bool -> Bool
not Bool
tables_next_to_code = forall (f :: * -> *) a. Applicative f => a -> f a
pure Int
0
| Bool
otherwise = do
ItblCodes
code' <- forall (m :: * -> *). MonadFail m => EntryFunPtr -> m ItblCodes
mkJumpToAddr forall a. HasCallStack => a
undefined
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ case ItblCodes
code' of
Left [Word8]
xs -> forall a. Storable a => a -> Int
sizeOf (forall a. [a] -> a
head [Word8]
xs) forall a. Num a => a -> a -> a
* forall (t :: * -> *) a. Foldable t => t a -> Int
length [Word8]
xs
Right [HalfWord]
xs -> forall a. Storable a => a -> Int
sizeOf (forall a. [a] -> a
head [HalfWord]
xs) forall a. Num a => a -> a -> a
* forall (t :: * -> *) a. Foldable t => t a -> Int
length [HalfWord]
xs
{-# LINE 307 "libraries/ghci/GHCi/InfoTable.hsc" #-}
newExecConItbl :: Bool -> StgInfoTable -> ByteString -> IO (FunPtr ())
newExecConItbl :: Bool -> StgInfoTable -> ByteString -> IO (FunPtr ())
newExecConItbl Bool
tables_next_to_code StgInfoTable
obj ByteString
con_desc = do
Int
sz0 <- forall (m :: * -> *). MonadFail m => Bool -> m Int
sizeOfEntryCode Bool
tables_next_to_code
let lcon_desc :: Int
lcon_desc = ByteString -> Int
BS.length ByteString
con_desc forall a. Num a => a -> a -> a
+ Int
1
sz :: CSize
sz = forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ Int
conInfoTableSizeB forall a. Num a => a -> a -> a
+ Int
sz0
Ptr StgConInfoTable
ex_ptr <- forall a. CSize -> (Ptr a -> Ptr a -> IO ()) -> IO (Ptr a)
fillExecBuffer (CSize
sz forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
lcon_desc) forall a b. (a -> b) -> a -> b
$ \Ptr StgConInfoTable
wr_ptr Ptr StgConInfoTable
ex_ptr -> do
let cinfo :: StgConInfoTable
cinfo = StgConInfoTable { conDesc :: Ptr Word8
conDesc = Ptr StgConInfoTable
ex_ptr forall a b. Ptr a -> Int -> Ptr b
`plusPtr` forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
sz
, infoTable :: StgInfoTable
infoTable = StgInfoTable
obj }
Bool
-> Ptr StgConInfoTable
-> Ptr StgConInfoTable
-> StgConInfoTable
-> IO ()
pokeConItbl Bool
tables_next_to_code Ptr StgConInfoTable
wr_ptr Ptr StgConInfoTable
ex_ptr StgConInfoTable
cinfo
forall a. ByteString -> (CStringLen -> IO a) -> IO a
BS.useAsCStringLen ByteString
con_desc forall a b. (a -> b) -> a -> b
$ \(Ptr CChar
src, Int
len) ->
forall a. Ptr a -> Ptr a -> Int -> IO ()
copyBytes (forall a b. Ptr a -> Ptr b
castPtr Ptr StgConInfoTable
wr_ptr forall a b. Ptr a -> Int -> Ptr b
`plusPtr` forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
sz) Ptr CChar
src Int
len
let null_off :: Int
null_off = forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
sz forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
BS.length ByteString
con_desc)
forall a. Storable a => Ptr a -> a -> IO ()
poke (forall a b. Ptr a -> Ptr b
castPtr Ptr StgConInfoTable
wr_ptr forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
null_off) (Word8
0 :: Word8)
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ if Bool
tables_next_to_code
then forall a b. Ptr a -> FunPtr b
castPtrToFunPtr forall a b. (a -> b) -> a -> b
$ Ptr StgConInfoTable
ex_ptr forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
conInfoTableSizeB
else forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr StgConInfoTable
ex_ptr
{-# LINE 358 "libraries/ghci/GHCi/InfoTable.hsc" #-}
{-# LINE 363 "libraries/ghci/GHCi/InfoTable.hsc" #-}
fillExecBuffer :: CSize -> (Ptr a -> Ptr a -> IO ()) -> IO (Ptr a)
{-# LINE 365 "libraries/ghci/GHCi/InfoTable.hsc" #-}
{-# LINE 367 "libraries/ghci/GHCi/InfoTable.hsc" #-}
data ExecPage
foreign import ccall unsafe "allocateExecPage"
_allocateExecPage :: IO (Ptr ExecPage)
foreign import ccall unsafe "freezeExecPage"
_freezeExecPage :: Ptr ExecPage -> IO ()
fillExecBuffer :: forall a. CSize -> (Ptr a -> Ptr a -> IO ()) -> IO (Ptr a)
fillExecBuffer CSize
sz Ptr a -> Ptr a -> IO ()
cont
| CSize
sz forall a. Ord a => a -> a -> Bool
> CSize
4096 = forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"withExecBuffer: Too large"
| Bool
otherwise = do
Ptr ExecPage
pg <- IO (Ptr ExecPage)
_allocateExecPage
Ptr a -> Ptr a -> IO ()
cont (forall a b. Ptr a -> Ptr b
castPtr Ptr ExecPage
pg) (forall a b. Ptr a -> Ptr b
castPtr Ptr ExecPage
pg)
Ptr ExecPage -> IO ()
_freezeExecPage Ptr ExecPage
pg
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a b. Ptr a -> Ptr b
castPtr Ptr ExecPage
pg)
{-# LINE 411 "libraries/ghci/GHCi/InfoTable.hsc" #-}
wORD_SIZE :: Int
wORD_SIZE :: Int
wORD_SIZE = (Int
8)
{-# LINE 417 "libraries/ghci/GHCi/InfoTable.hsc" #-}
conInfoTableSizeB :: Int
conInfoTableSizeB :: Int
conInfoTableSizeB = Int
wORD_SIZE forall a. Num a => a -> a -> a
+ Int
itblSize