Struct wasmtime_environ::wasm::FuncTranslator [−][src]
pub struct FuncTranslator { /* fields omitted */ }
Expand description
WebAssembly to Cranelift IR function translator.
A FuncTranslator
is used to translate a binary WebAssembly function into Cranelift IR guided
by a FuncEnvironment
object. A single translator instance can be reused to translate multiple
functions which will reduce heap allocation traffic.
Implementations
impl FuncTranslator
[src]
impl FuncTranslator
[src]pub fn new() -> FuncTranslator
[src]
pub fn new() -> FuncTranslator
[src]Create a new translator.
pub fn translate<FE>(
&mut self,
validator: &mut FuncValidator<impl WasmModuleResources>,
code: &[u8],
code_offset: usize,
func: &mut Function,
environ: &mut FE
) -> Result<(), WasmError> where
FE: FuncEnvironment + ?Sized,
[src]
pub fn translate<FE>(
&mut self,
validator: &mut FuncValidator<impl WasmModuleResources>,
code: &[u8],
code_offset: usize,
func: &mut Function,
environ: &mut FE
) -> Result<(), WasmError> where
FE: FuncEnvironment + ?Sized,
[src]Translate a binary WebAssembly function.
The code
slice contains the binary WebAssembly function code as it appears in the code
section of a WebAssembly module, not including the initial size of the function code. The
slice is expected to contain two parts:
- The declaration of locals, and
- The function body as an expression.
See the WebAssembly specification.
The Cranelift IR function func
should be completely empty except for the func.signature
and func.name
fields. The signature may contain special-purpose arguments which are not
regarded as WebAssembly local variables. Any signature arguments marked as
ArgumentPurpose::Normal
are made accessible as WebAssembly local variables.
pub fn translate_body<FE>(
&mut self,
validator: &mut FuncValidator<impl WasmModuleResources>,
body: FunctionBody<'_>,
func: &mut Function,
environ: &mut FE
) -> Result<(), WasmError> where
FE: FuncEnvironment + ?Sized,
[src]
pub fn translate_body<FE>(
&mut self,
validator: &mut FuncValidator<impl WasmModuleResources>,
body: FunctionBody<'_>,
func: &mut Function,
environ: &mut FE
) -> Result<(), WasmError> where
FE: FuncEnvironment + ?Sized,
[src]Translate a binary WebAssembly function from a FunctionBody
.