summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-04-01 16:43:21 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-04-01 16:43:21 -0700
commit8140bfd01a50374b3511434d89514af7e9e5c3cf (patch)
tree8a42089385fb02030881cb6c72f3ae000c3730f2 /src/js
parentdd3086a32e790c423c48bf2cfe6a7d8cc8754a15 (diff)
parent493e2d928189e97b0309cf25844a98061fbbf906 (diff)
downloadbinaryen-8140bfd01a50374b3511434d89514af7e9e5c3cf.tar.gz
binaryen-8140bfd01a50374b3511434d89514af7e9e5c3cf.tar.bz2
binaryen-8140bfd01a50374b3511434d89514af7e9e5c3cf.zip
Merge pull request #307 from WebAssembly/updates
Fix memory growth
Diffstat (limited to 'src/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
};
}