Enable the `useless_conversion` Clippy lint (#10838)* Enable the `useless_conversion` Clippy lintWe've got lots of types in Wasmtime and convert between them quite alot, but often over time conv
Enable the `useless_conversion` Clippy lint (#10838)* Enable the `useless_conversion` Clippy lintWe've got lots of types in Wasmtime and convert between them quite alot, but often over time conversions become unnecessary throughrefactorings or similar. This will hopefully enable us to clean up someconversions as they come up to try to have as few as possible ideally.* Review comments
show more ...
Enable the `from_over_into` Clippy lint (#10837)This requires implementing `From<T> for U` instead of `Into<U> for T`.While both trait impls are valid the `From` one is more useful becauseit imp
Enable the `from_over_into` Clippy lint (#10837)This requires implementing `From<T> for U` instead of `Into<U> for T`.While both trait impls are valid the `From` one is more useful becauseit implies `Into` and additionally gives you `From`. This additionallythen migrates the existing codebase to using the new style of impls.
Fix some more minor 2024 edition things (#9978)* Fix some doctests to be compatible with the 2024 edition.* Fix a `use<...>` that's an error in the 2024 edition but works in the 2021 edition.
Enable `impl-trait-overcaptures` 2024 transition lint (#9965)* Enable `impl-trait-overcaptures` 2024 transition lintThis lint detects cases where returning `impl Trait` will workdifferently in 2
Enable `impl-trait-overcaptures` 2024 transition lint (#9965)* Enable `impl-trait-overcaptures` 2024 transition lintThis lint detects cases where returning `impl Trait` will workdifferently in 2024 than in the current 2021 edition. Ambiguities areresolved with `use<..>` syntax stabilized in Rust 1.82.0 to mean thesame thing in both editions.* Fix some more `impl Trait` returns* Tighten bounds on settings `iter`* Fix build on 1.82.0* Fix another capture on MSRV
Remove the borrow checking from `wiggle` entirely (#8702)* Remove the borrow checking from `wiggle` entirelyThis commit is a refactoring of the `wiggle` crate which powers the`*.witx`-based bind
Remove the borrow checking from `wiggle` entirely (#8702)* Remove the borrow checking from `wiggle` entirelyThis commit is a refactoring of the `wiggle` crate which powers the`*.witx`-based bindings generation of Wasmtime for wasip1 support.Originally `wiggle` had a full-blown runtime borrow checker whichverified that borrows were disjoint when appropriate. In #8277 this wasremoved in favor of a more coarse "either all shared or all mutable"guarantee. It turns out that this exactly matches what the Rust typesystem guarantees at compile time as well.This commit removes all runtime borrow checking in favor of compile-timeborrow checking instead. This means that there is no longer thepossibility of a runtime error arising from borrowing errors. Currentbindings in Wasmtime needed no restructuring to work with this new API.The source of the refactors here are all in the `wiggle` crate. Changesinclude:* The `GuestPtr` type lost its type parameter. Additionally it only contains a `u32` pointer now instead.* The `GuestMemory` trait is replaced with a simple `enum` of possibilities.* Helper methods on `GuestPtr` are all moved to `GuestMemory`.* 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` and`wasi-common` crates in their preview0 and preview1 implementations ofWASI. All changes are just general refactors, no functional change isintended here.* Review comments* Fix publishing of wiggle-macro crate* Fix wiggle docs
Fix some typos (#8641)* occurred* winch typos* tests typos* cli typos* fuzz typos* examples typos* docs typos* crates/wasmtime typos* crates/environ typos* crates/cranelift typos
Fix some typos (#8641)* occurred* winch typos* tests typos* cli typos* fuzz typos* examples typos* docs typos* crates/wasmtime typos* crates/environ typos* crates/cranelift typos* crates/test-programs typos* crates/c-api typos* crates/cache typos* crates other typos* cranelift/codegen/src/isa typos* cranelift/codegen/src other typos* cranelift/codegen other typos* cranelift other typos* ci js typo* .github workflows typo* RELEASES typo* Fix clang-format documentation line---------Co-authored-by: Andrew Brown <[email protected]>
Update wiggle's `BorrowChecker` implementation (#8277)This commit is a refactoring and modernization of wiggle's`BorrowChecker` implementation. This type is quite old and predateseverything relat
Update wiggle's `BorrowChecker` implementation (#8277)This commit is a refactoring and modernization of wiggle's`BorrowChecker` implementation. This type is quite old and predateseverything related to the component model for example. This typeadditionally predates the implementation of WASI threads for Wasmtime aswell. In general, this type is old and has not been updated in a longtime.Originally a `BorrowChecker` was intended to be a somewhat cheap methodof enabling the host to have active safe shared and mutable borrows toguest memory. Over time though this hasn't really panned out. The WASIthreads proposal, for example, doesn't allow safe shared or mutableborrows at all. Instead everything must be modeled as a copy in or copyout of data. This means that all of `wasmtime-wasi` and `wasi-common`have largely already been rewritten in such a way to minimize borrowsinto linear memory.Nowadays the only types that represent safe borrows are the `GuestSlice`type and its equivalents (e.g. `GuestSliceMut`, `GuestStr`, etc). Theseare minimally used throughout `wasi-common` and `wasmtime-wasi` and whenthey are used they're typically isolated to a small region of memory.This is all coupled with the facst that `BorrowChecker` never ended upbeing optimized. It's a `Mutex<HashMap<..>>` effectively and a prettyexpensive one at that. The `Mutex` is required because `&BorrowChecker`must both allow mutations and be `Sync`. The `HashMap` is used toimplement precise byte-level region checking to fulfill the originaldesign requirements of what `wiggle` was envisioned to be.Given all that, this commit guts `BorrowChecker`'s implementation andfunctionality. The type is now effectively a glorified `RefCell` for theentire span of linear memory. Regions are no longer considered whenborrows are made and instead a shared borrow is considered as borrowingthe entirety of shared memory. This means that it's not possible tosimultaneously have a safe shared and mutable borrow, even if they'redisjoint, at the same time.The goal of this commit is to address performance issues seen in #7973which I've seen locally as well. The heavyweight implementation of`BorrowChecker` isn't really buying us much nowadays, especially withmuch development having since moved on to the component model. The hopeis that this much coarser way of implementing borrow checking, whichshould be much more easily optimizable, is sufficient for the needs ofWASI and not a whole lot else.
wiggle: Refactor with fewer raw pointers (#5268)This commit refactors the internals of `wiggle` to have fewer raw pointers and more liberally use `&[UnsafeCell<_>]`. The purpose of this refactoring
wiggle: Refactor with fewer raw pointers (#5268)This commit refactors the internals of `wiggle` to have fewer raw pointers and more liberally use `&[UnsafeCell<_>]`. The purpose of this refactoring is to more strictly thread through lifetime information throughout the crate to avoid getting it wrong. Additionally storing `UnsafeCell<T>` at rest pushes the unsafety of access to the leaves of modifications where Rust safety guarantees are upheld. Finally this provides what I believe is a safer internal representation of `WasmtimeGuestMemory` since it technically holds onto `&mut [u8]` un-soundly as other `&mut T` pointers are handed out. Additionally generated `GuestTypeTransparent` impls in the `wiggle` macro were removed because they are not safe for shared memories as-is and otherwise aren't needed for WASI today. The trait has been updated to indicate that all bit patterns must be valid in addition to having the same representation on the host as in the guest to accomodate this.
Implement RFC 11: Redesigning Wasmtime's APIs (#2897)Implement Wasmtime's new API as designed by RFC 11. This is quite a large commit which has had lots of discussion externally, so for more inform
Implement RFC 11: Redesigning Wasmtime's APIs (#2897)Implement Wasmtime's new API as designed by RFC 11. This is quite a large commit which has had lots of discussion externally, so for more information it's best to read the RFC thread and the PR thread.
delete GuestErrorConversion from docs, tests
refactor is_borrowed/unborrow into shared/mut variants
rename immutable borrows to shared borrows
wiggle: borrow checker lives in own crate, and supports both mut/immut
tests: exercise array getters
code review: remove `unsafe` on borrow checker constructor
wiggle: factor BorrowChecker concrete implementation to live in enginesThe BorrowChecker methods get inlined as part of the GuestMemory trait.The BorrowChecker implementation moves out to the eng
wiggle: factor BorrowChecker concrete implementation to live in enginesThe BorrowChecker methods get inlined as part of the GuestMemory trait.The BorrowChecker implementation moves out to the engines. Unfortunatelythis does mean having a copy in `test-helpers` along with another in`wasmtime-wiggle`. The `wasmtime-wiggle` copy will move into `wasmtime`itself in a subsequent PR.https://github.com/bytecodealliance/wasmtime/issues/1917
error conversion code: update test to actually execute it
wiggle: fix tests
wiggle: get BorrowChecker from GuestMemory method
wiggle: revamp error type conversions
GuestErrorType only needs to have a success constructor
Shuffle around the wiggle crates (#1414)* Shuffle around the wiggle crates This commit reorganizes the wiggle crates slightly by performing the following transforms: * The `crates/wiggle` cr
Shuffle around the wiggle crates (#1414)* Shuffle around the wiggle crates This commit reorganizes the wiggle crates slightly by performing the following transforms: * The `crates/wiggle` crate, previously named `wiggle`, was moved to `crates/wiggle/crates/macro` and is renamed to `wiggle-macro`. * The `crates/wiggle/crates/runtime` crate, previously named `wiggle-runtime`, was moved to `crates/wiggle` and is renamed to `wiggle`. * The new `wiggle` crate depends on `wiggle-macro` and reexports the macro. The goal here is that consumers only deal with the `wiggle` crate itself. No more crates depend on `wiggle-runtime` and all dependencies are entirely on just the `wiggle` crate. * Remove the `crates/wiggle/crates` directory Move everything into `crates/wiggle` directly, like `wasi-common` * Add wiggle-macro to test-all script * Fixup a test