-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: demonstrate copying bytes at the Wasm-WASI boundary
The fundamental concern with shared Wasm memories is that passing around a `&[T]` or `&mut [T]` (or `&str` or `&mut str`, though these are less common) to the Rust code implementing a WASI call would be prone to having "the ground shift under its feet." There is no way to guarantee that multiple threads are not reading or writing to the same Wasm address, but somehow we want to prevent the Rust code from being affected since it may have been written with Rust assumptions about `&[T]` and `&mut [T]` in mind. This problem is difficult due to Wasm's unrestricted access to linear memory; the best we can do is add a layer of protection at the Wasm-WASI boundary by copying the bytes. This change modifies `GuestSlice` (only this one for now to get early feedback) to copy the slice bytes out of linear memory into an allocation owned and later deallocated on the Wiggle side. There is a lot that can be improved but I am looking for feedback on whether this is the right approach (modulo some clean up).
- Loading branch information
Showing
3 changed files
with
54 additions
and
13 deletions.
There are no files selected for viewing
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 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 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