Commit 98d06b6
authored
Change
* Change `wasmtime wast` to be powered from JSON AST
This commit is a refactoring of the `wasmtime-wast` crate to use the
`json-from-wast` crate added in bytecodealliance/wasm-tools#2247 instead
of the `wast` 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 of `wasmtime-wast` was to use the JSON AST
as its "IR" instead of `wast` directly. The actual transformation of the
`wasmtime-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
with `wasmtime wast --precompile-save` and then runs in Miri with
`wasmtime 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.
* Document usage
* Adjust lint
* Fix CI issueswasmtime wast to be powered from JSON AST (#11113)1 parent 030a005 commit 98d06b6
File tree
16 files changed
+622
-438
lines changed- .github/workflows
- ci
- crates
- cranelift/src/func_environ
- gc
- fuzzing/src
- wast
- src
- src/commands
- supply-chain
- tests
16 files changed
+622
-438
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1026 | 1026 | | |
1027 | 1027 | | |
1028 | 1028 | | |
| 1029 | + | |
1029 | 1030 | | |
1030 | 1031 | | |
1031 | 1032 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
| 342 | + | |
342 | 343 | | |
343 | 344 | | |
344 | 345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| |||
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
76 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
77 | 83 | | |
78 | 84 | | |
79 | 85 | | |
| |||
461 | 467 | | |
462 | 468 | | |
463 | 469 | | |
464 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
465 | 474 | | |
466 | 475 | | |
467 | 476 | | |
| |||
473 | 482 | | |
474 | 483 | | |
475 | 484 | | |
476 | | - | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
477 | 489 | | |
478 | 490 | | |
479 | 491 | | |
| |||
1140 | 1152 | | |
1141 | 1153 | | |
1142 | 1154 | | |
1143 | | - | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
1144 | 1159 | | |
1145 | 1160 | | |
1146 | 1161 | | |
| |||
1185 | 1200 | | |
1186 | 1201 | | |
1187 | 1202 | | |
1188 | | - | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
1189 | 1207 | | |
1190 | 1208 | | |
1191 | 1209 | | |
| |||
1386 | 1404 | | |
1387 | 1405 | | |
1388 | 1406 | | |
1389 | | - | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
1390 | 1411 | | |
1391 | 1412 | | |
1392 | 1413 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
764 | 764 | | |
765 | 765 | | |
766 | 766 | | |
767 | | - | |
| 767 | + | |
768 | 768 | | |
769 | 769 | | |
770 | 770 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| |||
0 commit comments