Trait cranelift_wasm::FuncEnvironment[][src]

pub trait FuncEnvironment {
    fn triple(&self) -> &Triple;
fn flags(&self) -> &Flags;
fn make_global(
        &mut self,
        func: &mut Function,
        index: GlobalIndex
    ) -> GlobalVariable;
fn make_heap(&mut self, func: &mut Function, index: MemoryIndex) -> Heap;
fn make_indirect_sig(
        &mut self,
        func: &mut Function,
        index: SignatureIndex
    ) -> SigRef;
fn make_direct_func(
        &mut self,
        func: &mut Function,
        index: FunctionIndex
    ) -> FuncRef;
fn translate_call_indirect(
        &mut self,
        pos: FuncCursor,
        table_index: TableIndex,
        sig_index: SignatureIndex,
        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 native_pointer(&self) -> Type { ... }
fn translate_call(
        &mut self,
        pos: FuncCursor,
        _callee_index: FunctionIndex,
        callee: FuncRef,
        call_args: &[Value]
    ) -> WasmResult<Inst> { ... }
fn translate_loop_header(&mut self, _pos: FuncCursor) { ... } }

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

Get the triple for the current compilation.

Get the flags for the current compilation.

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.

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.

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.

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.

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.

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.

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.

Provided Methods

Get the Cranelift integer type to use for native pointers.

This returns I64 for 64-bit architectures and I32 for 32-bit architectures.

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.

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.

Implementors