summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-03-08 19:41:47 -0800
committerAlon Zakai <alonzakai@gmail.com>2016-03-08 19:41:47 -0800
commitdc395f29a075a33370e68ec853f763fd3894630d (patch)
tree1ae377c9a89287d41f303cda60a7b4ec513d0315
parent78214a4de784379722187042c8d6fa7a803d883a (diff)
parentf19f5c387941ee6a91145f043a1bbc0baf199f6a (diff)
downloadbinaryen-dc395f29a075a33370e68ec853f763fd3894630d.tar.gz
binaryen-dc395f29a075a33370e68ec853f763fd3894630d.tar.bz2
binaryen-dc395f29a075a33370e68ec853f763fd3894630d.zip
Merge pull request #234 from WebAssembly/integrate-wasm-fixes
Move to a cleaner way of emcc.py integrating with wasm.js-post.js
-rw-r--r--src/js/wasm.js-post.js14
m---------test/emscripten0
2 files changed, 9 insertions, 5 deletions
diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js
index 4071ace46..ff52e9868 100644
--- a/src/js/wasm.js-post.js
+++ b/src/js/wasm.js-post.js
@@ -20,11 +20,15 @@ function integrateWasmJS(Module) {
// * 'asm2wasm': load asm.js code and translate to wasm
// * 'just-asm': no wasm, just load the asm.js code and use that (good for testing)
// The method can be set at compile time (BINARYEN_METHOD), or runtime by setting Module['wasmJSMethod'].
- var method = Module['wasmJSMethod'] || 'wasm-s-parser';
+ var method = Module['wasmJSMethod'] || {{{ wasmJSMethod }}} || 'wasm-s-parser';
assert(method == 'asm2wasm' || method == 'wasm-s-parser' || method == 'just-asm');
+ var wasmCodeFile = Module['wasmCodeFile'] || {{{ wasmCodeFile }}};
+
+ var asmjsCodeFile = Module['asmjsCodeFile'] || {{{ asmjsCodeFile }}};
+
if (method == 'just-asm') {
- eval(Module['read'](Module['asmjsCodeFile']));
+ eval(Module['read'](asmjsCodeFile));
return;
}
@@ -103,7 +107,7 @@ function integrateWasmJS(Module) {
// output, either generated ahead of time or on the client, we need to apply those mapped
// globals after loading the module.
function applyMappedGlobals() {
- var mappedGlobals = JSON.parse(Module['read'](Module['wasmCodeFile'] + '.mappedGlobals'));
+ var mappedGlobals = JSON.parse(Module['read'](wasmCodeFile + '.mappedGlobals'));
for (var name in mappedGlobals) {
var global = mappedGlobals[name];
if (!global.import) continue; // non-imports are initialized to zero in the typed array anyhow, so nothing to do here
@@ -130,7 +134,7 @@ function integrateWasmJS(Module) {
assert(binary, "on the web, we need the wasm binary to be preloaded and set on Module['wasmBinary']. emcc.py will do that for you when generating HTML (but not JS)");
binary = new Uint8Array(binary);
} else {
- binary = Module['readBinary'](Module['wasmCodeFile']);
+ binary = Module['readBinary'](wasmCodeFile);
}
// Create an instance of the module using native support in the JS engine.
info['global'] = {
@@ -179,7 +183,7 @@ function integrateWasmJS(Module) {
wasmJS['providedTotalMemory'] = Module['buffer'].byteLength;
// Prepare to generate wasm, using either asm2wasm or wasm-s-parser
- var code = Module['read'](method == 'asm2wasm' ? Module['asmjsCodeFile'] : Module['wasmCodeFile']);
+ var code = Module['read'](method == 'asm2wasm' ? asmjsCodeFile : wasmCodeFile);
var temp = wasmJS['_malloc'](code.length + 1);
wasmJS['writeAsciiToMemory'](code, temp);
if (method == 'asm2wasm') {
diff --git a/test/emscripten b/test/emscripten
-Subproject f0df8a59b82d264f7e30ea878275a7f1853daec
+Subproject f68dcf31d78fc23d18b157a36eb13155ba7cfec