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 interpreter: control flow, calls, and structured blocks #224

open opened by pierrelf.com

Add the control-flow and call instructions to the WebAssembly interpreter. Depends on the numeric/memory interpreter issue.

Scope:

  • Block, loop, if/else: structured control with explicit label arity (multi-value blocks return multiple values).
  • Branch instructions: br, br_if, br_table — label-relative jumps with operand stack adjustment per the spec.
  • return: exit the current function honoring the function's result arity.
  • call: direct function call to an in-module function with type-checked arguments and returns.
  • call_indirect: type-checked dynamic call through a table; trap on type mismatch or null funcref.
  • unreachable: trap.
  • Activation records and call-stack growth with a configurable maximum recursion depth that produces StackOverflow traps (per the spec, host can pick the limit).
  • Pre-compute branch targets at validation/load time so runtime branching is O(1).

Acceptance criteria:

  • Tests cover deeply nested blocks, multi-value block results, br_table with varying target arities, indirect calls landing on host and wasm functions, mutual recursion across functions, and stack-overflow trap delivery.
  • Integration with the numeric interpreter is clean: control instructions stay separate, both share the same operand stack and trap machinery.
  • 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/3mm2tlcr2os23