From 573aa7adf10858b0bf8f566f72142be2775076c4 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sun, 6 Mar 2016 16:19:21 -0800 Subject: assume wasm binaries were preloaded on the web, where we lack sync binary reads --- src/js/wasm.js-post.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/js/wasm.js-post.js') 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, -- cgit v1.2.3