Struct wasmtime_environ::ObjectBuilder

source ·
pub struct ObjectBuilder<'a> { /* private fields */ }
Expand description

Helper structure to create an ELF file as a compilation artifact.

This structure exposes the process which Wasmtime will encode a core wasm module into an ELF file, notably managing data sections and all that good business going into the final file.

Implementations§

source§

impl<'a> ObjectBuilder<'a>

source

pub fn new( obj: Object<'a>, tunables: &'a Tunables, triple: Triple, ) -> ObjectBuilder<'a>

Creates a new builder for the obj specified.

source

pub fn push_debuginfo( &mut self, dwarf: &mut Vec<(u8, Range<u64>)>, debuginfo: &DebugInfoData<'_>, )

Insert the wasm raw wasm-based debuginfo into the output. Note that this is distinct from the native debuginfo possibly generated by the native compiler, hence these sections getting wasm-specific names.

source

pub fn append( &mut self, translation: ModuleTranslation<'_>, funcs: PrimaryMap<DefinedFuncIndex, CompiledFunctionInfo>, wasm_to_array_trampolines: Vec<(ModuleInternedTypeIndex, FunctionLoc)>, ) -> Result<CompiledModuleInfo>

Completes compilation of the translation specified, inserting everything necessary into the Object being built.

This function will consume the final results of compiling a wasm module and finish the ELF image in-progress as part of self.obj by appending any compiler-agnostic sections.

The auxiliary CompiledModuleInfo structure returned here has also been serialized into the object returned, but if the caller will quickly turn-around and invoke CompiledModule::from_artifacts after this then the information can be passed to that method to avoid extra deserialization. This is done to avoid a serialize-then-deserialize for API calls like Module::new where the compiled module is immediately going to be used.

The various arguments here are:

  • translation - the core wasm translation that’s being completed.

  • funcs - compilation metadata about functions within the translation as well as where the functions are located in the text section and any associated trampolines.

  • wasm_to_array_trampolines - list of all trampolines necessary for Wasm callers calling array callees (e.g. Func::wrap). One for each function signature in the module. Must be sorted by SignatureIndex.

Returns the CompiledModuleInfo corresponding to this core Wasm module as a result of this append operation. This is then serialized into the final artifact by the caller.

source

pub fn serialize_info<T>(&mut self, info: &T)
where T: Serialize,

Creates the ELF_WASMTIME_INFO section from the given serializable data structure.

source

pub fn finish<T: WritableBuffer>(self, t: &mut T) -> Result<()>

Serializes self into a buffer. This can be used for execution as well as serialization.

Auto Trait Implementations§

§

impl<'a> Freeze for ObjectBuilder<'a>

§

impl<'a> RefUnwindSafe for ObjectBuilder<'a>

§

impl<'a> Send for ObjectBuilder<'a>

§

impl<'a> Sync for ObjectBuilder<'a>

§

impl<'a> Unpin for ObjectBuilder<'a>

§

impl<'a> UnwindSafe for ObjectBuilder<'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, 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.