summaryrefslogtreecommitdiff
path: root/src/js/wasm.js-post.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/wasm.js-post.js')
-rw-r--r--src/js/wasm.js-post.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js
index 9851fc777..fefc2f12a 100644
--- a/src/js/wasm.js-post.js
+++ b/src/js/wasm.js-post.js
@@ -36,6 +36,8 @@ function integrateWasmJS(Module) {
// utilities
+ var wasmPageSize = 64*1024;
+
var asm2wasmImports = { // special asm2wasm imports
"f64-rem": function(x, y) {
return x % y;
@@ -94,8 +96,9 @@ function integrateWasmJS(Module) {
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); // tiny wasm method that just does grow_memory
+ 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
};
}