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>
impl<'a> ObjectBuilder<'a>
sourcepub fn new(obj: Object<'a>, tunables: &'a Tunables) -> ObjectBuilder<'a>
pub fn new(obj: Object<'a>, tunables: &'a Tunables) -> ObjectBuilder<'a>
Creates a new builder for the obj
specified.
sourcepub fn append(
&mut self,
translation: ModuleTranslation<'_>,
funcs: PrimaryMap<DefinedFuncIndex, CompiledFunctionInfo>,
wasm_to_native_trampolines: Vec<(ModuleInternedTypeIndex, FunctionLoc)>
) -> Result<CompiledModuleInfo>
pub fn append( &mut self, translation: ModuleTranslation<'_>, funcs: PrimaryMap<DefinedFuncIndex, CompiledFunctionInfo>, wasm_to_native_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_native_trampolines
- list of all trampolines necessary for Wasm callers calling native callees (e.g.Func::wrap
). One for each function signature in the module. Must be sorted bySignatureIndex
.
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.
sourcepub fn serialize_info<T>(&mut self, info: &T)where
T: Serialize,
pub fn serialize_info<T>(&mut self, info: &T)where
T: Serialize,
Creates the ELF_WASMTIME_INFO
section from the given serializable data
structure.