Trait wasmtime_environ::Compiler [−][src]
pub trait Compiler: Send + Sync {
fn compile_function(
&self,
translation: &ModuleTranslation<'_>,
index: DefinedFuncIndex,
data: FunctionBodyData<'_>,
tunables: &Tunables,
types: &TypeTables
) -> Result<Box<dyn Any + Send>, CompileError>;
fn emit_obj(
&self,
module: &ModuleTranslation<'_>,
types: &TypeTables,
funcs: PrimaryMap<DefinedFuncIndex, Box<dyn Any + Send>>,
emit_dwarf: bool,
obj: &mut Object
) -> Result<(PrimaryMap<DefinedFuncIndex, FunctionInfo>, Vec<Trampoline>)>;
fn emit_trampoline_obj(
&self,
ty: &WasmFuncType,
host_fn: usize,
obj: &mut Object
) -> Result<(Trampoline, Trampoline)>;
fn triple(&self) -> &Triple;
fn flags(&self) -> BTreeMap<String, FlagValue>;
fn isa_flags(&self) -> BTreeMap<String, FlagValue>;
fn object(&self) -> Result<Object> { ... }
}Expand description
An implementation of a compiler which can compile WebAssembly functions to machine code and perform other miscellaneous tasks needed by the JIT runtime.
Required methods
fn compile_function(
&self,
translation: &ModuleTranslation<'_>,
index: DefinedFuncIndex,
data: FunctionBodyData<'_>,
tunables: &Tunables,
types: &TypeTables
) -> Result<Box<dyn Any + Send>, CompileError>
fn compile_function(
&self,
translation: &ModuleTranslation<'_>,
index: DefinedFuncIndex,
data: FunctionBodyData<'_>,
tunables: &Tunables,
types: &TypeTables
) -> Result<Box<dyn Any + Send>, CompileError>
Compiles the function index within translation.
The body of the function is available in data and configuration
values are also passed in via tunables. Type information in
translation is all relative to types.
fn emit_obj(
&self,
module: &ModuleTranslation<'_>,
types: &TypeTables,
funcs: PrimaryMap<DefinedFuncIndex, Box<dyn Any + Send>>,
emit_dwarf: bool,
obj: &mut Object
) -> Result<(PrimaryMap<DefinedFuncIndex, FunctionInfo>, Vec<Trampoline>)>
fn emit_obj(
&self,
module: &ModuleTranslation<'_>,
types: &TypeTables,
funcs: PrimaryMap<DefinedFuncIndex, Box<dyn Any + Send>>,
emit_dwarf: bool,
obj: &mut Object
) -> Result<(PrimaryMap<DefinedFuncIndex, FunctionInfo>, Vec<Trampoline>)>
Collects the results of compilation into an in-memory object.
This function will receive the same Box<dyn Ayn> produced as part of
compile_function, as well as the general compilation environment with
the translation/types. This method is expected to populate information
in the object file such as:
- Compiled code in a
.textsection - Unwind information in Wasmtime-specific sections
- DWARF debugging information for the host, if
emit_dwarfistrueand the compiler supports it. - Relocations, if necessary, for the text section
The final result of compilation will contain more sections inserted by the compiler-agnostic runtime.
fn emit_trampoline_obj(
&self,
ty: &WasmFuncType,
host_fn: usize,
obj: &mut Object
) -> Result<(Trampoline, Trampoline)>
fn emit_trampoline_obj(
&self,
ty: &WasmFuncType,
host_fn: usize,
obj: &mut Object
) -> Result<(Trampoline, Trampoline)>
Inserts two functions for host-to-wasm and wasm-to-host trampolines into
the obj provided.
This will configure the same sections as emit_obj, but will likely be
much smaller. The two returned Trampoline structures describe where to
find the host-to-wasm and wasm-to-host trampolines in the text section,
respectively.
Returns a list of configured settings for this compiler.