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 leakingInstanceHandles 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); } }
Functions§
- wasmtime_
data_ ⚠drop - Implementation of
data.drop. - wasmtime_
defined_ ⚠memory_ copy - Implementation of
memory.copyfor locally defined memories. - wasmtime_
elem_ ⚠drop - Implementation of
elem.drop. - wasmtime_
f32_ ceil - Implementation of f32.ceil
- wasmtime_
f32_ floor - Implementation of f32.floor
- wasmtime_
f32_ nearest - Implementation of f32.nearest
- wasmtime_
f32_ trunc - Implementation of f32.trunc
- wasmtime_
f64_ ceil - Implementation of f64.ceil
- wasmtime_
f64_ floor - Implementation of f64.floor
- wasmtime_
f64_ nearest - Implementation of f64.nearest
- wasmtime_
f64_ trunc - Implementation of f64.trunc
- wasmtime_
imported_ ⚠memory32_ grow - Implementation of memory.grow for imported 32-bit memories.
- wasmtime_
imported_ ⚠memory32_ size - Implementation of memory.size for imported 32-bit memories.
- wasmtime_
imported_ ⚠memory_ copy - Implementation of
memory.copyfor imported memories. - wasmtime_
imported_ ⚠memory_ fill - Implementation of
memory.fillfor imported memories. - wasmtime_
memory32_ ⚠grow - Implementation of memory.grow for locally-defined 32-bit memories.
- wasmtime_
memory32_ ⚠size - Implementation of memory.size for locally-defined 32-bit memories.
- wasmtime_
memory_ ⚠fill - Implementation of
memory.fillfor locally defined memories. - wasmtime_
memory_ ⚠init - Implementation of
memory.init. - wasmtime_
table_ ⚠copy - Implementation of
table.copy. - wasmtime_
table_ ⚠init - Implementation of
table.init.