summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js')
-rw-r--r--src/js/wasm.js-post.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js
index f093ff64d..a4bc35f97 100644
--- a/src/js/wasm.js-post.js
+++ b/src/js/wasm.js-post.js
@@ -269,8 +269,18 @@ function integrateWasmJS(Module) {
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 result = exports['__growWasmMemory'](size / wasmPageSize); // tiny wasm method that just does grow_memory
+ if (Module["usingWasm"]) {
+ if (result !== (-1 | 0)) {
+ // success in native wasm memory growth, get the buffer from the memory
+ return Module['buffer'] = Module['wasmMemory'].buffer;
+ } else {
+ return null;
+ }
+ } else {
+ // in interpreter, we replace Module.buffer if we allocate
+ 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