we (web engine): Experimental web browser project to understand the limits of Claude
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

WebAssembly stack-machine interpreter: numeric, parametric, variable, table, memory instructions #223

open opened by pierrelf.com

Implement the WebAssembly execution model's straight-line instructions in a stack-machine interpreter. Depends on the runtime data structures. Control flow and call instructions are intentionally a separate issue.

Scope:

  • Operand stack of WasmValue (i32, i64, f32, f64, funcref, externref).
  • Locals frame and per-function activation record.
  • All numeric instructions for i32/i64/f32/f64: const, eqz, eq/ne/lt/gt/le/ge, add/sub/mul/div/rem, and/or/xor/shl/shr/rotl/rotr, clz/ctz/popcnt, abs/neg/sqrt/ceil/floor/trunc/nearest, min/max/copysign, all numeric conversions (wrap, extend, trunc_sat, convert, reinterpret) including saturating variants per the MVP+ baseline.
  • Parametric instructions: drop, select, select (typed).
  • Variable instructions: local.get/set/tee, global.get/set.
  • Table instructions: table.get, table.set, table.size, table.grow, table.fill (table.copy/init move into the post-MVP issue).
  • Memory instructions: i32/i64 loads (8s, 8u, 16s, 16u, 32s, 32u, full), i32/i64/f32/f64 stores, memory.size, memory.grow with bounds and alignment checks, generating Trap variants for out-of-bounds access and undefined behavior.
  • Trap type with structured variants (Unreachable, OutOfBoundsMemory, IntegerOverflow, IntegerDivideByZero, InvalidConversion, IndirectCallTypeMismatch, StackOverflow, etc.).

Acceptance criteria:

  • Unit tests exercise every numeric instruction's edge cases (overflow, NaN propagation, signed/unsigned semantics, saturating truncation boundary, IEEE-754 rounding) and every trap variant.
  • Memory load/store correctness verified against hand-written fixtures including unaligned access and bounds-check failures.
  • The interpreter integrates with the runtime store and validates against the parser+validator output (no separate validation pass during execution).
  • cargo clippy --workspace -- -D warnings passes; 100% safe Rust; zero external dependencies.
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mm2tkve7tv2w