From: Brendan Hansen Date: Sun, 17 Oct 2021 23:42:07 +0000 (-0500) Subject: made onyx-js work for non-multithreaded programs again X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=abe5811c5a2443db6d7bd279fb0060d5c9c3ff42;p=onyx.git made onyx-js work for non-multithreaded programs again --- diff --git a/bin/onyx-js b/bin/onyx-js index 36668b58..cf631947 100755 --- a/bin/onyx-js +++ b/bin/onyx-js @@ -46,13 +46,23 @@ const ENV = { if (isMainThread) { wasm_bytes = fs.readFileSync(process.argv[2]); + let multi_threaded = false; + if (process.argv.length >= 3 && process.argv[3] == "multi") { + multi_threaded = true; + } + // main thread - wasm_memory = new WebAssembly.Memory({ initial: 1024, maximum: 65536, shared: true }); - ENV.onyx.memory = wasm_memory; + if (multi_threaded) { + wasm_memory = new WebAssembly.Memory({ initial: 1024, maximum: 65536, shared: true }); + ENV.onyx.memory = wasm_memory; + } WebAssembly.instantiate(new Uint8Array(wasm_bytes), ENV) .then(res => { wasm_instance = res.instance; + if (!multi_threaded) { + wasm_memory = wasm_instance.exports.memory; + } const lib = res.instance.exports; lib._start();