Safe Haskell | None |
---|---|
Language | Haskell2010 |
Interacting with the iserv interpreter, whether it is running on an external process or in the current process.
Synopsis
- evalStmt :: HscEnv -> Bool -> EvalExpr ForeignHValue -> IO (EvalStatus_ [ForeignHValue] [HValueRef])
- data EvalStatus_ a b
- = EvalComplete Word64 (EvalResult a)
- | EvalBreak Bool HValueRef Int Int (RemoteRef (ResumeContext b)) (RemotePtr CostCentreStack)
- type EvalStatus a = EvalStatus_ a a
- data EvalResult a
- = EvalException SerializableException
- | EvalSuccess a
- data EvalExpr a
- resumeStmt :: HscEnv -> Bool -> ForeignRef (ResumeContext [HValueRef]) -> IO (EvalStatus_ [ForeignHValue] [HValueRef])
- abandonStmt :: HscEnv -> ForeignRef (ResumeContext [HValueRef]) -> IO ()
- evalIO :: HscEnv -> ForeignHValue -> IO ()
- evalString :: HscEnv -> ForeignHValue -> IO String
- evalStringToIOString :: HscEnv -> ForeignHValue -> String -> IO String
- mallocData :: HscEnv -> ByteString -> IO (RemotePtr ())
- createBCOs :: HscEnv -> [ResolvedBCO] -> IO [HValueRef]
- addSptEntry :: HscEnv -> Fingerprint -> ForeignHValue -> IO ()
- mkCostCentres :: HscEnv -> String -> [(String, String)] -> IO [RemotePtr CostCentre]
- costCentreStackInfo :: HscEnv -> RemotePtr CostCentreStack -> IO [String]
- newBreakArray :: HscEnv -> Int -> IO (ForeignRef BreakArray)
- enableBreakpoint :: HscEnv -> ForeignRef BreakArray -> Int -> Bool -> IO ()
- breakpointStatus :: HscEnv -> ForeignRef BreakArray -> Int -> IO Bool
- getBreakpointVar :: HscEnv -> ForeignHValue -> Int -> IO (Maybe ForeignHValue)
- getClosure :: HscEnv -> ForeignHValue -> IO (GenClosure ForeignHValue)
- getModBreaks :: HomeModInfo -> ModBreaks
- seqHValue :: HscEnv -> ForeignHValue -> IO (EvalResult ())
- interpreterDynamic :: Interp -> Bool
- interpreterProfiled :: Interp -> Bool
- initObjLinker :: HscEnv -> IO ()
- lookupSymbol :: HscEnv -> FastString -> IO (Maybe (Ptr ()))
- lookupClosure :: HscEnv -> String -> IO (Maybe HValueRef)
- loadDLL :: HscEnv -> String -> IO (Maybe String)
- loadArchive :: HscEnv -> String -> IO ()
- loadObj :: HscEnv -> String -> IO ()
- unloadObj :: HscEnv -> String -> IO ()
- addLibrarySearchPath :: HscEnv -> String -> IO (Ptr ())
- removeLibrarySearchPath :: HscEnv -> Ptr () -> IO Bool
- resolveObjs :: HscEnv -> IO SuccessFlag
- findSystemLibrary :: HscEnv -> String -> IO (Maybe String)
- iservCmd :: Binary a => HscEnv -> Message a -> IO a
- data Message a where
- Shutdown :: Message ()
- RtsRevertCAFs :: Message ()
- InitLinker :: Message ()
- LookupSymbol :: String -> Message (Maybe (RemotePtr ()))
- LookupClosure :: String -> Message (Maybe HValueRef)
- LoadDLL :: String -> Message (Maybe String)
- LoadArchive :: String -> Message ()
- LoadObj :: String -> Message ()
- UnloadObj :: String -> Message ()
- AddLibrarySearchPath :: String -> Message (RemotePtr ())
- RemoveLibrarySearchPath :: RemotePtr () -> Message Bool
- ResolveObjs :: Message Bool
- FindSystemLibrary :: String -> Message (Maybe String)
- CreateBCOs :: [ByteString] -> Message [HValueRef]
- FreeHValueRefs :: [HValueRef] -> Message ()
- AddSptEntry :: Fingerprint -> HValueRef -> Message ()
- MallocData :: ByteString -> Message (RemotePtr ())
- MallocStrings :: [ByteString] -> Message [RemotePtr ()]
- PrepFFI :: FFIConv -> [FFIType] -> FFIType -> Message (RemotePtr C_ffi_cif)
- FreeFFI :: RemotePtr C_ffi_cif -> Message ()
- MkConInfoTable :: Bool -> Int -> Int -> Int -> Int -> ByteString -> Message (RemotePtr StgInfoTable)
- EvalStmt :: EvalOpts -> EvalExpr HValueRef -> Message (EvalStatus_ [HValueRef] [HValueRef])
- ResumeStmt :: EvalOpts -> RemoteRef (ResumeContext [HValueRef]) -> Message (EvalStatus_ [HValueRef] [HValueRef])
- AbandonStmt :: RemoteRef (ResumeContext [HValueRef]) -> Message ()
- EvalString :: HValueRef -> Message (EvalResult String)
- EvalStringToString :: HValueRef -> String -> Message (EvalResult String)
- EvalIO :: HValueRef -> Message (EvalResult ())
- MkCostCentres :: String -> [(String, String)] -> Message [RemotePtr CostCentre]
- CostCentreStackInfo :: RemotePtr CostCentreStack -> Message [String]
- NewBreakArray :: Int -> Message (RemoteRef BreakArray)
- EnableBreakpoint :: RemoteRef BreakArray -> Int -> Bool -> Message ()
- BreakpointStatus :: RemoteRef BreakArray -> Int -> Message Bool
- GetBreakpointVar :: HValueRef -> Int -> Message (Maybe HValueRef)
- StartTH :: Message (RemoteRef (IORef QState))
- RunTH :: RemoteRef (IORef QState) -> HValueRef -> THResultType -> Maybe Loc -> Message (QResult ByteString)
- RunModFinalizers :: RemoteRef (IORef QState) -> [RemoteRef (Q ())] -> Message (QResult ())
- GetClosure :: HValueRef -> Message (GenClosure HValueRef)
- Seq :: HValueRef -> Message (EvalStatus_ () ())
- ResumeSeq :: RemoteRef (ResumeContext ()) -> Message (EvalStatus_ () ())
- withIServ :: ExceptionMonad m => IServConfig -> IServ -> (IServInstance -> m (IServInstance, a)) -> m a
- withIServ_ :: (MonadIO m, ExceptionMonad m) => IServConfig -> IServ -> (IServInstance -> m a) -> m a
- withInterp :: HscEnv -> (Interp -> IO a) -> IO a
- hscInterp :: HscEnv -> Interp
- stopInterp :: HscEnv -> IO ()
- iservCall :: Binary a => IServInstance -> Message a -> IO a
- readIServ :: IServInstance -> Get a -> IO a
- writeIServ :: IServInstance -> Put -> IO ()
- purgeLookupSymbolCache :: HscEnv -> IO ()
- freeHValueRefs :: HscEnv -> [HValueRef] -> IO ()
- mkFinalizedHValue :: HscEnv -> RemoteRef a -> IO (ForeignRef a)
- wormhole :: Interp -> ForeignRef a -> IO a
- wormholeRef :: Interp -> RemoteRef a -> IO a
- mkEvalOpts :: DynFlags -> Bool -> EvalOpts
- fromEvalResult :: EvalResult a -> IO a
High-level interface to the interpreter
evalStmt :: HscEnv -> Bool -> EvalExpr ForeignHValue -> IO (EvalStatus_ [ForeignHValue] [HValueRef]) Source #
Execute an action of type IO [a]
, returning ForeignHValue
s for
each of the results.
data EvalStatus_ a b #
EvalComplete Word64 (EvalResult a) | |
EvalBreak Bool HValueRef Int Int (RemoteRef (ResumeContext b)) (RemotePtr CostCentreStack) |
Instances
type EvalStatus a = EvalStatus_ a a #
data EvalResult a #
EvalException SerializableException | |
EvalSuccess a |
Instances
Show a => Show (EvalResult a) | |
Defined in GHCi.Message showsPrec :: Int -> EvalResult a -> ShowS # show :: EvalResult a -> String # showList :: [EvalResult a] -> ShowS # | |
Generic (EvalResult a) | |
Defined in GHCi.Message type Rep (EvalResult a) :: Type -> Type # from :: EvalResult a -> Rep (EvalResult a) x # to :: Rep (EvalResult a) x -> EvalResult a # | |
Binary a => Binary (EvalResult a) | |
Defined in GHCi.Message | |
type Rep (EvalResult a) | |
Defined in GHCi.Message type Rep (EvalResult a) = D1 ('MetaData "EvalResult" "GHCi.Message" "ghc-lib-parser-0.20201101-isyDBvgoNDKP6i3o2E3m7" 'False) (C1 ('MetaCons "EvalException" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SerializableException)) :+: C1 ('MetaCons "EvalSuccess" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) |
Instances
Show a => Show (EvalExpr a) | |
Generic (EvalExpr a) | |
Binary a => Binary (EvalExpr a) | |
type Rep (EvalExpr a) | |
Defined in GHCi.Message type Rep (EvalExpr a) = D1 ('MetaData "EvalExpr" "GHCi.Message" "ghc-lib-parser-0.20201101-isyDBvgoNDKP6i3o2E3m7" 'False) (C1 ('MetaCons "EvalThis" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "EvalApp" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (EvalExpr a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (EvalExpr a)))) |
resumeStmt :: HscEnv -> Bool -> ForeignRef (ResumeContext [HValueRef]) -> IO (EvalStatus_ [ForeignHValue] [HValueRef]) Source #
abandonStmt :: HscEnv -> ForeignRef (ResumeContext [HValueRef]) -> IO () Source #
evalString :: HscEnv -> ForeignHValue -> IO String Source #
Execute an action of type IO String
evalStringToIOString :: HscEnv -> ForeignHValue -> String -> IO String Source #
Execute an action of type String -> IO String
mallocData :: HscEnv -> ByteString -> IO (RemotePtr ()) Source #
Allocate and store the given bytes in memory, returning a pointer to the memory in the remote process.
createBCOs :: HscEnv -> [ResolvedBCO] -> IO [HValueRef] Source #
Create a set of BCOs that may be mutually recursive.
addSptEntry :: HscEnv -> Fingerprint -> ForeignHValue -> IO () Source #
mkCostCentres :: HscEnv -> String -> [(String, String)] -> IO [RemotePtr CostCentre] Source #
costCentreStackInfo :: HscEnv -> RemotePtr CostCentreStack -> IO [String] Source #
getBreakpointVar :: HscEnv -> ForeignHValue -> Int -> IO (Maybe ForeignHValue) Source #
getClosure :: HscEnv -> ForeignHValue -> IO (GenClosure ForeignHValue) Source #
getModBreaks :: HomeModInfo -> ModBreaks Source #
seqHValue :: HscEnv -> ForeignHValue -> IO (EvalResult ()) Source #
Send a Seq message to the iserv process to force a value #2950
interpreterDynamic :: Interp -> Bool Source #
Interpreter uses Dynamic way
interpreterProfiled :: Interp -> Bool Source #
Interpreter uses Profiling way
The object-code linker
initObjLinker :: HscEnv -> IO () Source #
loadDLL :: HscEnv -> String -> IO (Maybe String) Source #
loadDLL loads a dynamic library using the OS's native linker (i.e. dlopen() on Unix, LoadLibrary() on Windows). It takes either an absolute pathname to the file, or a relative filename (e.g. "libfoo.so" or "foo.dll"). In the latter case, loadDLL searches the standard locations for the appropriate library.
Returns:
Nothing => success Just err_msg => failure
resolveObjs :: HscEnv -> IO SuccessFlag Source #
Lower-level API using messages
iservCmd :: Binary a => HscEnv -> Message a -> IO a Source #
Run a command in the interpreter's context. With
-fexternal-interpreter
, the command is serialized and sent to an
external iserv process, and the response is deserialized (hence the
Binary
constraint). With -fno-external-interpreter
we execute
the command directly here.
Shutdown :: Message () | |
RtsRevertCAFs :: Message () | |
InitLinker :: Message () | |
LookupSymbol :: String -> Message (Maybe (RemotePtr ())) | |
LookupClosure :: String -> Message (Maybe HValueRef) | |
LoadDLL :: String -> Message (Maybe String) | |
LoadArchive :: String -> Message () | |
LoadObj :: String -> Message () | |
UnloadObj :: String -> Message () | |
AddLibrarySearchPath :: String -> Message (RemotePtr ()) | |
RemoveLibrarySearchPath :: RemotePtr () -> Message Bool | |
ResolveObjs :: Message Bool | |
FindSystemLibrary :: String -> Message (Maybe String) | |
CreateBCOs :: [ByteString] -> Message [HValueRef] | |
FreeHValueRefs :: [HValueRef] -> Message () | |
AddSptEntry :: Fingerprint -> HValueRef -> Message () | |
MallocData :: ByteString -> Message (RemotePtr ()) | |
MallocStrings :: [ByteString] -> Message [RemotePtr ()] | |
PrepFFI :: FFIConv -> [FFIType] -> FFIType -> Message (RemotePtr C_ffi_cif) | |
FreeFFI :: RemotePtr C_ffi_cif -> Message () | |
MkConInfoTable :: Bool -> Int -> Int -> Int -> Int -> ByteString -> Message (RemotePtr StgInfoTable) | |
EvalStmt :: EvalOpts -> EvalExpr HValueRef -> Message (EvalStatus_ [HValueRef] [HValueRef]) | |
ResumeStmt :: EvalOpts -> RemoteRef (ResumeContext [HValueRef]) -> Message (EvalStatus_ [HValueRef] [HValueRef]) | |
AbandonStmt :: RemoteRef (ResumeContext [HValueRef]) -> Message () | |
EvalString :: HValueRef -> Message (EvalResult String) | |
EvalStringToString :: HValueRef -> String -> Message (EvalResult String) | |
EvalIO :: HValueRef -> Message (EvalResult ()) | |
MkCostCentres :: String -> [(String, String)] -> Message [RemotePtr CostCentre] | |
CostCentreStackInfo :: RemotePtr CostCentreStack -> Message [String] | |
NewBreakArray :: Int -> Message (RemoteRef BreakArray) | |
EnableBreakpoint :: RemoteRef BreakArray -> Int -> Bool -> Message () | |
BreakpointStatus :: RemoteRef BreakArray -> Int -> Message Bool | |
GetBreakpointVar :: HValueRef -> Int -> Message (Maybe HValueRef) | |
StartTH :: Message (RemoteRef (IORef QState)) | |
RunTH :: RemoteRef (IORef QState) -> HValueRef -> THResultType -> Maybe Loc -> Message (QResult ByteString) | |
RunModFinalizers :: RemoteRef (IORef QState) -> [RemoteRef (Q ())] -> Message (QResult ()) | |
GetClosure :: HValueRef -> Message (GenClosure HValueRef) | |
Seq :: HValueRef -> Message (EvalStatus_ () ()) | |
ResumeSeq :: RemoteRef (ResumeContext ()) -> Message (EvalStatus_ () ()) |
withIServ :: ExceptionMonad m => IServConfig -> IServ -> (IServInstance -> m (IServInstance, a)) -> m a Source #
Grab a lock on the IServ
and do something with it.
Overloaded because this is used from TcM as well as IO.
withIServ_ :: (MonadIO m, ExceptionMonad m) => IServConfig -> IServ -> (IServInstance -> m a) -> m a Source #
withInterp :: HscEnv -> (Interp -> IO a) -> IO a Source #
Execute an action with the interpreter
Fails if no target code interpreter is available
hscInterp :: HscEnv -> Interp Source #
Retreive the targe code interpreter
Fails if no target code interpreter is available
stopInterp :: HscEnv -> IO () Source #
Stop the interpreter
iservCall :: Binary a => IServInstance -> Message a -> IO a Source #
Send a Message
and receive the response from the iserv process
writeIServ :: IServInstance -> Put -> IO () Source #
Send a value to the iserv process
purgeLookupSymbolCache :: HscEnv -> IO () Source #
freeHValueRefs :: HscEnv -> [HValueRef] -> IO () Source #
mkFinalizedHValue :: HscEnv -> RemoteRef a -> IO (ForeignRef a) Source #
Creates a ForeignRef
that will automatically release the
RemoteRef
when it is no longer referenced.
wormhole :: Interp -> ForeignRef a -> IO a Source #
Convert a ForeignRef
to the value it references directly. This
only works when the interpreter is running in the same process as
the compiler, so it fails when -fexternal-interpreter
is on.
wormholeRef :: Interp -> RemoteRef a -> IO a Source #
Convert an RemoteRef
to the value it references directly. This
only works when the interpreter is running in the same process as
the compiler, so it fails when -fexternal-interpreter
is on.
mkEvalOpts :: DynFlags -> Bool -> EvalOpts Source #
fromEvalResult :: EvalResult a -> IO a Source #