Canonical ABI Lifting and Lowering Support - #32
Open
jeremyg484 wants to merge 3 commits into
Open
Conversation
A canonical-abi module is added that provides all of the low-level operations needed for the runtime to lift and lower to the Component Model's Canonical ABI. CanonicalAbi.java provides the main API surface for consumers, with public methods for lifting and lowering function arguments and results. The semantics defined by the spec for loading from and storing to core wasm memory, as well as the "flattening" of arguments and results to avoid the memory reading and writing when possible. The methods implemented largely mirror those of the spec's Canonical ABI Python reference definitions, with idioms converted to Java as appropriate. A third "direct transfer" path is added as an optimization to potentially be used in component-to-component calls where the lifting and lowering is connecting the functions of two embedded core wasm modules. This path bypasses conversion to higher-level Java types in favor of either passing core wasm values and results directly (in the simplest cases) or by copying data directly between the modules' memories. This path still handles necessary work such as conversion between different string encodings, working at the byte level without intermediary conversion to Java Strings. Not all lift/lower pairs can be connected this way (for example, when resources are involved), so methods are provided to check eligibility. A suite of tests are implemented that verify the functionality of all three paths and ensure symmetry between them.
jeremyg484
marked this pull request as ready for review
August 12, 2026 11:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A canonical-abi module is added that provides all of the low-level
operations needed for the runtime to lift and lower to the Component
Model's Canonical ABI.
See https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md
for reference.
CanonicalAbi.java provides the main API surface for consumers, with
public methods for lifting and lowering function arguments and results.
The semantics defined by the spec for loading from and storing to core
wasm memory, as well as the "flattening" of arguments and results to
avoid the memory reading and writing when possible, are implemented
therein. The methods implemented largely mirror those of the spec's
Canonical ABI Python reference definitions, with idioms converted to
Java as appropriate.
A third "direct transfer" path is added as an optimization to
potentially be used in component-to-component calls where the lifting
and lowering is connecting the functions of two embedded core wasm
modules. This path bypasses conversion to higher-level Java types in
favor of either passing core wasm values and results directly (in the
simplest cases) or by copying data directly between the modules'
memories. This path still handles necessary work such as conversion
between different string encodings, working at the byte level without
intermediary conversion to Java Strings. Not all lift/lower pairs can
be connected this way (for example, when resources are involved), so
methods are provided to check eligibility.
A suite of tests are implemented that verify the functionality of all
three paths and ensure symmetry between them.
Note that Records are currently converted from/to Java Maps as a
starting point to keep things simple. Support for conversion from/to
higher-level strongly-typed objects should be able to be layered on top
of this later.
Also note that no attempt has been made yet to support the async ABI,
though care has been taken to ensure that such support can be added
at a later time.