-
Notifications
You must be signed in to change notification settings - Fork 55
Conversation
This PR proposes a "canonical ABI" for interface types. This feature was alluded to in Luke's recent [presentation to the CG][pres], and this PR intends to flesh it out more and get a more formal specification of what it might be. The idea of a canonical ABI is that the adapter language for interface types is one of the most complicated parts of the proposal, but with a canonical ABI we might be able to separate out the adapter language to a future proposal so we can get the goodness of interface types on a smaller time-scale. The ABI proposed here is not intended to be a "one size fits all" ABI. It does not express the full power of interface types as-proposed today (intentionally). It's hoped, though, that the adapter language as proposed in this repository right now can be seen as largely just an optimization over what the canonical ABI specifies. This way languages and tooling can work with the canonical ABI by default, and if necessary for performance a custom ABI can be used with custom adapters in the future. One way to think about this canonical ABI is that it's a generalization of the current `list.lift_canon` into encompassing entire function signatures in addition to lists. This PR describes the canonical ABI with a large amount of Python-like pseudo-code which describes the `lift` and `lower` operations for types, culminating in a `fuse` function which shows precisely how lifting/lowering happens when modules call each other. [pres]: https://docs.google.com/presentation/d/1PSC3Q5oFsJEaYyV5lNJvVgh-SNxhySWUqZ6puyojMi8
This was always intended, just wasn't clear from the pseudo-code!
It's not currently used.
Co-authored-by: Luke Wagner <[email protected]>
Co-authored-by: Luke Wagner <[email protected]>
Looks great to me. :) There's an "f31" typo that seems to have snuck in. |
One note: I find the "import" and "export" terminology confusing -- I've been mentally translating it into "parameter" or "result" as appropriate, but I sometimes get it backwards... |
I did not mean to approve this PR (too many GitHub tabs open). Sorry about that! |
@alexcrichton Awesome to see progress on this! ⭐ |
If I understand correctly, buffers require special notation because you want to statically verify that the buffer passed in as an argument can not be accessed anymore after the call has finished? For example: // This is some wasm module:
let my_large_buffer = // ...
another_wasm_module::process(&my_large_buffer);
// Here You want to make sure that there is no way for If so, could this be solved using a more generic type which is defined to be unusable after the functions returns? I.e.
That way, Buffers can be just™ a WASI module. Updated: Changed wording. Remembered that interface types are supposed to compile away and not introduce new Wasm types. Yet, the general idea still holds. |
im curious what if any places this is being discussed or worked on? last commits here are from july. the other piece of Component Model, module-linking, seems to be under fairly active development. does that work need to get closer to release before this PR can be revisited? https://github.com/WebAssembly/component-model |
That's a great question. I've been working on a branch in the component-model repo that combines module-linking and MVP-interface-types (viz., using the canonical ABI instead of custom adapters) into a single simpler and easier-to-understand AST and binary format. While it's not there yet, the idea is to include an updated form of the |
Just as an update here, the PR I mentioned in the last comment is up. Still unfortunately no updated CanonicalABI.md but that's what I'm going to actively work on now that the merged PR is up. |
Finally done in component-model/#23, so closing this issue. |
This PR proposes a "canonical ABI" for interface types. This feature was
alluded to in Luke's recent presentation to the CG, and this PR
intends to flesh it out more and get a more formal specification of what
it might be.
The idea of a canonical ABI is that the adapter language for interface
types is one of the most complicated parts of the proposal, but with a
canonical ABI we might be able to separate out the adapter language to a
future proposal so we can get the goodness of interface types on a
smaller time-scale.
The ABI proposed here is not intended to be a "one size fits all" ABI.
It does not express the full power of interface types as-proposed today
(intentionally). It's hoped, though, that the adapter language as
proposed in this repository right now can be seen as largely just an
optimization over what the canonical ABI specifies. This way languages
and tooling can work with the canonical ABI by default, and if necessary
for performance a custom ABI can be used with custom adapters in the future.
One way to think about this canonical ABI is that it's a generalization
of the current
list.lift_canon
into encompassing entire functionsignatures in addition to lists.
This PR describes the canonical ABI with a large amount of Python-like
pseudo-code which describes the
lift
andlower
operations for types,culminating in a
fuse
function which shows precisely howlifting/lowering happens when modules call each other.
As a note this is a reopening of #132 with a new base branch of
main
after the branch was renamed.