Skip to content

Instantly share code, notes, and snippets.

@bnjbvr
Created April 20, 2020 17:03
Show Gist options
  • Save bnjbvr/1c034ae62e37d9957e8a0c9d1f889994 to your computer and use it in GitHub Desktop.
Save bnjbvr/1c034ae62e37d9957e8a0c9d1f889994 to your computer and use it in GitHub Desktop.
Spidermonkey script to compile a single wasm module
// Usage: $jsshell ./compile.js /path/to/wasm-binary.wasm
if (scriptArgs.length !== 1) {
console.log('one argument required: path to wasm binary');
}
let pathToBinary = scriptArgs[0];
let binary;
try {
binary = os.file.readFile(pathToBinary, 'binary');
} catch(err) {
console.log("couldn't read file:", err);
quit(2);
}
try {
let before = dateNow();
new WebAssembly.Module(binary);
let time = dateNow() - before;
console.log('compilation took', time, 'milliseconds');
} catch (err) {
console.log("couldn't compile wasm module:", err);
quit(3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment