-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Change all WASI impls to being concrete, not blanket #8609
Merged
alexcrichton
merged 1 commit into
bytecodealliance:main
from
alexcrichton:refactor-wasi
May 14, 2024
Merged
Change all WASI impls to being concrete, not blanket #8609
alexcrichton
merged 1 commit into
bytecodealliance:main
from
alexcrichton:refactor-wasi
May 14, 2024
Conversation
This file contains 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
This commit builds on the support from bytecodealliance#8448 to remove all blanket impls from the WASI crates and instead replace them with concrete impls. This is slightly functionally different from before where impls are now on trait objects meaning dynamic dispatch is involved where previously dynamic dispatch was used. That being said the perf hit here is expected to be negligible-to-nonexistent since the implementations are large enough that the dynamic dispatch won't be the hot path. The motivations for this commit are: * Removes the need for an odd `skip_mut_forwarding_impls` option - but this'll be left for a bit in case others need it. * Improves incremental compile time of these crates where the crates themselves now contain all object code for all of WASI instead of forcing the final consume to codegen everything (although there's still a significant amount monomorphized). * Improves future compatibility with refactorings of bindgen-generated-traits and such because blanket impls are pretty hard to work around where concrete impls are easier to reason about (and document).
pchickey
approved these changes
May 14, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it!
alexcrichton
added a commit
to alexcrichton/wasmtime
that referenced
this pull request
Jun 10, 2024
This commit is a partial revert of bytecodealliance#8609 to return `wasmtime-wasi` and `wasmtime-wasi-http` back to using blanket impls. The main change from before is to change the blanket impls to be in terms of a local newtype wrapper to avoid trait coherence issues. This is done because otherwise using the traits before required `&mut dyn WasiView` to exist but sometimes only a `Foo<'a>` is held which is not easy to get a `&mut dyn ...` view of. By changing to a blanket impl in terms of a newtype wrapper, `WasiImpl`, it's possible to call `bindgen!`-generated `add_to_linker_get_host` functions with a return value of `WasiImpl<Foo<'a>>` which enables hooking into all the generated bindings.
alexcrichton
added a commit
to alexcrichton/wasmtime
that referenced
this pull request
Jun 10, 2024
…#8766) This commit is a partial revert of bytecodealliance#8609 to return `wasmtime-wasi` and `wasmtime-wasi-http` back to using blanket impls. The main change from before is to change the blanket impls to be in terms of a local newtype wrapper to avoid trait coherence issues. This is done because otherwise using the traits before required `&mut dyn WasiView` to exist but sometimes only a `Foo<'a>` is held which is not easy to get a `&mut dyn ...` view of. By changing to a blanket impl in terms of a newtype wrapper, `WasiImpl`, it's possible to call `bindgen!`-generated `add_to_linker_get_host` functions with a return value of `WasiImpl<Foo<'a>>` which enables hooking into all the generated bindings.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jun 10, 2024
This commit is a partial revert of #8609 to return `wasmtime-wasi` and `wasmtime-wasi-http` back to using blanket impls. The main change from before is to change the blanket impls to be in terms of a local newtype wrapper to avoid trait coherence issues. This is done because otherwise using the traits before required `&mut dyn WasiView` to exist but sometimes only a `Foo<'a>` is held which is not easy to get a `&mut dyn ...` view of. By changing to a blanket impl in terms of a newtype wrapper, `WasiImpl`, it's possible to call `bindgen!`-generated `add_to_linker_get_host` functions with a return value of `WasiImpl<Foo<'a>>` which enables hooking into all the generated bindings.
alexcrichton
added a commit
that referenced
this pull request
Jun 10, 2024
* Change WASI trait impls back to being blanket impls (#8766) This commit is a partial revert of #8609 to return `wasmtime-wasi` and `wasmtime-wasi-http` back to using blanket impls. The main change from before is to change the blanket impls to be in terms of a local newtype wrapper to avoid trait coherence issues. This is done because otherwise using the traits before required `&mut dyn WasiView` to exist but sometimes only a `Foo<'a>` is held which is not easy to get a `&mut dyn ...` view of. By changing to a blanket impl in terms of a newtype wrapper, `WasiImpl`, it's possible to call `bindgen!`-generated `add_to_linker_get_host` functions with a return value of `WasiImpl<Foo<'a>>` which enables hooking into all the generated bindings. * Update release notes
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.
This commit builds on the support from #8448 to remove all blanket impls from the WASI crates and instead replace them with concrete impls. This is slightly functionally different from before where impls are now on trait objects meaning dynamic dispatch is involved where previously dynamic dispatch was used. That being said the perf hit here is expected to be negligible-to-nonexistent since the implementations are large enough that the dynamic dispatch won't be the hot path.
The motivations for this commit are:
skip_mut_forwarding_impls
option - but this'll be left for a bit in case others need it.