Skip to content

Instantly share code, notes, and snippets.

@kg
Created October 10, 2019 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kg/64b2402fbc132927b71886e8bdfbd36e to your computer and use it in GitHub Desktop.
Save kg/64b2402fbc132927b71886e8bdfbd36e to your computer and use it in GitHub Desktop.
const instance = new WebAssembly.Instance(wasmModule, {});
const { count } = instance.exports;
var limit = 50000;
var speed = 100;
var res = null;
for (i = 0; i < limit; i += speed) {
try {
res = count(i, 0);
} catch (exc) {
console.log("failed at limit ", i, " with ", exc);
break;
}
}
console.log("result ", res);
(module
(func $count (export "count") (param $depth i32) (param $counter i32) (result i32) (local $one i32)
i32.const 1
local.set $one
local.get $depth
i32.const 0
i32.eq
if (result i32)
local.get $counter
return
else
local.get $depth
local.get $one
i32.sub
local.get $counter
local.get $one
i32.add
call $count
end
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment