diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-03-22 15:20:00 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-03-22 15:20:00 -0700 |
commit | 468e0dde46724e2a40fa311a878d0d50cac8f831 (patch) | |
tree | 2c9b0a6aa78dd1fd2da9dc71a5bbea41e4384aac /src | |
parent | 94bf9d12986fb069323738247bea5a480cfd8ef6 (diff) | |
parent | 3cde7acb07202af8f04f73eaaa9c7579e19a32cf (diff) | |
download | binaryen-468e0dde46724e2a40fa311a878d0d50cac8f831.tar.gz binaryen-468e0dde46724e2a40fa311a878d0d50cac8f831.tar.bz2 binaryen-468e0dde46724e2a40fa311a878d0d50cac8f831.zip |
Merge pull request #273 from WebAssembly/memory-growth
Fix and test memory growth
Diffstat (limited to 'src')
-rw-r--r-- | src/js/wasm.js-post.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index 0549dbd51..91ca0c4e8 100644 --- a/src/js/wasm.js-post.js +++ b/src/js/wasm.js-post.js @@ -55,6 +55,8 @@ function integrateWasmJS(Module) { parent: Module // Module inside wasm-js.cpp refers to wasm-js.cpp; this allows access to the outside program. }; + var exports = null; + function lookupImport(mod, base) { var lookup = info; if (mod.indexOf('.') < 0) { @@ -93,7 +95,7 @@ function integrateWasmJS(Module) { updateGlobalBufferViews(); Module['reallocBuffer'] = function(size) { var old = Module['buffer']; - wasmJS['asmExports']['__growWasmMemory'](size); // tiny wasm method that just does grow_memory + exports['__growWasmMemory'](size); // tiny wasm method that just does grow_memory return Module['buffer'] !== old ? Module['buffer'] : null; // if it was reallocated, it changed }; } @@ -183,11 +185,12 @@ function integrateWasmJS(Module) { info['env'] = env; var instance; instance = Wasm.instantiateModule(getBinary(), info); - mergeMemory(instance.exports.memory); + exports = instance.exports; + mergeMemory(exports.memory); applyMappedGlobals(wasmBinaryFile); - return instance.exports; + return exports; }; return true; @@ -221,12 +224,6 @@ function integrateWasmJS(Module) { info.global = global; info.env = env; - Module['reallocBuffer'] = function(size) { - var old = Module['buffer']; - wasmJS['asmExports']['__growWasmMemory'](size); // tiny wasm method that just does grow_memory - return Module['buffer'] !== old ? Module['buffer'] : null; // if it was reallocated, it changed - }; - wasmJS['providedTotalMemory'] = Module['buffer'].byteLength; // Prepare to generate wasm, using either asm2wasm or s-exprs @@ -267,7 +264,9 @@ function integrateWasmJS(Module) { applyMappedGlobals(wasmBinaryFile); } - return wasmJS['asmExports']; + exports = wasmJS['asmExports']; + + return exports; }; return true; |