Skip to content

Symmetrical ABI for component fusion and shared everything #386

@cpetig

Description

@cpetig

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions