summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-08-24 14:46:36 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-09-07 09:55:54 -0700
commitb8ff5de842769fe2c1cc7c6d626c29ac5d503572 (patch)
tree118054c35645098a255543830415ff8106bf9621 /src/js
parent5e8ae1770e66d3a7ff00b3991195fd15c27ac65b (diff)
downloadbinaryen-b8ff5de842769fe2c1cc7c6d626c29ac5d503572.tar.gz
binaryen-b8ff5de842769fe2c1cc7c6d626c29ac5d503572.tar.bz2
binaryen-b8ff5de842769fe2c1cc7c6d626c29ac5d503572.zip
add asm2wasm option to import a mem init file
apply memory segments only if there isn't a memory initializer (which we need for asmjs and asm2wasm modes) use wasm-opt to check recreated wasts for validity, as wasm-shell would try to execute them add testing for combined modes like asmjs,interpret-binary
Diffstat (limited to 'src/js')
-rw-r--r--src/js/wasm.js-post.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js
index 1c207b3f3..5a1de4c9e 100644
--- a/src/js/wasm.js-post.js
+++ b/src/js/wasm.js-post.js
@@ -29,6 +29,7 @@ function integrateWasmJS(Module) {
// inputs
var method = Module['wasmJSMethod'] || {{{ wasmJSMethod }}} || 'native-wasm,interpret-s-expr'; // by default, try native and then .wast
+ Module['wasmJSMethod'] = method;
var wasmTextFile = Module['wasmTextFile'] || {{{ wasmTextFile }}};
var wasmBinaryFile = Module['wasmBinaryFile'] || {{{ wasmBinaryFile }}};
@@ -100,10 +101,12 @@ function integrateWasmJS(Module) {
}
var oldView = new Int8Array(oldBuffer);
var newView = new Int8Array(newBuffer);
- if ({{{ WASM_BACKEND }}}) {
- // memory segments arrived in the wast, do not trample them
+
+ // If we have a mem init file, do not trample it
+ if (!memoryInitializer) {
oldView.set(newView.subarray(STATIC_BASE, STATIC_BASE + STATIC_BUMP), STATIC_BASE);
}
+
newView.set(oldView);
updateGlobalBuffer(newBuffer);
updateGlobalBufferViews();
@@ -215,6 +218,10 @@ function integrateWasmJS(Module) {
info.global = global;
info.env = env;
+ if (!('memInitBase' in env)) {
+ env['memInitBase'] = STATIC_BASE; // tell the memory segments where to place themselves
+ }
+
wasmJS['providedTotalMemory'] = Module['buffer'].byteLength;
// Prepare to generate wasm, using either asm2wasm or s-exprs