Trait wasmtime_environ::wasm::FuncEnvironment[][src]

pub trait FuncEnvironment: TargetEnvironment {
    pub fn make_global(
        &mut self,
        func: &mut Function,
        index: GlobalIndex
    ) -> Result<GlobalVariable, WasmError>;
pub fn make_heap(
        &mut self,
        func: &mut Function,
        index: MemoryIndex
    ) -> Result<Heap, WasmError>;
pub fn make_table(
        &mut self,
        func: &mut Function,
        index: TableIndex
    ) -> Result<Table, WasmError>;
pub fn make_indirect_sig(
        &mut self,
        func: &mut Function,
        index: TypeIndex
    ) -> Result<SigRef, WasmError>;
pub fn make_direct_func(
        &mut self,
        func: &mut Function,
        index: FuncIndex
    ) -> Result<FuncRef, WasmError>;
pub fn translate_call_indirect(
        &mut self,
        pos: FuncCursor<'_>,
        table_index: TableIndex,
        table: Table,
        sig_index: TypeIndex,
        sig_ref: SigRef,
        callee: Value,
        call_args: &[Value]
    ) -> Result<Inst, WasmError>;
pub fn translate_memory_grow(
        &mut self,
        pos: FuncCursor<'_>,
        index: MemoryIndex,
        heap: Heap,
        val: Value
    ) -> Result<Value, WasmError>;
pub fn translate_memory_size(
        &mut self,
        pos: FuncCursor<'_>,
        index: MemoryIndex,
        heap: Heap
    ) -> Result<Value, WasmError>;
pub 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
    ) -> Result<(), WasmError>;
pub fn translate_memory_fill(
        &mut self,
        pos: FuncCursor<'_>,
        index: MemoryIndex,
        heap: Heap,
        dst: Value,
        val: Value,
        len: Value
    ) -> Result<(), WasmError>;
pub fn translate_memory_init(
        &mut self,
        pos: FuncCursor<'_>,
        index: MemoryIndex,
        heap: Heap,
        seg_index: u32,
        dst: Value,
        src: Value,
        len: Value
    ) -> Result<(), WasmError>;
pub fn translate_data_drop(
        &mut self,
        pos: FuncCursor<'_>,
        seg_index: u32
    ) -> Result<(), WasmError>;
pub fn translate_table_size(
        &mut self,
        pos: FuncCursor<'_>,
        index: TableIndex,
        table: Table
    ) -> Result<Value, WasmError>;
pub fn translate_table_grow(
        &mut self,
        pos: FuncCursor<'_>,
        table_index: TableIndex,
        table: Table,
        delta: Value,
        init_value: Value
    ) -> Result<Value, WasmError>;
pub fn translate_table_get(
        &mut self,
        builder: &mut FunctionBuilder<'_>,
        table_index: TableIndex,
        table: Table,
        index: Value
    ) -> Result<Value, WasmError>;
pub fn translate_table_set(
        &mut self,
        builder: &mut FunctionBuilder<'_>,
        table_index: TableIndex,
        table: Table,
        value: Value,
        index: Value
    ) -> Result<(), WasmError>;
pub fn translate_table_copy(
        &mut self,
        pos: FuncCursor<'_>,
        dst_table_index: TableIndex,
        dst_table: Table,
        src_table_index: TableIndex,
        src_table: Table,
        dst: Value,
        src: Value,
        len: Value
    ) -> Result<(), WasmError>;
pub fn translate_table_fill(
        &mut self,
        pos: FuncCursor<'_>,
        table_index: TableIndex,
        dst: Value,
        val: Value,
        len: Value
    ) -> Result<(), WasmError>;
pub fn translate_table_init(
        &mut self,
        pos: FuncCursor<'_>,
        seg_index: u32,
        table_index: TableIndex,
        table: Table,
        dst: Value,
        src: Value,
        len: Value
    ) -> Result<(), WasmError>;
pub fn translate_elem_drop(
        &mut self,
        pos: FuncCursor<'_>,
        seg_index: u32
    ) -> Result<(), WasmError>;
pub fn translate_ref_func(
        &mut self,
        pos: FuncCursor<'_>,
        func_index: FuncIndex
    ) -> Result<Value, WasmError>;
pub fn translate_custom_global_get(
        &mut self,
        pos: FuncCursor<'_>,
        global_index: GlobalIndex
    ) -> Result<Value, WasmError>;
pub fn translate_custom_global_set(
        &mut self,
        pos: FuncCursor<'_>,
        global_index: GlobalIndex,
        val: Value
    ) -> Result<(), WasmError>;
pub fn translate_atomic_wait(
        &mut self,
        pos: FuncCursor<'_>,
        index: MemoryIndex,
        heap: Heap,
        addr: Value,
        expected: Value,
        timeout: Value
    ) -> Result<Value, WasmError>;
pub fn translate_atomic_notify(
        &mut self,
        pos: FuncCursor<'_>,
        index: MemoryIndex,
        heap: Heap,
        addr: Value,
        count: Value
    ) -> Result<Value, WasmError>; pub fn is_wasm_parameter(&self, signature: &Signature, index: usize) -> bool { ... }
