SimpleJITModule

Struct SimpleJITModule 

Source
pub struct SimpleJITModule { /* private fields */ }
Expand description

A SimpleJITModule implements Module and emits code and data into memory where it can be directly called and accessed.

See the SimpleJITBuilder for a convenient way to construct SimpleJITModule instances.

Implementations§

Source§

impl SimpleJITModule

Source

pub fn get_finalized_function(&self, func_id: FuncId) -> *const u8

Returns the address of a finalized function.

Source

pub fn get_finalized_data(&self, data_id: DataId) -> (*const u8, usize)

Returns the address and size of a finalized data object.

Source

pub fn finalize_definitions(&mut self)

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.

Source

pub fn new(builder: SimpleJITBuilder) -> Self

Create a new SimpleJITModule.

Source§

impl SimpleJITModule

Source

pub fn finish(self) -> SimpleJITProduct

SimpleJIT emits code and data into memory as it processes them. This method performs no additional processing, but returns a handle which allows freeing the allocated memory. Otherwise said memory is leaked to enable safe handling of the resulting pointers.

This method does not need to be called when access to the memory handle is not required.

Trait Implementations§

Source§

impl<'simple_jit_backend> Module for SimpleJITModule

Source§

fn isa(&self) -> &dyn TargetIsa

Return the TargetIsa to compile for.
Source§

fn declarations(&self) -> &ModuleDeclarations

Get all declarations in this module.
Source§

fn declare_function( &mut self, name: &str, linkage: Linkage, signature: &Signature, ) -> ModuleResult<FuncId>

Declare a function in this module.
Source§

fn declare_data( &mut self, name: &str, linkage: Linkage, writable: bool, tls: bool, ) -> ModuleResult<DataId>

Declare a data object in this module.
Source§

fn define_function<TS>( &mut self, id: FuncId, ctx: &mut Context, trap_sink: &mut TS, ) -> ModuleResult<ModuleCompiledFunction>
where TS: TrapSink,

Define a function, producing the function body from the given Context. Read more
Source§

fn define_function_bytes( &mut self, id: FuncId, bytes: &[u8], ) -> ModuleResult<ModuleCompiledFunction>

Define a function, taking the function body from the given bytes. Read more
Source§

fn define_data(&mut self, id: DataId, data: &DataContext) -> ModuleResult<()>

Define a data object, producing the data contents from the given DataContext.
Source§

fn get_name(&self, name: &str) -> Option<FuncOrDataId>

Get the module identifier for a given name, if that name has been declared.
Source§

fn target_config(&self) -> TargetFrontendConfig

Return the target information needed by frontends to produce Cranelift IR for the current target.
Source§

fn make_context(&self) -> Context

Create a new Context initialized for use with this Module. Read more
Source§

fn clear_context(&self, ctx: &mut Context)

Clear the given Context and reset it for use with a new function. Read more
Source§

fn make_signature(&self) -> Signature

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.
Source§

fn clear_signature(&self, sig: &mut Signature)

Clear the given Signature and reset for use with a new function. Read more
Source§

fn declare_func_in_func(&self, func: FuncId, in_func: &mut Function) -> FuncRef

Use this when you’re building the IR of a function to reference a function. Read more
Source§

fn declare_data_in_func(&self, data: DataId, func: &mut Function) -> GlobalValue

Use this when you’re building the IR of a function to reference a data object. Read more
Source§

fn declare_func_in_data(&self, func: FuncId, ctx: &mut DataContext) -> FuncRef

TODO: Same as above.
Source§

fn declare_data_in_data( &self, data: DataId, ctx: &mut DataContext, ) -> GlobalValue

TODO: Same as above.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.