WebAssembly / WebAssembly/component-model

Symmetrical ABI for component fusion and shared everything

Open
#386 15 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
1.4k
Forks
130
Avg merge
2d 1h
Merged PRs (30d)
15

Description

While the asymmetry between imported and exported functions and resources is directly caused by the asymmetry between guest and host, a symmetrical ABI option would enable direct fusion of components into a single core module.

Similarly this enables combining components compiled as shared objects without a runtime doing the impedance matching. Full insulation between components is still possible using this symmetric ABI, but calling exported functions becomes less elegant.

The proposal is to reuse the ABI for imported interfaces (functions and resources) also for exported interfaces. This means that arguments become only borrowed and return values are allocated from linear memory using realloc, no more cabi_post_. Similarly dtor is replaced with [resource-drop] and [resource-new] and [resource-rep] are only used internally. Also the member functions always receive ID, never the rep.

You can find a proof of concept at https://github.com/cpetig/wit-bindgen/tree/main/crates/cpp/tests/meshless_resources and a presentation at https://hackmd.io/@cpetig/rJp4l6vKC#/ , code generation for C++ and Rust are available.

PS: This also removes the conceptual difference between guest and host implementations.

PPS: To save overhead in a shared everything environment the resource ID should become usize instead of i32, so that the mapping table between rep and ID becomes optional for shared everything between friendly components. (Similarly IDs for async objects should become usize wherever meaningful - no change for wasm32, but more handy on x86_64 or wasm64)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the proof of concept in crates/cpp/tests/meshless_resources and the linked presentation, then compare the available C++ and Rust code generation mentioned in the issue. This work is done when the symmetric ABI proposal has an agreed design and the affected implementations are specified or updated accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust, wasm
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.