Skip to content

Instantly share code, notes, and snippets.

@bnjbvr
Created May 5, 2020 12:53
Show Gist options
  • Save bnjbvr/b17faedfd384b240fabc2277709c7eee to your computer and use it in GitHub Desktop.
Save bnjbvr/b17faedfd384b240fabc2277709c7eee to your computer and use it in GitHub Desktop.
Run a wasm binary in Spidermonkey's shell
if (scriptArgs.length < 1) {
console.log('path to a wasm binary is required');
quit(-1);
}
let binary = os.file.readFile(scriptArgs[0], 'binary');
// If the wasm instance expects imported functions from js, put them in here.
// let maybeImports = { std: { f: function() { }} };
let maybeImports;
let { exports } = new WebAssembly.Instance(
new WebAssembly.Module(binary), maybeImports
);
// If the wasm module exports a function f.
exports.f();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment