diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-04-28 10:50:46 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-04-28 10:50:46 -0700 |
commit | 1620162471a60a905e1e8e6072e676d73b8ddfff (patch) | |
tree | a4818dd7549a4bc5421f075fb5dbef111132ab30 /src/js/wasm.js-post.js | |
parent | 91c8337db2421f027de77e9dfa6085b69a195f2c (diff) | |
download | binaryen-1620162471a60a905e1e8e6072e676d73b8ddfff.tar.gz binaryen-1620162471a60a905e1e8e6072e676d73b8ddfff.tar.bz2 binaryen-1620162471a60a905e1e8e6072e676d73b8ddfff.zip |
fall back from wasm compilation errors, and add logging
Diffstat (limited to 'src/js/wasm.js-post.js')
-rw-r--r-- | src/js/wasm.js-post.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index 2e73e6b31..a0c026c91 100644 --- a/src/js/wasm.js-post.js +++ b/src/js/wasm.js-post.js @@ -187,7 +187,12 @@ function integrateWasmJS(Module) { info['global.Math'] = global.Math; info['env'] = env; var instance; - instance = Wasm.instantiateModule(getBinary(), info); + try { + instance = Wasm.instantiateModule(getBinary(), info); + } catch (e) { + Module['printErr']('failed to compile wasm module: ' + e); + return false; + } exports = instance.exports; mergeMemory(exports.memory); @@ -283,7 +288,9 @@ function integrateWasmJS(Module) { for (var i = 0; i < methods.length; i++) { var curr = methods[i]; - //Module['printErr']('using wasm/js method: ' + curr); + + Module['printErr']('trying binaryen method: ' + curr); + if (curr === 'native-wasm') { if (exports = doNativeWasm(global, env, providedBuffer)) break; } else if (curr === 'asmjs') { @@ -295,7 +302,9 @@ function integrateWasmJS(Module) { } } - if (!exports) throw 'no wasm method succeeded'; + if (!exports) throw 'no binaryen method succeeded'; + + Module['printErr']('binaryen method succeeded.'); return exports; }; |