Module wasmer_vm::libcalls[][src]

Expand description

Runtime library calls.

Note that Wasm compilers may sometimes perform these inline rather than calling them, particularly when CPUs have special instructions which compute them directly.

These functions are called by compiled Wasm code, and therefore must take certain care about some things:

  • They must always be pub extern "C" and should only contain basic, raw i32/i64/f32/f64/pointer parameters that are safe to pass across the system ABI!

  • If any nested function propagates an Err(trap) out to the library function frame, we need to raise it. This involves some nasty and quite unsafe code under the covers! Notable, after raising the trap, drops will not be run for local variables! This can lead to things like leaking InstanceHandles which leads to never deallocating JIT code, instances, and modules! Therefore, always use nested blocks to ensure drops run before raising a trap:

    pub extern "C" fn my_lib_function(...) {
        let result = {
            // Do everything in here so drops run at the end of the block.
            ...
        };
        if let Err(trap) = result {
            // Now we can safely raise the trap without leaking!
            raise_lib_trap(trap);
        }
    }

Enums

The name of a runtime library routine.

Statics

Probestack check

Functions

Implementation of data.drop.

Implementation of elem.drop.

Implementation of externref decrement

Implementation of externref increment

Implementation of f32.ceil

Implementation of f32.floor

Implementation of f32.nearest

Implementation of f32.trunc

Implementation of f64.ceil

Implementation of f64.floor

Implementation of f64.nearest

Implementation of f64.trunc

Implementation of func.ref.

Implementation of memory.copy for imported memories.

Implementation of memory.fill for imported memories.

Implementation of memory.grow for imported 32-bit memories.

Implementation of memory.size for imported 32-bit memories.

Implementation of table.get for imported tables.

Implementation of table.grow for imported tables.

Implementation of table.set for imported tables.

Implementation of table.size for imported tables.

Implementation of memory.copy for locally defined memories.

Implementation of memory.fill for locally defined memories.

Implementation of memory.grow for locally-defined 32-bit memories.

Implementation of memory.init.

Implementation of memory.size for locally-defined 32-bit memories.

Implementation for raising a trap

Implementation of table.copy.

Implementation of table.fill.

Implementation of table.get.

Implementation of table.grow for locally-defined tables.

Implementation of table.init.

Implementation of table.set.

Implementation of table.size.