Struct cranelift_jit::JITModule [−][src]
pub struct JITModule { /* fields omitted */ }
Expand description
A JITModule
implements Module
and emits code and data into memory where it can be
directly called and accessed.
See the JITBuilder
for a convenient way to construct JITModule
instances.
Implementations
Free memory allocated for code and data segments of compiled functions.
Safety
Because this function invalidates any pointers retrived from the
corresponding module, it should only be used when none of the functions
from that module are currently executing and none of the fn
pointers
are called afterwards.
Returns the given function’s entry in the Global Offset Table.
Panics if there’s no entry in the table for the given function.
Returns the address of a finalized function.
The pointer remains valid until either JITModule::free_memory
is called or in the future
some way of deallocating this individual function is used.
Returns the address and size of a finalized data object.
The pointer remains valid until either JITModule::free_memory
is called or in the future
some way of deallocating this individual data object is used.
Finalize all functions and data objects that are defined but not yet finalized. All symbols referenced in their bodies that are declared as needing a definition must be defined by this point.
Use get_finalized_function
and get_finalized_data
to obtain the final
artifacts.
Create a new JITModule
.
Allow a single future define_function
on a previously defined function. This allows for
hot code swapping and lazy compilation of functions.
This requires hotswap support to be enabled first using JITBuilder::hotswap
.
Trait Implementations
Use this when you’re building the IR of a function to reference a function.
TODO: Coalesce redundant decls and signatures. TODO: Look into ways to reduce the risk of using a FuncRef in the wrong function.
Use this when you’re building the IR of a function to reference a data object.
TODO: Same as above.
TODO: Same as above.
TODO: Same as above.
Get all declarations in this module.
fn declare_function(
&mut self,
name: &str,
linkage: Linkage,
signature: &Signature
) -> ModuleResult<FuncId>
fn declare_function(
&mut self,
name: &str,
linkage: Linkage,
signature: &Signature
) -> ModuleResult<FuncId>
Declare a function in this module.
Declare an anonymous function in this module.
fn declare_data(
&mut self,
name: &str,
linkage: Linkage,
writable: bool,
tls: bool
) -> ModuleResult<DataId>
fn declare_data(
&mut self,
name: &str,
linkage: Linkage,
writable: bool,
tls: bool
) -> ModuleResult<DataId>
Declare a data object in this module.
Declare an anonymous data object in this module.
fn define_function(
&mut self,
id: FuncId,
ctx: &mut Context,
trap_sink: &mut dyn TrapSink,
stack_map_sink: &mut dyn StackMapSink
) -> ModuleResult<ModuleCompiledFunction>
fn define_function(
&mut self,
id: FuncId,
ctx: &mut Context,
trap_sink: &mut dyn TrapSink,
stack_map_sink: &mut dyn StackMapSink
) -> ModuleResult<ModuleCompiledFunction>
Define a function, producing the function body from the given Context
. Read more
fn define_function_bytes(
&mut self,
id: FuncId,
bytes: &[u8],
relocs: &[RelocRecord]
) -> ModuleResult<ModuleCompiledFunction>
fn define_function_bytes(
&mut self,
id: FuncId,
bytes: &[u8],
relocs: &[RelocRecord]
) -> ModuleResult<ModuleCompiledFunction>
Define a function, taking the function body from the given bytes
. Read more
Define a data object, producing the data contents from the given DataContext
.
Get the module identifier for a given name, if that name has been declared. Read more
Return the target information needed by frontends to produce Cranelift IR for the current target. Read more
Create a new Context
initialized for use with this Module
. Read more
Clear the given Context
and reset it for use with a new function. Read more
Create a new empty Signature
with the default calling convention for
the TargetIsa
, to which parameter and return types can be added for
declaring a function to be called by this Module
. Read more
Clear the given Signature
and reset for use with a new function. Read more