Skip to content
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

refactor concurrent_imports support in wasmtime-wit-bindgen #18

Merged
merged 2 commits into from
Feb 21, 2025

Conversation

dicej
Copy link
Collaborator

@dicej dicej commented Feb 21, 2025

This is yet another major rework of concurrent_imports; this time, the goal is to support add_to_linker_get_host properly such that input and output types of the host_getter param need not be the same. After much perserverance with Alex and Lann, we arrived at something the compiler would accept, but it requires thread-local storage and unsafe here and there, alas.

One drawback of this approach is that we no longer generate forwarding impls for &mut T, and thus no add_to_linker functions. That's related to concurrent functions taking &mut Accessor<T, Self> as a parameter and the borrow checker not allowing us to map an Accessor<T, &mut U> to a Accessor<T, U> despite all our efforts to convince it.

Finally, this adds SpawnHandle and AbortOnDropHandle types for aborting spawned tasks. I haven't actually tested this yet, but Roman has a test case for his WASIp3 implementation, so I'm sure he'll let me know if there are problems.

@dicej dicej force-pushed the dicej/another-bindgen-refactor branch 2 times, most recently from 1552104 to 90c7e4e Compare February 21, 2025 03:22
This is yet another major rework of `concurrent_imports`; this time, the goal is
to support `add_to_linker_get_host` properly such that input and output types of
the `host_getter` param need not be the same.  After much perserverance with
Alex and Lann, we arrived at something the compiler would accept, but it
requires thread-local storage and `unsafe` here and there, alas.

One drawback of this approach is that we no longer generate forwarding `impl`s
for `&mut T`, and thus no `add_to_linker` functions.  That's related to
concurrent functions taking `&mut Accessor<T, Self>` as a parameter and the
borrow checker not allowing us to map an `Accessor<T, &mut U>` to a `Accessor<T,
U>` despite all our efforts to convince it.

Finally, this adds `SpawnHandle` and `AbortOnDropHandle` types for aborting
`spawn`ed tasks.  I haven't actually tested this yet, but Roman has a test case
for his WASIp3 implementation, so I'm sure he'll let me know if there are
problems.

Signed-off-by: Joel Dice <[email protected]>
@rvolosatovs rvolosatovs force-pushed the dicej/another-bindgen-refactor branch from 90c7e4e to 016dba4 Compare February 21, 2025 15:57
These tests are currently flaky due to an occasional deadlock in
`HostTcpSocket::drop` which I expect will be resolved by using
`AbortOnDropHandle` instead of the current `tokio::spawn`+channels approach.

Signed-off-by: Joel Dice <[email protected]>
@dicej dicej merged commit ad41493 into main Feb 21, 2025
25 checks passed
@dicej dicej deleted the dicej/another-bindgen-refactor branch February 21, 2025 23:21
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.

1 participant