Safe Haskell | None |
---|---|
Language | Haskell98 |
- class CompileLayer l
- data ModuleHandle
- addModule :: CompileLayer l => l -> Module -> SymbolResolver -> IO ModuleHandle
- removeModule :: CompileLayer l => l -> ModuleHandle -> IO ()
- withModule :: CompileLayer l => l -> Module -> SymbolResolver -> (ModuleHandle -> IO a) -> IO a
- findSymbol :: CompileLayer l => l -> MangledSymbol -> Bool -> IO JITSymbol
- findSymbolIn :: CompileLayer l => l -> ModuleHandle -> MangledSymbol -> Bool -> IO JITSymbol
- data JITSymbol = JITSymbol {}
- data JITSymbolFlags = JITSymbolFlags {
- jitSymbolWeak :: !Bool
- jitSymbolExported :: !Bool
- data SymbolResolver = SymbolResolver {}
- data MangledSymbol
- mangleSymbol :: CompileLayer l => l -> ShortByteString -> IO MangledSymbol
- data IRCompileLayer linkingLayer
- newIRCompileLayer :: LinkingLayer l => l -> TargetMachine -> IO (IRCompileLayer l)
- withIRCompileLayer :: LinkingLayer l => l -> TargetMachine -> (IRCompileLayer l -> IO a) -> IO a
- data CompileOnDemandLayer baseLayer
- newCompileOnDemandLayer :: CompileLayer l => l -> TargetMachine -> (Ptr Function -> IO [Ptr Function]) -> JITCompileCallbackManager -> IndirectStubsManagerBuilder -> Bool -> IO (CompileOnDemandLayer l)
- withCompileOnDemandLayer :: CompileLayer l => l -> TargetMachine -> (Ptr Function -> IO [Ptr Function]) -> JITCompileCallbackManager -> IndirectStubsManagerBuilder -> Bool -> (CompileOnDemandLayer l -> IO a) -> IO a
- data IRTransformLayer baseLayer
- newIRTransformLayer :: CompileLayer l => l -> TargetMachine -> (Ptr Module -> IO (Ptr Module)) -> IO (IRTransformLayer l)
- withIRTransformLayer :: CompileLayer l => l -> TargetMachine -> (Ptr Module -> IO (Ptr Module)) -> (IRTransformLayer l -> IO a) -> IO a
- disposeCompileLayer :: CompileLayer l => l -> IO ()
- class LinkingLayer l
- data ObjectLinkingLayer
- newObjectLinkingLayer :: IO ObjectLinkingLayer
- withObjectLinkingLayer :: (ObjectLinkingLayer -> IO a) -> IO a
- disposeLinkingLayer :: LinkingLayer l => l -> IO ()
- data JITCompileCallbackManager
- newJITCompileCallbackManager :: ShortByteString -> Maybe (IO ()) -> IO JITCompileCallbackManager
- disposeJITCompileCallbackManager :: JITCompileCallbackManager -> IO ()
- withJITCompileCallbackManager :: ShortByteString -> Maybe (IO ()) -> (JITCompileCallbackManager -> IO a) -> IO a
- data IndirectStubsManagerBuilder
- newIndirectStubsManagerBuilder :: ShortByteString -> IO IndirectStubsManagerBuilder
- disposeIndirectStubsManagerBuilder :: IndirectStubsManagerBuilder -> IO ()
- withIndirectStubsManagerBuilder :: ShortByteString -> (IndirectStubsManagerBuilder -> IO a) -> IO a
CompileLayer
class CompileLayer l Source #
There are two main types of operations provided by instances of CompileLayer
.
- You can add / remove modules using
addModule
/removeModuleSet
. - You can search for symbols using
findSymbol
/findSymbolIn
in the previously added modules.
Add/remove modules
data ModuleHandle Source #
Abstract type representing a module in a CompileLayer
.
addModule :: CompileLayer l => l -> Module -> SymbolResolver -> IO ModuleHandle Source #
Add a module to the CompileLayer
. The SymbolResolver
is used
to resolve external symbols in the module.
Note: This function consumes the module passed to it and it must not be used after calling this method.
removeModule :: CompileLayer l => l -> ModuleHandle -> IO () Source #
Remove a previously added module.
withModule :: CompileLayer l => l -> Module -> SymbolResolver -> (ModuleHandle -> IO a) -> IO a Source #
bracket
-style wrapper around addModule
and removeModule
.
Note: This function consumes the module passed to it and it must not be used after calling this method.
Search for symbols
findSymbol :: CompileLayer l => l -> MangledSymbol -> Bool -> IO JITSymbol Source #
searches for
findSymbol
layer symbol exportedSymbolsOnlysymbol
in all modules added to layer
. If exportedSymbolsOnly
is True
only exported symbols are searched.
findSymbolIn :: CompileLayer l => l -> ModuleHandle -> MangledSymbol -> Bool -> IO JITSymbol Source #
searches for
findSymbolIn
layer handle symbol exportedSymbolsOnlysymbol
in the context of the module represented by handle
. If
exportedSymbolsOnly
is True
only exported symbols are searched.
JITSymbol | |
|
data JITSymbolFlags Source #
JITSymbolFlags | |
|
data SymbolResolver Source #
Specifies how external symbols in a module added to a
CompielLayer
should be resolved.
SymbolResolver | |
|
MonadIO m => EncodeM m SymbolResolver (IORef [IO ()] -> IO (Ptr LambdaResolver)) Source # | |
Symbol mangling
data MangledSymbol Source #
A mangled symbol which can be used in findSymbol
. This can be
created using mangleSymbol
.
mangleSymbol :: CompileLayer l => l -> ShortByteString -> IO MangledSymbol Source #
Mangle a symbol according to the data layout stored in the
CompileLayer
.
IRCompileLayer
data IRCompileLayer linkingLayer Source #
IRCompileLayer
compiles modules immediately when they are
added. It parametrized by a LinkingLayer
which handles linking of
the generated object files.
Eq (IRCompileLayer linkingLayer) Source # | |
CompileLayer (IRCompileLayer l) Source # | |
newIRCompileLayer :: LinkingLayer l => l -> TargetMachine -> IO (IRCompileLayer l) Source #
Create a new IRCompileLayer
.
When the layer is no longer needed, it should be disposed using 'disposeCompileLayer.
withIRCompileLayer :: LinkingLayer l => l -> TargetMachine -> (IRCompileLayer l -> IO a) -> IO a Source #
bracket
-style wrapper around newIRCompileLayer
and disposeCompileLayer
.
CompileOnDemandLayer
data CompileOnDemandLayer baseLayer Source #
Adding a module to a CompileOnDemandLayer
creates stubs for its
functions definitions. When one of those stubs is called, the
corresponding function body is extracted and compiled.
Eq (CompileOnDemandLayer baseLayer) Source # | |
CompileLayer (CompileOnDemandLayer l) Source # | |
newCompileOnDemandLayer Source #
:: CompileLayer l | |
=> l | |
-> TargetMachine | |
-> (Ptr Function -> IO [Ptr Function]) | partitioning function |
-> JITCompileCallbackManager | |
-> IndirectStubsManagerBuilder | |
-> Bool | clone stubs into partitions |
-> IO (CompileOnDemandLayer l) |
Create a new CompileOnDemandLayer
. The partitioning function
specifies which functions should be compiled when a function is
called.
When the layer is no longer needed, it should be disposed using disposeCompileLayer
.
withCompileOnDemandLayer Source #
:: CompileLayer l | |
=> l | |
-> TargetMachine | |
-> (Ptr Function -> IO [Ptr Function]) | partitioning function |
-> JITCompileCallbackManager | |
-> IndirectStubsManagerBuilder | |
-> Bool | clone stubs into partitions |
-> (CompileOnDemandLayer l -> IO a) | |
-> IO a |
bracket
-style wrapper around newCompileOnDemandLayer
and disposeCompileLayer
.
IRTRansformLayer
data IRTransformLayer baseLayer Source #
IRTransformLayer
allows transforming modules before handing off
compilation to the underlying CompileLayer
.
Eq (IRTransformLayer baseLayer) Source # | |
CompileLayer (IRTransformLayer l) Source # | |
:: CompileLayer l | |
=> l | |
-> TargetMachine | |
-> (Ptr Module -> IO (Ptr Module)) | module transformation |
-> IO (IRTransformLayer l) |
Create a new IRTransformLayer
.
When the layer is no longer needed, it should be disposed using disposeCompileLayer
.
:: CompileLayer l | |
=> l | |
-> TargetMachine | |
-> (Ptr Module -> IO (Ptr Module)) | module transformation |
-> (IRTransformLayer l -> IO a) | |
-> IO a |
bracket
-style wrapper around newIRTransformLayer
and disposeCompileLayer
.
Dispose of compile layers
disposeCompileLayer :: CompileLayer l => l -> IO () Source #
Dispose of a CompileLayer
. This should called when the
CompileLayer
is not needed anymore.
LinkingLayer
class LinkingLayer l Source #
After a CompileLayer
has compiled the modules to object code,
it passes the resulting object files to a LinkingLayer
.
Create linking layers
data ObjectLinkingLayer Source #
Bare bones implementation of a LinkingLayer
.
newObjectLinkingLayer :: IO ObjectLinkingLayer Source #
Create a new ObjectLinkingLayer
. This should be disposed using
disposeLinkingLayer
when it is no longer needed.
withObjectLinkingLayer :: (ObjectLinkingLayer -> IO a) -> IO a Source #
bracket
-style wrapper around newObjectLinkingLayer
and disposeLinkingLayer
.
Dispose of linking layers
disposeLinkingLayer :: LinkingLayer l => l -> IO () Source #
Dispose of a LinkingLayer
.
JITCompileCallbackManager
data JITCompileCallbackManager Source #
This is used by CompileOnDemandLayer
to create callback that
compile functions when they are called.
newJITCompileCallbackManager Source #
:: ShortByteString | target triple |
-> Maybe (IO ()) | called on compilation errors |
-> IO JITCompileCallbackManager |
Create a new JITCompileCallbackManager
.
When the callback manager is no longer needed, it should be freed
using disposeJITCompileCallbackManager
.
disposeJITCompileCallbackManager :: JITCompileCallbackManager -> IO () Source #
Dispose of a JITCompileCallbackManager
.
withJITCompileCallbackManager Source #
:: ShortByteString | target triple |
-> Maybe (IO ()) | called on compilation errors |
-> (JITCompileCallbackManager -> IO a) | |
-> IO a |
Execute a computation using a new JITCompileCallbackManager
.
IndirectStubsManagerBuilder
data IndirectStubsManagerBuilder Source #
This is used by CompileOnDemandLayer
to manage the stubs
created for function definitions that have not yet been compiled.
newIndirectStubsManagerBuilder Source #
:: ShortByteString | target triple |
-> IO IndirectStubsManagerBuilder |
Create a new IndirectStubsManagerBuilder
.
When the stubs manager is no longer needed, it should be freed
using disposeIndirectStubsManagerBuilder
.
disposeIndirectStubsManagerBuilder :: IndirectStubsManagerBuilder -> IO () Source #
Dispose of an IndirectStubsManagerBuilder
.
withIndirectStubsManagerBuilder Source #
:: ShortByteString | target triple |
-> (IndirectStubsManagerBuilder -> IO a) | |
-> IO a |
bracket
-style wrapper around newIndirectStubsManagerBuilder
and disposeIndirectStubsManagerBuilder
.