pub fn is_wasm_return(&self, signature: &Signature, index: usize) -> bool { ... }
pub fn return_mode(&self) -> ReturnMode { ... }
pub fn translate_call(
        &mut self,
        pos: FuncCursor<'_>,
        _callee_index: FuncIndex,
        callee: FuncRef,
        call_args: &[Value]
    ) -> Result<Inst, WasmError> { ... }
pub fn translate_ref_null(
        &mut self,
        pos: FuncCursor<'_>,
        ty: WasmType
    ) -> Result<Value, WasmError> { ... }
pub fn translate_ref_is_null(
        &mut self,
        pos: FuncCursor<'_>,
        value: Value
    ) -> Result<Value, WasmError> { ... }
pub fn translate_loop_header(
        &mut self,
        _pos: FuncCursor<'_>
    ) -> Result<(), WasmError> { ... }
pub fn before_translate_operator(
        &mut self,
        _op: &Operator<'_>,
        _builder: &mut FunctionBuilder<'_>,
        _state: &FuncTranslationState
    ) -> Result<(), WasmError> { ... }
pub fn after_translate_operator(
        &mut self,
        _op: &Operator<'_>,
        _builder: &mut FunctionBuilder<'_>,
        _state: &FuncTranslationState
    ) -> Result<(), WasmError> { ... }
pub fn before_translate_function(
        &mut self,
        _builder: &mut FunctionBuilder<'_>,
        _state: &FuncTranslationState
    ) -> Result<(), WasmError> { ... }
pub fn after_translate_function(
        &mut self,
        _builder: &mut FunctionBuilder<'_>,
        _state: &FuncTranslationState
    ) -> Result<(), WasmError> { ... } }

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

pub fn make_global(
    &mut self,
    func: &mut Function,
    index: GlobalIndex
) -> Result<GlobalVariable, WasmError>
[src]

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.

pub fn make_heap(
    &mut self,
    func: &mut Function,
    index: MemoryIndex
) -> Result<Heap, WasmError>
[src]

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.

pub fn make_table(
    &mut self,
    func: &mut Function,
    index: TableIndex
) -> Result<Table, WasmError>
[src]

Set up the necessary preamble definitions in func to access the table identified by index.

The index space covers both imported and locally declared tables.

pub fn make_indirect_sig(
    &mut self,
    func: &mut Function,
    index: TypeIndex
) -> Result<SigRef, WasmError>
[src]

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.

pub fn make_direct_func(
    &mut self,
    func: &mut Function,
    index: FuncIndex
) -> Result<FuncRef, WasmError>
[src]

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.

pub fn translate_call_indirect(
    &mut self,
    pos: FuncCursor<'_>,
    table_index: TableIndex,
    table: Table,
    sig_index: TypeIndex,
    sig_ref: SigRef,
    callee: Value,
    call_args: &[Value]
) -> Result<Inst, WasmError>
[src]

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.

pub fn translate_memory_grow(
    &mut self,
    pos: FuncCursor<'_>,
    index: MemoryIndex,
    heap: Heap,
    val: Value
) -> Result<Value, WasmError>
[src]

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.

pub fn translate_memory_size(
    &mut self,
    pos: FuncCursor<'_>,
    index: MemoryIndex,
    heap: Heap
) -> Result<Value, WasmError>
[src]

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.

pub 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
) -> Result<(), WasmError>
[src]

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.

pub fn translate_memory_fill(
    &mut self,
    pos: FuncCursor<'_>,
    index: MemoryIndex,
    heap: Heap,
    dst: Value,
    val: Value,
    len: Value
) -> Result<(), WasmError>
[src]

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.

pub fn translate_memory_init(
    &mut self,
    pos: FuncCursor<'_>,
    index: MemoryIndex,
    heap: Heap,
    seg_index: u32,
    dst: Value,
    src: Value,
    len: Value
) -> Result<(), WasmError>
[src]

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.

pub fn translate_data_drop(
    &mut self,
    pos: FuncCursor<'_>,
    seg_index: u32
) -> Result<(), WasmError>
[src]

Translate a data.drop WebAssembly instruction.

pub fn translate_table_size(
    &mut self,
    pos: FuncCursor<'_>,
    index: TableIndex,
    table: Table
) -> Result<Value, WasmError>
[src]

Translate a table.size WebAssembly instruction.

pub fn translate_table_grow(
    &mut self,
    pos: FuncCursor<'_>,
    table_index: TableIndex,
    table: Table,
    delta: Value,
    init_value: Value
) -> Result<Value, WasmError>
[src]

Translate a table.grow WebAssembly instruction.

pub fn translate_table_get(
    &mut self,
    builder: &mut FunctionBuilder<'_>,
    table_index: TableIndex,
    table: Table,
    index: Value
) -> Result<Value, WasmError>
[src]

Translate a table.get WebAssembly instruction.

pub fn translate_table_set(
    &mut self,
    builder: &mut FunctionBuilder<'_>,
    table_index: TableIndex,
    table: Table,
    value: Value,
    index: Value
) -> Result<(), WasmError>
[src]

