pub struct FuncTranslator {
func_ctx: FunctionBuilderContext,
state: FuncTranslationState,
}
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.
Fields§
§func_ctx: FunctionBuilderContext
§state: FuncTranslationState
Implementations§
source§impl FuncTranslator
impl FuncTranslator
sourcepub fn translate<FE: FuncEnvironment + ?Sized>(
&mut self,
module_translation_state: &ModuleTranslationState,
reader: &mut dyn FunctionBinaryReader<'_>,
func: &mut Function,
environ: &mut FE,
local_function_index: LocalFunctionIndex,
) -> WasmResult<()>
pub fn translate<FE: FuncEnvironment + ?Sized>( &mut self, module_translation_state: &ModuleTranslationState, reader: &mut dyn FunctionBinaryReader<'_>, func: &mut Function, environ: &mut FE, local_function_index: LocalFunctionIndex, ) -> WasmResult<()>
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.
sourcepub fn translate_from_reader<FE: FuncEnvironment + ?Sized>(
&mut self,
module_translation_state: &ModuleTranslationState,
reader: &mut dyn FunctionBinaryReader<'_>,
func: &mut Function,
environ: &mut FE,
) -> WasmResult<()>
pub fn translate_from_reader<FE: FuncEnvironment + ?Sized>( &mut self, module_translation_state: &ModuleTranslationState, reader: &mut dyn FunctionBinaryReader<'_>, func: &mut Function, environ: &mut FE, ) -> WasmResult<()>
Translate a binary WebAssembly function from a FunctionBinaryReader
.
Auto Trait Implementations§
impl Freeze for FuncTranslator
impl RefUnwindSafe for FuncTranslator
impl Send for FuncTranslator
impl Sync for FuncTranslator
impl Unpin for FuncTranslator
impl UnwindSafe for FuncTranslator
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more