Struct cranelift_jit::JITBuilder

source ·
pub struct JITBuilder { /* private fields */ }
Expand description

A builder for JITModule.

Implementations§

source§

impl JITBuilder

source

pub fn new( libcall_names: Box<dyn Fn(LibCall) -> String + Send + Sync> ) -> ModuleResult<Self>

Create a new JITBuilder.

The libcall_names function provides a way to translate cranelift_codegen’s ir::LibCall enum to symbols. LibCalls are inserted in the IR as part of the legalization for certain floating point instructions, and for stack probes. If you don’t know what to use for this argument, use cranelift_module::default_libcall_names().

source

pub fn with_flags( flags: &[(&str, &str)], libcall_names: Box<dyn Fn(LibCall) -> String + Send + Sync> ) -> ModuleResult<Self>

Create a new JITBuilder with the given flags.

The libcall_names function provides a way to translate cranelift_codegen’s ir::LibCall enum to symbols. LibCalls are inserted in the IR as part of the legalization for certain floating point instructions, and for stack probes. If you don’t know what to use for this argument, use cranelift_module::default_libcall_names().

source

pub fn with_isa( isa: OwnedTargetIsa, libcall_names: Box<dyn Fn(LibCall) -> String + Send + Sync> ) -> Self

Create a new JITBuilder with an arbitrary target. This is mainly useful for testing.

To create a JITBuilder for native use, use the new or with_flags constructors instead.

The libcall_names function provides a way to translate cranelift_codegen’s ir::LibCall enum to symbols. LibCalls are inserted in the IR as part of the legalization for certain floating point instructions, and for stack probes. If you don’t know what to use for this argument, use cranelift_module::default_libcall_names().

source

pub fn symbol<K>(&mut self, name: K, ptr: *const u8) -> &mut Self
where K: Into<String>,

Define a symbol in the internal symbol table.

The JIT will use the symbol table to resolve names that are declared, but not defined, in the module being compiled. A common example is external functions. With this method, functions and data can be exposed to the code being compiled which are defined by the host.

If a symbol is defined more than once, the most recent definition will be retained.

If the JIT fails to find a symbol in its internal table, it will fall back to a platform-specific search (this typically involves searching the current process for public symbols, followed by searching the platform’s C runtime).

source

pub fn symbols<It, K>(&mut self, symbols: It) -> &mut Self
where It: IntoIterator<Item = (K, *const u8)>, K: Into<String>,

Define multiple symbols in the internal symbol table.

Using this is equivalent to calling symbol on each element.

source

pub fn symbol_lookup_fn( &mut self, symbol_lookup_fn: Box<dyn Fn(&str) -> Option<*const u8>> ) -> &mut Self

Add a symbol lookup fn.

Symbol lookup fn’s are used to lookup symbols when they couldn’t be found in the internal symbol table. Symbol lookup fn’s are called in reverse of the order in which they were added.

source

pub fn hotswap(&mut self, enabled: bool) -> &mut Self

Enable or disable hotswap support. See JITModule::prepare_for_function_redefine for more information.

Enabling hotswap support requires PIC code.

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>,

§

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>,

§

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.