Skip to content

Update some async intrinsic signatures #2116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 31, 2025

Conversation

alexcrichton
Copy link
Member

@alexcrichton alexcrichton commented Mar 27, 2025

  • future.new - returns a 64-bit value instead of a 32-bit value
  • future.close-{readable,writable} - drop the error-context argument second field.

* `future.new` - takes a pointer parameter instead of returning a
  result.
* `future.close-{readable,writable}` - drop the `error-context` argument
  second field.
@alexcrichton
Copy link
Member Author

This is intended to encompass upstream issues such as WebAssembly/component-model#474 and WebAssembly/component-model#475. Not complete as more changes may be necessary. I hope to add intrinsics for task cancellation soon to. Nevertheless I'm using this in my wit-bindgen refactor.

cc @dicej

Copy link
Member Author

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I think this is good to go @dicej, just some minor changes here and I'll follow-up later with task cancellation intrinsics in a future PR.

Comment on lines -195 to +201
(import {module:?} "[future-new-{i}]{name}" (func (result i32)))
(import {module:?} "[future-new-{i}]{name}" (func (result i64)))
(import {module:?} "[future-read-{i}]{name}" (func (param i32 i32) (result i32)))
(import {module:?} "[future-write-{i}]{name}" (func (param i32 i32) (result i32)))
(import {module:?} "[future-cancel-read-{i}]{name}" (func (param i32) (result i32)))
(import {module:?} "[future-cancel-write-{i}]{name}" (func (param i32) (result i32)))
(import {module:?} "[future-close-readable-{i}]{name}" (func (param i32 i32)))
(import {module:?} "[future-close-writable-{i}]{name}" (func (param i32 i32)))
(import {module:?} "[future-close-readable-{i}]{name}" (func (param i32)))
(import {module:?} "[future-close-writable-{i}]{name}" (func (param i32)))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a basic summary of the changes here, notably:

  • {future,stream}.new intrinsics return a two 32-bit handles as a result packed into a 64-bit integer. It kind of sucks we don't have multi-value and I also didn't want to go the route of adding canonopts to these intrinsics just to write values into memory. It's a bit wonky since bit packing doesn't happen anywhere else in the canonical ABI but it happens in other async intrinsics so maybe ok?
  • For {future,stream}.close-{readable,writable} the only change is to drop the error-context parameter.

@alexcrichton alexcrichton added this pull request to the merge queue Mar 31, 2025
Merged via the queue into bytecodealliance:main with commit 8bd9442 Mar 31, 2025
32 checks passed
@alexcrichton alexcrichton deleted the new-async-signatures branch March 31, 2025 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants