Replace guts of wasmTextToBinary with the wat subsystem
Categories
(Core :: JavaScript: WebAssembly, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox76 | --- | fixed |
People
(Reporter: lth, Assigned: rhunt)
References
Details
Attachments
(16 files)
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review |
According to Alex, the wat crate (https://crates.io/crates/wat) strives to have everything that wabt has and he takes a liberal view on accepting extensions (eg for our experimental GC stuff). With that in mind, it's plausible that we can just replace the guts of wasmTextToBinary with the wat crate and thus get rid of our non-standard C++-based parser without impacting our velocity. This would then in principle resolve a lot of open bugs (attaching a partial list of blocked bugs, but there are more, follow the bug trees) and reduce effort on future maintenance.
Assignee | ||
Comment 1•5 years ago
|
||
I've got a prototype of this hooked up here [1]. I've tested locally that it can compile (module)
, and give error messages for failures.
Beyond that, this try run will probably be very red due to syntax misalignment.
[1] https://treeherder.mozilla.org/#/jobs?repo=try&revision=f7517c9e0ff88bc90a95be0c008bfea70e74c33f
Assignee | ||
Comment 2•5 years ago
|
||
Fix for unused build errors. Now we can see the syntax errors.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=b88fb8575f0d97d05e74a97adacf7360e48ffdad
Reporter | ||
Comment 3•5 years ago
|
||
(In reply to Ryan Hunt [:rhunt] from comment #2)
Fix for unused build errors. Now we can see the syntax errors.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=b88fb8575f0d97d05e74a97adacf7360e48ffdad
I think "the first 1% of the syntax errors" is probably more like it, judging from the output... Great start though!
Assignee | ||
Comment 4•5 years ago
|
||
(In reply to Lars T Hansen [:lth] from comment #3)
(In reply to Ryan Hunt [:rhunt] from comment #2)
Fix for unused build errors. Now we can see the syntax errors.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=b88fb8575f0d97d05e74a97adacf7360e48ffdad
I think "the first 1% of the syntax errors" is probably more like it, judging from the output... Great start though!
I've now gotten all non-gc jit-tests passing. It was indeed just the first 1%.
I've tried to fix most issues with regex, and then did a manual pass on the rest.
These are significant areas of change:
- Different 'inf' vs 'infinity'
- Different float constant overflow behavior (wat fails, we overflow to infinity)
- 'Block, loop, if' type syntax
- call_indirect type syntax
- import defaulting to 'func' or not
- export defaulting to 'func' or not
- imports allowed after other definitions or not
- (result) allowed before (param) or not
- (local) allowed before (result)/(param) or not
Overall, wat seems to do an excellent job here. There were multiple tests where the behavior changed to be more spec-compliant in subtle ways. There were a couple issues, but Alex quickly resolved them [1] [2] [3].
[1] https://github.com/bytecodealliance/wat/issues/59
[2] https://github.com/bytecodealliance/wat/issues/60
[3] https://github.com/bytecodealliance/wat/issues/62
Assignee | ||
Comment 5•5 years ago
|
||
Finally have all tests passing, including the GC ones. There's another PR with some misc fixes on the 'wat' crate that will need to be merged first. Other than that, the only outstanding issue is the 'withOffsets' parameter to wasmTextToBinary
.
This flag changes wasmTextToBinary
to record an offsets array of the offset of the start of each function's code. It's only used in a couple places as far as I can tell, mostly debugging tests. Somehow, returning an empty offsets array still allows them to pass so I didn't notice until late. The wat crate will probably need to get support added somehow for this.
Try run here [1]. It may just burn and crash with a build error if I didn't import 'wat' correctly. Couldn't use the normal mach vendor as there are some fixes upstream that haven't been released.
[1] https://treeherder.mozilla.org/#/jobs?repo=try&revision=786874c04b959810e70f5e64ab5e9e8cc5550059
Assignee | ||
Comment 6•5 years ago
|
||
This commit removes the old WasmTextToBinary implementation and replaces
it with a stub that calls into the rust wat implementation.
The old wasmTextToBinary function took an optional boolean parameter to
indicate that additional metadata was desired. This extra metadata was
a list of offsets of instructions in the code section. I'm not sure if
this was intentional or not, but it looks like it only includes root
expressions of nested s-exprs.
These offsets were used in two tests, debug/wasm-breakpoints.js and a
wasm/regress test. Adding this functionality into 'wat' proved to be a large
change for a function that didn't seem to have much use cases. A new
wasmCodeOffsets function was added to replicate this feature. It's implemented
in rust using the 'wasmparser' crate that cranelift uses. When cranelift is
compiled, this shouldn't result in an increased binary size. If the compile
time or binary size proves to be an issue in non-cranelift builds, I think
we can make this a conditional feature for JS-shells only.
Assignee | ||
Comment 7•5 years ago
|
||
Depends on D67245
Assignee | ||
Comment 8•5 years ago
|
||
This commit uses a regex to automatically replace uses of
block valtype
with
block (result valtype)
Depends on D67246
Assignee | ||
Comment 9•5 years ago
|
||
This commit uses a regex to automatically replace uses of
if valtype
with
if (result valtype)
Depends on D67247
Assignee | ||
Comment 10•5 years ago
|
||
This commit uses a regex to automatically switch call_indirect type signature
immediates to use an explicit '(type $id)' wrapper.
This has a negative interaction with the gc/ tests which use an identifier
immediately after call_indirect to specify the table and not the signature. A
later commit fixes this.
Depends on D67248
Assignee | ||
Comment 11•5 years ago
|
||
This commit uses a regex to automatically change exports of indices
to specify that they are exporting functions.
Depends on D67249
Assignee | ||
Comment 12•5 years ago
|
||
This commit uses a regex to automatically switch the export syntax
for memory.
Depends on D67250
Assignee | ||
Comment 13•5 years ago
|
||
This commit uses a regex to automatically switch the export syntax for table.
Depends on D67251
Assignee | ||
Comment 14•5 years ago
|
||
This commit uses a regex to automatically switch
(loop valtype ...
with
(loop (result valtype ...
Depends on D67252
Assignee | ||
Comment 15•5 years ago
|
||
This commit uses a regex to automatically switch
(block $label valtype ...
with
(block $label (result valtype ...
This should have been combined with the earlier 'block' commit, but was not
realised until too late.
Depends on D67253
Assignee | ||
Comment 16•5 years ago
|
||
This commit includes all the manual changes needed to get 'wasm/' jit-tests
passing.
Depends on D67254
Assignee | ||
Comment 17•5 years ago
|
||
This commit includes all the manual changes needed to get 'wasm/bigint'
jit-tests passing.
Depends on D67255
Assignee | ||
Comment 18•5 years ago
|
||
This commit includes all the changes necessary to get 'wasm/gc' jit-tests
passing.
Depends on D67256
Assignee | ||
Comment 19•5 years ago
|
||
This commit includes all the changes needed to get 'wasm/regress/' passing
jit-tests.
Depends on D67257
Assignee | ||
Comment 20•5 years ago
|
||
Depends on D67259
Assignee | ||
Comment 21•5 years ago
|
||
Depends on D67260
Comment 22•5 years ago
|
||
Comment 23•5 years ago
|
||
Backed out 16 changesets (Bug 1612534) for spidermonkey build bustages in /builds/worker/workspace/build/src/js/src/wasm/WasmTesting.h CLOSED TREE
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=293758930&repo=autoland&lineNumber=88071
Comment 24•5 years ago
|
||
Assignee | ||
Comment 25•5 years ago
|
||
Missed a test and some non-unified build issues.
Comment 26•5 years ago
|
||
Comment 27•5 years ago
|
||
Backed out 16 changesets (bug 1612534) for SM and multiple mochitests failures.
Push that started the failures: https://treeherder.mozilla.org/#/jobs?repo=autoland&resultStatus=superseded%2Ctestfailed%2Cbusted%2Cexception%2Crunnable&revision=c5950b8fed9f48e59b32b1fd30abc265a70f1372&selectedJob=293939554
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=293939554&repo=autoland&lineNumber=26871
and for mochitests:
TH link: https://treeherder.mozilla.org/#/jobs?repo=autoland&resultStatus=superseded%2Ctestfailed%2Cbusted%2Cexception%2Crunnable&revision=c5950b8fed9f48e59b32b1fd30abc265a70f1372&selectedJob=293942623
log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=293942623&repo=autoland&lineNumber=2327
Backout: https://hg.mozilla.org/integration/autoland/rev/59829f8b9f009d957a861a896c8d70d467a65b9e
Assignee | ||
Comment 28•5 years ago
|
||
More tests to fix that I should've known of.
Comment 29•5 years ago
|
||
Comment 30•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/7636e6d6990c
https://hg.mozilla.org/mozilla-central/rev/b5923a09f47b
https://hg.mozilla.org/mozilla-central/rev/a6f189bdd87c
https://hg.mozilla.org/mozilla-central/rev/c84bc5841266
https://hg.mozilla.org/mozilla-central/rev/d0807ab80319
https://hg.mozilla.org/mozilla-central/rev/bfdc8a02829b
https://hg.mozilla.org/mozilla-central/rev/20a7f0d29c6f
https://hg.mozilla.org/mozilla-central/rev/583d043bfeac
https://hg.mozilla.org/mozilla-central/rev/2eec4b8552ad
https://hg.mozilla.org/mozilla-central/rev/9426dc357014
https://hg.mozilla.org/mozilla-central/rev/757afe060150
https://hg.mozilla.org/mozilla-central/rev/b6bcf6dfed53
https://hg.mozilla.org/mozilla-central/rev/dddb970d1a04
https://hg.mozilla.org/mozilla-central/rev/8eefe5980f50
https://hg.mozilla.org/mozilla-central/rev/e2151aa71196
https://hg.mozilla.org/mozilla-central/rev/16f2eded7e00
Description
•