This file contains hidden or 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
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; |
This file contains hidden or 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 { |
This file contains hidden or 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
1. When running configure, pass the `--enable-perf` configuration option. Re-build the shell. | |
2. Run the shell with | |
``` | |
IONPERF=func perf record $jsshell --no-wasm-multi-value --shared-memory=off --wasm-compiler=cranelift /path/to/script.js | |
``` | |
An ExecutableAllocator is leaked on shutdown, which causes an assertion to | |
trigger: `Assertion failure: m_refCount == 1, at /home/ben/code/mozilla-inbound/js/src/jit/ExecutableAllocator.cpp:51` |
This file contains hidden or 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
#[derive(Debug)] | |
pub enum Command { | |
Publish(String), | |
Retrieve | |
} | |
#[derive(Debug)] | |
pub enum Error { | |
VerbMissing, | |
UnknownVerb, |
This file contains hidden or 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
const wasmEvalText = (txt, maybeImports) => new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(txt)), maybeImports); | |
let module = new WebAssembly.Module(wasmTextToBinary(` | |
(module | |
(import "global" "func" (result i32)) | |
(table (import "env" "table") 3 anyfunc) | |
(func (export "func_0") (result i32) | |
call 0 ;; calls the import, which is func #0 | |
) | |
(memory (export "mem") 10) |
This file contains hidden or 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
### Keybase proof | |
I hereby claim: | |
* I am bnjbvr on github. | |
* I am bnjbvr (https://keybase.io/bnjbvr) on keybase. | |
* I have a public key whose fingerprint is FB2E 08CF ADFF 7CE0 6067 A3A2 4864 9898 2667 C10E | |
To claim this, I am signing this object: |
This file contains hidden or 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
function promisify(func) { | |
return function(...args) { | |
return new Promise(function(resolve, reject) { | |
func(...args, function(err, ...rest) { | |
if (err) | |
return reject(err); | |
resolve(...rest); | |
}); | |
}); | |
} |
This file contains hidden or 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
static bool add (JSContext *cx, unsigned argc, jsval *vp){ | |
JS::CallArgs args = CallArgsFromVp(argc, vp); | |
std::cout<<(args[0].toInt32()+args[1].toInt32()); | |
RootedFunction func(cx, JS_ValueToFunction(cx, args[2])); | |
// JSFunction* function; | |
JS::RootedValue rval(cx); | |
JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx)); | |
JS_CallFunction(cx, global, &func, 0, nullptr, &rval); | |
return true; | |
} |
This file contains hidden or 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
if (window.SIMD) { | |
// yay, SIMD available, let's do a little stereo mixdown routine | |
for (var i = 0; i < bufsize; i+=4) { | |
var lhs = SIMD.float32x4(left[i+0], left[i+1], | |
left[i+2], left[i+3]), | |
rhs = SIMD.float32x4(right[i+0], right[i+1], | |
right[i+2], right[i+3]); | |
var mixdown = SIMD.float32x4.add(lhs, rhs); | |
SIMD.float32x4.store(center, i, mixdown); | |
} |
This file contains hidden or 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
var proxy = { | |
get: function(target, name, receiver) { | |
var original = target[name]; | |
return function() { | |
// for instance, print all arguments | |
for(var i = 0; i<arguments.length;++i) | |
print(arguments[i]); | |
return original.apply(receiver, arguments) | |
} |
NewerOlder