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.