Skip to content

std/memory

std/wasm/memory — memory load / store / size / grow instruction encoders for the WebAssembly Core 1.0 binary format. Spec: https://webassembly.github.io/spec/core/binary/instructions.html#memory-instructions Fifth slice of Phase 1 of docs/TOOLCHAIN-SELF-HOSTING.md. After the numeric opcodes (single-byte, no immediate), memory ops are the second-largest opcode family. Every load / store carries a memarg immediate — an alignment hint plus a base offset, both uleb-encoded. memory.size / memory.grow each take a one-byte reserved “memory index” immediate (always 0 in wasm 1.0, since the multi-memory proposal hadn’t landed). The “load_8_s” / “load_16_u” etc. variants only exist for the integer widths — float types have no narrow-load form because IEEE-754 doesn’t decompose that way. The bulk-memory ops the production backend actually emits — memory.copy and memory.fill, both under the 0xFC multi-byte opcode prefix — are covered at the bottom of this file. The rest of the bulk-memory family (memory.init / data.drop) and the saturating-truncate ops aren’t included; the backend’s memcpy / memset helpers only reach for copy + fill.

pub function inst_i32_load(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i64_load(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_f32_load(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_f64_load(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i32_load8_s(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i32_load8_u(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i32_load16_s(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i32_load16_u(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i64_load8_s(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i64_load8_u(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i64_load16_s(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i64_load16_u(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i64_load32_s(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i64_load32_u(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i32_store(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i64_store(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_f32_store(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_f64_store(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i32_store8(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i32_store16(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i64_store8(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i64_store16(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_i64_store32(buf: u8[], align: u32, offset: u32): u8[]
pub function inst_memory_size(buf: u8[]): u8[]
pub function inst_memory_grow(buf: u8[]): u8[]
pub function inst_memory_copy(buf: u8[]): u8[]
pub function inst_memory_fill(buf: u8[]): u8[]