diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-08-28 08:31:32 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-09-07 09:55:55 -0700 |
commit | 304fef1d997f1c43249996737ef7ce6deb961481 (patch) | |
tree | ab18c66847af0e8b7b81c44cbb1ae35b5538ca18 /src | |
parent | 88e8b7138e4e37ee092d9e0657257f079f8c279e (diff) | |
download | binaryen-304fef1d997f1c43249996737ef7ce6deb961481.tar.gz binaryen-304fef1d997f1c43249996737ef7ce6deb961481.tar.bz2 binaryen-304fef1d997f1c43249996737ef7ce6deb961481.zip |
refactor reallocBuffer assignment location, it is not technically part of mergeMemory
Diffstat (limited to 'src')
-rw-r--r-- | src/js/wasm.js-post.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index 5a1de4c9e..05c648ed0 100644 --- a/src/js/wasm.js-post.js +++ b/src/js/wasm.js-post.js @@ -110,12 +110,6 @@ function integrateWasmJS(Module) { newView.set(oldView); updateGlobalBuffer(newBuffer); updateGlobalBufferViews(); - Module['reallocBuffer'] = function(size) { - size = Math.ceil(size / wasmPageSize) * wasmPageSize; // round up to wasm page size - var old = Module['buffer']; - exports['__growWasmMemory'](size / wasmPageSize); // tiny wasm method that just does grow_memory - return Module['buffer'] !== old ? Module['buffer'] : null; // if it was reallocated, it changed - }; } var WasmTypes = { @@ -264,6 +258,14 @@ function integrateWasmJS(Module) { // We may have a preloaded value in Module.asm, save it Module['asmPreload'] = Module['asm']; + // Memory growth integration code + Module['reallocBuffer'] = function(size) { + size = Math.ceil(size / wasmPageSize) * wasmPageSize; // round up to wasm page size + var old = Module['buffer']; + exports['__growWasmMemory'](size / wasmPageSize); // tiny wasm method that just does grow_memory + return Module['buffer'] !== old ? Module['buffer'] : null; // if it was reallocated, it changed + }; + // Provide an "asm.js function" for the application, called to "link" the asm.js module. We instantiate // the wasm module at that time, and it receives imports and provides exports and so forth, the app // doesn't need to care that it is wasm or olyfilled wasm or asm.js. |