Make sure devtools works with multi-value WebAssembly
Categories
(Core :: JavaScript: WebAssembly, task, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox78 | --- | fixed |
People
(Reporter: wingo, Assigned: wingo)
References
Details
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
In https://bugzilla.mozilla.org/show_bug.cgi?id=1628321 we are looking to ship multi-value WebAssembly and need to make sure that devtools is usable for multi-value WebAssembly modules. :yury on cc at suggestion of :lth.
Assignee | ||
Comment 1•5 years ago
|
||
Current status is unknown to me.
Assignee | ||
Comment 2•5 years ago
|
||
Did a little testing with bbouvier.
If you load this one: https://wingolog.org/pub/return-three.wasm, instantiate with no imports, and call the "run" export, then you should get the array [52, 10, 0]
.
If you load https://wingolog.org/pub/sub-three.wasm, which requires imports {env: {f: () => [52, 10, 0]}}
, then calling run() should return 42.
If you load https://wingolog.org/pub/sum.wasm, no imports, and call run(), it should return 55. (It has a multi-value loop inside it.)
bbouvier says they all work, that stepping appears to work, though you can't see the contents of the virtual stack.
Updated•5 years ago
|
Updated•5 years ago
|
Assignee | ||
Comment 3•4 years ago
|
||
I honestly think this one is done. The debugging experience is not great, if I understand it right, but it's no worse than the rest of wasm.
To test, visit https://wingolog.org/pub/
, then open a console.
async function loadWasm(url, imports) {
let {module, instance} = await WebAssembly.instantiateStreaming(fetch(url), imports);
return instance.exports.run;
}
// Return three vals to JS
var returnThree = await loadWasm("https://wingolog.org/pub/return-three.wasm");
returnThree();
// => Array(3) [ 0.5, 52.5, 10.5 ]
// Require 3 vals from JS
var subThree = await loadWasm("https://wingolog.org/pub/sub-three.wasm",
{env: {f: () => [52, 10, 0]}});
subThree();
// => 42
// A multi-value loop
var sum = await loadWasm("https://wingolog.org/pub/sum.wasm");
sum();
// 55
I don't know how to single-step in wasm, or to view the wasm stack. Changing subThree's import to return the wrong number of values does allow the debugger to break on the exception, but I can't do much interesting. What am I missing? :)
Assignee | ||
Comment 4•4 years ago
|
||
I did succeed in the end via the "debug a tab" option. One error, the disassembler raised an exception on disassembling sum.wasm
:
console.error: (new Error("Unexpected type 1", "resource://devtools/client/shared/vendor/WasmDis.js", 40))
console.warn: "Action loadSourceText had an exception:" (new Error("Unexpected type 1", "resource://devtools/client/shared/vendor/WasmDis.js", 40))
Assignee | ||
Comment 5•4 years ago
|
||
Filed https://github.com/wasdk/wasmparser/issues/40 for the WasmDis.js bug.
Assignee | ||
Comment 6•4 years ago
|
||
Assignee | ||
Comment 7•4 years ago
|
||
I checked and with the patch above, disassembly and single-stepping do now work with multi-value. Thanks, Yury!
Comment 8•4 years ago
|
||
\o/
Comment 10•4 years ago
|
||
bugherder |
Description
•