The WebAssembly component model  defines a portable, load- and run-time-efficient binary format […] that enables portable, cross-language compositio

Building host implementations for WebAssembly interfaces | radu's blog

submited by
Style Pass
2022-01-20 14:30:06

The WebAssembly component model defines a portable, load- and run-time-efficient binary format […] that enables portable, cross-language composition, effectively enabling a wide range of scenarios for WebAssembly modules built in different programming languages to interoperate. The previous article in this series showcased how to start from a WebAssembly interface, implement it as a WebAssembly component in Rust, then consume the interface and its Rust implementation from other Wasm components built in C++ and Rust.

Satisfying interfaces through other WebAssembly components means they will be executed in the same WebAssembly sandbox, and will not get access to anything outside the sandbox — this means no default access to any host APIs, not hardware acceleration support, or no networking. So how could we build an implementation of an interface, get access to resources that are not available in the WebAssembly sandbox, but still ensure that we only expose the functionality needed for the interface we are implementing?

We could build a host implementation. We could use to all host capabilities (hardware acceleration, networking), and transparently expose them to guest modules through regular Wasm imports. Because we are implementing the same interface, users of it (consumer modules, such as the components from the previous article ) don’t have to change at all, but the host runtime can be updated, or potentially patched for a security vulnerability without recompiling the consumers of the interface.

Leave a Comment