Translate a table.set WebAssembly instruction.

pub fn translate_table_copy(
    &mut self,
    pos: FuncCursor<'_>,
    dst_table_index: TableIndex,
    dst_table: Table,
    src_table_index: TableIndex,
    src_table: Table,
    dst: Value,
    src: Value,
    len: Value
) -> Result<(), WasmError>
[src]

Translate a table.copy WebAssembly instruction.

pub fn translate_table_fill(
    &mut self,
    pos: FuncCursor<'_>,
    table_index: TableIndex,
    dst: Value,
    val: Value,
    len: Value
) -> Result<(), WasmError>
[src]

Translate a table.fill WebAssembly instruction.

pub fn translate_table_init(
    &mut self,
    pos: FuncCursor<'_>,
    seg_index: u32,
    table_index: TableIndex,
    table: Table,
    dst: Value,
    src: Value,
    len: Value
) -> Result<(), WasmError>
[src]

Translate a table.init WebAssembly instruction.

pub fn translate_elem_drop(
    &mut self,
    pos: FuncCursor<'_>,
    seg_index: u32
) -> Result<(), WasmError>
[src]

Translate a elem.drop WebAssembly instruction.

pub fn translate_ref_func(
    &mut self,
    pos: FuncCursor<'_>,
    func_index: FuncIndex
) -> Result<Value, WasmError>
[src]

Translate a ref.func WebAssembly instruction.

pub fn translate_custom_global_get(
    &mut self,
    pos: FuncCursor<'_>,
    global_index: GlobalIndex
) -> Result<Value, WasmError>
[src]

Translate a global.get WebAssembly instruction at pos for a global that is custom.

pub fn translate_custom_global_set(
    &mut self,
    pos: FuncCursor<'_>,
    global_index: GlobalIndex,
    val: Value
) -> Result<(), WasmError>
[src]

Translate a global.set WebAssembly instruction at pos for a global that is custom.

pub fn translate_atomic_wait(
    &mut self,
    pos: FuncCursor<'_>,
    index: MemoryIndex,
    heap: Heap,
    addr: Value,
    expected: Value,
    timeout: Value
) -> Result<Value, WasmError>
[src]

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.

Returns an i32, which is negative if the helper call failed.

pub fn translate_atomic_notify(
    &mut self,
    pos: FuncCursor<'_>,
    index: MemoryIndex,
    heap: Heap,
    addr: Value,
    count: Value
) -> Result<Value, WasmError>
[src]

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.

Returns an i64, which is negative if the helper call failed.

Loading content...

Provided methods

pub fn is_wasm_parameter(&self, signature: &Signature, index: usize) -> bool[src]

Is the given parameter of the given function a wasm-level parameter, as opposed to a hidden parameter added for use by the implementation?

pub fn is_wasm_return(&self, signature: &Signature, index: usize) -> bool[src]

Is the given return of the given function a wasm-level parameter, as opposed to a hidden parameter added for use by the implementation?

pub fn return_mode(&self) -> ReturnMode[src]

Should the code be structured to use a single fallthrough_return instruction at the end of the function body, rather than return instructions as needed? This is used by VMs to append custom epilogues.

pub fn translate_call(
    &mut self,
    pos: FuncCursor<'_>,
    _callee_index: FuncIndex,
    callee: FuncRef,
    call_args: &[Value]
) -> Result<Inst, WasmError>
[src]

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.

pub fn translate_ref_null(
    &mut self,
    pos: FuncCursor<'_>,
    ty: WasmType
) -> Result<Value, WasmError>
[src]

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 funcrefs) 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.

pub fn translate_ref_is_null(
    &mut self,
    pos: FuncCursor<'_>,
    value: Value
) -> Result<Value, WasmError>
[src]

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.

pub fn translate_loop_header(
    &mut self,
    _pos: FuncCursor<'_>
) -> Result<(), WasmError>
[src]

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.

pub fn before_translate_operator(
    &mut self,
    _op: &Operator<'_>,
    _builder: &mut FunctionBuilder<'_>,
    _state: &FuncTranslationState
) -> Result<(), WasmError>
[src]

Optional callback for the FunctionEnvironment performing this translation to maintain internal state or prepare custom state for the operator to translate

pub fn after_translate_operator(
    &mut self,
    _op: &Operator<'_>,
    _builder: &mut FunctionBuilder<'_>,
    _state: &FuncTranslationState
) -> Result<(), WasmError>
[src]

Optional callback for the FunctionEnvironment performing this translation to maintain internal state or finalize custom state for the operator that was translated

pub fn before_translate_function(
    &mut self,
    _builder: &mut FunctionBuilder<'_>,
    _state: &FuncTranslationState
) -> Result<(), WasmError>
[src]

Optional callback for the FunctionEnvironment performing this translation to perform work before the function body is translated.

pub fn after_translate_function(
    &mut self,
    _builder: &mut FunctionBuilder<'_>,
    _state: &FuncTranslationState
) -> Result<(), WasmError>
[src]

Optional callback for the FunctionEnvironment performing this translation to perform work after the function body is translated.

Loading content...

Implementors

Loading content...