summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-11-19 20:35:53 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-11-19 20:35:53 -0800
commitc8ae18ee624867d1d7598a9a936ebf7c381903ae (patch)
tree8b6c79937606ddf01bffe3422b67bc2bfe9df451 /src/js
parentf7070e21f92a2fedb61bdc9fa1f28a092852d7aa (diff)
downloadbinaryen-c8ae18ee624867d1d7598a9a936ebf7c381903ae.tar.gz
binaryen-c8ae18ee624867d1d7598a9a936ebf7c381903ae.tar.bz2
binaryen-c8ae18ee624867d1d7598a9a936ebf7c381903ae.zip
work towards memory growth in asm2wasm code
Diffstat (limited to 'src/js')
-rw-r--r--src/js/post.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/js/post.js b/src/js/post.js
index c2552c5a8..3c7bd05a4 100644
--- a/src/js/post.js
+++ b/src/js/post.js
@@ -20,6 +20,12 @@
var theBuffer = Module['buffer'] = new ArrayBuffer(Module['providedTotalMemory'] || 64*1024*1024);
wasmJS['providedTotalMemory'] = theBuffer.byteLength;
+ Module['reallocBuffer'] = function(size) {
+ var old = Module['buffer']
+ Module['__growWasmMemory'](size); // tiny wasm method that just does grow_memory
+ return Module['buffer'] !== old ? Module['buffer'] : null; // if it was reallocated, it changed
+ };
+
var temp = wasmJS._malloc(code.length + 1);
wasmJS.writeAsciiToMemory(code, temp);
wasmJS._load_asm(temp);
@@ -61,7 +67,7 @@
// The asm.js function, called to "link" the asm.js module.
Module['asm'] = function(global, env, buffer) {
- assert(buffer === theBuffer); // we should not even need to pass it as a 3rd arg for wasm, but that's the asm.js way.
+ assert(buffer === Module['buffer']); // we should not even need to pass it as a 3rd arg for wasm, but that's the asm.js way.
// write the provided data to a location the wasm instance can get at it.
info.global = global;
info.env = env;