Created
April 20, 2020 17:03
-
-
Save bnjbvr/1c034ae62e37d9957e8a0c9d1f889994 to your computer and use it in GitHub Desktop.
Spidermonkey script to compile a single wasm module
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
// 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