-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests and support for wasm stack frames
- Loading branch information
Showing
6 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
To test support for WASM stack traces, we have a tiny WASM module that we call | ||
into. | ||
|
||
It imports a JS function and exports a WASM function | ||
that, when called, will call the JS function. | ||
|
||
When we call the wasm function, it calls back into JS. We can throw an error | ||
and know that one of the stack frames will be wasm. | ||
|
||
The module is described in both text and binary formats. Compilation from text | ||
to binary format was done using an online tool. I didn't bother to set up a | ||
build script, opting instead ot store the binary in version control. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
exports.call_js_function = async function(fn) { | ||
const mod = await WebAssembly.instantiate( | ||
fs.readFileSync(path.resolve(__dirname, 'wasm.wasm')), | ||
{ | ||
jsapi: { | ||
fn | ||
} | ||
} | ||
); | ||
mod.instance.exports.call_js_function(); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(module | ||
(import "jsapi" "fn" (func $jsapi_fn)) | ||
(func (export "call_js_function") | ||
call $jspapi_fn | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters