pub struct JITModule { /* private fields */ }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§
Source§impl JITModule
impl JITModule
Sourcepub unsafe fn free_memory(self)
pub unsafe fn free_memory(self)
Free memory allocated for code and data segments of compiled functions.
§Safety
Because this function invalidates any pointers retrieved 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.
Sourcepub fn get_finalized_function(&self, func_id: FuncId) -> *const u8
pub fn get_finalized_function(&self, func_id: FuncId) -> *const u8
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.
Sourcepub fn get_finalized_data(&self, data_id: DataId) -> (*const u8, usize)
pub fn get_finalized_data(&self, data_id: DataId) -> (*const u8, usize)
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.
Sourcepub fn finalize_definitions(&mut self) -> ModuleResult<()>
pub fn finalize_definitions(&mut self) -> ModuleResult<()>
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.
Returns ModuleError in case of allocation or syscall failure
Sourcepub fn new(builder: JITBuilder) -> Self
pub fn new(builder: JITBuilder) -> Self
Create a new JITModule.
Trait Implementations§
Source§impl Module for JITModule
impl Module for JITModule
Source§fn declarations(&self) -> &ModuleDeclarations
fn declarations(&self) -> &ModuleDeclarations
Source§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>
Source§fn declare_anonymous_function(
&mut self,
signature: &Signature,
) -> ModuleResult<FuncId>
fn declare_anonymous_function( &mut self, signature: &Signature, ) -> ModuleResult<FuncId>
Source§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>
Source§fn declare_anonymous_data(
&mut self,
writable: bool,
tls: bool,
) -> ModuleResult<DataId>
fn declare_anonymous_data( &mut self, writable: bool, tls: bool, ) -> ModuleResult<DataId>
Source§fn define_function_with_control_plane(
&mut self,
id: FuncId,
ctx: &mut Context,
ctrl_plane: &mut ControlPlane,
) -> ModuleResult<()>
fn define_function_with_control_plane( &mut self, id: FuncId, ctx: &mut Context, ctrl_plane: &mut ControlPlane, ) -> ModuleResult<()>
Context. Read moreSource§fn define_function_bytes(
&mut self,
id: FuncId,
alignment: u64,
bytes: &[u8],
relocs: &[ModuleReloc],
) -> ModuleResult<()>
fn define_function_bytes( &mut self, id: FuncId, alignment: u64, bytes: &[u8], relocs: &[ModuleReloc], ) -> ModuleResult<()>
bytes. Read moreSource§fn define_data(
&mut self,
id: DataId,
data: &DataDescription,
) -> ModuleResult<()>
fn define_data( &mut self, id: DataId, data: &DataDescription, ) -> ModuleResult<()>
DataDescription.Source§fn get_name(&self, name: &str) -> Option<FuncOrDataId>
fn get_name(&self, name: &str) -> Option<FuncOrDataId>
Source§fn target_config(&self) -> TargetFrontendConfig
fn target_config(&self) -> TargetFrontendConfig
Source§fn make_context(&self) -> Context
fn make_context(&self) -> Context
Source§fn clear_context(&self, ctx: &mut Context)
fn clear_context(&self, ctx: &mut Context)
Context and reset it for use with a new function. Read moreSource§fn make_signature(&self) -> Signature
fn make_signature(&self) -> Signature
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.Source§fn clear_signature(&self, sig: &mut Signature)
fn clear_signature(&self, sig: &mut Signature)
Signature and reset for use with a new function. Read moreSource§fn declare_func_in_func(
&mut self,
func_id: FuncId,
func: &mut Function,
) -> FuncRef
fn declare_func_in_func( &mut self, func_id: FuncId, func: &mut Function, ) -> FuncRef
Source§fn declare_data_in_func(&self, data: DataId, func: &mut Function) -> GlobalValue
fn declare_data_in_func(&self, data: DataId, func: &mut Function) -> GlobalValue
Source§fn declare_func_in_data(
&self,
func_id: FuncId,
data: &mut DataDescription,
) -> FuncRef
fn declare_func_in_data( &self, func_id: FuncId, data: &mut DataDescription, ) -> FuncRef
Source§fn declare_data_in_data(
&self,
data_id: DataId,
data: &mut DataDescription,
) -> GlobalValue
fn declare_data_in_data( &self, data_id: DataId, data: &mut DataDescription, ) -> GlobalValue
Source§fn define_function(
&mut self,
func: FuncId,
ctx: &mut Context,
) -> Result<(), ModuleError>
fn define_function( &mut self, func: FuncId, ctx: &mut Context, ) -> Result<(), ModuleError>
Context. Read more