Fix off-by-one bounds check for atomic operations (#11977)They're allowed to happen if the final address is the memory's length,as opposed to being one-less-than-the-memory's length.Closes #11975
Refactor how wasm features are calculated for `*.wast` tests (#9560)* Refactor how wasm features are calculated for `*.wast` testsThis commit refactors the `tests/wast.rs` test suite which runs a
Refactor how wasm features are calculated for `*.wast` tests (#9560)* Refactor how wasm features are calculated for `*.wast` testsThis commit refactors the `tests/wast.rs` test suite which runs all ofthe upstream spec tests as `*.wast` files as well as our own`misc_testsuite` which has its own suite of `*.wast` files. Previouslythe set of wasm features active for each test was a sort of randommishmash and convoluted set of conditionals which was updated and editedover time as upstream proposal test suites evolved. This was thenmirrored into our own conventions for `misc_testsuite` as well. Overallthough this has a number of downsides I'm trying to fix here:* The calculation of what features are enabled is quite complicated and effectively a random mishmash of `||` conditionals with hierarchies that don't make any sense beyond "this is just required to get things to pass".* There is no means of per-test configuration. For example `canonicalize-nans.wast` had hardcoded logic in `tests/wast.rs` that it needed a different setting turned on in `Config`.* There was no easy means to write tests for Wasmtime which take a union of a number of proposals together without having lots of sub-folders that may not make sense.* Tests that require a particular proposal had to have duplicate logic for Winch as it doesn't support the full suite of features of all proposals that Cranelift does.The new system implemented in this commit takes a leaf out of the`disas` tests. There is a new `TestConfig` structure in the`tests/wast.rs` harness which is decoded from each test (leading `;;!`comments) which enables specifying, in each test, what's required. Thisencompasses many wasm proposals but additionally captures other behaviorlike nan-canonicalization. This means that all test files in`misc_testsuite/**/*.wast` are now manually annotated with what wasmfeatures they require and what's needed to run. This makes per-testconfiguration much easier, per-config-setting much easier, and blanketignore-by-proposal for Winch much easier as well.For spec tests we can't modify the contents of the upstream `*.wast`files. To handle this they're handled specially where `TestConfig` ismanually created and manipulated for each spec proposal and the maintest suite itself. This enables per-proposal configuration that doesn'tleak into any others and makes it more obvious what proposals are doingwhat.* Hack around Winch support for aarch64
show more ...
Implement support for `thread` in `*.wast` tests (#7289)* Implement support for `thread` in `*.wast` testsThis commit implements support for `thread` and `wait` in `*.wast` filesand imports the
Implement support for `thread` in `*.wast` tests (#7289)* Implement support for `thread` in `*.wast` testsThis commit implements support for `thread` and `wait` in `*.wast` filesand imports the upstream spec test suite from the `threads` proposal.This additionally and hopefully makes it a bit easier to write threadedtests in the future if necessary too.* Fix compile of fuzzing
feat: implement memory.atomic.notify,wait32,wait64 (#5255)* feat: implement memory.atomic.notify,wait32,wait64 Added the parking_spot crate, which provides the needed registry for the operation
feat: implement memory.atomic.notify,wait32,wait64 (#5255)* feat: implement memory.atomic.notify,wait32,wait64 Added the parking_spot crate, which provides the needed registry for the operations. Signed-off-by: Harald Hoyer <[email protected]> * fix: change trap message for HeapMisaligned The threads spec test wants "unaligned atomic" instead of "misaligned memory access". Signed-off-by: Harald Hoyer <[email protected]> * tests: add test for atomic wait on non-shared memory Signed-off-by: Harald Hoyer <[email protected]> * tests: add tests/spec_testsuite/proposals/threads without pooling and reference types. Also "shared_memory" is added to the "spectest" interface. Signed-off-by: Harald Hoyer <[email protected]> * tests: add atomics_notify.wast checking that notify with 0 waiters returns 0 on shared and non-shared memory. Signed-off-by: Harald Hoyer <[email protected]> * tests: add tests for atomic wait on shared memory - return 2 - timeout for 0 - return 2 - timeout for 1000ns - return 1 - invalid value Signed-off-by: Harald Hoyer <[email protected]> * fixup! feat: implement memory.atomic.notify,wait32,wait64 Signed-off-by: Harald Hoyer <[email protected]> * fixup! feat: implement memory.atomic.notify,wait32,wait64 Signed-off-by: Harald Hoyer <[email protected]> Signed-off-by: Harald Hoyer <[email protected]>
Upgrade wasm-tools crates, namely the component model (#4715)* Upgrade wasm-tools crates, namely the component model This commit pulls in the latest versions of all of the `wasm-tools` family
Upgrade wasm-tools crates, namely the component model (#4715)* Upgrade wasm-tools crates, namely the component model This commit pulls in the latest versions of all of the `wasm-tools` family of crates. There were two major changes that happened in `wasm-tools` in the meantime: * bytecodealliance/wasm-tools#697 - this commit introduced a new API for more efficiently reading binary operators from a wasm binary. The old `Operator`-based reading was left in place, however, and continues to be what Wasmtime uses. I hope to update Wasmtime in a future PR to use this new API, but for now the biggest change is... * bytecodealliance/wasm-tools#703 - this commit was a major update to the component model AST. This commit almost entirely deals with the fallout of this change. The changes made to the component model were: 1. The `unit` type no longer exists. This was generally a simple change where the `Unit` case in a few different locations were all removed. 2. The `expected` type was renamed to `result`. This similarly was relatively lightweight and mostly just a renaming on the surface. I took this opportunity to rename `val::Result` to `val::ResultVal` and `types::Result` to `types::ResultType` to avoid clashing with the standard library types. The `Option`-based types were handled with this as well. 3. The payload type of `variant` and `result` types are now optional. This affected many locations that calculate flat type representations, ABI information, etc. The `#[derive(ComponentType)]` macro now specifically handles Rust-defined `enum` types which have no payload to the equivalent in the component model. 4. Functions can now return multiple parameters. This changed the signature of invoking component functions because the return value is now bound by `ComponentNamedList` (renamed from `ComponentParams`). This had a large effect in the tests, fuzz test case generation, etc. 5. Function types with 2-or-more parameters/results must uniquely name all parameters/results. This mostly affected the text format used throughout the tests. I haven't added specifically new tests for multi-return but I changed a number of tests to use it. Additionally I've updated the fuzzers to all exercise multi-return as well so I think we should get some good coverage with that. * Update version numbers * Use crates.io
Consolidate address calculations for atomics (#3143)* Consolidate address calculations for atomics This commit consolidates all calcuations of guest addresses into one `prepare_addr` function.
Consolidate address calculations for atomics (#3143)* Consolidate address calculations for atomics This commit consolidates all calcuations of guest addresses into one `prepare_addr` function. This notably remove the atomics-specifics paths as well as the `prepare_load` function (now renamed to `prepare_addr` and folded into `get_heap_addr`). The goal of this commit is to simplify how addresses are managed in the code generator for atomics to use all the shared infrastrucutre of other loads/stores as well. This additionally fixes #3132 via the use of `heap_addr` in clif for all operations. I also added a number of tests for loads/stores with varying alignments. Originally I was going to allow loads/stores to not be aligned since that's what the current formal specification says, but the overview of the threads proposal disagrees with the formal specification, so I figured I'd leave it as-is but adding tests probably doesn't hurt. Closes #3132 * Fix old backend * Guarantee misalignment checks happen before out-of-bounds
[Cranelift][Atomics] Add address folding for atomic notify/wait. (#2556)* fold address in wasm wait and notify ops * add atomics addr folding tests