diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-03-06 16:19:21 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-03-06 16:21:14 -0800 |
commit | 573aa7adf10858b0bf8f566f72142be2775076c4 (patch) | |
tree | 5ec17c323a890655e56f9f2a53281b0e4eca2110 /src/js/wasm.js-post.js | |
parent | 5acbb8d34f88eae9b5b50cf5d00f86dc56a7057c (diff) | |
download | binaryen-573aa7adf10858b0bf8f566f72142be2775076c4.tar.gz binaryen-573aa7adf10858b0bf8f566f72142be2775076c4.tar.bz2 binaryen-573aa7adf10858b0bf8f566f72142be2775076c4.zip |
assume wasm binaries were preloaded on the web, where we lack sync binary reads
Diffstat (limited to 'src/js/wasm.js-post.js')
-rw-r--r-- | src/js/wasm.js-post.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index de1ee2752..4071ace46 100644 --- a/src/js/wasm.js-post.js +++ b/src/js/wasm.js-post.js @@ -124,7 +124,14 @@ function integrateWasmJS(Module) { // doesn't need to care that it is wasm and not asm. Module['asm'] = function(global, env, providedBuffer) { // Load the wasm module - var binary = Module['readBinary'](Module['wasmCodeFile']); + var binary; + if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { + binary = Module['wasmBinary']; + 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']); + } // Create an instance of the module using native support in the JS engine. info['global'] = { 'NaN': NaN, |