diff --git a/ChangeLog.md b/ChangeLog.md index 39938f12e5a7a..c38e5207ea6f1 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -23,6 +23,9 @@ See docs/process.md for more on how version tagging works. - The file system was updated to independently track atime, mtime and ctime instead of using the same time for all three. (#22998) - The minimum supported chrome version was bumped from 32 to 33. (#23077) +- Emscripten-generated code will now use async/await internally when loading + the Wasm module. This will be lowered away by babel when targeting older + browsers. (#23068) 3.1.73 - 11/28/24 ----------------- diff --git a/src/preamble.js b/src/preamble.js index af274a7ac888f..d097c857f89be 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -647,7 +647,7 @@ function getBinarySync(file) { #endif } -function getBinaryPromise(binaryFile) { +async function getWasmBinary(binaryFile) { #if !SINGLE_FILE // If we don't have the binary yet, load it asynchronously using readAsync. if (!wasmBinary @@ -656,16 +656,17 @@ function getBinaryPromise(binaryFile) { #endif ) { // Fetch the binary using readAsync - return readAsync(binaryFile).then( - (response) => new Uint8Array(/** @type{!ArrayBuffer} */(response)), - // Fall back to getBinarySync if readAsync fails - () => getBinarySync(binaryFile) - ); + try { + var response = await readAsync(binaryFile); + return new Uint8Array(response); + } catch { + // Fall back to getBinarySync below; + } } #endif // Otherwise, getBinarySync should be able to get it synchronously - return Promise.resolve(getBinarySync(binaryFile)); + return getBinarySync(binaryFile); } #if LOAD_SOURCE_MAP @@ -773,56 +774,47 @@ function resetPrototype(constructor, attrs) { #endif #if WASM_ASYNC_COMPILATION -function instantiateArrayBuffer(binaryFile, imports) { +async function instantiateArrayBuffer(binaryFile, imports) { + try { + var binary = await getWasmBinary(binaryFile); + var instance = await WebAssembly.instantiate(binary, imports); #if USE_OFFSET_CONVERTER - var savedBinary; + // wasmOffsetConverter needs to be assigned before calling resolve. + // See comments below in instantiateAsync. + wasmOffsetConverter = new WasmOffsetConverter(binary, instance.module); #endif - return new Promise((resolve, reject) => { - getBinaryPromise(binaryFile).then((binary) => { -#if USE_OFFSET_CONVERTER - savedBinary = binary; -#endif - return WebAssembly.instantiate(binary, imports); -#if USE_OFFSET_CONVERTER - }).then((instance) => { - // wasmOffsetConverter needs to be assigned before calling resolve. - // See comments below in instantiateAsync. - wasmOffsetConverter = new WasmOffsetConverter(savedBinary, instance.module); - return instance; -#endif - }).then(resolve, (reason) => { - err(`failed to asynchronously prepare wasm: ${reason}`); - + return instance; + } catch (reason) { + err(`failed to asynchronously prepare wasm: ${reason}`); #if WASM == 2 #if ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL - if (typeof location != 'undefined') { -#endif - // WebAssembly compilation failed, try running the JS fallback instead. - var search = location.search; - if (search.indexOf('_rwasm=0') < 0) { - location.href += (search ? search + '&' : '?') + '_rwasm=0'; - // Return here to avoid calling abort() below. The application - // still has a chance to start successfully do we don't want to - // trigger onAbort or onExit handlers. - return; - } -#if ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL + if (typeof location != 'undefined') { +#endif + // WebAssembly compilation failed, try running the JS fallback instead. + var search = location.search; + if (search.indexOf('_rwasm=0') < 0) { + // Reload the page with the `_rwasm=0` argument + location.href += (search ? search + '&' : '?') + '_rwasm=0'; + // Return a promise that never resolves. We don't want to + // call abort below, or return an error to our caller. + return new Promise(() => {}); } +#if ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL + } #endif #endif // WASM == 2 #if ASSERTIONS - // Warn on some common problems. - if (isFileURI(wasmBinaryFile)) { - err(`warning: Loading from a file URI (${wasmBinaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`); - } + // Warn on some common problems. + if (isFileURI(wasmBinaryFile)) { + err(`warning: Loading from a file URI (${wasmBinaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`); + } #endif - abort(reason); - }); - }); + abort(reason); + } } -function instantiateAsync(binary, binaryFile, imports) { +async function instantiateAsync(binary, binaryFile, imports) { #if !SINGLE_FILE if (!binary && typeof WebAssembly.instantiateStreaming == 'function' && @@ -841,56 +833,41 @@ function instantiateAsync(binary, binaryFile, imports) { !ENVIRONMENT_IS_NODE && #endif typeof fetch == 'function') { - return new Promise((resolve) => { - fetch(binaryFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}).then((response) => { - // Suppress closure warning here since the upstream definition for - // instantiateStreaming only allows Promise rather than - // an actual Response. - // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed. - /** @suppress {checkTypes} */ - var result = WebAssembly.instantiateStreaming(response, imports); - + try { + var response = fetch(binaryFile, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}}); #if USE_OFFSET_CONVERTER - // We need the wasm binary for the offset converter. Clone the response - // in order to get its arrayBuffer (cloning should be more efficient - // than doing another entire request). - // (We must clone the response now in order to use it later, as if we - // try to clone it asynchronously lower down then we will get a - // "response was already consumed" error.) - var clonedResponsePromise = response.clone().arrayBuffer(); -#endif - - result.then( + // We need the wasm binary for the offset converter. Clone the response + // in order to get its arrayBuffer (cloning should be more efficient + // than doing another entire request). + // (We must clone the response now in order to use it later, as if we + // try to clone it asynchronously lower down then we will get a + // "response was already consumed" error.) + var clonedResponse = (await response).clone(); +#endif + var instantiationResult = await WebAssembly.instantiateStreaming(response, imports); #if USE_OFFSET_CONVERTER - (instantiationResult) => { - // When using the offset converter, we must interpose here. First, - // the instantiation result must arrive (if it fails, the error - // handling later down will handle it). Once it arrives, we can - // initialize the offset converter. And only then is it valid to - // call receiveInstantiationResult, as that function will use the - // offset converter (in the case of pthreads, it will create the - // pthreads and send them the offsets along with the wasm instance). - - clonedResponsePromise.then((arrayBufferResult) => { - wasmOffsetConverter = new WasmOffsetConverter(new Uint8Array(arrayBufferResult), instantiationResult.module); - resolve(instantiationResult); - }, - (reason) => err(`failed to initialize offset-converter: ${reason}`) - ); - }, -#else - resolve, -#endif - (reason) => { - // We expect the most common failure cause to be a bad MIME type for the binary, - // in which case falling back to ArrayBuffer instantiation should work. - err(`wasm streaming compile failed: ${reason}`); - err('falling back to ArrayBuffer instantiation'); - return resolve(instantiateArrayBuffer(binaryFile, imports)); - } - ); - }); - }); + // When using the offset converter, we must interpose here. First, + // the instantiation result must arrive (if it fails, the error + // handling later down will handle it). Once it arrives, we can + // initialize the offset converter. And only then is it valid to + // call receiveInstantiationResult, as that function will use the + // offset converter (in the case of pthreads, it will create the + // pthreads and send them the offsets along with the wasm instance). + var arrayBufferResult = await clonedResponse.arrayBuffer(); + try { + wasmOffsetConverter = new WasmOffsetConverter(new Uint8Array(arrayBufferResult), instantiationResult.module); + } catch (reason) { + err(`failed to initialize offset-converter: ${reason}`); + } +#endif + return instantiationResult; + } catch (reason) { + // We expect the most common failure cause to be a bad MIME type for the binary, + // in which case falling back to ArrayBuffer instantiation should work. + err(`wasm streaming compile failed: ${reason}`); + err('falling back to ArrayBuffer instantiation'); + // fall back of instantiateArrayBuffer below + }; } #endif return instantiateArrayBuffer(binaryFile, imports); @@ -936,7 +913,7 @@ function getWasmImports() { // Create the wasm instance. // Receives the wasm imports, returns the exports. -function createWasm() { +{{{ asyncIf(WASM_ASYNC_COMPILATION) }}} function createWasm() { // Load the wasm module and create an instance of using native support in the JS engine. // handle a generated wasm instance, receiving its exports and // performing other necessary setup @@ -1104,17 +1081,23 @@ function createWasm() { #if RUNTIME_DEBUG dbg('asynchronously preparing wasm'); #endif - instantiateAsync(wasmBinary, wasmBinaryFile, info).then(receiveInstantiationResult) #if MODULARIZE - // If instantiation fails, reject the module ready promise. - .catch(readyPromiseReject) + try { #endif - ; + var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info); + receiveInstantiationResult(result); #if LOAD_SOURCE_MAP - getSourceMapPromise().then(receiveSourceMapJSON); + receiveSourceMapJSON(await getSourceMapPromise()); #endif - return {}; // no exports yet; we'll fill them in later -#else + return result; +#if MODULARIZE + } catch (e) { + // If instantiation fails, reject the module ready promise. + readyPromiseReject(e); + return; + } +#endif +#else // WASM_ASYNC_COMPILATION var result = instantiateSync(wasmBinaryFile, info); #if PTHREADS || MAIN_MODULE return receiveInstance(result[0], result[1]); @@ -1124,7 +1107,7 @@ function createWasm() { // When the regression is fixed, we can remove this if/else. return receiveInstance(result[0]); #endif -#endif +#endif // WASM_ASYNC_COMPILATION } #if !WASM_BIGINT diff --git a/test/other/codesize/test_codesize_cxx_ctors1.gzsize b/test/other/codesize/test_codesize_cxx_ctors1.gzsize index 41c0b94155b12..25b558280e945 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors1.gzsize @@ -1 +1 @@ -8592 +8576 diff --git a/test/other/codesize/test_codesize_cxx_ctors1.jssize b/test/other/codesize/test_codesize_cxx_ctors1.jssize index f411f89f35087..f0d741b18ae22 100644 --- a/test/other/codesize/test_codesize_cxx_ctors1.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors1.jssize @@ -1 +1 @@ -21002 +20969 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.gzsize b/test/other/codesize/test_codesize_cxx_ctors2.gzsize index b6b3cc1b768f1..3ea5f236f6c35 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.gzsize +++ b/test/other/codesize/test_codesize_cxx_ctors2.gzsize @@ -1 +1 @@ -8578 +8560 diff --git a/test/other/codesize/test_codesize_cxx_ctors2.jssize b/test/other/codesize/test_codesize_cxx_ctors2.jssize index f0d741b18ae22..4ef99cdd0785e 100644 --- a/test/other/codesize/test_codesize_cxx_ctors2.jssize +++ b/test/other/codesize/test_codesize_cxx_ctors2.jssize @@ -1 +1 @@ -20969 +20937 diff --git a/test/other/codesize/test_codesize_cxx_except.gzsize b/test/other/codesize/test_codesize_cxx_except.gzsize index 699dbbf52f13f..0fa8352cf2331 100644 --- a/test/other/codesize/test_codesize_cxx_except.gzsize +++ b/test/other/codesize/test_codesize_cxx_except.gzsize @@ -1 +1 @@ -9626 +9614 diff --git a/test/other/codesize/test_codesize_cxx_except.jssize b/test/other/codesize/test_codesize_cxx_except.jssize index 6a720ff726ff1..4a76440f1a1cc 100644 --- a/test/other/codesize/test_codesize_cxx_except.jssize +++ b/test/other/codesize/test_codesize_cxx_except.jssize @@ -1 +1 @@ -24845 +24814 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize index d9d8063900671..e6ab5d0c9b589 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.gzsize @@ -1 +1 @@ -8562 +8543 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm.jssize b/test/other/codesize/test_codesize_cxx_except_wasm.jssize index b8733f59e9281..8b47153f81043 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm.jssize @@ -1 +1 @@ -20895 +20863 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize index d9d8063900671..e6ab5d0c9b589 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize @@ -1 +1 @@ -8562 +8543 diff --git a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize index b8733f59e9281..8b47153f81043 100644 --- a/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize +++ b/test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize @@ -1 +1 @@ -20895 +20863 diff --git a/test/other/codesize/test_codesize_cxx_lto.gzsize b/test/other/codesize/test_codesize_cxx_lto.gzsize index 67e22b94ef20a..732a842aa12a6 100644 --- a/test/other/codesize/test_codesize_cxx_lto.gzsize +++ b/test/other/codesize/test_codesize_cxx_lto.gzsize @@ -1 +1 @@ -8490 +8475 diff --git a/test/other/codesize/test_codesize_cxx_lto.jssize b/test/other/codesize/test_codesize_cxx_lto.jssize index 9ebbda6b548c9..c8b5e7421405b 100644 --- a/test/other/codesize/test_codesize_cxx_lto.jssize +++ b/test/other/codesize/test_codesize_cxx_lto.jssize @@ -1 +1 @@ -20580 +20548 diff --git a/test/other/codesize/test_codesize_cxx_mangle.gzsize b/test/other/codesize/test_codesize_cxx_mangle.gzsize index 4dda8754d31a0..58e0f00ae02c8 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.gzsize +++ b/test/other/codesize/test_codesize_cxx_mangle.gzsize @@ -1 +1 @@ -9629 +9613 diff --git a/test/other/codesize/test_codesize_cxx_mangle.jssize b/test/other/codesize/test_codesize_cxx_mangle.jssize index 6a720ff726ff1..4a76440f1a1cc 100644 --- a/test/other/codesize/test_codesize_cxx_mangle.jssize +++ b/test/other/codesize/test_codesize_cxx_mangle.jssize @@ -1 +1 @@ -24845 +24814 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.gzsize b/test/other/codesize/test_codesize_cxx_noexcept.gzsize index 41c0b94155b12..25b558280e945 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.gzsize +++ b/test/other/codesize/test_codesize_cxx_noexcept.gzsize @@ -1 +1 @@ -8592 +8576 diff --git a/test/other/codesize/test_codesize_cxx_noexcept.jssize b/test/other/codesize/test_codesize_cxx_noexcept.jssize index f411f89f35087..f0d741b18ae22 100644 --- a/test/other/codesize/test_codesize_cxx_noexcept.jssize +++ b/test/other/codesize/test_codesize_cxx_noexcept.jssize @@ -1 +1 @@ -21002 +20969 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize index d8d3e7a082033..24a12a49287ba 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.gzsize @@ -1 +1 @@ -3865 +3836 diff --git a/test/other/codesize/test_codesize_cxx_wasmfs.jssize b/test/other/codesize/test_codesize_cxx_wasmfs.jssize index d870f6684df37..c4ec7c412ff1e 100644 --- a/test/other/codesize/test_codesize_cxx_wasmfs.jssize +++ b/test/other/codesize/test_codesize_cxx_wasmfs.jssize @@ -1 +1 @@ -8639 +8606 diff --git a/test/other/codesize/test_codesize_files_js_fs.gzsize b/test/other/codesize/test_codesize_files_js_fs.gzsize index edc514e920e03..956717deae581 100644 --- a/test/other/codesize/test_codesize_files_js_fs.gzsize +++ b/test/other/codesize/test_codesize_files_js_fs.gzsize @@ -1 +1 @@ -7730 +7710 diff --git a/test/other/codesize/test_codesize_files_js_fs.jssize b/test/other/codesize/test_codesize_files_js_fs.jssize index b88e32899034b..2314d683d7cb3 100644 --- a/test/other/codesize/test_codesize_files_js_fs.jssize +++ b/test/other/codesize/test_codesize_files_js_fs.jssize @@ -1 +1 @@ -18909 +18876 diff --git a/test/other/codesize/test_codesize_files_wasmfs.gzsize b/test/other/codesize/test_codesize_files_wasmfs.gzsize index a4fe1614722ba..43a5478d767d8 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_files_wasmfs.gzsize @@ -1 +1 @@ -2941 +2915 diff --git a/test/other/codesize/test_codesize_files_wasmfs.jssize b/test/other/codesize/test_codesize_files_wasmfs.jssize index 83aaf27e746bc..5aecb7d32517a 100644 --- a/test/other/codesize/test_codesize_files_wasmfs.jssize +++ b/test/other/codesize/test_codesize_files_wasmfs.jssize @@ -1 +1 @@ -6244 +6214 diff --git a/test/other/codesize/test_codesize_hello_O0.gzsize b/test/other/codesize/test_codesize_hello_O0.gzsize index f436d64e54792..af0a7b0a886ac 100644 --- a/test/other/codesize/test_codesize_hello_O0.gzsize +++ b/test/other/codesize/test_codesize_hello_O0.gzsize @@ -1 +1 @@ -8043 +8034 diff --git a/test/other/codesize/test_codesize_hello_O0.jssize b/test/other/codesize/test_codesize_hello_O0.jssize index 1f1ac91c270cf..0b07ab883de47 100644 --- a/test/other/codesize/test_codesize_hello_O0.jssize +++ b/test/other/codesize/test_codesize_hello_O0.jssize @@ -1 +1 @@ -21457 +21479 diff --git a/test/other/codesize/test_codesize_hello_O1.gzsize b/test/other/codesize/test_codesize_hello_O1.gzsize index 621b7ce5342a6..ece5108dd4bce 100644 --- a/test/other/codesize/test_codesize_hello_O1.gzsize +++ b/test/other/codesize/test_codesize_hello_O1.gzsize @@ -1 +1 @@ -2788 +2785 diff --git a/test/other/codesize/test_codesize_hello_O1.jssize b/test/other/codesize/test_codesize_hello_O1.jssize index 027dd3849dd58..13068939d1a42 100644 --- a/test/other/codesize/test_codesize_hello_O1.jssize +++ b/test/other/codesize/test_codesize_hello_O1.jssize @@ -1 +1 @@ -7021 +7004 diff --git a/test/other/codesize/test_codesize_hello_O2.gzsize b/test/other/codesize/test_codesize_hello_O2.gzsize index 8aa001e241409..51d5790fa9f86 100644 --- a/test/other/codesize/test_codesize_hello_O2.gzsize +++ b/test/other/codesize/test_codesize_hello_O2.gzsize @@ -1 +1 @@ -2462 +2434 diff --git a/test/other/codesize/test_codesize_hello_O2.jssize b/test/other/codesize/test_codesize_hello_O2.jssize index 5a3b1c0e3cc2a..032c246660549 100644 --- a/test/other/codesize/test_codesize_hello_O2.jssize +++ b/test/other/codesize/test_codesize_hello_O2.jssize @@ -1 +1 @@ -4984 +4955 diff --git a/test/other/codesize/test_codesize_hello_O3.gzsize b/test/other/codesize/test_codesize_hello_O3.gzsize index 37a2cebe6b9c9..c4fdb9ba8959b 100644 --- a/test/other/codesize/test_codesize_hello_O3.gzsize +++ b/test/other/codesize/test_codesize_hello_O3.gzsize @@ -1 +1 @@ -2380 +2346 diff --git a/test/other/codesize/test_codesize_hello_O3.jssize b/test/other/codesize/test_codesize_hello_O3.jssize index ddeb3cf88bf70..534d8e6bdcc90 100644 --- a/test/other/codesize/test_codesize_hello_O3.jssize +++ b/test/other/codesize/test_codesize_hello_O3.jssize @@ -1 +1 @@ -4830 +4802 diff --git a/test/other/codesize/test_codesize_hello_Os.gzsize b/test/other/codesize/test_codesize_hello_Os.gzsize index 37a2cebe6b9c9..c4fdb9ba8959b 100644 --- a/test/other/codesize/test_codesize_hello_Os.gzsize +++ b/test/other/codesize/test_codesize_hello_Os.gzsize @@ -1 +1 @@ -2380 +2346 diff --git a/test/other/codesize/test_codesize_hello_Os.jssize b/test/other/codesize/test_codesize_hello_Os.jssize index ddeb3cf88bf70..534d8e6bdcc90 100644 --- a/test/other/codesize/test_codesize_hello_Os.jssize +++ b/test/other/codesize/test_codesize_hello_Os.jssize @@ -1 +1 @@ -4830 +4802 diff --git a/test/other/codesize/test_codesize_hello_Oz.gzsize b/test/other/codesize/test_codesize_hello_Oz.gzsize index 7d945b944dabc..ffcd151c41f04 100644 --- a/test/other/codesize/test_codesize_hello_Oz.gzsize +++ b/test/other/codesize/test_codesize_hello_Oz.gzsize @@ -1 +1 @@ -2359 +2328 diff --git a/test/other/codesize/test_codesize_hello_Oz.jssize b/test/other/codesize/test_codesize_hello_Oz.jssize index f2bb280333202..9f4f637fcdccb 100644 --- a/test/other/codesize/test_codesize_hello_Oz.jssize +++ b/test/other/codesize/test_codesize_hello_Oz.jssize @@ -1 +1 @@ -4797 +4769 diff --git a/test/other/codesize/test_codesize_hello_dylink.gzsize b/test/other/codesize/test_codesize_hello_dylink.gzsize index d18a1e2dd1c2e..e88f7f6787c9d 100644 --- a/test/other/codesize/test_codesize_hello_dylink.gzsize +++ b/test/other/codesize/test_codesize_hello_dylink.gzsize @@ -1 +1 @@ -6246 +6227 diff --git a/test/other/codesize/test_codesize_hello_dylink.jssize b/test/other/codesize/test_codesize_hello_dylink.jssize index 99087d0d64926..a9336124ba7fb 100644 --- a/test/other/codesize/test_codesize_hello_dylink.jssize +++ b/test/other/codesize/test_codesize_hello_dylink.jssize @@ -1 +1 @@ -13767 +13729 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.gzsize b/test/other/codesize/test_codesize_hello_export_nothing.gzsize index 8d937ef32a302..a894381fc572f 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.gzsize +++ b/test/other/codesize/test_codesize_hello_export_nothing.gzsize @@ -1 +1 @@ -1736 +1721 diff --git a/test/other/codesize/test_codesize_hello_export_nothing.jssize b/test/other/codesize/test_codesize_hello_export_nothing.jssize index bb7949a47215f..1e144d1f73aa3 100644 --- a/test/other/codesize/test_codesize_hello_export_nothing.jssize +++ b/test/other/codesize/test_codesize_hello_export_nothing.jssize @@ -1 +1 @@ -3687 +3662 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.gzsize b/test/other/codesize/test_codesize_hello_wasmfs.gzsize index 37a2cebe6b9c9..c4fdb9ba8959b 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_hello_wasmfs.gzsize @@ -1 +1 @@ -2380 +2346 diff --git a/test/other/codesize/test_codesize_hello_wasmfs.jssize b/test/other/codesize/test_codesize_hello_wasmfs.jssize index ddeb3cf88bf70..534d8e6bdcc90 100644 --- a/test/other/codesize/test_codesize_hello_wasmfs.jssize +++ b/test/other/codesize/test_codesize_hello_wasmfs.jssize @@ -1 +1 @@ -4830 +4802 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize index a60b19c7d3e35..e37d15a094a6b 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.gzsize @@ -1 +1 @@ -1942 +1920 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize index 8fd7a8244755f..19e6874d5c5ec 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3.jssize @@ -1 +1 @@ -4064 +4040 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize index 144764295069b..b22803ae9b835 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.gzsize @@ -1 +1 @@ -1976 +1957 diff --git a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize index aff4d86fafce6..64c1a80470aad 100644 --- a/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_libcxxabi_message_O3_standalone.jssize @@ -1 +1 @@ -4111 +4087 diff --git a/test/other/codesize/test_codesize_mem_O3.gzsize b/test/other/codesize/test_codesize_mem_O3.gzsize index 8c88d58d59dbc..37a2cebe6b9c9 100644 --- a/test/other/codesize/test_codesize_mem_O3.gzsize +++ b/test/other/codesize/test_codesize_mem_O3.gzsize @@ -1 +1 @@ -2399 +2380 diff --git a/test/other/codesize/test_codesize_mem_O3.jssize b/test/other/codesize/test_codesize_mem_O3.jssize index ce43cdbca097f..f32a182f1e944 100644 --- a/test/other/codesize/test_codesize_mem_O3.jssize +++ b/test/other/codesize/test_codesize_mem_O3.jssize @@ -1 +1 @@ -4973 +4943 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.gzsize b/test/other/codesize/test_codesize_mem_O3_grow.gzsize index fe534adb03b4b..13c8e99a99bbb 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow.gzsize @@ -1 +1 @@ -2543 +2529 diff --git a/test/other/codesize/test_codesize_mem_O3_grow.jssize b/test/other/codesize/test_codesize_mem_O3_grow.jssize index 651ba07e2d020..c016a774c8a64 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow.jssize @@ -1 +1 @@ -5254 +5228 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize index 137c70ae46487..e60a9452f5c52 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.gzsize @@ -1 +1 @@ -2239 +2225 diff --git a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize index a42fbf5bc5e93..b02620cff6eb4 100644 --- a/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_grow_standalone.jssize @@ -1 +1 @@ -4663 +4636 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize index b17e4bdb15f56..0ed0ea4a170d1 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.gzsize @@ -1 +1 @@ -2208 +2190 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone.jssize b/test/other/codesize/test_codesize_mem_O3_standalone.jssize index b2b760360bf47..835fe1beea0f2 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone.jssize @@ -1 +1 @@ -4593 +4566 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize index adf4269e68338..6e371fb2389ae 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.gzsize @@ -1 +1 @@ -1960 +1944 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize index 5535a4d07c950..64c1a80470aad 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_lib.jssize @@ -1 +1 @@ -4115 +4087 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize index 144764295069b..b22803ae9b835 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.gzsize @@ -1 +1 @@ -1976 +1957 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize index aff4d86fafce6..64c1a80470aad 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg.jssize @@ -1 +1 @@ -4111 +4087 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize index 144764295069b..b22803ae9b835 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.gzsize @@ -1 +1 @@ -1976 +1957 diff --git a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize index aff4d86fafce6..64c1a80470aad 100644 --- a/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize +++ b/test/other/codesize/test_codesize_mem_O3_standalone_narg_flto.jssize @@ -1 +1 @@ -4111 +4087 diff --git a/test/other/codesize/test_codesize_minimal_64.gzsize b/test/other/codesize/test_codesize_minimal_64.gzsize index 131de0bdc4713..3591ec6784c2f 100644 --- a/test/other/codesize/test_codesize_minimal_64.gzsize +++ b/test/other/codesize/test_codesize_minimal_64.gzsize @@ -1 +1 @@ -1499 +1492 diff --git a/test/other/codesize/test_codesize_minimal_64.jssize b/test/other/codesize/test_codesize_minimal_64.jssize index 518ea7fd5d661..b2858f3749035 100644 --- a/test/other/codesize/test_codesize_minimal_64.jssize +++ b/test/other/codesize/test_codesize_minimal_64.jssize @@ -1 +1 @@ -3143 +3142 diff --git a/test/other/codesize/test_codesize_minimal_O0.gzsize b/test/other/codesize/test_codesize_minimal_O0.gzsize index 26d97f396bfab..bde5b49b5d9d5 100644 --- a/test/other/codesize/test_codesize_minimal_O0.gzsize +++ b/test/other/codesize/test_codesize_minimal_O0.gzsize @@ -1 +1 @@ -6571 +6567 diff --git a/test/other/codesize/test_codesize_minimal_O0.jssize b/test/other/codesize/test_codesize_minimal_O0.jssize index 4705c7d0c2aad..17bded2757b92 100644 --- a/test/other/codesize/test_codesize_minimal_O0.jssize +++ b/test/other/codesize/test_codesize_minimal_O0.jssize @@ -1 +1 @@ -17606 +17513 diff --git a/test/other/codesize/test_codesize_minimal_O1.gzsize b/test/other/codesize/test_codesize_minimal_O1.gzsize index 6fcfa77a477e8..1c631e1e4ce7e 100644 --- a/test/other/codesize/test_codesize_minimal_O1.gzsize +++ b/test/other/codesize/test_codesize_minimal_O1.gzsize @@ -1 +1 @@ -1574 +1568 diff --git a/test/other/codesize/test_codesize_minimal_O1.jssize b/test/other/codesize/test_codesize_minimal_O1.jssize index e4ab713200d2c..c73c83400cc5d 100644 --- a/test/other/codesize/test_codesize_minimal_O1.jssize +++ b/test/other/codesize/test_codesize_minimal_O1.jssize @@ -1 +1 @@ -3739 +3669 diff --git a/test/other/codesize/test_codesize_minimal_O2.gzsize b/test/other/codesize/test_codesize_minimal_O2.gzsize index b322e68302d81..4e6ee1e5ffb6e 100644 --- a/test/other/codesize/test_codesize_minimal_O2.gzsize +++ b/test/other/codesize/test_codesize_minimal_O2.gzsize @@ -1 +1 @@ -1427 +1421 diff --git a/test/other/codesize/test_codesize_minimal_O2.jssize b/test/other/codesize/test_codesize_minimal_O2.jssize index f36482a747146..b36a2e0278445 100644 --- a/test/other/codesize/test_codesize_minimal_O2.jssize +++ b/test/other/codesize/test_codesize_minimal_O2.jssize @@ -1 +1 @@ -2848 +2847 diff --git a/test/other/codesize/test_codesize_minimal_O3.gzsize b/test/other/codesize/test_codesize_minimal_O3.gzsize index f252370658e8f..1aca63ba8cd53 100644 --- a/test/other/codesize/test_codesize_minimal_O3.gzsize +++ b/test/other/codesize/test_codesize_minimal_O3.gzsize @@ -1 +1 @@ -1393 +1386 diff --git a/test/other/codesize/test_codesize_minimal_O3.jssize b/test/other/codesize/test_codesize_minimal_O3.jssize index 3327d2792ed58..9ddd587ee7d83 100644 --- a/test/other/codesize/test_codesize_minimal_O3.jssize +++ b/test/other/codesize/test_codesize_minimal_O3.jssize @@ -1 +1 @@ -2798 +2797 diff --git a/test/other/codesize/test_codesize_minimal_Os.gzsize b/test/other/codesize/test_codesize_minimal_Os.gzsize index f252370658e8f..1aca63ba8cd53 100644 --- a/test/other/codesize/test_codesize_minimal_Os.gzsize +++ b/test/other/codesize/test_codesize_minimal_Os.gzsize @@ -1 +1 @@ -1393 +1386 diff --git a/test/other/codesize/test_codesize_minimal_Os.jssize b/test/other/codesize/test_codesize_minimal_Os.jssize index 3327d2792ed58..9ddd587ee7d83 100644 --- a/test/other/codesize/test_codesize_minimal_Os.jssize +++ b/test/other/codesize/test_codesize_minimal_Os.jssize @@ -1 +1 @@ -2798 +2797 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize index a9b14017bfece..30ed602b91565 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.gzsize @@ -1 +1 @@ -1383 +1378 diff --git a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize index 7ab19b5b480cf..baa5fd743de19 100644 --- a/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz-ctors.jssize @@ -1 +1 @@ -2783 +2782 diff --git a/test/other/codesize/test_codesize_minimal_Oz.gzsize b/test/other/codesize/test_codesize_minimal_Oz.gzsize index f252370658e8f..1aca63ba8cd53 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.gzsize +++ b/test/other/codesize/test_codesize_minimal_Oz.gzsize @@ -1 +1 @@ -1393 +1386 diff --git a/test/other/codesize/test_codesize_minimal_Oz.jssize b/test/other/codesize/test_codesize_minimal_Oz.jssize index 3327d2792ed58..9ddd587ee7d83 100644 --- a/test/other/codesize/test_codesize_minimal_Oz.jssize +++ b/test/other/codesize/test_codesize_minimal_Oz.jssize @@ -1 +1 @@ -2798 +2797 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.gzsize b/test/other/codesize/test_codesize_minimal_pthreads.gzsize index a4ca075180c97..7223c3c378623 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.gzsize +++ b/test/other/codesize/test_codesize_minimal_pthreads.gzsize @@ -1 +1 @@ -4188 +4177 diff --git a/test/other/codesize/test_codesize_minimal_pthreads.jssize b/test/other/codesize/test_codesize_minimal_pthreads.jssize index 179d18debb431..b26b806a10c6c 100644 --- a/test/other/codesize/test_codesize_minimal_pthreads.jssize +++ b/test/other/codesize/test_codesize_minimal_pthreads.jssize @@ -1 +1 @@ -8667 +8656 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize index f252370658e8f..1aca63ba8cd53 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.gzsize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.gzsize @@ -1 +1 @@ -1393 +1386 diff --git a/test/other/codesize/test_codesize_minimal_wasmfs.jssize b/test/other/codesize/test_codesize_minimal_wasmfs.jssize index 3327d2792ed58..9ddd587ee7d83 100644 --- a/test/other/codesize/test_codesize_minimal_wasmfs.jssize +++ b/test/other/codesize/test_codesize_minimal_wasmfs.jssize @@ -1 +1 @@ -2798 +2797 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index 48f4d8dcae999..ba18cec99cb25 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -54928 +54390 diff --git a/test/other/test_unoptimized_code_size_no_asserts.js.size b/test/other/test_unoptimized_code_size_no_asserts.js.size index cec4a3ebfe845..921d6b46a36b7 100644 --- a/test/other/test_unoptimized_code_size_no_asserts.js.size +++ b/test/other/test_unoptimized_code_size_no_asserts.js.size @@ -1 +1 @@ -30416 +29886 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index 5c3cf64221739..f49c2da41fbc0 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -53724 +53186 diff --git a/test/test_browser.py b/test/test_browser.py index 91521d09db869..0e8d7edee8a93 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -5519,7 +5519,7 @@ def test(args, expect_fail): if expect_fail: js = read_file('a.out.js') create_file('a.out.js', 'let origFetch = fetch; fetch = undefined;\n' + js) - return self.run_browser('a.out.html', '/report_result?exception:fetch is not a function') + return self.run_browser('a.out.html', '/report_result?abort:both async and sync fetching of the wasm failed') else: return self.run_browser('a.out.html', '/report_result?exit:42') diff --git a/test/test_other.py b/test/test_other.py index dd46dd1df2569..f3e6b7ee59b9a 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -2955,20 +2955,25 @@ def test_m_mm(self): self.assertNotContained('error', proc.stderr) @uses_canonical_tmp - def test_emcc_debug_files(self): - for opts in (0, 1, 2, 3): - for debug in (None, '1', '2'): - print(opts, debug) - if os.path.exists(self.canonical_temp_dir): - shutil.rmtree(self.canonical_temp_dir) - - with env_modify({'EMCC_DEBUG': debug}): - self.run_process([EMCC, test_file('hello_world.c'), '-O' + str(opts)], stderr=PIPE) - if debug is None: - self.assertFalse(os.path.exists(self.canonical_temp_dir)) - else: - print(sorted(os.listdir(self.canonical_temp_dir))) - self.assertExists(os.path.join(self.canonical_temp_dir, 'emcc-03-original.js')) + @parameterized({ + 'O0': ('-O0',), + 'O1': ('-O1',), + 'O2': ('-O2',), + 'O3': ('-O3',), + }) + def test_emcc_debug_files(self, opt): + for debug in (None, '1', '2'): + print('debug =', debug) + if os.path.exists(self.canonical_temp_dir): + shutil.rmtree(self.canonical_temp_dir) + + with env_modify({'EMCC_DEBUG': debug}): + self.run_process([EMCC, test_file('hello_world.c'), opt], stderr=PIPE) + if debug is None: + self.assertFalse(os.path.exists(self.canonical_temp_dir)) + else: + print(sorted(os.listdir(self.canonical_temp_dir))) + self.assertExists(os.path.join(self.canonical_temp_dir, 'emcc-03-original.js')) def test_debuginfo_line_tables_only(self): def test(do_compile): diff --git a/tools/emscripten.py b/tools/emscripten.py index 65584d17e0144..c2d36561d7776 100644 --- a/tools/emscripten.py +++ b/tools/emscripten.py @@ -989,7 +989,10 @@ def create_module(receiving, metadata, global_exports, library_symbols): module.append('var wasmImports = %s;\n' % sending) if not settings.MINIMAL_RUNTIME: - module.append("var wasmExports = createWasm();\n") + if settings.WASM_ASYNC_COMPILATION: + module.append("var wasmExports;\ncreateWasm();\n") + else: + module.append("var wasmExports = createWasm();\n") module.append(receiving) if settings.SUPPORT_LONGJMP == 'emscripten' or not settings.DISABLE_EXCEPTION_CATCHING: