pub struct FuncEnvironment<'module_environment> {Show 36 fields
target_config: TargetFrontendConfig,
module: &'module_environment ModuleInfo,
type_stack: Vec<Type>,
signatures: &'module_environment PrimaryMap<SignatureIndex, Signature>,
signature_hashes: &'module_environment PrimaryMap<SignatureIndex, SignatureHash>,
heaps: PrimaryMap<Heap, HeapData>,
vmctx: Option<GlobalValue>,
memory32_size_sig: Option<SigRef>,
table_size_sig: Option<SigRef>,
memory_grow_sig: Option<SigRef>,
table_grow_sig: Option<SigRef>,
table_copy_sig: Option<SigRef>,
table_init_sig: Option<SigRef>,
elem_drop_sig: Option<SigRef>,
memory_copy_sig: Option<SigRef>,
memory_fill_sig: Option<SigRef>,
memory_init_sig: Option<SigRef>,
data_drop_sig: Option<SigRef>,
table_get_sig: Option<SigRef>,
table_set_sig: Option<SigRef>,
func_ref_sig: Option<SigRef>,
table_fill_sig: Option<SigRef>,
memory32_atomic_wait32_sig: Option<SigRef>,
memory32_atomic_wait64_sig: Option<SigRef>,
memory32_atomic_notify_sig: Option<SigRef>,
raise_trap_sig: Option<SigRef>,
personality2_sig: Option<SigRef>,
throw_sig: Option<SigRef>,
alloc_exception_sig: Option<SigRef>,
read_exception_sig: Option<SigRef>,
read_exnref_sig: Option<SigRef>,
exception_type_layouts: HashMap<u32, ExceptionTypeLayout>,
offsets: VMOffsets,
memory_styles: &'module_environment PrimaryMap<MemoryIndex, MemoryStyle>,
tables: SecondaryMap<TableIndex, Option<TableData>>,
table_styles: &'module_environment PrimaryMap<TableIndex, TableStyle>,
}Expand description
The FuncEnvironment implementation for use by the ModuleEnvironment.
Fields§
§target_config: TargetFrontendConfigTarget-specified configuration.
module: &'module_environment ModuleInfoThe module-level environment which this function-level environment belongs to.
type_stack: Vec<Type>A stack tracking the type of local variables.
signatures: &'module_environment PrimaryMap<SignatureIndex, Signature>The module function signatures
signature_hashes: &'module_environment PrimaryMap<SignatureIndex, SignatureHash>Cached stable hashes for module signatures.
heaps: PrimaryMap<Heap, HeapData>Heaps implementing WebAssembly linear memories.
vmctx: Option<GlobalValue>The Cranelift global holding the vmctx address.
memory32_size_sig: Option<SigRef>The external function signature for implementing wasm’s memory.size
for locally-defined 32-bit memories.
table_size_sig: Option<SigRef>The external function signature for implementing wasm’s table.size
for locally-defined tables.
memory_grow_sig: Option<SigRef>The external function signature for implementing wasm’s memory.grow
for locally-defined memories.
table_grow_sig: Option<SigRef>The external function signature for implementing wasm’s table.grow
for locally-defined tables.
table_copy_sig: Option<SigRef>The external function signature for implementing wasm’s table.copy
(it’s the same for both local and imported tables).
table_init_sig: Option<SigRef>The external function signature for implementing wasm’s table.init.
elem_drop_sig: Option<SigRef>The external function signature for implementing wasm’s elem.drop.
memory_copy_sig: Option<SigRef>The external function signature for implementing wasm’s memory.copy
(it’s the same for both local and imported memories).
memory_fill_sig: Option<SigRef>The external function signature for implementing wasm’s memory.fill
(it’s the same for both local and imported memories).
memory_init_sig: Option<SigRef>The external function signature for implementing wasm’s memory.init.
data_drop_sig: Option<SigRef>The external function signature for implementing wasm’s data.drop.
table_get_sig: Option<SigRef>The external function signature for implementing wasm’s table.get.
table_set_sig: Option<SigRef>The external function signature for implementing wasm’s table.set.
func_ref_sig: Option<SigRef>The external function signature for implementing wasm’s func.ref.
table_fill_sig: Option<SigRef>The external function signature for implementing wasm’s table.fill.
memory32_atomic_wait32_sig: Option<SigRef>The external function signature for implementing wasm’s memory32.atomic.wait32.
memory32_atomic_wait64_sig: Option<SigRef>The external function signature for implementing wasm’s memory32.atomic.wait64.
memory32_atomic_notify_sig: Option<SigRef>The external function signature for implementing wasm’s memory32.atomic.notify.
raise_trap_sig: Option<SigRef>Cached signatures for exception helper builtins.
personality2_sig: Option<SigRef>§throw_sig: Option<SigRef>§alloc_exception_sig: Option<SigRef>§read_exception_sig: Option<SigRef>§read_exnref_sig: Option<SigRef>§exception_type_layouts: HashMap<u32, ExceptionTypeLayout>Cached payload layouts for exception tags.
offsets: VMOffsetsOffsets to struct fields accessed by JIT code.
memory_styles: &'module_environment PrimaryMap<MemoryIndex, MemoryStyle>The memory styles
tables: SecondaryMap<TableIndex, Option<TableData>>Cranelift tables we have created to implement Wasm tables.
table_styles: &'module_environment PrimaryMap<TableIndex, TableStyle>Implementations§
Source§impl<'module_environment> FuncEnvironment<'module_environment>
impl<'module_environment> FuncEnvironment<'module_environment>
pub fn new( target_config: TargetFrontendConfig, module: &'module_environment ModuleInfo, signatures: &'module_environment PrimaryMap<SignatureIndex, Signature>, signature_hashes: &'module_environment PrimaryMap<SignatureIndex, SignatureHash>, memory_styles: &'module_environment PrimaryMap<MemoryIndex, MemoryStyle>, table_styles: &'module_environment PrimaryMap<TableIndex, TableStyle>, ) -> Self
pub(crate) fn target_config(&self) -> TargetFrontendConfig
pub(crate) fn pointer_type(&self) -> Type
pub(crate) fn reference_type(&self) -> Type
fn ensure_table_exists(&mut self, func: &mut Function, index: TableIndex)
fn vmctx(&mut self, func: &mut Function) -> GlobalValue
fn get_table_fill_sig(&mut self, func: &mut Function) -> SigRef
fn get_table_fill_func( &mut self, func: &mut Function, table_index: TableIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_func_ref_sig(&mut self, func: &mut Function) -> SigRef
fn get_func_ref_func( &mut self, func: &mut Function, function_index: FunctionIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_table_get_sig(&mut self, func: &mut Function) -> SigRef
fn get_table_get_func( &mut self, func: &mut Function, table_index: TableIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_table_set_sig(&mut self, func: &mut Function) -> SigRef
fn get_table_set_func( &mut self, func: &mut Function, table_index: TableIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_table_grow_sig(&mut self, func: &mut Function) -> SigRef
Sourcefn get_table_grow_func(
&mut self,
func: &mut Function,
index: TableIndex,
) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_table_grow_func( &mut self, func: &mut Function, index: TableIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
Return the table.grow function signature to call for the given index, along with the
translated index value to pass to it and its index in VMBuiltinFunctionsArray.
fn get_memory_grow_sig(&mut self, func: &mut Function) -> SigRef
Sourcefn get_memory_grow_func(
&mut self,
func: &mut Function,
index: MemoryIndex,
) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_memory_grow_func( &mut self, func: &mut Function, index: MemoryIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
Return the memory.grow function signature to call for the given index, along with the
translated index value to pass to it and its index in VMBuiltinFunctionsArray.
fn get_table_size_sig(&mut self, func: &mut Function) -> SigRef
Sourcefn get_table_size_func(
&mut self,
func: &mut Function,
index: TableIndex,
) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_table_size_func( &mut self, func: &mut Function, index: TableIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
Return the memory.size function signature to call for the given index, along with the
translated index value to pass to it and its index in VMBuiltinFunctionsArray.
fn get_memory32_size_sig(&mut self, func: &mut Function) -> SigRef
Sourcefn get_memory_size_func(
&mut self,
func: &mut Function,
index: MemoryIndex,
) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_memory_size_func( &mut self, func: &mut Function, index: MemoryIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
Return the memory.size function signature to call for the given index, along with the
translated index value to pass to it and its index in VMBuiltinFunctionsArray.
fn get_table_copy_sig(&mut self, func: &mut Function) -> SigRef
fn get_table_copy_func( &mut self, func: &mut Function, dst_table_index: TableIndex, src_table_index: TableIndex, ) -> (SigRef, usize, usize, VMBuiltinFunctionIndex)
fn get_table_init_sig(&mut self, func: &mut Function) -> SigRef
fn get_table_init_func( &mut self, func: &mut Function, table_index: TableIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_elem_drop_sig(&mut self, func: &mut Function) -> SigRef
fn get_elem_drop_func( &mut self, func: &mut Function, ) -> (SigRef, VMBuiltinFunctionIndex)
fn get_memory_copy_sig(&mut self, func: &mut Function) -> SigRef
fn get_memory_copy_func( &mut self, func: &mut Function, memory_index: MemoryIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_memory_fill_sig(&mut self, func: &mut Function) -> SigRef
fn get_memory_fill_func( &mut self, func: &mut Function, memory_index: MemoryIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_memory_init_sig(&mut self, func: &mut Function) -> SigRef
fn get_memory_init_func( &mut self, func: &mut Function, ) -> (SigRef, VMBuiltinFunctionIndex)
fn get_data_drop_sig(&mut self, func: &mut Function) -> SigRef
fn get_data_drop_func( &mut self, func: &mut Function, ) -> (SigRef, VMBuiltinFunctionIndex)
fn get_memory32_atomic_wait32_sig(&mut self, func: &mut Function) -> SigRef
Sourcefn get_memory_atomic_wait32_func(
&mut self,
func: &mut Function,
index: MemoryIndex,
) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_memory_atomic_wait32_func( &mut self, func: &mut Function, index: MemoryIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
Return the memory.atomic.wait32 function signature to call for the given index,
along with the translated index value to pass to it
and its index in VMBuiltinFunctionsArray.
fn get_memory32_atomic_wait64_sig(&mut self, func: &mut Function) -> SigRef
Sourcefn get_memory_atomic_wait64_func(
&mut self,
func: &mut Function,
index: MemoryIndex,
) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_memory_atomic_wait64_func( &mut self, func: &mut Function, index: MemoryIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
Return the memory.atomic.wait64 function signature to call for the given index,
along with the translated index value to pass to it
and its index in VMBuiltinFunctionsArray.
fn get_memory32_atomic_notify_sig(&mut self, func: &mut Function) -> SigRef
Sourcefn get_memory_atomic_notify_func(
&mut self,
func: &mut Function,
index: MemoryIndex,
) -> (SigRef, usize, VMBuiltinFunctionIndex)
fn get_memory_atomic_notify_func( &mut self, func: &mut Function, index: MemoryIndex, ) -> (SigRef, usize, VMBuiltinFunctionIndex)
Return the memory.atomic.notify function signature to call for the given index,
along with the translated index value to pass to it
and its index in VMBuiltinFunctionsArray.
fn get_personality2_func( &mut self, func: &mut Function, ) -> (SigRef, VMBuiltinFunctionIndex)
fn get_throw_func( &mut self, func: &mut Function, ) -> (SigRef, VMBuiltinFunctionIndex)
fn get_raise_trap_func( &mut self, func: &mut Function, ) -> (SigRef, VMBuiltinFunctionIndex)
fn get_alloc_exception_func( &mut self, func: &mut Function, ) -> (SigRef, VMBuiltinFunctionIndex)
fn get_read_exnref_func( &mut self, func: &mut Function, ) -> (SigRef, VMBuiltinFunctionIndex)
fn get_read_exception_func( &mut self, func: &mut Function, ) -> (SigRef, VMBuiltinFunctionIndex)
fn exception_type_layout( &mut self, tag_index: TagIndex, ) -> WasmResult<&ExceptionTypeLayout>
fn compute_exception_type_layout( &self, tag_index: TagIndex, ) -> WasmResult<ExceptionTypeLayout>
fn map_wasmer_type_to_ir(&self, ty: WasmerType) -> WasmResult<Type>
fn call_with_handlers( &mut self, builder: &mut FunctionBuilder<'_>, callee: FuncRef, args: &[Value], context: Option<Value>, landing_pad: Option<LandingPad>, unreachable_on_return: bool, ) -> SmallVec<[Value; 4]>
fn call_indirect_with_handlers( &mut self, builder: &mut FunctionBuilder<'_>, sig: SigRef, func_addr: Value, args: &[Value], context: Option<Value>, landing_pad: Option<LandingPad>, unreachable_on_return: bool, ) -> SmallVec<[Value; 4]>
Sourcefn translate_load_builtin_function_address(
&mut self,
pos: &mut FuncCursor<'_>,
callee_func_idx: VMBuiltinFunctionIndex,
) -> (Value, Value)
fn translate_load_builtin_function_address( &mut self, pos: &mut FuncCursor<'_>, callee_func_idx: VMBuiltinFunctionIndex, ) -> (Value, Value)
Translates load of builtin function and returns a pair of values vmctx
and address of the loaded function.
fn get_or_init_funcref_table_elem( &mut self, builder: &mut FunctionBuilder<'_>, table_index: TableIndex, index: Value, ) -> (Value, bool)
Source§impl FuncEnvironment<'_>
impl FuncEnvironment<'_>
pub(crate) fn is_wasm_parameter( &self, _signature: &Signature, index: usize, ) -> bool
pub(crate) fn translate_unreachable( &mut self, builder: &mut FunctionBuilder<'_>, ) -> WasmResult<()>
pub(crate) fn translate_table_grow( &mut self, pos: FuncCursor<'_>, table_index: TableIndex, delta: Value, init_value: Value, ) -> WasmResult<Value>
pub(crate) fn translate_table_get( &mut self, builder: &mut FunctionBuilder<'_>, table_index: TableIndex, index: Value, ) -> WasmResult<Value>
pub(crate) fn translate_table_set( &mut self, builder: &mut FunctionBuilder<'_>, table_index: TableIndex, value: Value, index: Value, ) -> WasmResult<()>
pub(crate) fn translate_table_fill( &mut self, pos: FuncCursor<'_>, table_index: TableIndex, dst: Value, val: Value, len: Value, ) -> WasmResult<()>
pub(crate) fn translate_ref_null( &mut self, pos: FuncCursor<'_>, ty: HeapType, ) -> WasmResult<Value>
pub(crate) fn translate_ref_is_null( &mut self, pos: FuncCursor<'_>, value: Value, ) -> WasmResult<Value>
pub(crate) fn translate_ref_func( &mut self, pos: FuncCursor<'_>, func_index: FunctionIndex, ) -> WasmResult<Value>
pub(crate) fn translate_custom_global_get( &mut self, _pos: FuncCursor<'_>, _index: GlobalIndex, ) -> WasmResult<Value>
pub(crate) fn translate_custom_global_set( &mut self, _pos: FuncCursor<'_>, _index: GlobalIndex, _value: Value, ) -> WasmResult<()>
pub(crate) fn make_heap( &mut self, func: &mut Function, index: MemoryIndex, ) -> WasmResult<Heap>
pub(crate) fn make_global( &mut self, func: &mut Function, index: GlobalIndex, ) -> WasmResult<GlobalVariable>
pub(crate) fn make_indirect_sig( &mut self, func: &mut Function, index: SignatureIndex, ) -> WasmResult<SigRef>
pub(crate) fn make_direct_func( &mut self, func: &mut Function, index: FunctionIndex, ) -> WasmResult<FuncRef>
pub(crate) fn translate_call_indirect( &mut self, builder: &mut FunctionBuilder<'_>, table_index: TableIndex, sig_index: SignatureIndex, sig_ref: SigRef, callee: Value, call_args: &[Value], landing_pad: Option<LandingPad>, ) -> WasmResult<SmallVec<[Value; 4]>>
pub(crate) fn translate_call( &mut self, builder: &mut FunctionBuilder<'_>, callee_index: FunctionIndex, callee: FuncRef, call_args: &[Value], landing_pad: Option<LandingPad>, ) -> WasmResult<SmallVec<[Value; 4]>>
pub(crate) fn tag_param_arity(&self, tag_index: TagIndex) -> usize
pub(crate) fn translate_exn_pointer_to_ref( &mut self, builder: &mut FunctionBuilder<'_>, exn_ptr: Value, ) -> Value
pub(crate) fn translate_exn_unbox( &mut self, builder: &mut FunctionBuilder<'_>, tag_index: TagIndex, exnref: Value, ) -> WasmResult<SmallVec<[Value; 4]>>
pub(crate) fn translate_exn_throw( &mut self, builder: &mut FunctionBuilder<'_>, tag_index: TagIndex, args: &[Value], landing_pad: Option<LandingPad>, ) -> WasmResult<()>
pub(crate) fn translate_exn_throw_ref( &mut self, builder: &mut FunctionBuilder<'_>, exnref: Value, landing_pad: Option<LandingPad>, ) -> WasmResult<()>
pub(crate) fn translate_exn_personality_selector( &mut self, builder: &mut FunctionBuilder<'_>, exn_ptr: Value, ) -> WasmResult<Value>
pub(crate) fn translate_exn_reraise_unmatched( &mut self, builder: &mut FunctionBuilder<'_>, exnref: Value, ) -> WasmResult<()>
pub(crate) fn translate_memory_grow( &mut self, pos: FuncCursor<'_>, index: MemoryIndex, _heap: Heap, val: Value, ) -> WasmResult<Value>
pub(crate) fn translate_memory_size( &mut self, pos: FuncCursor<'_>, index: MemoryIndex, _heap: Heap, ) -> WasmResult<Value>
pub(crate) fn translate_memory_copy( &mut self, pos: FuncCursor<'_>, src_index: MemoryIndex, _src_heap: Heap, _dst_index: MemoryIndex, _dst_heap: Heap, dst: Value, src: Value, len: Value, ) -> WasmResult<()>
pub(crate) fn translate_memory_fill( &mut self, pos: FuncCursor<'_>, memory_index: MemoryIndex, _heap: Heap, dst: Value, val: Value, len: Value, ) -> WasmResult<()>
pub(crate) fn translate_memory_init( &mut self, pos: FuncCursor<'_>, memory_index: MemoryIndex, _heap: Heap, seg_index: u32, dst: Value, src: Value, len: Value, ) -> WasmResult<()>
pub(crate) fn translate_data_drop( &mut self, pos: FuncCursor<'_>, seg_index: u32, ) -> WasmResult<()>
pub(crate) fn translate_table_size( &mut self, pos: FuncCursor<'_>, table_index: TableIndex, ) -> WasmResult<Value>
pub(crate) fn translate_table_copy( &mut self, pos: FuncCursor<'_>, dst_table_index: TableIndex, src_table_index: TableIndex, dst: Value, src: Value, len: Value, ) -> WasmResult<()>
pub(crate) fn translate_table_init( &mut self, pos: FuncCursor<'_>, seg_index: u32, table_index: TableIndex, dst: Value, src: Value, len: Value, ) -> WasmResult<()>
pub(crate) fn translate_elem_drop( &mut self, pos: FuncCursor<'_>, elem_index: u32, ) -> WasmResult<()>
pub(crate) fn translate_atomic_wait( &mut self, pos: FuncCursor<'_>, index: MemoryIndex, _heap: Heap, addr: Value, expected: Value, timeout: Value, ) -> WasmResult<Value>
pub(crate) fn translate_atomic_notify( &mut self, pos: FuncCursor<'_>, index: MemoryIndex, _heap: Heap, addr: Value, count: Value, ) -> WasmResult<Value>
pub(crate) fn push_local_decl_on_stack(&mut self, ty: WasmerType)
pub(crate) fn push_params_on_stack( &mut self, function_index: LocalFunctionIndex, )
pub(crate) fn heap_access_spectre_mitigation(&self) -> bool
pub(crate) fn heaps(&self) -> &PrimaryMap<Heap, HeapData>
pub(crate) fn is_wasm_return(&self, signature: &Signature, index: usize) -> bool
Auto Trait Implementations§
impl<'module_environment> Freeze for FuncEnvironment<'module_environment>
impl<'module_environment> RefUnwindSafe for FuncEnvironment<'module_environment>
impl<'module_environment> Send for FuncEnvironment<'module_environment>
impl<'module_environment> Sync for FuncEnvironment<'module_environment>
impl<'module_environment> Unpin for FuncEnvironment<'module_environment>
impl<'module_environment> UnwindSafe for FuncEnvironment<'module_environment>
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