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 imports, exports, and instantiation pipeline #225

open opened by pierrelf.com

Connect parsed/validated modules to the runtime by resolving imports, exposing exports, and running the start function. Depends on the interpreter (both numeric/memory and control-flow issues).

Scope:

  • ImportObject API: host code (typically the JS bindings) supplies a map from (module_name, name) to a runtime value (function, table, memory, or global) that matches the import's declared type.
  • Type-check every supplied import against the module's declared import descriptor; reject with a structured LinkError if the type does not match.
  • Initialize linear memories from data segments and tables from element segments per the spec's instantiation algorithm, including active vs passive segments.
  • Run the start function (if present) once after segment initialization, propagating any trap as an InstantiationError.
  • Export resolution: produce a typed Exports collection keyed by name with funcref/memory/table/global handles into the new Instance.
  • Module-side host functions: host can register a Rust closure that wraps an imported function and receives WasmValue arguments, returning WasmValue results or a trap.

Acceptance criteria:

  • Unit tests cover successful linking, every LinkError variant (missing import, wrong kind, mismatched signature, mismatched mutability, incompatible limits), data/element segment initialization edge cases, and start-function trap propagation.
  • A small end-to-end test loads a tiny hand-authored module with a host-imported function, calls an exported function, and verifies the result.
  • 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/3mm2tltcehp2n