wasmtime_cranelift

Struct ModuleTextBuilder

Source
pub struct ModuleTextBuilder<'a> { /* private fields */ }
Expand description

A helper structure used to assemble the final text section of an executable, plus unwinding information and other related details.

This builder relies on Cranelift-specific internals but assembles into a generic Object which will get further appended to in a compiler-agnostic fashion later.

Implementations§

Source§

impl<'a> ModuleTextBuilder<'a>

Source

pub fn new( obj: &'a mut Object<'static>, compiler: &'a dyn Compiler, text: Box<dyn TextSectionBuilder>, ) -> Self

Creates a new builder for the text section of an executable.

The .text section will be appended to the specified obj along with any unwinding or such information as necessary. The num_funcs parameter indicates the number of times the append_func function will be called. The finish function will panic if this contract is not met.

Source

pub fn append_func( &mut self, name: &str, compiled_func: &'a CompiledFunction, resolve_reloc_target: impl Fn(RelocationTarget) -> usize, ) -> (SymbolId, Range<u64>)

Appends the func specified named name to this object.

The resolve_reloc_target closure is used to resolve a relocation target to an adjacent function which has already been added or will be added to this object. The argument is the relocation target specified within CompiledFunction and the return value must be an index where the target will be defined by the nth call to append_func.

Returns the symbol associated with the function as well as the range that the function resides within the text section.

Source

pub fn force_veneers(&mut self)

Forces “veneers” to be used for inter-function calls in the text section which means that in-bounds optimized addresses are never used.

This is only useful for debugging cranelift itself and typically this option is disabled.

Source

pub fn append_padding(&mut self, padding: usize)

Appends the specified amount of bytes of padding into the text section.

This is only useful when fuzzing and/or debugging cranelift itself and for production scenarios padding is 0 and this function does nothing.

Source

pub fn finish(self)

Indicates that the text section has been written completely and this will finish appending it to the original object.

Note that this will also write out the unwind information sections if necessary.

Auto Trait Implementations§

§

impl<'a> Freeze for ModuleTextBuilder<'a>

§

impl<'a> !RefUnwindSafe for ModuleTextBuilder<'a>

§

impl<'a> !Send for ModuleTextBuilder<'a>

§

impl<'a> !Sync for ModuleTextBuilder<'a>

§

impl<'a> Unpin for ModuleTextBuilder<'a>

§

impl<'a> !UnwindSafe for ModuleTextBuilder<'a>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.