From abe5811c5a2443db6d7bd279fb0060d5c9c3ff42 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sun, 17 Oct 2021 18:42:07 -0500 Subject: [PATCH] made onyx-js work for non-multithreaded programs again --- bin/onyx-js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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(); -- 2.25.1