SimpleJITBuilder

Struct SimpleJITBuilder 

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

A builder for SimpleJITModule.

Implementations§

Source§

impl SimpleJITBuilder

Source

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

Create a new SimpleJITBuilder.

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: Box<dyn TargetIsa>, libcall_names: Box<dyn Fn(LibCall) -> String>, ) -> Self

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

SimpleJIT requires a TargetIsa configured for non-PIC.

To create a SimpleJITBuilder for native use, use the new constructor 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) -> &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) -> &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.

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.