alexcrichton opened PR #11113 from alexcrichton:wast-json to bytecodealliance:main:
This commit is a refactoring of the
wasmtime-wastcrate to use thejson-from-wastcrate added in bytecodealliance/wasm-tools#2247 instead of thewastcrate 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
*.wastfiles and basically need to be precompiled to run in Miri.Parsing the
*.wastscript 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-wastto 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*.cwasmfiles. The main change then required ofwasmtime-wastwas to use the JSON AST as its "IR" instead ofwastdirectly. The actual transformation of thewasmtime-wastcrate isn't too bad, mostly just some refactorings here and there.A new
./ci/miri-wast.shscript is added which first runs on native withwasmtime wast --precompile-saveand then runs in Miri withwasmtime wast --precompile-load. In this manner I was able to get a number of spec test*.wastfiles running in Miri.Unfortunately, though, Miri is still far too slow to run in CI. One major bottleneck is that the
*.jsonfiles 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
*.wasttests 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.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton commented on PR #11113:
My rough hope here is that we can at least use this to run scripts during development, but I'm also curious what others' thoughts on this are.
github-actions[bot] commented on PR #11113:
Subscribe to Label Action
cc @fitzgen
<details>
This issue or pull request has been labeled: "fuzzing"Thus the following users have been cc'd because of the following labels:
- fitzgen: fuzzing
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
fitzgen submitted PR review:
In general, I like the approach.
We can potentially try
bincodeorpeekpokeor something for the serialization.
fitzgen created PR review comment:
Can you put a comment at the top with an example usage, showing the CLI args expected and all that?
alexcrichton updated PR #11113.
alexcrichton updated PR #11113.
alexcrichton updated PR #11113.
alexcrichton has marked PR #11113 as ready for review.
alexcrichton requested wasmtime-fuzz-reviewers for a review on PR #11113.
alexcrichton requested fitzgen for a review on PR #11113.
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #11113.
alexcrichton requested wasmtime-core-reviewers for a review on PR #11113.
alexcrichton requested wasmtime-default-reviewers for a review on PR #11113.
alexcrichton commented on PR #11113:
Ok with the publication of wasm-tools this is now ready to go. I tried
bincodeandpostcardbut unfortunately neither works with the#[serde]attributes being used injson-from-wastwhich are done to match thewast2jsonoutput (mostly). This still ends up accelerating wast tests by a fair bit by skipping the whole compilation stage though, but there's still work to be done to improve the json parsing (or actually get it onto a binary format)
alexcrichton updated PR #11113.
fitzgen submitted PR review.
alexcrichton updated PR #11113.
alexcrichton has enabled auto merge for PR #11113.
alexcrichton has disabled auto merge for PR #11113.
alexcrichton merged PR #11113.
Last updated: Dec 06 2025 at 06:05 UTC