pub trait FuncEnvironment: TargetEnvironment {
Show 56 methods
// Required methods
fn make_global(
&mut self,
func: &mut Function,
index: GlobalIndex,
) -> WasmResult<GlobalVariable>;
fn heaps(&self) -> &PrimaryMap<Heap, HeapData>;
fn make_heap(
&mut self,
func: &mut Function,
index: MemoryIndex,
) -> WasmResult<Heap>;
fn make_indirect_sig(
&mut self,
func: &mut Function,
index: TypeIndex,
) -> WasmResult<SigRef>;
fn make_direct_func(
&mut self,
func: &mut Function,
index: FuncIndex,
) -> WasmResult<FuncRef>;
fn translate_call_indirect(
&mut self,
builder: &mut FunctionBuilder<'_>,
table_index: TableIndex,
sig_index: TypeIndex,
sig_ref: SigRef,
callee: Value,
call_args: &[Value],
) -> WasmResult<Option<Inst>>;
fn translate_return_call_indirect(
&mut self,
builder: &mut FunctionBuilder<'_>,
table_index: TableIndex,
sig_index: TypeIndex,
sig_ref: SigRef,
callee: Value,
call_args: &[Value],
) -> WasmResult<()>;
fn translate_return_call_ref(
&mut self,
builder: &mut FunctionBuilder<'_>,
sig_ref: SigRef,
callee: Value,
call_args: &[Value],
) -> WasmResult<()>;
fn translate_call_ref(
&mut self,
builder: &mut FunctionBuilder<'_>,
sig_ref: SigRef,
callee: Value,
call_args: &[Value],
) -> WasmResult<Inst>;
fn translate_memory_grow(
&mut self,
pos: FuncCursor<'_>,
index: MemoryIndex,
heap: Heap,
val: Value,
) -> WasmResult<Value>;
fn translate_memory_size(
&mut self,
pos: FuncCursor<'_>,
index: MemoryIndex,
heap: Heap,
) -> WasmResult<Value>;
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<()>;
fn translate_memory_fill(
&mut self,
pos: FuncCursor<'_>,
index: MemoryIndex,
heap: Heap,
dst: Value,
val: Value,
len: Value,
) -> WasmResult<()>;
fn translate_memory_init(
&mut self,
pos: FuncCursor<'_>,
index: MemoryIndex,
heap: Heap,
seg_index: u32,
dst: Value,
src: Value,
len: Value,
) -> WasmResult<()>;
fn translate_data_drop(
&mut self,
pos: FuncCursor<'_>,
seg_index: u32,
) -> WasmResult<()>;
fn translate_table_size(
&mut self,
pos: FuncCursor<'_>,
index: TableIndex,
) -> WasmResult<Value>;
fn translate_table_grow(
&mut self,
pos: FuncCursor<'_>,
table_index: TableIndex,
delta: Value,
init_value: Value,
) -> WasmResult<Value>;
fn translate_table_get(
&mut self,
builder: &mut FunctionBuilder<'_>,
table_index: TableIndex,
index: Value,
) -> WasmResult<Value>;
fn translate_table_set(
&mut self,
builder: &mut FunctionBuilder<'_>,
table_index: TableIndex,
value: Value,
index: Value,
) -> WasmResult<()>;
fn translate_table_copy(
&mut self,
pos: FuncCursor<'_>,
dst_table_index: TableIndex,
src_table_index: TableIndex,
dst: Value,
src: Value,
len: Value,
) -> WasmResult<()>;
fn translate_table_fill(
&mut self,
pos: FuncCursor<'_>,
table_index: TableIndex,
dst: Value,
val: Value,
len: Value,
) -> WasmResult<()>;
fn translate_table_init(
&mut self,
pos: FuncCursor<'_>,
seg_index: u32,
table_index: TableIndex,
dst: Value,
src: Value,
len: Value,
) -> WasmResult<()>;
fn translate_elem_drop(
&mut self,
pos: FuncCursor<'_>,
seg_index: u32,
) -> WasmResult<()>;
fn translate_ref_func(
&mut self,
pos: FuncCursor<'_>,
func_index: FuncIndex,
) -> WasmResult<Value>;
fn translate_custom_global_get(
&mut self,
pos: FuncCursor<'_>,
global_index: GlobalIndex,
) -> WasmResult<Value>;
fn translate_custom_global_set(
&mut self,
pos: FuncCursor<'_>,
global_index: GlobalIndex,
val: Value,
) -> WasmResult<()>;
fn translate_atomic_wait(
&mut self,
pos: FuncCursor<'_>,
index: MemoryIndex,
heap: Heap,
addr: Value,
expected: Value,
timeout: Value,
) -> WasmResult<Value>;
fn translate_atomic_notify(
&mut self,
pos: FuncCursor<'_>,
index: MemoryIndex,
heap: Heap,
addr: Value,
count: Value,
) -> WasmResult<Value>;
fn translate_ref_i31(
&mut self,
pos: FuncCursor<'_>,
val: Value,
) -> WasmResult<Value>;
fn translate_i31_get_s(
&mut self,
pos: FuncCursor<'_>,
i31ref: Value,
) -> WasmResult<Value>;
fn translate_i31_get_u(
&mut self,
pos: FuncCursor<'_>,
i31ref: Value,
) -> WasmResult<Value>;
// Provided methods
fn is_wasm_parameter(&self, signature: &Signature, index: usize) -> bool { ... }
fn is_wasm_return(&self, signature: &Signature, index: usize) -> bool { ... }
fn after_locals(&mut self, num_locals_defined: usize) { ... }
fn translate_call(
&mut self,
builder: &mut FunctionBuilder<'_>,
_callee_index: FuncIndex,
callee: FuncRef,
call_args: &[Value],
) -> WasmResult<Inst> { ... }
fn translate_return_call(
&mut self,
builder: &mut FunctionBuilder<'_>,
_callee_index: FuncIndex,
callee: FuncRef,
call_args: &[Value],
) -> WasmResult<()> { ... }
fn translate_ref_null(
&mut self,
pos: FuncCursor<'_>,
ty: WasmHeapType,
) -> WasmResult<Value> { ... }
fn translate_ref_is_null(
&mut self,
pos: FuncCursor<'_>,
value: Value,
) -> WasmResult<Value> { ... }
fn translate_loop_header(
&mut self,
_builder: &mut FunctionBuilder<'_>,
) -> WasmResult<()> { ... }
fn before_translate_operator(
&mut self,
_op: &Operator<'_>,
_builder: &mut FunctionBuilder<'_>,
_state: &FuncTranslationState,
) -> WasmResult<()> { ... }
fn after_translate_operator(
&mut self,
_op: &Operator<'_>,
_builder: &mut FunctionBuilder<'_>,
_state: &FuncTranslationState,
) -> WasmResult<()> { ... }
fn before_unconditionally_trapping_memory_access(
&mut self,
_builder: &mut FunctionBuilder<'_>,
) -> WasmResult<()> { ... }
fn before_translate_function(
&mut self,
_builder: &mut FunctionBuilder<'_>,
_state: &FuncTranslationState,
) -> WasmResult<()> { ... }
fn after_translate_function(
&mut self,
_builder: &mut FunctionBuilder<'_>,
_state: &FuncTranslationState,
) -> WasmResult<()> { ... }
fn relaxed_simd_deterministic(&self) -> bool { ... }
fn has_native_fma(&self) -> bool { ... }
fn is_x86(&self) -> bool { ... }
fn use_x86_blendv_for_relaxed_laneselect(&self, ty: Type) -> bool { ... }
fn use_x86_pshufb_for_relaxed_swizzle(&self) -> bool { ... }
fn use_x86_pmulhrsw_for_relaxed_q15mul(&self) -> bool { ... }
fn use_x86_pmaddubsw_for_dot(&self) -> bool { ... }
fn handle_before_return(
&mut self,
_retvals: &[Value],
_builder: &mut FunctionBuilder<'_>,
) { ... }
fn before_load(
&mut self,
_builder: &mut FunctionBuilder<'_>,
_val_size: u8,
_addr: Value,
_offset: u64,
) { ... }
fn before_store(
&mut self,
_builder: &mut FunctionBuilder<'_>,
_val_size: u8,
_addr: Value,
_offset: u64,
) { ... }
fn update_global(
&mut self,
_builder: &mut FunctionBuilder<'_>,
_global_index: u32,
_value: Value,
) { ... }
fn before_memory_grow(
&mut self,
_builder: &mut FunctionBuilder<'_>,
_num_bytes: Value,
_mem_index: MemoryIndex,
) { ... }
}
Expand description
Environment affecting the translation of a single WebAssembly function.
A FuncEnvironment
trait object is required to translate a WebAssembly function to Cranelift
IR. The function environment provides information about the WebAssembly module as well as the
runtime environment.
Required Methods§
Sourcefn make_global(
&mut self,
func: &mut Function,
index: GlobalIndex,
) -> WasmResult<GlobalVariable>
fn make_global( &mut self, func: &mut Function, index: GlobalIndex, ) -> WasmResult<GlobalVariable>
Set up the necessary preamble definitions in func
to access the global variable
identified by index
.
The index space covers both imported globals and globals defined by the module.
Return the global variable reference that should be used to access the global and the WebAssembly type of the global.
Sourcefn heaps(&self) -> &PrimaryMap<Heap, HeapData>
fn heaps(&self) -> &PrimaryMap<Heap, HeapData>
Get the heaps for this function environment.
The returned map should provide heap format details (encoded in
HeapData
) for each Heap
that was previously returned by
make_heap()
. The translator will first call make_heap for each Wasm
memory, and then later when translating code, will invoke heaps()
to
learn how to access the environment’s implementation of each memory.
Sourcefn make_heap(
&mut self,
func: &mut Function,
index: MemoryIndex,
) -> WasmResult<Heap>
fn make_heap( &mut self, func: &mut Function, index: MemoryIndex, ) -> WasmResult<Heap>
Set up the necessary preamble definitions in func
to access the linear memory identified
by index
.
The index space covers both imported and locally declared memories.
Sourcefn make_indirect_sig(
&mut self,
func: &mut Function,
index: TypeIndex,
) -> WasmResult<SigRef>
fn make_indirect_sig( &mut self, func: &mut Function, index: TypeIndex, ) -> WasmResult<SigRef>
Set up a signature definition in the preamble of func
that can be used for an indirect
call with signature index
.
The signature may contain additional arguments needed for an indirect call, but the
arguments marked as ArgumentPurpose::Normal
must correspond to the WebAssembly signature
arguments.
The signature will only be used for indirect calls, even if the module has direct function calls with the same WebAssembly type.
Sourcefn make_direct_func(
&mut self,
func: &mut Function,
index: FuncIndex,
) -> WasmResult<FuncRef>
fn make_direct_func( &mut self, func: &mut Function, index: FuncIndex, ) -> WasmResult<FuncRef>
Set up an external function definition in the preamble of func
that can be used to
directly call the function index
.
The index space covers both imported functions and functions defined in the current module.
The function’s signature may contain additional arguments needed for a direct call, but the
arguments marked as ArgumentPurpose::Normal
must correspond to the WebAssembly signature
arguments.
The function’s signature will only be used for direct calls, even if the module has indirect calls with the same WebAssembly type.
Sourcefn translate_call_indirect(
&mut self,
builder: &mut FunctionBuilder<'_>,
table_index: TableIndex,
sig_index: TypeIndex,
sig_ref: SigRef,
callee: Value,
call_args: &[Value],
) -> WasmResult<Option<Inst>>
fn translate_call_indirect( &mut self, builder: &mut FunctionBuilder<'_>, table_index: TableIndex, sig_index: TypeIndex, sig_ref: SigRef, callee: Value, call_args: &[Value], ) -> WasmResult<Option<Inst>>
Translate a call_indirect
WebAssembly instruction at pos
.
Insert instructions at pos
for an indirect call to the function callee
in the table
table_index
with WebAssembly signature sig_index
. The callee
value will have type
i32
.
The signature sig_ref
was previously created by make_indirect_sig()
.
Return the call instruction whose results are the WebAssembly return values.
Returns None
if this statically traps instead of creating a call
instruction.
Sourcefn translate_return_call_indirect(
&mut self,
builder: &mut FunctionBuilder<'_>,
table_index: TableIndex,
sig_index: TypeIndex,
sig_ref: SigRef,
callee: Value,
call_args: &[Value],
) -> WasmResult<()>
fn translate_return_call_indirect( &mut self, builder: &mut FunctionBuilder<'_>, table_index: TableIndex, sig_index: TypeIndex, sig_ref: SigRef, callee: Value, call_args: &[Value], ) -> WasmResult<()>
Translate a return_call_indirect
WebAssembly instruction at the
builder’s current position.
Insert instructions at the builder’s current position for an indirect
tail call to the function callee
in the table table_index
with
WebAssembly signature sig_index
. The callee
value will have type
i32
.
The signature sig_ref
was previously created by make_indirect_sig()
.
Sourcefn translate_return_call_ref(
&mut self,
builder: &mut FunctionBuilder<'_>,
sig_ref: SigRef,
callee: Value,
call_args: &[Value],
) -> WasmResult<()>
fn translate_return_call_ref( &mut self, builder: &mut FunctionBuilder<'_>, sig_ref: SigRef, callee: Value, call_args: &[Value], ) -> WasmResult<()>
Translate a return_call_ref
WebAssembly instruction at the builder’s
given position.
Insert instructions at the builder’s current position for an indirect
tail call to the function callee
. The callee
value will be a Wasm
funcref that may need to be translated to a native function address
depending on your implementation of this trait.
The signature sig_ref
was previously created by make_indirect_sig()
.
Sourcefn translate_call_ref(
&mut self,
builder: &mut FunctionBuilder<'_>,
sig_ref: SigRef,
callee: Value,
call_args: &[Value],
) -> WasmResult<Inst>
fn translate_call_ref( &mut self, builder: &mut FunctionBuilder<'_>, sig_ref: SigRef, callee: Value, call_args: &[Value], ) -> WasmResult<Inst>
Translate a call_ref
WebAssembly instruction at the builder’s current
position.
Insert instructions at the builder’s current position for an indirect
call to the function callee
. The callee
value will be a Wasm funcref
that may need to be translated to a native function address depending on
your implementation of this trait.
The signature sig_ref
was previously created by make_indirect_sig()
.
Return the call instruction whose results are the WebAssembly return values.
Sourcefn translate_memory_grow(
&mut self,
pos: FuncCursor<'_>,
index: MemoryIndex,
heap: Heap,
val: Value,
) -> WasmResult<Value>
fn translate_memory_grow( &mut self, pos: FuncCursor<'_>, index: MemoryIndex, heap: Heap, val: Value, ) -> WasmResult<Value>
Translate a memory.grow
WebAssembly instruction.
The index
provided identifies the linear memory to grow, and heap
is the heap reference
returned by make_heap
for the same index.
The val
value is the requested memory size in pages.
Returns the old size (in pages) of the memory.
Sourcefn translate_memory_size(
&mut self,
pos: FuncCursor<'_>,
index: MemoryIndex,
heap: Heap,
) -> WasmResult<Value>
fn translate_memory_size( &mut self, pos: FuncCursor<'_>, index: MemoryIndex, heap: Heap, ) -> WasmResult<Value>
Translates a memory.size
WebAssembly instruction.
The index
provided identifies the linear memory to query, and heap
is the heap reference
returned by make_heap
for the same index.
Returns the size in pages of the memory.
Sourcefn 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<()>
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<()>
Translate a memory.copy
WebAssembly instruction.
The index
provided identifies the linear memory to query, and heap
is the heap reference
returned by make_heap
for the same index.
Sourcefn translate_memory_fill(
&mut self,
pos: FuncCursor<'_>,
index: MemoryIndex,
heap: Heap,
dst: Value,
val: Value,
len: Value,
) -> WasmResult<()>
fn translate_memory_fill( &mut self, pos: FuncCursor<'_>, index: MemoryIndex, heap: Heap, dst: Value, val: Value, len: Value, ) -> WasmResult<()>
Translate a memory.fill
WebAssembly instruction.
The index
provided identifies the linear memory to query, and heap
is the heap reference
returned by make_heap
for the same index.
Sourcefn translate_memory_init(
&mut self,
pos: FuncCursor<'_>,
index: MemoryIndex,
heap: Heap,
seg_index: u32,
dst: Value,
src: Value,
len: Value,
) -> WasmResult<()>
fn translate_memory_init( &mut self, pos: FuncCursor<'_>, index: MemoryIndex, heap: Heap, seg_index: u32, dst: Value, src: Value, len: Value, ) -> WasmResult<()>
Translate a memory.init
WebAssembly instruction.
The index
provided identifies the linear memory to query, and heap
is the heap reference
returned by make_heap
for the same index. seg_index
is the index of the segment to copy
from.
Sourcefn translate_data_drop(
&mut self,
pos: FuncCursor<'_>,
seg_index: u32,
) -> WasmResult<()>
fn translate_data_drop( &mut self, pos: FuncCursor<'_>, seg_index: u32, ) -> WasmResult<()>
Translate a data.drop
WebAssembly instruction.
Sourcefn translate_table_size(
&mut self,
pos: FuncCursor<'_>,
index: TableIndex,
) -> WasmResult<Value>
fn translate_table_size( &mut self, pos: FuncCursor<'_>, index: TableIndex, ) -> WasmResult<Value>
Translate a table.size
WebAssembly instruction.
Sourcefn translate_table_grow(
&mut self,
pos: FuncCursor<'_>,
table_index: TableIndex,
delta: Value,
init_value: Value,
) -> WasmResult<Value>
fn translate_table_grow( &mut self, pos: FuncCursor<'_>, table_index: TableIndex, delta: Value, init_value: Value, ) -> WasmResult<Value>
Translate a table.grow
WebAssembly instruction.
Sourcefn translate_table_get(
&mut self,
builder: &mut FunctionBuilder<'_>,
table_index: TableIndex,
index: Value,
) -> WasmResult<Value>
fn translate_table_get( &mut self, builder: &mut FunctionBuilder<'_>, table_index: TableIndex, index: Value, ) -> WasmResult<Value>
Translate a table.get
WebAssembly instruction.
Sourcefn translate_table_set(
&mut self,
builder: &mut FunctionBuilder<'_>,
table_index: TableIndex,
value: Value,
index: Value,
) -> WasmResult<()>
fn translate_table_set( &mut self, builder: &mut FunctionBuilder<'_>, table_index: TableIndex, value: Value, index: Value, ) -> WasmResult<()>
Translate a table.set
WebAssembly instruction.
Sourcefn translate_table_copy(
&mut self,
pos: FuncCursor<'_>,
dst_table_index: TableIndex,
src_table_index: TableIndex,
dst: Value,
src: Value,
len: Value,
) -> WasmResult<()>
fn translate_table_copy( &mut self, pos: FuncCursor<'_>, dst_table_index: TableIndex, src_table_index: TableIndex, dst: Value, src: Value, len: Value, ) -> WasmResult<()>
Translate a table.copy
WebAssembly instruction.
Sourcefn translate_table_fill(
&mut self,
pos: FuncCursor<'_>,
table_index: TableIndex,
dst: Value,
val: Value,
len: Value,
) -> WasmResult<()>
fn translate_table_fill( &mut self, pos: FuncCursor<'_>, table_index: TableIndex, dst: Value, val: Value, len: Value, ) -> WasmResult<()>
Translate a table.fill
WebAssembly instruction.
Sourcefn translate_table_init(
&mut self,
pos: FuncCursor<'_>,
seg_index: u32,
table_index: TableIndex,
dst: Value,
src: Value,
len: Value,
) -> WasmResult<()>
fn translate_table_init( &mut self, pos: FuncCursor<'_>, seg_index: u32, table_index: TableIndex, dst: Value, src: Value, len: Value, ) -> WasmResult<()>
Translate a table.init
WebAssembly instruction.
Sourcefn translate_elem_drop(
&mut self,
pos: FuncCursor<'_>,
seg_index: u32,
) -> WasmResult<()>
fn translate_elem_drop( &mut self, pos: FuncCursor<'_>, seg_index: u32, ) -> WasmResult<()>
Translate a elem.drop
WebAssembly instruction.
Sourcefn translate_ref_func(
&mut self,
pos: FuncCursor<'_>,
func_index: FuncIndex,
) -> WasmResult<Value>
fn translate_ref_func( &mut self, pos: FuncCursor<'_>, func_index: FuncIndex, ) -> WasmResult<Value>
Translate a ref.func
WebAssembly instruction.
Sourcefn translate_custom_global_get(
&mut self,
pos: FuncCursor<'_>,
global_index: GlobalIndex,
) -> WasmResult<Value>
fn translate_custom_global_get( &mut self, pos: FuncCursor<'_>, global_index: GlobalIndex, ) -> WasmResult<Value>
Translate a global.get
WebAssembly instruction at pos
for a global
that is custom.
Sourcefn translate_custom_global_set(
&mut self,
pos: FuncCursor<'_>,
global_index: GlobalIndex,
val: Value,
) -> WasmResult<()>
fn translate_custom_global_set( &mut self, pos: FuncCursor<'_>, global_index: GlobalIndex, val: Value, ) -> WasmResult<()>
Translate a global.set
WebAssembly instruction at pos
for a global
that is custom.
Sourcefn translate_atomic_wait(
&mut self,
pos: FuncCursor<'_>,
index: MemoryIndex,
heap: Heap,
addr: Value,
expected: Value,
timeout: Value,
) -> WasmResult<Value>
fn translate_atomic_wait( &mut self, pos: FuncCursor<'_>, index: MemoryIndex, heap: Heap, addr: Value, expected: Value, timeout: Value, ) -> WasmResult<Value>
Translate an i32.atomic.wait
or i64.atomic.wait
WebAssembly instruction.
The index
provided identifies the linear memory containing the value
to wait on, and heap
is the heap reference returned by make_heap
for the same index. Whether the waited-on value is 32- or 64-bit can be
determined by examining the type of expected
, which must be only I32 or I64.
Note that the addr
here is the host linear memory address rather
than a relative wasm linear memory address. The type of this value is
the same as the host’s pointer.
Returns an i32, which is negative if the helper call failed.
Sourcefn translate_atomic_notify(
&mut self,
pos: FuncCursor<'_>,
index: MemoryIndex,
heap: Heap,
addr: Value,
count: Value,
) -> WasmResult<Value>
fn translate_atomic_notify( &mut self, pos: FuncCursor<'_>, index: MemoryIndex, heap: Heap, addr: Value, count: Value, ) -> WasmResult<Value>
Translate an atomic.notify
WebAssembly instruction.
The index
provided identifies the linear memory containing the value
to wait on, and heap
is the heap reference returned by make_heap
for the same index.
Note that the addr
here is the host linear memory address rather
than a relative wasm linear memory address. The type of this value is
the same as the host’s pointer.
Returns an i64, which is negative if the helper call failed.
Sourcefn translate_ref_i31(
&mut self,
pos: FuncCursor<'_>,
val: Value,
) -> WasmResult<Value>
fn translate_ref_i31( &mut self, pos: FuncCursor<'_>, val: Value, ) -> WasmResult<Value>
Translate an i32
value into an i31ref
.
Sourcefn translate_i31_get_s(
&mut self,
pos: FuncCursor<'_>,
i31ref: Value,
) -> WasmResult<Value>
fn translate_i31_get_s( &mut self, pos: FuncCursor<'_>, i31ref: Value, ) -> WasmResult<Value>
Sign-extend an i31ref
into an i32
.
Sourcefn translate_i31_get_u(
&mut self,
pos: FuncCursor<'_>,
i31ref: Value,
) -> WasmResult<Value>
fn translate_i31_get_u( &mut self, pos: FuncCursor<'_>, i31ref: Value, ) -> WasmResult<Value>
Zero-extend an i31ref
into an i32
.
Provided Methods§
Sourcefn is_wasm_parameter(&self, signature: &Signature, index: usize) -> bool
fn is_wasm_parameter(&self, signature: &Signature, index: usize) -> bool
Is the given parameter of the given function a wasm-level parameter, as opposed to a hidden parameter added for use by the implementation?
Sourcefn is_wasm_return(&self, signature: &Signature, index: usize) -> bool
fn is_wasm_return(&self, signature: &Signature, index: usize) -> bool
Is the given return of the given function a wasm-level parameter, as opposed to a hidden parameter added for use by the implementation?
Sourcefn after_locals(&mut self, num_locals_defined: usize)
fn after_locals(&mut self, num_locals_defined: usize)
Called after the locals for a function have been parsed, and the number of variables defined by this function is provided.
Sourcefn translate_call(
&mut self,
builder: &mut FunctionBuilder<'_>,
_callee_index: FuncIndex,
callee: FuncRef,
call_args: &[Value],
) -> WasmResult<Inst>
fn translate_call( &mut self, builder: &mut FunctionBuilder<'_>, _callee_index: FuncIndex, callee: FuncRef, call_args: &[Value], ) -> WasmResult<Inst>
Translate a call
WebAssembly instruction at pos
.
Insert instructions at pos
for a direct call to the function callee_index
.
The function reference callee
was previously created by make_direct_func()
.
Return the call instruction whose results are the WebAssembly return values.
Sourcefn translate_return_call(
&mut self,
builder: &mut FunctionBuilder<'_>,
_callee_index: FuncIndex,
callee: FuncRef,
call_args: &[Value],
) -> WasmResult<()>
fn translate_return_call( &mut self, builder: &mut FunctionBuilder<'_>, _callee_index: FuncIndex, callee: FuncRef, call_args: &[Value], ) -> WasmResult<()>
Translate a return_call
WebAssembly instruction at the builder’s
current position.
Insert instructions at the builder’s current position for a direct tail
call to the function callee_index
.
The function reference callee
was previously created by make_direct_func()
.
Return the call instruction whose results are the WebAssembly return values.
Sourcefn translate_ref_null(
&mut self,
pos: FuncCursor<'_>,
ty: WasmHeapType,
) -> WasmResult<Value>
fn translate_ref_null( &mut self, pos: FuncCursor<'_>, ty: WasmHeapType, ) -> WasmResult<Value>
Translate a ref.null T
WebAssembly instruction.
By default, translates into a null reference type.
Override this if you don’t use Cranelift reference types for all Wasm
reference types (e.g. you use a raw pointer for funcref
s) or if the
null sentinel is not a null reference type pointer for your type. If you
override this method, then you should also override
translate_ref_is_null
as well.
Sourcefn translate_ref_is_null(
&mut self,
pos: FuncCursor<'_>,
value: Value,
) -> WasmResult<Value>
fn translate_ref_is_null( &mut self, pos: FuncCursor<'_>, value: Value, ) -> WasmResult<Value>
Translate a ref.is_null
WebAssembly instruction.
By default, assumes that value
is a Cranelift reference type, and that
a null Cranelift reference type is the null value for all Wasm reference
types.
If you override this method, you probably also want to override
translate_ref_null
as well.
Sourcefn translate_loop_header(
&mut self,
_builder: &mut FunctionBuilder<'_>,
) -> WasmResult<()>
fn translate_loop_header( &mut self, _builder: &mut FunctionBuilder<'_>, ) -> WasmResult<()>
Emit code at the beginning of every wasm loop.
This can be used to insert explicit interrupt or safepoint checking at the beginnings of loops.
Sourcefn before_translate_operator(
&mut self,
_op: &Operator<'_>,
_builder: &mut FunctionBuilder<'_>,
_state: &FuncTranslationState,
) -> WasmResult<()>
fn before_translate_operator( &mut self, _op: &Operator<'_>, _builder: &mut FunctionBuilder<'_>, _state: &FuncTranslationState, ) -> WasmResult<()>
Optional callback for the FunctionEnvironment
performing this translation to maintain
internal state or prepare custom state for the operator to translate
Sourcefn after_translate_operator(
&mut self,
_op: &Operator<'_>,
_builder: &mut FunctionBuilder<'_>,
_state: &FuncTranslationState,
) -> WasmResult<()>
fn after_translate_operator( &mut self, _op: &Operator<'_>, _builder: &mut FunctionBuilder<'_>, _state: &FuncTranslationState, ) -> WasmResult<()>
Optional callback for the FunctionEnvironment
performing this translation to maintain
internal state or finalize custom state for the operator that was translated
Sourcefn before_unconditionally_trapping_memory_access(
&mut self,
_builder: &mut FunctionBuilder<'_>,
) -> WasmResult<()>
fn before_unconditionally_trapping_memory_access( &mut self, _builder: &mut FunctionBuilder<'_>, ) -> WasmResult<()>
Optional callback for the FuncEnvironment
performing this translation
to maintain, prepare, or finalize custom, internal state when we
statically determine that a Wasm memory access will unconditionally
trap, rendering the rest of the block unreachable. Called just before
the unconditional trap is emitted.
Sourcefn before_translate_function(
&mut self,
_builder: &mut FunctionBuilder<'_>,
_state: &FuncTranslationState,
) -> WasmResult<()>
fn before_translate_function( &mut self, _builder: &mut FunctionBuilder<'_>, _state: &FuncTranslationState, ) -> WasmResult<()>
Optional callback for the FunctionEnvironment
performing this translation to perform work
before the function body is translated.
Sourcefn after_translate_function(
&mut self,
_builder: &mut FunctionBuilder<'_>,
_state: &FuncTranslationState,
) -> WasmResult<()>
fn after_translate_function( &mut self, _builder: &mut FunctionBuilder<'_>, _state: &FuncTranslationState, ) -> WasmResult<()>
Optional callback for the FunctionEnvironment
performing this translation to perform work
after the function body is translated.
Sourcefn relaxed_simd_deterministic(&self) -> bool
fn relaxed_simd_deterministic(&self) -> bool
Whether or not to force relaxed simd instructions to have deterministic lowerings meaning they will produce the same results across all hosts, regardless of the cost to performance.
Sourcefn has_native_fma(&self) -> bool
fn has_native_fma(&self) -> bool
Whether or not the target being translated for has a native fma
instruction. If it does not then when relaxed simd isn’t deterministic
the translation of the f32x4.relaxed_fma
instruction, for example,
will do a multiplication and then an add instead of the fused version.
Sourcefn is_x86(&self) -> bool
fn is_x86(&self) -> bool
Returns whether this is an x86 target, which may alter lowerings of relaxed simd instructions.
Sourcefn use_x86_blendv_for_relaxed_laneselect(&self, ty: Type) -> bool
fn use_x86_blendv_for_relaxed_laneselect(&self, ty: Type) -> bool
Returns whether the CLIF x86_blendv
instruction should be used for the
relaxed simd *.relaxed_laneselect
instruction for the specified type.
Sourcefn use_x86_pshufb_for_relaxed_swizzle(&self) -> bool
fn use_x86_pshufb_for_relaxed_swizzle(&self) -> bool
Returns whether the CLIF x86_pshufb
instruction should be used for the
i8x16.relaxed_swizzle
instruction.
Sourcefn use_x86_pmulhrsw_for_relaxed_q15mul(&self) -> bool
fn use_x86_pmulhrsw_for_relaxed_q15mul(&self) -> bool
Returns whether the CLIF x86_pmulhrsw
instruction should be used for
the i8x16.relaxed_q15mulr_s
instruction.
Sourcefn use_x86_pmaddubsw_for_dot(&self) -> bool
fn use_x86_pmaddubsw_for_dot(&self) -> bool
Returns whether the CLIF x86_pmaddubsw
instruction should be used for
the relaxed-simd dot-product instructions instruction.
Sourcefn handle_before_return(
&mut self,
_retvals: &[Value],
_builder: &mut FunctionBuilder<'_>,
)
fn handle_before_return( &mut self, _retvals: &[Value], _builder: &mut FunctionBuilder<'_>, )
Inserts code before a function return.
Sourcefn before_load(
&mut self,
_builder: &mut FunctionBuilder<'_>,
_val_size: u8,
_addr: Value,
_offset: u64,
)
fn before_load( &mut self, _builder: &mut FunctionBuilder<'_>, _val_size: u8, _addr: Value, _offset: u64, )
Inserts code before a load.
Sourcefn before_store(
&mut self,
_builder: &mut FunctionBuilder<'_>,
_val_size: u8,
_addr: Value,
_offset: u64,
)
fn before_store( &mut self, _builder: &mut FunctionBuilder<'_>, _val_size: u8, _addr: Value, _offset: u64, )
Inserts code before a store.
Sourcefn update_global(
&mut self,
_builder: &mut FunctionBuilder<'_>,
_global_index: u32,
_value: Value,
)
fn update_global( &mut self, _builder: &mut FunctionBuilder<'_>, _global_index: u32, _value: Value, )
Inserts code before updating a global.
Sourcefn before_memory_grow(
&mut self,
_builder: &mut FunctionBuilder<'_>,
_num_bytes: Value,
_mem_index: MemoryIndex,
)
fn before_memory_grow( &mut self, _builder: &mut FunctionBuilder<'_>, _num_bytes: Value, _mem_index: MemoryIndex, )
Inserts code before memory.grow.