Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Bytecode Alliance 17 min read Deep dive hardMaster

The Async Component Model

WASI 0.3 builds on the Component Model's new async features, which let each language implement its own concurrency in Wasm while still calling async functions across components without knowing how the other side works. The building blocks are an `async` effect on component function types, `async` lift/lower canonical options, epoll-like waitable sets referenced by i32 handle-table indices, streams and futures, and cooperative threads. Functions block either stackfully via `waitable-set.wait` or stacklessly by returning a WAIT exit code and supplying a callback. Async-lowered calls return a bit-packed status plus subtask index, and results come back through `task.return`. A full annotated WAT example walks through summing two async `get-random` calls. As of WASI 0.3.3 the stackful ABI is not yet released, so a callback is still required.

Related posts

  • WASI 0.3 Launched

    Bytecode Alliance mediumAdept

    WASI 0.3.0 is ratified and rebases WASI onto the Component Model's native async primitives. The canonical ABI gains `stream<T>`, `future<T>` and `async func`, which replace `wasi:io` pollables and streams. Scheduling moves to a single host-managed, completion-based event loop modeled on io_uring/IOCP, so async components can finally be composed with each other. Streams now return a separate error future, and `wasi:http` is reorganized into `service` and `middleware` worlds that allow in-process service chaining. Wasmtime 46 will enable WASI 0.3 by default, jco already supports it, and Rust and Go bindings illustrate idiomatic stackless and stackful async.

  • The Road to Component Model 1.0

    Bytecode Alliance hardMaster

    Component Model 1.0 is planned around five workstreams: a lazy ABI that replaces cabi_realloc-based eager allocation with opaque value handles and inlinable built-ins, native implementation in at least two browser engines, simpler implementation via guest and host C ABIs plus a component-smashing tool, ecosystem and tooling growth, and WIT expressivity features such as optional imports, callbacks, resource subtyping and a map type. The ABI change ships opt-in in a 0.3.x release and becomes the default at 1.0, with adapters keeping P1, P2 and P3 components working. Other planned work removes the roughly 3.5x overhead on synchronous cross-component calls and adds cooperative threads and stream splicing in WASI P3 follow-up releases. jco's "use components" marker borrows the asm.js telemetry strategy to build the case for native browser support.

  • Introducing the WebAssembly JavaScript Promise Integration API

    V8 mediumAdept

    JSPI lets WebAssembly code written against synchronous APIs call asynchronous Web APIs. It intercepts Promises returned from wrapped JavaScript imports, suspends the Wasm computation, and resumes it from the browser's event loop when the Promise resolves. Wrapped exports return a Promise instead of a direct value. JSPI changes neither JavaScript nor Wasm, and suspend/resume costs are roughly constant: a deliberately bad Promise-based Fibonacci benchmark puts each JSPI'd call at about 1μs. The API is at phase 4 and ships in Chrome 137 and Firefox 139. Emscripten examples show `-s JSPI` with `EM_ASYNC_JS`, plus a trampoline pattern that lazily fetches and instantiates a Wasm module on first call.

  • How Wasm components enable pluggable tooling through interposition

    Bytecode Alliance mediumAdept

    The WASI 0.3 `wasi:http` middleware world (import handler, export handler) shows how Wasm component composition enables in-process service chaining and, more generally, interposition: inserting a component between any caller and callee without modifying either. Interposition addresses three limits of language-level middleware: per-language fragmentation, the assumption of a fixed HTTP request/response interface, and opaque binaries that cannot be re-wired. Because component interfaces expose full type information, a tool can adapt generic middleware such as logging, tracing, fuzzers or record/replay to arbitrary interfaces. The `splicer` research tool discovers a component's composition graph and interposes components driven by a YAML config. It currently supports passthrough and read-only adapters, with read/write adapters planned.

  • Five ways of looking at Jco, Part 1

    Bytecode Alliance easyNovice

    Jco, the Bytecode Alliance's JavaScript WebAssembly multi-tool, is best understood as a layered stack. StarlingMonkey (SpiderMonkey compiled to Wasm with Component Model wiring) sits at the base. componentize-js bundles JS into it and pre-initializes with Wizer so startup cost is paid at build time, and it is being rewritten on wit-dylib to remove a circular dependency. jco transpile unbundles any component into core Wasm modules plus JS glue generated by the Rust crate js-component-bindgen, so components run in Node.js or browsers without native Component Model support. WASI P2 shims supply the I/O, with P3 shims landing first for Node.js.

The quest for software engineering knowledge.

Look:
Layout: