From cc4646b2e76256ece1068c4b79b06a414ad2d96e Mon Sep 17 00:00:00 2001 From: Alexey Date: Fri, 26 Jul 2019 18:31:27 +0300 Subject: [PATCH] configurable wasm memory allocation --- src/groth16.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/groth16.js b/src/groth16.js index ac7c304..748ddf3 100644 --- a/src/groth16.js +++ b/src/groth16.js @@ -169,8 +169,7 @@ function thread(self) { }; } -async function build() { - +async function build({wasmInitialMemory = 5000}) { const groth16 = new Groth16(); groth16.q = bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208583"); @@ -179,7 +178,7 @@ async function build() { groth16.n32 = groth16.n64*2; groth16.n8 = groth16.n64*8; - groth16.memory = new WebAssembly.Memory({initial:5000}); + groth16.memory = new WebAssembly.Memory({initial:wasmInitialMemory}); groth16.i32 = new Uint32Array(groth16.memory.buffer); const wasmModule = await WebAssembly.compile(groth16_wasm.code); @@ -247,7 +246,7 @@ async function build() { const copyCode = groth16_wasm.code.buffer.slice(0); initPromises.push(groth16.postAction(i, { command: "INIT", - init: 5000, + init: wasmInitialMemory, code: copyCode }, [copyCode]));