alexcrichton requested elliottt for a review on PR #8702.
alexcrichton opened PR #8702 from alexcrichton:wiggle-no-borrow-checking
to bytecodealliance:main
:
This commit is a refactoring of the
wiggle
crate which powers the*.witx
-based bindings generation of Wasmtime for wasip1 support. Originallywiggle
had a full-blown runtime borrow checker which verified that borrows were disjoint when appropriate. In #8277 this was removed in favor of a more coarse "either all shared or all mutable" guarantee. It turns out that this exactly matches what the Rust type system guarantees at compile time as well.This commit removes all runtime borrow checking in favor of compile-time borrow checking instead. This means that there is no longer the possibility of a runtime error arising from borrowing errors. Current bindings in Wasmtime needed no restructuring to work with this new API.
The source of the refactors here are all in the
wiggle
crate. Changes include:
- The
GuestPtr
type lost its type parameter. Additionally it only contains au32
pointer now instead.- The
GuestMemory
trait is replaced with a simpleenum
of possibilities.- Helper methods on
GuestPtr
are all moved toGuestMemory
.- A number of abstractions were simplified now that borrow checking is no longer necessary.
- Generated trait methods now all take
&mut GuestMemory<'_>
as an argument.These changes were then propagated to the
wasmtime-wasi
andwasi-common
crates in their preview0 and preview1 implementations of WASI. All changes are just general refactors, no functional change is intended here.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested wasmtime-core-reviewers for a review on PR #8702.
pchickey submitted PR review:
We sure did spend turn a lot of CPU cycles into heat by dynamically checking a property that was statically provable all these years, didnt we
pchickey submitted PR review:
We sure did spend turn a lot of CPU cycles into heat by dynamically checking a property that was statically provable all these years, didnt we
pchickey created PR review comment:
Wish I had done this years ago
pchickey created PR review comment:
Docs TODO
alexcrichton updated PR #8702.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
I should wrap this up in a helper as well since I'm starting to litter this all over the macros I work on...
iximeow commented on PR #8702:
to be fair to ourselves, when we thought embedders might provide functions that involve multiple concurrent outstanding borrows it all made a bit more sense :)
alexcrichton updated PR #8702.
alexcrichton has enabled auto merge for PR #8702.
alexcrichton updated PR #8702.
alexcrichton has enabled auto merge for PR #8702.
acfoltzer commented on PR #8702:
I'm so glad we're able to do this now, thank you!!
alexcrichton updated PR #8702.
alexcrichton has enabled auto merge for PR #8702.
alexcrichton merged PR #8702.
Last updated: Nov 22 2024 at 16:03 UTC