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) -> ObjectBuilder<'a>

Creates a new builder for the obj specified.

source

pub fn append( &mut self, translation: ModuleTranslation<'_>, funcs: PrimaryMap<DefinedFuncIndex, (WasmFunctionInfo, FunctionLoc)>, trampolines: Vec<(SignatureIndex, 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.

  • trampolines - list of all trampolines necessary for this module and where they’re located in the text section.

Returns the CompiledModuleInfo corresopnding 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(self) -> Result<MmapVec>

Creates a new MmapVec from self.

The returned MmapVec will contain the serialized version of self and is sized appropriately to the exact size of the object serialized.

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.