Change wasmtime wast
to be powered from JSON AST
#11113
Draft
+630
−466
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit is a refactoring of the
wasmtime-wast
crate to use thejson-from-wast
crate added in bytecodealliance/wasm-tools#2247 instead of thewast
crate directly. The primary motivation for this PR is to make spec tests more suitable for running inside of Miri. There are two primary factors in how Miri is slow with wast tests today:Compiling WebAssembly modules. These are all embedded throughout
*.wast
files and basically need to be precompiled to run in Miri.Parsing the
*.wast
script itself. The scripts are generally quite large in the upstream spec test suite and parsing the script requires parsing all modules as well, so this can take quite some time.The goal of this commit was to leverage
json-from-wast
to perform much of the heavy lifting on the host and then have a "cheap" parse step in Miri which deserializes the JSON and runs precompiled*.cwasm
files. The main change then required ofwasmtime-wast
was to use the JSON AST as its "IR" instead ofwast
directly. The actual transformation of thewasmtime-wast
crate isn't too bad, mostly just some refactorings here and there.A new
./ci/miri-wast.sh
script is added which first runs on native withwasmtime wast --precompile-save
and then runs in Miri withwasmtime wast --precompile-load
. In this manner I was able to get a number of spec test*.wast
files running in Miri.Unfortunately, though, Miri is still far too slow to run in CI. One major bottleneck is that the
*.json
files are pretty large and take a nontrivial amount of time to parse. Another issue is that these tests run a fair bit of code which with Miri's ~million-x slowdown. For the first problem I tried using other more-binary serialization formats but the JSON AST is unfortunately not compatible with many of them (e.g.postcard
, which we use for Wasmtime, is not compatible with the JSON AST's structure in Rust types). For the latter I'm not sure what to do...In the end I figured this might be a reasonable refactoring to go ahead and land anyway. It at least enables running
*.wast
tests in Miri while removing a large part of the runtime slowdown. We can in theory still allow-list some tests to run as they don't all take forever. Some future breakthrough is still going to be required though to run everything through Miri.