-
Notifications
You must be signed in to change notification settings - Fork 824
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
Add fn for splitting borrow of memory & data in Ctx, use in WASI #1069
Conversation
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.
Why this change? It appears to be a convenience method?
lib/runtime-core/src/vm.rs
Outdated
@@ -401,6 +401,21 @@ impl Ctx { | |||
} | |||
} | |||
|
|||
/// Splits the borrow, getting both Memory and a mutable reference to |
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.
"Splits the borrow" sounds like a function that takes a borrow and splits it. Instead, this is a variation on memory
that returns a Memory and a mutable reference to the Ctx.data.
Also, I'd replace "a hostcall" with simply "the host".
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.
It's required by the Rust borrow checker; it's a split borrow in that one borrow comes in and 2 come out that otherwise is not possible with safe Rust. There's a function for splitting borrows over slices I believe &mut [u8] -> (&mut [u8], &mut [u8])
which is where I got the terminology from
Co-Authored-By: nlewycky <[email protected]>
bors r+ |
1069: Add fn for splitting borrow of memory & data in Ctx, use in WASI r=MarkMcCaskey a=MarkMcCaskey Fixes a soundness issue / some undefined behavior # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <[email protected]> Co-authored-by: Mark McCaskey <[email protected]>
bors r- |
Canceled |
bors r+ |
1069: Add fn for splitting borrow of memory & data in Ctx, use in WASI r=MarkMcCaskey a=MarkMcCaskey Fixes a soundness issue / some undefined behavior # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <[email protected]> Co-authored-by: Mark McCaskey <[email protected]>
Build succeeded
|
Fixes a soundness issue / some undefined behavior
Review