From cd192bb9dd77736ce6f21c0e06aad2729dfcfb77 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Thu, 30 Nov 2023 16:07:41 +0000 Subject: [PATCH] Leverage coalescing operators. NFC Note that this bumps minimum Chrome & Firefox versions, as well as JS version from ES2020 to ES2021. I believe this is not blocked on https://github.com/emscripten-core/emscripten/issues/11984 as it doesn't require Closure to emit runtime helpers. This is mostly automated with ast-grep, bunch of custom rules, and a few manual fixups. Best viewed with "ignore whitespace changes" (https://github.com/emscripten-core/emscripten/pull/20531/files) due to indentation changes and due to first commit being #20530. Care was taken to ensure that false-y conditions still use `||` where it might matter and only null-ish conditions use `??`. --- src/Fetch.js | 34 +++---- src/cpuprofiler.js | 68 +++++++------- src/embind/embind.js | 16 +--- src/embind/emval.js | 4 +- src/headless.js | 38 ++++---- src/library.js | 6 +- src/library_async.js | 2 +- src/library_browser.js | 31 ++++--- src/library_ccall.js | 2 +- src/library_dylink.js | 10 +-- src/library_eventloop.js | 2 +- src/library_exceptions.js | 2 +- src/library_exports.js | 2 +- src/library_fs.js | 6 +- src/library_fs_shared.js | 6 +- src/library_glemu.js | 28 +++--- src/library_glew.js | 4 +- src/library_glfw.js | 14 +-- src/library_html5.js | 12 +-- src/library_html5_webgl.js | 12 +-- src/library_memfs.js | 90 +++++++++---------- src/library_openal.js | 10 +-- src/library_pthread.js | 4 +- src/library_sdl.js | 30 +++---- src/library_strings.js | 8 +- src/library_syscall.js | 4 +- src/library_trace.js | 4 +- src/library_wasi.js | 4 +- src/library_wasmfs.js | 8 +- src/library_webgl.js | 4 +- src/library_websocket.js | 8 +- src/library_wget.js | 4 +- src/library_workerfs.js | 4 +- src/memoryprofiler.js | 8 +- src/parseTools.js | 6 +- src/polyfill/bigint64array.js | 8 +- src/postamble.js | 2 +- src/preamble.js | 16 +--- src/proxyClient.js | 8 +- src/proxyWorker.js | 10 +-- src/runtime_math.js | 4 +- src/utility.js | 4 +- src/webGLWorker.js | 2 +- src/worker.js | 6 +- test/code_size/embind_val_wasm.json | 8 +- test/code_size/hello_webgl2_wasm.json | 4 +- test/code_size/hello_webgl2_wasm2js.json | 8 +- test/code_size/hello_webgl_wasm.json | 8 +- test/code_size/hello_webgl_wasm2js.json | 8 +- test/common.py | 1 + .../metadce/test_metadce_cxx_ctors1.jssize | 2 +- .../metadce/test_metadce_cxx_ctors2.jssize | 2 +- .../metadce/test_metadce_cxx_except.jssize | 2 +- .../test_metadce_cxx_except_wasm.jssize | 2 +- .../metadce/test_metadce_cxx_mangle.jssize | 2 +- .../metadce/test_metadce_cxx_noexcept.jssize | 2 +- .../metadce/test_metadce_cxx_wasmfs.jssize | 2 +- .../metadce/test_metadce_files_js_fs.jssize | 2 +- .../metadce/test_metadce_files_wasmfs.jssize | 2 +- .../metadce/test_metadce_hello_O0.jssize | 2 +- .../metadce/test_metadce_hello_O1.jssize | 2 +- .../metadce/test_metadce_hello_O2.jssize | 2 +- .../metadce/test_metadce_hello_O3.jssize | 2 +- .../metadce/test_metadce_hello_Os.jssize | 2 +- .../metadce/test_metadce_hello_Oz.jssize | 2 +- .../metadce/test_metadce_hello_dylink.jssize | 2 +- .../test_metadce_hello_export_nothing.jssize | 2 +- .../metadce/test_metadce_hello_wasmfs.jssize | 2 +- .../test_metadce_libcxxabi_message_O3.jssize | 2 +- ...dce_libcxxabi_message_O3_standalone.jssize | 2 +- test/other/metadce/test_metadce_mem_O3.jssize | 2 +- .../metadce/test_metadce_mem_O3_grow.jssize | 2 +- ...test_metadce_mem_O3_grow_standalone.jssize | 2 +- .../test_metadce_mem_O3_standalone.jssize | 2 +- .../test_metadce_mem_O3_standalone_lib.jssize | 2 +- ...test_metadce_mem_O3_standalone_narg.jssize | 2 +- ...metadce_mem_O3_standalone_narg_flto.jssize | 2 +- .../metadce/test_metadce_minimal_O0.jssize | 2 +- .../test_metadce_minimal_pthreads.jssize | 2 +- test/other/test_unoptimized_code_size.js.size | 2 +- ...t_unoptimized_code_size_no_asserts.js.size | 2 +- .../test_unoptimized_code_size_strict.js.size | 2 +- test/test_other.py | 10 +-- tools/link.py | 26 +++--- 84 files changed, 311 insertions(+), 381 deletions(-) diff --git a/src/Fetch.js b/src/Fetch.js index 86adf84d036f2..122719321c301 100644 --- a/src/Fetch.js +++ b/src/Fetch.js @@ -84,7 +84,7 @@ function fetchDeleteCachedData(db, fetch, onsuccess, onerror) { var fetch_attr = fetch + {{{ C_STRUCTS.emscripten_fetch_t.__attributes }}}; var path = HEAPU32[fetch_attr + {{{ C_STRUCTS.emscripten_fetch_attr_t.destinationPath }}} >> 2]; - if (!path) path = HEAPU32[fetch + {{{ C_STRUCTS.emscripten_fetch_t.url }}} >> 2]; + path ||= HEAPU32[fetch + {{{ C_STRUCTS.emscripten_fetch_t.url }}} >> 2]; var pathStr = UTF8ToString(path); try { @@ -133,7 +133,7 @@ function fetchLoadCachedData(db, fetch, onsuccess, onerror) { var fetch_attr = fetch + {{{ C_STRUCTS.emscripten_fetch_t.__attributes }}}; var path = HEAPU32[fetch_attr + {{{ C_STRUCTS.emscripten_fetch_attr_t.destinationPath }}} >> 2]; - if (!path) path = HEAPU32[fetch + {{{ C_STRUCTS.emscripten_fetch_t.url }}} >> 2]; + path ||= HEAPU32[fetch + {{{ C_STRUCTS.emscripten_fetch_t.url }}} >> 2]; var pathStr = UTF8ToString(path); try { @@ -198,7 +198,7 @@ function fetchCacheData(/** @type {IDBDatabase} */ db, fetch, data, onsuccess, o var fetch_attr = fetch + {{{ C_STRUCTS.emscripten_fetch_t.__attributes }}}; var destinationPath = HEAPU32[fetch_attr + {{{ C_STRUCTS.emscripten_fetch_attr_t.destinationPath }}} >> 2]; - if (!destinationPath) destinationPath = HEAPU32[fetch + {{{ C_STRUCTS.emscripten_fetch_t.url }}} >> 2]; + destinationPath ||= HEAPU32[fetch + {{{ C_STRUCTS.emscripten_fetch_t.url }}} >> 2]; var destinationPathStr = UTF8ToString(destinationPath); try { @@ -248,7 +248,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) { var fetch_attr = fetch + {{{ C_STRUCTS.emscripten_fetch_t.__attributes }}}; var requestMethod = UTF8ToString(fetch_attr + {{{ C_STRUCTS.emscripten_fetch_attr_t.requestMethod }}}); - if (!requestMethod) requestMethod = 'GET'; + requestMethod ||= 'GET'; var timeoutMsecs = {{{ makeGetValue('fetch_attr', C_STRUCTS.emscripten_fetch_attr_t.timeoutMSecs, 'u32') }}}; var userName = {{{ makeGetValue('fetch_attr', C_STRUCTS.emscripten_fetch_attr_t.userName, '*') }}}; var password = {{{ makeGetValue('fetch_attr', C_STRUCTS.emscripten_fetch_attr_t.password, '*') }}}; @@ -354,12 +354,12 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) { #if FETCH_DEBUG dbg(`fetch: xhr of URL "${xhr.url_}" / responseURL "${xhr.responseURL}" succeeded with status ${xhr.status}`); #endif - if (onsuccess) onsuccess(fetch, xhr, e); + onsuccess?.(fetch, xhr, e); } else { #if FETCH_DEBUG dbg(`fetch: xhr of URL "${xhr.url_}" / responseURL "${xhr.responseURL}" failed with status ${xhr.status}`); #endif - if (onerror) onerror(fetch, xhr, e); + onerror?.(fetch, xhr, e); } }; xhr.onerror = (e) => { @@ -371,7 +371,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) { dbg(`fetch: xhr of URL "${xhr.url_}" / responseURL "${xhr.responseURL}" finished with error, readyState ${xhr.readyState} and status ${xhr.status}`); #endif saveResponseAndStatus(); - if (onerror) onerror(fetch, xhr, e); + onerror?.(fetch, xhr, e); }; xhr.ontimeout = (e) => { // check if xhr was aborted by user and don't try to call back @@ -381,7 +381,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) { #if FETCH_DEBUG dbg(`fetch: xhr of URL "${xhr.url_}" / responseURL "${xhr.responseURL}" timed out, readyState ${xhr.readyState} and status ${xhr.status}`); #endif - if (onerror) onerror(fetch, xhr, e); + onerror?.(fetch, xhr, e); }; xhr.onprogress = (e) => { // check if xhr was aborted by user and don't try to call back @@ -410,7 +410,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) { if (xhr.readyState >= 3 && xhr.status === 0 && e.loaded > 0) xhr.status = 200; HEAPU16[fetch + {{{ C_STRUCTS.emscripten_fetch_t.status }}} >> 1] = xhr.status; if (xhr.statusText) stringToUTF8(xhr.statusText, fetch + {{{ C_STRUCTS.emscripten_fetch_t.statusText }}}, 64); - if (onprogress) onprogress(fetch, xhr, e); + onprogress?.(fetch, xhr, e); if (ptr) { _free(ptr); } @@ -425,7 +425,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) { if (xhr.readyState >= 2) { HEAPU16[fetch + {{{ C_STRUCTS.emscripten_fetch_t.status }}} >> 1] = xhr.status; } - if (onreadystatechange) onreadystatechange(fetch, xhr, e); + onreadystatechange?.(fetch, xhr, e); }; #if FETCH_DEBUG dbg(`fetch: xhr.send(data=${data})`); @@ -436,7 +436,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) { #if FETCH_DEBUG dbg(`fetch: xhr failed with exception: ${e}`); #endif - if (onerror) onerror(fetch, xhr, e); + onerror?.(fetch, xhr, e); } } @@ -468,14 +468,14 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) { {{{ runtimeKeepalivePop() }}} doCallback(() => { if (onsuccess) {{{ makeDynCall('vp', 'onsuccess') }}}(fetch); - else if (successcb) successcb(fetch); + else successcb?.(fetch); }); }; var reportProgress = (fetch, xhr, e) => { doCallback(() => { if (onprogress) {{{ makeDynCall('vp', 'onprogress') }}}(fetch); - else if (progresscb) progresscb(fetch); + else progresscb?.(fetch); }); }; @@ -486,7 +486,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) { {{{ runtimeKeepalivePop() }}} doCallback(() => { if (onerror) {{{ makeDynCall('vp', 'onerror') }}}(fetch); - else if (errorcb) errorcb(fetch); + else errorcb?.(fetch); }); }; @@ -496,7 +496,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) { #endif doCallback(() => { if (onreadystatechange) {{{ makeDynCall('vp', 'onreadystatechange') }}}(fetch); - else if (readystatechangecb) readystatechangecb(fetch); + else readystatechangecb?.(fetch); }); }; @@ -519,7 +519,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) { {{{ runtimeKeepalivePop() }}} doCallback(() => { if (onsuccess) {{{ makeDynCall('vp', 'onsuccess') }}}(fetch); - else if (successcb) successcb(fetch); + else successcb?.(fetch); }); }; var storeError = (fetch, xhr, e) => { @@ -529,7 +529,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) { {{{ runtimeKeepalivePop() }}} doCallback(() => { if (onsuccess) {{{ makeDynCall('vp', 'onsuccess') }}}(fetch); - else if (successcb) successcb(fetch); + else successcb?.(fetch); }); }; fetchCacheData(Fetch.dbInstance, fetch, xhr.response, storeSuccess, storeError); diff --git a/src/cpuprofiler.js b/src/cpuprofiler.js index 8929f6e07ded0..6d0393584eba4 100644 --- a/src/cpuprofiler.js +++ b/src/cpuprofiler.js @@ -148,37 +148,35 @@ var emscriptenCpuProfiler = { createSection: function createSection(number, name, drawColor, traceable) { while (this.sections.length <= number) this.sections.push(null); // Keep an array structure. var sect = this.sections[number]; - if (!sect) { - sect = { - count: 0, - name, - startTick: 0, - accumulatedTimeInsideMainLoop: 0, - accumulatedTimeOutsideMainLoop: 0, - frametimesInsideMainLoop: [], - frametimesOutsideMainLoop: [], - drawColor, - traceable, - accumulatedFrameTimeInsideMainLoop: function(startX, numSamples) { - var total = 0; - numSamples = Math.min(numSamples, this.frametimesInsideMainLoop.length); - for (var i = 0; i < numSamples; ++i) { - var x = (startX + i) % this.frametimesInsideMainLoop.length; - if (this.frametimesInsideMainLoop[x]) total += this.frametimesInsideMainLoop[x]; - } - return total; - }, - accumulatedFrameTimeOutsideMainLoop: function(startX, numSamples) { - var total = 0; - numSamples = Math.min(numSamples, this.frametimesInsideMainLoop.length); - for (var i = 0; i < numSamples; ++i) { - var x = (startX + i) % this.frametimesInsideMainLoop.length; - if (this.frametimesOutsideMainLoop[x]) total += this.frametimesOutsideMainLoop[x]; - } - return total; + sect ||= { + count: 0, + name, + startTick: 0, + accumulatedTimeInsideMainLoop: 0, + accumulatedTimeOutsideMainLoop: 0, + frametimesInsideMainLoop: [], + frametimesOutsideMainLoop: [], + drawColor, + traceable, + accumulatedFrameTimeInsideMainLoop: function(startX, numSamples) { + var total = 0; + numSamples = Math.min(numSamples, this.frametimesInsideMainLoop.length); + for (var i = 0; i < numSamples; ++i) { + var x = (startX + i) % this.frametimesInsideMainLoop.length; + if (this.frametimesInsideMainLoop[x]) total += this.frametimesInsideMainLoop[x]; } - }; - } + return total; + }, + accumulatedFrameTimeOutsideMainLoop: function(startX, numSamples) { + var total = 0; + numSamples = Math.min(numSamples, this.frametimesInsideMainLoop.length); + for (var i = 0; i < numSamples; ++i) { + var x = (startX + i) % this.frametimesInsideMainLoop.length; + if (this.frametimesOutsideMainLoop[x]) total += this.frametimesOutsideMainLoop[x]; + } + return total; + } + }; sect.name = name; this.sections[number] = sect; }, @@ -368,7 +366,7 @@ var emscriptenCpuProfiler = { fpsOverlay.style = 'position: fixed; font-weight: bold; padding: 3px; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; cursor: pointer;'; fpsOverlay.onclick = () => { var view = document.getElementById('cpuprofiler_canvas'); - if (view) view.scrollIntoView(); + view?.scrollIntoView(); }; fpsOverlay.oncontextmenu = (e) => e.preventDefault(); document.body.appendChild(fpsOverlay); @@ -532,14 +530,14 @@ var emscriptenCpuProfiler = { }, detectWebGLContext: function() { - if (Module['canvas'] && Module['canvas'].GLctxObject && Module['canvas'].GLctxObject.GLctx) return Module['canvas'].GLctxObject.GLctx; + if (Module['canvas']?.GLctxObject?.GLctx) return Module['canvas'].GLctxObject.GLctx; else if (typeof GLctx != 'undefined') return GLctx; else if (Module.ctx) return Module.ctx; return null; }, toggleHookWebGL: function(glCtx) { - if (!glCtx) glCtx = this.detectWebGLContext(); + glCtx ||= this.detectWebGLContext(); if (this.hookedWebGLContexts.includes(glCtx)) this.unhookWebGL(glCtx); else this.hookWebGL(glCtx); }, @@ -563,7 +561,7 @@ var emscriptenCpuProfiler = { }, unhookWebGL: function(glCtx) { - if (!glCtx) glCtx = this.detectWebGLContext(); + glCtx ||= this.detectWebGLContext(); if (!glCtx.cpuprofilerAlreadyHooked) return; glCtx.cpuprofilerAlreadyHooked = false; this.hookedWebGLContexts.splice(this.hookedWebGLContexts.indexOf(glCtx), 1); @@ -601,7 +599,7 @@ var emscriptenCpuProfiler = { }, hookWebGL: function(glCtx) { - if (!glCtx) glCtx = this.detectWebGLContext(); + glCtx ||= this.detectWebGLContext(); if (!glCtx) return; if (!((typeof WebGLRenderingContext != 'undefined' && glCtx instanceof WebGLRenderingContext) || (typeof WebGL2RenderingContext != 'undefined' && glCtx instanceof WebGL2RenderingContext))) { diff --git a/src/embind/embind.js b/src/embind/embind.js index 9a6e2ac23c941..6ff80369c48d9 100644 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -1307,9 +1307,7 @@ var LibraryEmbind = { return ptr; }, destructor(ptr) { - if (this.rawDestructor) { - this.rawDestructor(ptr); - } + this.rawDestructor?.(ptr); }, 'argPackAdvance': GenericWireTypeSize, 'readValueFromPointer': readPointer, @@ -1743,12 +1741,8 @@ var LibraryEmbind = { rawDestructor) => { name = readLatin1String(name); getActualType = embind__requireFunction(getActualTypeSignature, getActualType); - if (upcast) { - upcast = embind__requireFunction(upcastSignature, upcast); - } - if (downcast) { - downcast = embind__requireFunction(downcastSignature, downcast); - } + upcast &&= embind__requireFunction(upcastSignature, upcast); + downcast &&= embind__requireFunction(downcastSignature, downcast); rawDestructor = embind__requireFunction(destructorSignature, rawDestructor); var legalFunctionName = makeLegalFunctionName(name); @@ -1803,9 +1797,7 @@ var LibraryEmbind = { if (registeredClass.baseClass) { // Keep track of class hierarchy. Used to allow sub-classes to inherit class functions. - if (registeredClass.baseClass.__derivedClasses === undefined) { - registeredClass.baseClass.__derivedClasses = []; - } + registeredClass.baseClass.__derivedClasses ??= []; registeredClass.baseClass.__derivedClasses.push(registeredClass); } diff --git a/src/embind/emval.js b/src/embind/emval.js index d91ed78351196..ea0bac04252c5 100644 --- a/src/embind/emval.js +++ b/src/embind/emval.js @@ -336,9 +336,7 @@ var LibraryEmVal = { } var rv = kind === /* CONSTRUCTOR */ 1 ? reflectConstruct(func, argN) : func.apply(obj, argN); for (var i = 0; i < argCount; ++i) { - if (types[i].deleteObject) { - types[i].deleteObject(argN[i]); - } + types[i].deleteObject?.(argN[i]); } return emval_returnValue(retType, destructorsRef, rv); }; diff --git a/src/headless.js b/src/headless.js index 72baac8aa8284..65fe29165771f 100644 --- a/src/headless.js +++ b/src/headless.js @@ -83,9 +83,7 @@ var window = { eventListeners: {}, addEventListener(id, func) { var listeners = this.eventListeners[id]; - if (!listeners) { - listeners = this.eventListeners[id] = []; - } + listeners ||= this.eventListeners[id] = []; listeners.push(func); }, removeEventListener(id, func) { @@ -100,9 +98,7 @@ var window = { }, callEventListeners(id) { var listeners = this.eventListeners[id]; - if (listeners) { - listeners.forEach((listener) => listener()); - } + listeners?.forEach((listener) => listener()); }, URL: { createObjectURL(x) { @@ -161,17 +157,15 @@ var document = { }, elements: {}, querySelector(id) { - if (!document.elements[id]) { - document.elements[id] = { - classList: { - add() {}, - remove() {}, - }, - eventListeners: {}, - addEventListener: document.addEventListener, - removeEventListener: document.removeEventListener, - callEventListeners: document.callEventListeners, - }; + document.elements[id] ||= { + classList: { + add() {}, + remove() {}, + }, + eventListeners: {}, + addEventListener: document.addEventListener, + removeEventListener: document.removeEventListener, + callEventListeners: document.callEventListeners, }; return document.elements[id]; }, @@ -214,7 +208,7 @@ var XMLHttpRequest = function() { } else { window.setTimeout(() => { this.doSend(); - if (this.onload) this.onload(); + this.onload?.(); }, 0); } }, @@ -239,7 +233,7 @@ var Image = () => { this.complete = true; this.width = 64; this.height = 64; - if (this.onload) this.onload(); + this.onload?.(); }); }; var Worker = (workerPath) => { @@ -252,7 +246,7 @@ var Worker = (workerPath) => { function duplicateJSON(json) { function handleTypedArrays(key, value) { - if (value && value.toString && value.toString().substring(0, 8) == '[object ' && value.length && value.byteLength) { + if (value?.toString && value.toString().substring(0, 8) == '[object ' && value.length && value.byteLength) { return Array.prototype.slice.call(value); } return value; @@ -293,6 +287,4 @@ if (typeof console == 'undefined') { } // additional setup -if (!Module['canvas']) { - Module['canvas'] = document.getElementById('canvas'); -} +Module['canvas'] ||= document.getElementById('canvas'); diff --git a/src/library.js b/src/library.js index ec2d5de2e4053..ba8b85dcaa529 100644 --- a/src/library.js +++ b/src/library.js @@ -2418,7 +2418,7 @@ addToLibrary({ _emscripten_get_now_is_monotonic: () => nowIsMonotonic, $warnOnce: (text) => { - if (!warnOnce.shown) warnOnce.shown = {}; + warnOnce.shown ||= {}; if (!warnOnce.shown[text]) { warnOnce.shown[text] = 1; #if ENVIRONMENT_MAY_BE_NODE @@ -2498,7 +2498,7 @@ addToLibrary({ if (flags & {{{ cDefs.EM_LOG_C_STACK }}}) { var orig = emscripten_source_map.originalPositionFor({line: lineno, column: column}); - haveSourceMap = (orig && orig.source); + haveSourceMap = orig?.source; if (haveSourceMap) { if (flags & {{{ cDefs.EM_LOG_NO_PATHS }}}) { orig.source = orig.source.substring(orig.source.replace(/\\/g, "/").lastIndexOf('/')+1); @@ -3139,7 +3139,7 @@ addToLibrary({ #else assert(('dynCall_' + sig) in Module, `bad function pointer type - dynCall function not found for sig '${sig}'`); #endif - if (args && args.length) { + if (args?.length) { #if WASM_BIGINT // j (64-bit integer) is fine, and is implemented as a BigInt. Without // legalization, the number of parameters should match (j is not expanded diff --git a/src/library_async.js b/src/library_async.js index 2cc9185b3152f..dcad4bd15062a 100644 --- a/src/library_async.js +++ b/src/library_async.js @@ -435,7 +435,7 @@ addToLibrary({ // WebAssembly.Functions. asyncExports: null, isAsyncExport(func) { - return Asyncify.asyncExports && Asyncify.asyncExports.has(func); + return Asyncify.asyncExports?.has(func); }, handleAsync: async (startAsync) => { {{{ runtimeKeepalivePush(); }}} diff --git a/src/library_browser.js b/src/library_browser.js index 12b851767fc5e..3d4a8aa69c7f3 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -95,7 +95,7 @@ var LibraryBrowser = { } } callUserCallback(func); - if (Module['postMainLoop']) Module['postMainLoop'](); + Module['postMainLoop']?.(); } }, isFullscreen: false, @@ -140,11 +140,11 @@ var LibraryBrowser = { ctx.drawImage(img, 0, 0); preloadedImages[name] = canvas; URL.revokeObjectURL(url); - if (onload) onload(byteArray); + onload?.(byteArray); }; img.onerror = (event) => { err(`Image ${url} could not be decoded`); - if (onerror) onerror(); + onerror?.(); }; img.src = url; }; @@ -160,13 +160,13 @@ var LibraryBrowser = { if (done) return; done = true; preloadedAudios[name] = audio; - if (onload) onload(byteArray); + onload?.(byteArray); } function fail() { if (done) return; done = true; preloadedAudios[name] = new Audio(); // empty shim - if (onerror) onerror(); + onerror?.(); } var b = new Blob([byteArray], { type: Browser.getMimetype(name) }); var url = URL.createObjectURL(b); // XXX we never revoke this! @@ -344,8 +344,8 @@ var LibraryBrowser = { Browser.updateCanvasDimensions(canvas); } } - if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullscreen); - if (Module['onFullscreen']) Module['onFullscreen'](Browser.isFullscreen); + Module['onFullScreen']?.(Browser.isFullscreen); + Module['onFullscreen']?.(Browser.isFullscreen); } if (!Browser.fullscreenHandlersInstalled) { @@ -459,10 +459,8 @@ var LibraryBrowser = { }, getUserMedia(func) { - if (!window.getUserMedia) { - window.getUserMedia = navigator['getUserMedia'] || + window.getUserMedia ||= navigator['getUserMedia'] || navigator['mozGetUserMedia']; - } window.getUserMedia(func); }, @@ -610,7 +608,7 @@ var LibraryBrowser = { Browser.touches[touch.identifier] = coords; } else if (event.type === 'touchend' || event.type === 'touchmove') { var last = Browser.touches[touch.identifier]; - if (!last) last = coords; + last ||= coords; Browser.lastTouches[touch.identifier] = last; Browser.touches[touch.identifier] = coords; } @@ -732,14 +730,15 @@ var LibraryBrowser = { return 0; }, + $Browser_asyncPrepareDataCounter: 0, + emscripten_run_preload_plugins_data__proxy: 'sync', - emscripten_run_preload_plugins_data__deps: ['$stringToNewUTF8'], + emscripten_run_preload_plugins_data__deps: ['$stringToNewUTF8', '$Browser_asyncPrepareDataCounter'], emscripten_run_preload_plugins_data: (data, size, suffix, arg, onload, onerror) => { {{{ runtimeKeepalivePush() }}} var _suffix = UTF8ToString(suffix); - if (!Browser.asyncPrepareDataCounter) Browser.asyncPrepareDataCounter = 0; - var name = 'prepare_data_' + (Browser.asyncPrepareDataCounter++) + '.' + _suffix; + var name = 'prepare_data_' + (Browser_asyncPrepareDataCounter++) + '.' + _suffix; var cname = stringToNewUTF8(name); FS.createPreloadedFile( '/', @@ -795,7 +794,7 @@ var LibraryBrowser = { var loadError = () => { {{{ runtimeKeepalivePop() }}} - if (onerror) onerror(); + onerror?.(); }; #if ENVIRONMENT_MAY_BE_NODE && DYNAMIC_EXECUTION @@ -1029,7 +1028,7 @@ var LibraryBrowser = { // to queue the newest produced audio samples. // TODO: Consider adding pre- and post- rAF callbacks so that GL.newRenderingFrameStarted() and SDL.audio.queueNewAudioData() // do not need to be hardcoded into this function, but can be more generic. - if (typeof SDL == 'object' && SDL.audio && SDL.audio.queueNewAudioData) SDL.audio.queueNewAudioData(); + if (typeof SDL == 'object') SDL.audio?.queueNewAudioData?.(); Browser.mainLoop.scheduler(); } diff --git a/src/library_ccall.js b/src/library_ccall.js index 05d96fb73bea4..0c73ff7ecaaaa 100644 --- a/src/library_ccall.js +++ b/src/library_ccall.js @@ -86,7 +86,7 @@ addToLibrary({ return convertReturnValue(ret); } #if ASYNCIFY - var asyncMode = opts && opts.async; + var asyncMode = opts?.async; #endif #if ASYNCIFY == 1 diff --git a/src/library_dylink.js b/src/library_dylink.js index aa78f6b712ddc..7685f113c7975 100644 --- a/src/library_dylink.js +++ b/src/library_dylink.js @@ -218,9 +218,7 @@ var LibraryDylink = { } #endif - if (!GOT[symName]) { - GOT[symName] = new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': true}); - } + GOT[symName] ||= new WebAssembly.Global({'value': '{{{ POINTER_WASM_TYPE }}}', 'mutable': true}); if (replace || GOT[symName].value == 0) { #if DYLINK_DEBUG == 2 dbg(`updateGOT: before: ${symName} : ${GOT[symName].value}`); @@ -710,7 +708,7 @@ var LibraryDylink = { if (!(prop in stubs)) { var resolved; stubs[prop] = function() { - if (!resolved) resolved = resolveSymbol(prop); + resolved ||= resolveSymbol(prop); return resolved.apply(null, arguments); }; } @@ -895,9 +893,7 @@ var LibraryDylink = { dbg(`setDylinkStackLimits for '${name}'`); #endif var lib = LDSO.loadedLibsByName[name]; - if (lib.exports['__set_stack_limits']) { - lib.exports['__set_stack_limits']({{{ to64("stackTop") }}}, {{{ to64("stackMax") }}}); - } + lib.exports['__set_stack_limits']?.({{{ to64("stackTop") }}}, {{{ to64("stackMax") }}}); } }, #endif diff --git a/src/library_eventloop.js b/src/library_eventloop.js index b6a71bd07d7ff..8bbc0883074cf 100644 --- a/src/library_eventloop.js +++ b/src/library_eventloop.js @@ -24,7 +24,7 @@ LibraryJSEventLoop = { // Just like setImmediate but returns an i32 that can be passed back // to wasm rather than a JS object. $setImmediateWrapped: (func) => { - if (!setImmediateWrapped.mapping) setImmediateWrapped.mapping = []; + setImmediateWrapped.mapping ||= []; var id = setImmediateWrapped.mapping.length; setImmediateWrapped.mapping[id] = setImmediate(() => { setImmediateWrapped.mapping[id] = undefined; diff --git a/src/library_exceptions.js b/src/library_exceptions.js index d97e704149efd..bfe919e890fe5 100644 --- a/src/library_exceptions.js +++ b/src/library_exceptions.js @@ -228,7 +228,7 @@ var LibraryExceptions = { $findMatchingCatch: (args) => { var thrown = #if EXCEPTION_STACK_TRACES - exceptionLast && exceptionLast.excPtr; + exceptionLast?.excPtr; #else exceptionLast; #endif diff --git a/src/library_exports.js b/src/library_exports.js index 3bf963c490a00..385d3c684e4fb 100644 --- a/src/library_exports.js +++ b/src/library_exports.js @@ -16,7 +16,7 @@ addToLibrary({ // Record the created function pointer to each function object, // so that if the same function pointer is obtained several times, // the same address will be returned. - if (!exportedFunc.ptr) exportedFunc.ptr = addFunction(exportedFunc); + exportedFunc.ptr ||= addFunction(exportedFunc); return exportedFunc.ptr; } #if ASSERTIONS diff --git a/src/library_fs.js b/src/library_fs.js index d5010632b67db..92880694e80f2 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -459,9 +459,7 @@ FS.staticInit();` + // override node's stream ops with the device's stream.stream_ops = device.stream_ops; // forward the open call - if (stream.stream_ops.open) { - stream.stream_ops.open(stream); - } + stream.stream_ops.open?.(stream); }, llseek() { throw new FS.ErrnoError({{{ cDefs.ESPIPE }}}); @@ -1607,7 +1605,7 @@ FS.staticInit();` + }, close(stream) { // flush any pending line data - if (output && output.buffer && output.buffer.length) { + if (output?.buffer?.length) { output({{{ charCode('\n') }}}); } }, diff --git a/src/library_fs_shared.js b/src/library_fs_shared.js index 0e9426cc9f46f..cdc9d9ef5df11 100644 --- a/src/library_fs_shared.js +++ b/src/library_fs_shared.js @@ -57,16 +57,16 @@ addToLibrary({ var dep = getUniqueRunDependency(`cp ${fullname}`); // might have several active requests for the same fullname function processData(byteArray) { function finish(byteArray) { - if (preFinish) preFinish(); + preFinish?.(); if (!dontCreateFile) { FS_createDataFile(parent, name, byteArray, canRead, canWrite, canOwn); } - if (onload) onload(); + onload?.(); removeRunDependency(dep); } #if !MINIMAL_RUNTIME if (FS_handledByPreloadPlugin(byteArray, fullname, finish, () => { - if (onerror) onerror(); + onerror?.(); removeRunDependency(dep); })) { return; diff --git a/src/library_glemu.js b/src/library_glemu.js index 190f01b262490..51cf48fa57c46 100644 --- a/src/library_glemu.js +++ b/src/library_glemu.js @@ -182,7 +182,7 @@ var LibraryGLEmulation = { _glEnable = _emscripten_glEnable = (cap) => { // Clean up the renderer on any change to the rendering state. The optimization of // skipping renderer setup is aimed at the case of multiple glDraw* right after each other - if (GLImmediate.lastRenderer) GLImmediate.lastRenderer.cleanup(); + GLImmediate.lastRenderer?.cleanup(); if (cap == 0xB60 /* GL_FOG */) { if (GLEmulation.fogEnabled != true) { GLImmediate.currentRenderer = null; // Fog parameter is part of the FFP shader state, we must re-lookup the renderer to use. @@ -231,7 +231,7 @@ var LibraryGLEmulation = { var glDisable = _glDisable; _glDisable = _emscripten_glDisable = (cap) => { - if (GLImmediate.lastRenderer) GLImmediate.lastRenderer.cleanup(); + GLImmediate.lastRenderer?.cleanup(); if (cap == 0xB60 /* GL_FOG */) { if (GLEmulation.fogEnabled != false) { GLImmediate.currentRenderer = null; // Fog parameter is part of the FFP shader state, we must re-lookup the renderer to use. @@ -559,7 +559,7 @@ var LibraryGLEmulation = { GL.programShaders = {}; var glAttachShader = _glAttachShader; _glAttachShader = _emscripten_glAttachShader = (program, shader) => { - if (!GL.programShaders[program]) GL.programShaders[program] = []; + GL.programShaders[program] ||= []; GL.programShaders[program].push(shader); glAttachShader(program, shader); }; @@ -1998,16 +1998,14 @@ var LibraryGLEmulation = { var attrib = GLImmediate.clientAttributes[name]; if (!attrib) { for (var i = 0; i <= name; i++) { // keep flat - if (!GLImmediate.clientAttributes[i]) { - GLImmediate.clientAttributes[i] = { - name, - size, - type, - stride, - pointer, - offset: 0 - }; - } + GLImmediate.clientAttributes[i] ||= { + name, + size, + type, + stride, + pointer, + offset: 0 + }; } } else { attrib.name = name; @@ -2925,7 +2923,7 @@ var LibraryGLEmulation = { #if GL_ASSERTIONS warnOnce('Rendering from planar client-side vertex arrays. This is a very slow emulation path! Use interleaved vertex arrays for best performance.'); #endif - if (!GLImmediate.restrideBuffer) GLImmediate.restrideBuffer = _malloc(GL.MAX_TEMP_BUFFER_SIZE); + GLImmediate.restrideBuffer ||= _malloc(GL.MAX_TEMP_BUFFER_SIZE); var start = GLImmediate.restrideBuffer; bytes = 0; // calculate restrided offsets and total size @@ -3539,7 +3537,7 @@ var LibraryGLEmulation = { $emulGlBindVertexArray: (vao) => { // undo vao-related things, wipe the slate clean, both for vao of 0 or an actual vao GLEmulation.currentVao = null; // make sure the commands we run here are not recorded - if (GLImmediate.lastRenderer) GLImmediate.lastRenderer.cleanup(); + GLImmediate.lastRenderer?.cleanup(); _glBindBuffer(GLctx.ARRAY_BUFFER, 0); // XXX if one was there before we were bound? _glBindBuffer(GLctx.ELEMENT_ARRAY_BUFFER, 0); for (var vaa in GLEmulation.enabledVertexAttribArrays) { diff --git a/src/library_glew.js b/src/library_glew.js index ad231d6f206df..0c03085c3d8a3 100644 --- a/src/library_glew.js +++ b/src/library_glew.js @@ -99,9 +99,7 @@ var LibraryGLEW = { }, extensionIsSupported(name) { - if (!GLEW.extensions) { - GLEW.extensions = GL.getExtensions(); - } + GLEW.extensions ||= GL.getExtensions(); if (GLEW.extensions.includes(name)) return 1; diff --git a/src/library_glfw.js b/src/library_glfw.js index f9220763d24d3..ebdca229efd23 100644 --- a/src/library_glfw.js +++ b/src/library_glfw.js @@ -729,7 +729,7 @@ var LibraryGLFW = { refreshJoysticks: () => { // Produce a new Gamepad API sample if we are ticking a new game frame, or if not using emscripten_set_main_loop() at all to drive animation. if (Browser.mainLoop.currentFrameNumber !== GLFW.lastGamepadStateFrame || !Browser.mainLoop.currentFrameNumber) { - GLFW.lastGamepadState = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads : []); + GLFW.lastGamepadState = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads || []); GLFW.lastGamepadStateFrame = Browser.mainLoop.currentFrameNumber; for (var joy = 0; joy < GLFW.lastGamepadState.length; ++joy) { @@ -1469,9 +1469,7 @@ var LibraryGLFW = { glfwExtensionSupported__deps: ['glGetString'], glfwExtensionSupported: (extension) => { - if (!GLFW.extensions) { - GLFW.extensions = GL.getExtensions(); - } + GLFW.extensions ||= GL.getExtensions(); if (GLFW.extensions.includes(extension)) return 1; @@ -1489,9 +1487,7 @@ var LibraryGLFW = { #if USE_GLFW == 3 glfwGetVersionString: () => { - if (!GLFW.versionString) { - GLFW.versionString = stringToNewUTF8("3.2.1 JS WebGL Emscripten"); - } + GLFW.versionString ||= stringToNewUTF8("3.2.1 JS WebGL Emscripten"); return GLFW.versionString; }, @@ -1545,9 +1541,7 @@ var LibraryGLFW = { }, glfwGetMonitorName: (mon) => { - if (!GLFW.monitorString) { - GLFW.monitorString = stringToNewUTF8("HTML5 WebGL Canvas"); - } + GLFW.monitorString ||= stringToNewUTF8("HTML5 WebGL Canvas"); return GLFW.monitorString; }, diff --git a/src/library_html5.js b/src/library_html5.js index 50f7a220f96e6..abbf7a458619b 100644 --- a/src/library_html5.js +++ b/src/library_html5.js @@ -234,7 +234,7 @@ var LibraryHTML5 = { if (!target) return ''; if (target == window) return '#window'; if (target == screen) return '#screen'; - return (target && target.nodeName) ? target.nodeName : ''; + return target?.nodeName || ''; }, fullscreenEnabled() { @@ -1070,7 +1070,7 @@ var LibraryHTML5 = { // If transitioning to windowed mode, report info about the element that just was fullscreen. var reportedElement = isFullscreen ? fullscreenElement : JSEvents.previousFullscreenElement; var nodeName = JSEvents.getNodeNameForTarget(reportedElement); - var id = (reportedElement && reportedElement.id) ? reportedElement.id : ''; + var id = reportedElement?.id || ''; stringToUTF8(nodeName, eventStruct + {{{ C_STRUCTS.EmscriptenFullscreenChangeEvent.nodeName }}}, {{{ cDefs.EM_HTML5_LONG_STRING_LEN_BYTES }}}); stringToUTF8(id, eventStruct + {{{ C_STRUCTS.EmscriptenFullscreenChangeEvent.id }}}, {{{ cDefs.EM_HTML5_LONG_STRING_LEN_BYTES }}}); {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenFullscreenChangeEvent.elementWidth, 'reportedElement ? reportedElement.clientWidth : 0', 'i32') }}}; @@ -1550,7 +1550,7 @@ var LibraryHTML5 = { emscripten_enter_soft_fullscreen__proxy: 'sync', emscripten_enter_soft_fullscreen: (target, fullscreenStrategy) => { #if !DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR - if (!target) target = '#canvas'; + target ||= '#canvas'; #endif target = findEventTarget(target); if (!target) return {{{ cDefs.EMSCRIPTEN_RESULT_UNKNOWN_TARGET }}}; @@ -1608,7 +1608,7 @@ var LibraryHTML5 = { emscripten_exit_soft_fullscreen__deps: ['$restoreOldWindowedStyle'], emscripten_exit_soft_fullscreen__proxy: 'sync', emscripten_exit_soft_fullscreen: () => { - if (restoreOldWindowedStyle) restoreOldWindowedStyle(); + restoreOldWindowedStyle?.(); restoreOldWindowedStyle = null; return {{{ cDefs.EMSCRIPTEN_RESULT_SUCCESS }}}; @@ -1655,7 +1655,7 @@ var LibraryHTML5 = { #endif {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenPointerlockChangeEvent.isActive, 'isPointerlocked', 'i32') }}}; var nodeName = JSEvents.getNodeNameForTarget(pointerLockElement); - var id = (pointerLockElement && pointerLockElement.id) ? pointerLockElement.id : ''; + var id = pointerLockElement?.id || ''; stringToUTF8(nodeName, eventStruct + {{{ C_STRUCTS.EmscriptenPointerlockChangeEvent.nodeName }}}, {{{ cDefs.EM_HTML5_LONG_STRING_LEN_BYTES }}}); stringToUTF8(id, eventStruct + {{{ C_STRUCTS.EmscriptenPointerlockChangeEvent.id }}}, {{{ cDefs.EM_HTML5_LONG_STRING_LEN_BYTES }}}); }, @@ -2323,7 +2323,7 @@ var LibraryHTML5 = { if (!canvas.controlTransferredOffscreen) { #endif var autoResizeViewport = false; - if (canvas.GLctxObject && canvas.GLctxObject.GLctx) { + if (canvas.GLctxObject?.GLctx) { var prevViewport = canvas.GLctxObject.GLctx.getParameter(0xBA2 /* GL_VIEWPORT */); // TODO: Perhaps autoResizeViewport should only be true if FBO 0 is currently active? autoResizeViewport = (prevViewport[0] === 0 && prevViewport[1] === 0 && prevViewport[2] === canvas.width && prevViewport[3] === canvas.height); diff --git a/src/library_html5_webgl.js b/src/library_html5_webgl.js index 4a70b543c7424..c0e984bc4dd62 100644 --- a/src/library_html5_webgl.js +++ b/src/library_html5_webgl.js @@ -31,10 +31,10 @@ var LibraryHtml5WebGL = { } HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.alpha }}}>>2)] = - HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.depth }}}>>2)] = - HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.antialias }}}>>2)] = - HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.premultipliedAlpha }}}>>2)] = - HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.majorVersion }}}>>2)] = + HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.depth }}}>>2)] = + HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.antialias }}}>>2)] = + HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.premultipliedAlpha }}}>>2)] = + HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.majorVersion }}}>>2)] = HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.enableExtensionsByDefault }}}>>2)] = 1; #if PTHREADS @@ -473,7 +473,7 @@ var LibraryHtml5WebGL = { emscripten_webgl_get_vertex_attrib_o__proxy: 'sync_on_current_webgl_context_thread', emscripten_webgl_get_vertex_attrib_o: (index, param) => { var obj = GLctx.getVertexAttrib(index, param); - return obj && obj.name; + return obj?.name; }, emscripten_webgl_get_vertex_attrib_v__proxy: 'sync_on_current_webgl_context_thread', @@ -502,7 +502,7 @@ var LibraryHtml5WebGL = { emscripten_webgl_get_parameter_o__proxy: 'sync_on_current_webgl_context_thread', emscripten_webgl_get_parameter_o: (param) => { var obj = GLctx.getParameter(param); - return obj && obj.name; + return obj?.name; }, emscripten_webgl_get_parameter_utf8__deps: ['$stringToNewUTF8'], diff --git a/src/library_memfs.js b/src/library_memfs.js index 47fb74d830cd5..8c15b707d21c1 100644 --- a/src/library_memfs.js +++ b/src/library_memfs.js @@ -16,55 +16,53 @@ addToLibrary({ // no supported throw new FS.ErrnoError({{{ cDefs.EPERM }}}); } - if (!MEMFS.ops_table) { - MEMFS.ops_table = { - dir: { - node: { - getattr: MEMFS.node_ops.getattr, - setattr: MEMFS.node_ops.setattr, - lookup: MEMFS.node_ops.lookup, - mknod: MEMFS.node_ops.mknod, - rename: MEMFS.node_ops.rename, - unlink: MEMFS.node_ops.unlink, - rmdir: MEMFS.node_ops.rmdir, - readdir: MEMFS.node_ops.readdir, - symlink: MEMFS.node_ops.symlink - }, - stream: { - llseek: MEMFS.stream_ops.llseek - } - }, - file: { - node: { - getattr: MEMFS.node_ops.getattr, - setattr: MEMFS.node_ops.setattr - }, - stream: { - llseek: MEMFS.stream_ops.llseek, - read: MEMFS.stream_ops.read, - write: MEMFS.stream_ops.write, - allocate: MEMFS.stream_ops.allocate, - mmap: MEMFS.stream_ops.mmap, - msync: MEMFS.stream_ops.msync - } + MEMFS.ops_table ||= { + dir: { + node: { + getattr: MEMFS.node_ops.getattr, + setattr: MEMFS.node_ops.setattr, + lookup: MEMFS.node_ops.lookup, + mknod: MEMFS.node_ops.mknod, + rename: MEMFS.node_ops.rename, + unlink: MEMFS.node_ops.unlink, + rmdir: MEMFS.node_ops.rmdir, + readdir: MEMFS.node_ops.readdir, + symlink: MEMFS.node_ops.symlink }, - link: { - node: { - getattr: MEMFS.node_ops.getattr, - setattr: MEMFS.node_ops.setattr, - readlink: MEMFS.node_ops.readlink - }, - stream: {} + stream: { + llseek: MEMFS.stream_ops.llseek + } + }, + file: { + node: { + getattr: MEMFS.node_ops.getattr, + setattr: MEMFS.node_ops.setattr }, - chrdev: { - node: { - getattr: MEMFS.node_ops.getattr, - setattr: MEMFS.node_ops.setattr - }, - stream: FS.chrdev_stream_ops + stream: { + llseek: MEMFS.stream_ops.llseek, + read: MEMFS.stream_ops.read, + write: MEMFS.stream_ops.write, + allocate: MEMFS.stream_ops.allocate, + mmap: MEMFS.stream_ops.mmap, + msync: MEMFS.stream_ops.msync } - }; - } + }, + link: { + node: { + getattr: MEMFS.node_ops.getattr, + setattr: MEMFS.node_ops.setattr, + readlink: MEMFS.node_ops.readlink + }, + stream: {} + }, + chrdev: { + node: { + getattr: MEMFS.node_ops.getattr, + setattr: MEMFS.node_ops.setattr + }, + stream: FS.chrdev_stream_ops + } + }; var node = FS.createNode(parent, name, mode, dev); if (FS.isDir(node.mode)) { node.node_ops = MEMFS.ops_table.dir.node; diff --git a/src/library_openal.js b/src/library_openal.js index e5b909bf8b9a6..b39961cf3b788 100644 --- a/src/library_openal.js +++ b/src/library_openal.js @@ -1886,7 +1886,7 @@ var LibraryOpenAL = { }; // The latest way to call getUserMedia() - if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { + if (navigator.mediaDevices?.getUserMedia) { navigator.mediaDevices .getUserMedia({audio: true}) .then(onSuccess) @@ -1911,11 +1911,11 @@ var LibraryOpenAL = { // This clean-up might be unnecessary (paranoid) ? // May happen if user hasn't decided to grant or deny input - if (c.mediaStreamSourceNode) c.mediaStreamSourceNode.disconnect(); - if (c.mergerNode) c.mergerNode.disconnect(); - if (c.splitterNode) c.splitterNode.disconnect(); + c.mediaStreamSourceNode?.disconnect(); + c.mergerNode?.disconnect(); + c.splitterNode?.disconnect(); // May happen if user hasn't decided to grant or deny input - if (c.scriptProcessorNode) c.scriptProcessorNode.disconnect(); + c.scriptProcessorNode?.disconnect(); if (c.mediaStream) { // Disabling the microphone of the browser. // Without this operation, the red dot on the browser tab page will remain. diff --git a/src/library_pthread.js b/src/library_pthread.js index 509832f5ad947..328dacdf9a949 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -773,8 +773,8 @@ var LibraryPThread = { transferredCanvasNames = '{{{ OFFSCREENCANVASES_TO_PTHREAD }}}'; } else #endif - if (transferredCanvasNames) transferredCanvasNames = UTF8ToString(transferredCanvasNames).trim(); - if (transferredCanvasNames) transferredCanvasNames = transferredCanvasNames.split(','); + transferredCanvasNames &&= UTF8ToString(transferredCanvasNames).trim(); + transferredCanvasNames &&= transferredCanvasNames.split(','); #if GL_DEBUG dbg(`pthread_create: transferredCanvasNames="${transferredCanvasNames}"`); #endif diff --git a/src/library_sdl.js b/src/library_sdl.js index b85f81e259a43..8d40ab872cac5 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -1506,7 +1506,7 @@ var LibrarySDL = { } } var audio = /** @type {HTMLMediaElement} */ (SDL.music.audio); - if (audio) audio.pause(); + audio?.pause(); SDL.music.audio = undefined; }, @@ -1728,7 +1728,7 @@ var LibrarySDL = { if (title) { _emscripten_set_window_title(title); } - icon = icon && UTF8ToString(icon); + icon &&= UTF8ToString(icon); }, // TODO @@ -1749,9 +1749,7 @@ var LibrarySDL = { SDL_GetKeyName__proxy: 'sync', SDL_GetKeyName__deps: ['$stringToNewUTF8'], SDL_GetKeyName: (key) => { - if (!SDL.keyName) { - SDL.keyName = stringToNewUTF8('unknown key'); - } + SDL.keyName ||= stringToNewUTF8('unknown key'); return SDL.keyName; }, @@ -1802,9 +1800,7 @@ var LibrarySDL = { SDL_GetError__proxy: 'sync', SDL_GetError__deps: ['$stringToNewUTF8'], SDL_GetError: () => { - if (!SDL.errorMessage) { - SDL.errorMessage = stringToNewUTF8("unknown SDL-emscripten error"); - } + SDL.errorMessage ||= stringToNewUTF8("unknown SDL-emscripten error"); return SDL.errorMessage; }, @@ -2397,7 +2393,7 @@ var LibrarySDL = { #if ASYNCIFY var sleepCallback = () => { - if (SDL.audio && SDL.audio.queueNewAudioData) SDL.audio.queueNewAudioData(); + SDL.audio?.queueNewAudioData?.(); }; Asyncify.sleepCallbacks.push(sleepCallback); SDL.audio.callbackRemover = () => { @@ -2936,13 +2932,13 @@ var LibrarySDL = { Mix_PauseMusic__proxy: 'sync', Mix_PauseMusic: () => { var audio = /** @type {HTMLMediaElement} */ (SDL.music.audio); - if (audio) audio.pause(); + audio?.pause(); }, Mix_ResumeMusic__proxy: 'sync', Mix_ResumeMusic: () => { var audio = SDL.music.audio; - if (audio) audio.play(); + audio?.play(); }, Mix_HaltMusic__proxy: 'sync', @@ -2981,7 +2977,7 @@ var LibrarySDL = { return count; } var info = SDL.channels[channel]; - if (info && info.audio && !info.audio.paused) { + if (info?.audio && !info.audio.paused) { return 1; } return 0; @@ -2997,7 +2993,7 @@ var LibrarySDL = { } /** @type {{ audio: HTMLMediaElement }} */ var info = SDL.channels[channel]; - if (info && info.audio) { + if (info?.audio) { info.audio.pause(); } else { //err(`Mix_Pause: no sound found for channel: ${channel}`); @@ -3015,14 +3011,14 @@ var LibrarySDL = { return pausedCount; } var info = SDL.channels[channel]; - if (info && info.audio && info.audio.paused) { + if (info?.audio?.paused) { return 1; } return 0; }, Mix_PausedMusic__proxy: 'sync', - Mix_PausedMusic: () => (SDL.music.audio && SDL.music.audio.paused) ? 1 : 0, + Mix_PausedMusic: () => SDL.music.audio?.paused ? 1 : 0, // http://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_33.html#SEC33 Mix_Resume__proxy: 'sync', @@ -3034,7 +3030,7 @@ var LibrarySDL = { return; } var info = SDL.channels[channel]; - if (info && info.audio) info.audio.play(); + if (info?.audio) info.audio.play(); }, // SDL TTF @@ -3293,7 +3289,7 @@ var LibrarySDL = { SDL_GL_SwapBuffers__proxy: 'sync', SDL_GL_SwapBuffers: () => { - if (Browser.doSwapBuffers) Browser.doSwapBuffers(); // in workers, this is used to send out a buffered frame + Browser.doSwapBuffers?.(); // in workers, this is used to send out a buffered frame }, // SDL 2 diff --git a/src/library_strings.js b/src/library_strings.js index 0773172718ba9..72e4f46746485 100644 --- a/src/library_strings.js +++ b/src/library_strings.js @@ -364,9 +364,7 @@ addToLibrary({ assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!'); #endif // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed. - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 0x7FFFFFFF; - } + maxBytesToWrite ??= 0x7FFFFFFF; if (maxBytesToWrite < 2) return 0; maxBytesToWrite -= 2; // Null terminator. var startPtr = outPtr; @@ -439,9 +437,7 @@ addToLibrary({ assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!'); #endif // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed. - if (maxBytesToWrite === undefined) { - maxBytesToWrite = 0x7FFFFFFF; - } + maxBytesToWrite ??= 0x7FFFFFFF; if (maxBytesToWrite < 4) return 0; var startPtr = outPtr; var endPtr = startPtr + maxBytesToWrite - 4; diff --git a/src/library_syscall.js b/src/library_syscall.js index 66eb936346ef2..215124fcfa3d5 100644 --- a/src/library_syscall.js +++ b/src/library_syscall.js @@ -715,9 +715,7 @@ var SyscallsLibrary = { __syscall_getdents64__deps: ['$stringToUTF8'], __syscall_getdents64: (fd, dirp, count) => { var stream = SYSCALLS.getStreamFromFD(fd) - if (!stream.getdents) { - stream.getdents = FS.readdir(stream.path); - } + stream.getdents ||= FS.readdir(stream.path); var struct_size = {{{ C_STRUCTS.dirent.__size__ }}}; var pos = 0; diff --git a/src/library_trace.js b/src/library_trace.js index f83292e2b9550..91cf3b5965a94 100644 --- a/src/library_trace.js +++ b/src/library_trace.js @@ -63,9 +63,7 @@ var LibraryTracing = { req.addEventListener('load', function() { var blob = new Blob([this.responseText], { type: 'text/javascript' }); var worker = new Worker(window.URL.createObjectURL(blob)); - if (ready) { - ready.call(scope, worker); - } + ready?.call(scope, worker); }, req); req.open("get", url, false); req.send(); diff --git a/src/library_wasi.js b/src/library_wasi.js index 860439fced02d..9551f69dcc1d7 100644 --- a/src/library_wasi.js +++ b/src/library_wasi.js @@ -29,7 +29,7 @@ var WasiLibrary = { PThread.terminateAllThreads(); #endif #if expectToReceiveOnModule('onExit') - if (Module['onExit']) Module['onExit'](code); + Module['onExit']?.(code); #endif ABORT = true; } @@ -551,7 +551,7 @@ var WasiLibrary = { }); }); #else - if (stream.stream_ops && stream.stream_ops.fsync) { + if (stream.stream_ops?.fsync) { return stream.stream_ops.fsync(stream); } return 0; // we can't do anything synchronously; the in-memory FS is already synced to diff --git a/src/library_wasmfs.js b/src/library_wasmfs.js index a5fc072d5a51b..3087abe038658 100644 --- a/src/library_wasmfs.js +++ b/src/library_wasmfs.js @@ -512,9 +512,8 @@ FS.init(); })), $FS_create__deps: ['$FS_mknod'], - $FS_create: (path, mode) => { - // Default settings copied from the legacy JS FS API. - mode = mode !== undefined ? mode : 438 /* 0666 */; + // Default settings copied from the legacy JS FS API. + $FS_create: (path, mode = 438 /* 0666 */) => { mode &= {{{ cDefs.S_IALLUGO }}}; mode |= {{{ cDefs.S_IFREG }}}; return FS_mknod(path, mode, 0); @@ -541,8 +540,7 @@ FS.init(); }), $FS_mkdir__deps: ['_wasmfs_mkdir'], - $FS_mkdir: (path, mode) => FS.handleError(withStackSave(() => { - mode = mode !== undefined ? mode : 511 /* 0777 */; + $FS_mkdir: (path, mode = 511 /* 0777 */) => FS.handleError(withStackSave(() => { var buffer = stringToUTF8OnStack(path); return __wasmfs_mkdir(buffer, mode); })), diff --git a/src/library_webgl.js b/src/library_webgl.js index ab7157bc8b0d7..c894f3dbe8a72 100644 --- a/src/library_webgl.js +++ b/src/library_webgl.js @@ -1157,7 +1157,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; // Active Emscripten GL layer context object. GL.currentContext = GL.contexts[contextHandle]; // Active WebGL context object. - Module.ctx = GLctx = GL.currentContext && GL.currentContext.GLctx; + Module.ctx = GLctx = GL.currentContext?.GLctx; return !(contextHandle && !GLctx); }, @@ -1194,7 +1194,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; initExtensions: (context) => { // If this function is called without a specific context object, init the // extensions of the currently active context. - if (!context) context = GL.currentContext; + context ||= GL.currentContext; if (context.initExtensionsDone) return; context.initExtensionsDone = true; diff --git a/src/library_websocket.js b/src/library_websocket.js index 25349b65f1a4b..4ea12baaa66e1 100644 --- a/src/library_websocket.js +++ b/src/library_websocket.js @@ -137,7 +137,7 @@ var LibraryWebSocket = { // if (thread == {{{ cDefs.EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD }}} || // (thread == _pthread_self()) return emscripten_websocket_set_onopen_callback_on_calling_thread(socketId, userData, callbackFunc); - if (!WS.socketEvent) WS.socketEvent = _malloc(1024); // TODO: sizeof(EmscriptenWebSocketCloseEvent), which is the largest event struct + WS.socketEvent ||= _malloc(1024); // TODO: sizeof(EmscriptenWebSocketCloseEvent), which is the largest event struct var socket = WS.sockets[socketId]; if (!socket) { @@ -163,7 +163,7 @@ var LibraryWebSocket = { emscripten_websocket_set_onerror_callback_on_thread__deps: ['$WS'], emscripten_websocket_set_onerror_callback_on_thread__proxy: 'sync', emscripten_websocket_set_onerror_callback_on_thread: (socketId, userData, callbackFunc, thread) => { - if (!WS.socketEvent) WS.socketEvent = _malloc(1024); // TODO: sizeof(EmscriptenWebSocketCloseEvent), which is the largest event struct + WS.socketEvent ||= _malloc(1024); // TODO: sizeof(EmscriptenWebSocketCloseEvent), which is the largest event struct var socket = WS.sockets[socketId]; if (!socket) { @@ -189,7 +189,7 @@ var LibraryWebSocket = { emscripten_websocket_set_onclose_callback_on_thread__deps: ['$WS', '$stringToUTF8'], emscripten_websocket_set_onclose_callback_on_thread__proxy: 'sync', emscripten_websocket_set_onclose_callback_on_thread: (socketId, userData, callbackFunc, thread) => { - if (!WS.socketEvent) WS.socketEvent = _malloc(1024); // TODO: sizeof(EmscriptenWebSocketCloseEvent), which is the largest event struct + WS.socketEvent ||= _malloc(1024); // TODO: sizeof(EmscriptenWebSocketCloseEvent), which is the largest event struct var socket = WS.sockets[socketId]; if (!socket) { @@ -218,7 +218,7 @@ var LibraryWebSocket = { emscripten_websocket_set_onmessage_callback_on_thread__deps: ['$WS', '$stringToNewUTF8', 'malloc', 'free'], emscripten_websocket_set_onmessage_callback_on_thread__proxy: 'sync', emscripten_websocket_set_onmessage_callback_on_thread: (socketId, userData, callbackFunc, thread) => { - if (!WS.socketEvent) WS.socketEvent = _malloc(1024); // TODO: sizeof(EmscriptenWebSocketCloseEvent), which is the largest event struct + WS.socketEvent ||= _malloc(1024); // TODO: sizeof(EmscriptenWebSocketCloseEvent), which is the largest event struct var socket = WS.sockets[socketId]; if (!socket) { diff --git a/src/library_wget.js b/src/library_wget.js index a69f41271c346..7ee54b0b129a8 100644 --- a/src/library_wget.js +++ b/src/library_wget.js @@ -232,9 +232,7 @@ var LibraryWget = { emscripten_async_wget2_abort__proxy: 'sync', emscripten_async_wget2_abort: (handle) => { var http = wget.wgetRequests[handle]; - if (http) { - http.abort(); - } + http?.abort(); }, }; diff --git a/src/library_workerfs.js b/src/library_workerfs.js index 9b34d39f5616e..974f57f8ac472 100644 --- a/src/library_workerfs.js +++ b/src/library_workerfs.js @@ -28,9 +28,7 @@ addToLibrary({ // are just their corresponding parts within their given path, // rather than incremental aggregates which include their parent's // directories. - if (!createdParents[curr]) { - createdParents[curr] = WORKERFS.createNode(parent, parts[i], WORKERFS.DIR_MODE, 0); - } + createdParents[curr] ||= WORKERFS.createNode(parent, parts[i], WORKERFS.DIR_MODE, 0); parent = createdParents[curr]; } return parent; diff --git a/src/memoryprofiler.js b/src/memoryprofiler.js index 7008abae839bc..d42cbeaabbc08 100644 --- a/src/memoryprofiler.js +++ b/src/memoryprofiler.js @@ -190,7 +190,7 @@ var emscriptenMemoryProfiler = { if (!self.pagePreRunIsFinished) self.sizeOfPreRunAllocatedPtr[ptr] = size; var loc = new Error().stack.toString(); - if (!self.allocationsAtLoc[loc]) self.allocationsAtLoc[loc] = [0, 0, self.filterCallstackForMalloc(loc)]; + self.allocationsAtLoc[loc] ||= [0, 0, self.filterCallstackForMalloc(loc)]; self.allocationsAtLoc[loc][0] += 1; self.allocationsAtLoc[loc][1] += size; self.allocationSitePtrs[ptr] = loc; @@ -247,7 +247,7 @@ var emscriptenMemoryProfiler = { emscriptenMemoryProfiler.recordStackWatermark(); // Add a tracking mechanism to detect when VFS loading is complete. - if (!Module['preRun']) Module['preRun'] = []; + Module['preRun'] ||= []; Module['preRun'].push(emscriptenMemoryProfiler.onPreloadComplete); if (emscriptenMemoryProfiler.hookStackAlloc && typeof stackAlloc == 'function') { @@ -563,9 +563,7 @@ var emscriptenMemoryProfiler = { stack = self.filterCallstackAfterFunctionName(stack, s); } sbrk.filteredStack = stack; - if (!uniqueSources[stack]) { - uniqueSources[stack] = self.hsvToRgb(Object.keys(uniqueSources).length * 0.618033988749895 % 1, 0.5, 0.95); - } + uniqueSources[stack] ||= self.hsvToRgb(Object.keys(uniqueSources).length * 0.618033988749895 % 1, 0.5, 0.95); self.drawContext.fillStyle = sbrk.color = uniqueSources[stack]; self.fillRect(sbrk.begin, sbrk.end, 0.25); } diff --git a/src/parseTools.js b/src/parseTools.js index de45c421d09f3..ef91fc93198bb 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -767,7 +767,7 @@ function isSymbolNeeded(symName) { function makeRemovedModuleAPIAssert(moduleName, localName) { if (!ASSERTIONS) return ''; - if (!localName) localName = moduleName; + localName ||= moduleName; return `legacyModuleProp('${moduleName}', '${localName}');`; } @@ -779,7 +779,7 @@ function checkReceiving(name) { // Make code to receive a value on the incoming Module object. function makeModuleReceive(localName, moduleName) { - if (!moduleName) moduleName = localName; + moduleName ||= localName; checkReceiving(moduleName); let ret = ''; if (expectToReceiveOnModule(moduleName)) { @@ -801,7 +801,7 @@ function makeModuleReceiveExpr(name, defaultValue) { } function makeModuleReceiveWithVar(localName, moduleName, defaultValue, noAssert) { - if (!moduleName) moduleName = localName; + moduleName ||= localName; checkReceiving(moduleName); let ret = `var ${localName}`; if (!expectToReceiveOnModule(moduleName)) { diff --git a/src/polyfill/bigint64array.js b/src/polyfill/bigint64array.js index 5828b609bad9d..e237e19d2224c 100644 --- a/src/polyfill/bigint64array.js +++ b/src/polyfill/bigint64array.js @@ -39,9 +39,7 @@ if (typeof globalThis.BigInt64Array === "undefined") { var proxy = new Proxy( { slice(min, max) { - if (max === undefined) { - max = array.length; - } + max ??= array.length; var new_buf = array.slice(min * 2, max * 2); return createBigInt64Array(new_buf); }, @@ -64,9 +62,7 @@ if (typeof globalThis.BigInt64Array === "undefined") { return proxy; }, set(source, targetOffset) { - if (targetOffset === undefined) { - targetOffset = 0; - } + targetOffset ??= 0; if (2 * (source.length + targetOffset) > array.length) { // This is the Chrome error message // Firefox: "invalid or out-of-range index" diff --git a/src/postamble.js b/src/postamble.js index a674ee95efb83..c3e3a906a2641 100644 --- a/src/postamble.js +++ b/src/postamble.js @@ -295,7 +295,7 @@ function checkUnflushedContent() { var stream = info.object; var rdev = stream.rdev; var tty = TTY.ttys[rdev]; - if (tty && tty.output && tty.output.length) { + if (tty?.output?.length) { has = true; } }); diff --git a/src/preamble.js b/src/preamble.js index 3fa3129fa47db..ee38da9aa4d99 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -362,9 +362,7 @@ function addRunDependency(id) { runDependencies++; #if expectToReceiveOnModule('monitorRunDependencies') - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies); - } + Module['monitorRunDependencies']?.(runDependencies); #endif #if ASSERTIONS @@ -402,9 +400,7 @@ function removeRunDependency(id) { runDependencies--; #if expectToReceiveOnModule('monitorRunDependencies') - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies); - } + Module['monitorRunDependencies']?.(runDependencies); #endif #if ASSERTIONS @@ -431,9 +427,7 @@ function removeRunDependency(id) { /** @param {string|number=} what */ function abort(what) { #if expectToReceiveOnModule('onAbort') - if (Module['onAbort']) { - Module['onAbort'](what); - } + Module['onAbort']?.(what); #endif what = 'Aborted(' + what + ')'; @@ -763,9 +757,7 @@ function instantiateSync(file, info) { } } } - if (!module) { - module = new WebAssembly.Module(binary); - } + module ||= new WebAssembly.Module(binary); if (ENVIRONMENT_IS_NODE && !hasCached) { #if RUNTIME_DEBUG dbg('NODE_CODE_CACHING: saving module'); diff --git a/src/proxyClient.js b/src/proxyClient.js index 80c7a3392e126..49c3f1c9eab81 100644 --- a/src/proxyClient.js +++ b/src/proxyClient.js @@ -134,9 +134,7 @@ var SUPPORT_BASE64_EMBEDDING; // Worker var filename; -if (!filename) { - filename = '<<< filename >>>'; -} +filename ||= '<<< filename >>>'; var workerURL = filename; if (SUPPORT_BASE64_EMBEDDING) { @@ -174,7 +172,7 @@ worker.onmessage = (event) => { //dump('\nclient got ' + JSON.stringify(event.data).substr(0, 150) + '\n'); if (!workerResponded) { workerResponded = true; - if (Module.setStatus) Module.setStatus(''); + Module.setStatus?.(''); if (SUPPORT_BASE64_EMBEDDING && workerURL !== filename) URL.revokeObjectURL(workerURL); } @@ -205,7 +203,7 @@ worker.onmessage = (event) => { case 'resize': { Module.canvas.width = data.width; Module.canvas.height = data.height; - if (Module.ctx && Module.ctx.getImageData) Module.canvasData = Module.ctx.getImageData(0, 0, data.width, data.height); + if (Module.ctx?.getImageData) Module.canvasData = Module.ctx.getImageData(0, 0, data.width, data.height); worker.postMessage({ target: 'canvas', boundingClientRect: cloneObject(Module.canvas.getBoundingClientRect()) }); break; } diff --git a/src/proxyWorker.js b/src/proxyWorker.js index 341d85e26aa67..c48f5af7d15a5 100644 --- a/src/proxyWorker.js +++ b/src/proxyWorker.js @@ -65,7 +65,7 @@ function EventListener() { this.listeners = {}; this.addEventListener = function addEventListener(event, func) { - if (!this.listeners[event]) this.listeners[event] = []; + this.listeners[event] ||= []; this.listeners[event].push(func); }; @@ -211,8 +211,8 @@ document.createElement = (what) => { canvas.style = new PropertyBag(); canvas.exitPointerLock = () => {}; - canvas.width_ = canvas.width_ || 0; - canvas.height_ = canvas.height_ || 0; + canvas.width_ ||= 0; + canvas.height_ ||= 0; Object.defineProperty(canvas, 'width', { set: (value) => { canvas.width_ = value; @@ -344,7 +344,7 @@ var clientFrameId = 0; var postMainLoop = Module['postMainLoop']; Module['postMainLoop'] = () => { - if (postMainLoop) postMainLoop(); + postMainLoop?.(); // frame complete, send a frame id postMessage({ target: 'tick', id: frameId++ }); commandBuffer = []; @@ -372,7 +372,7 @@ var messageResenderTimeout = null; var calledMain = false; // Set calledMain to true during postRun which happens onces main returns -if (!Module['postRun']) Module['postRun'] = []; +Module['postRun'] ||= []; if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']]; Module['postRun'].push(() => { calledMain = true; }); diff --git a/src/runtime_math.js b/src/runtime_math.js index 9a14fd5afe5c9..6bc3658001682 100644 --- a/src/runtime_math.js +++ b/src/runtime_math.js @@ -27,7 +27,7 @@ if (!Math.fround) { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 #if POLYFILL_OLD_MATH_FUNCTIONS || MIN_CHROME_VERSION < 38 || MIN_EDGE_VERSION < 12 || MIN_FIREFOX_VERSION < 31 || MIN_IE_VERSION != TARGET_NOT_SUPPORTED // || MIN_NODE_VERSION < 0.12 -if (!Math.clz32) Math.clz32 = (x) => { +Math.clz32 ||= (x) => { var n = 32; var y = x >> 16; if (y) { n -= 16; x = y; } y = x >> 8; if (y) { n -= 8; x = y; } @@ -40,7 +40,7 @@ if (!Math.clz32) Math.clz32 = (x) => { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc #if POLYFILL_OLD_MATH_FUNCTIONS || MIN_CHROME_VERSION < 38 || MIN_EDGE_VERSION < 12 || MIN_FIREFOX_VERSION < 25 || MIN_IE_VERSION != TARGET_NOT_SUPPORTED || MIN_SAFARI_VERSION < 80000 // || MIN_NODE_VERSION < 0.12 -if (!Math.trunc) Math.trunc = (x) => { +Math.trunc ||= (x) => { return x < 0 ? Math.ceil(x) : Math.floor(x); }; #endif diff --git a/src/utility.js b/src/utility.js index 4dd851f57cccc..926e63292ef03 100644 --- a/src/utility.js +++ b/src/utility.js @@ -64,7 +64,7 @@ function warnOnce(a, msg) { a = false; } if (!a) { - if (!warnOnce.msgs) warnOnce.msgs = {}; + warnOnce.msgs ||= {}; if (msg in warnOnce.msgs) return; warnOnce.msgs[msg] = true; warn(msg); @@ -244,7 +244,7 @@ globalThis.Benchmarker = function() { } lastTime = now; ids.push(id); - totals[id] = totals[id] || 0; + totals[id] ||= 0; }; this.stop = function(id) { const now = Date.now(); diff --git a/src/webGLWorker.js b/src/webGLWorker.js index 9495cddb32004..37ce56d8c0cae 100644 --- a/src/webGLWorker.js +++ b/src/webGLWorker.js @@ -738,7 +738,7 @@ function WebGLWorker() { } if (!obj[name]) { obj[name] = { what: type, name: fullname, size, location: -1, type: getTypeId(m[1]) }; - if (vec) vec.push(name); + vec?.push(name); } }); }); diff --git a/src/worker.js b/src/worker.js index 2fbadcfa61991..3a863ffaf0ef2 100644 --- a/src/worker.js +++ b/src/worker.js @@ -271,11 +271,9 @@ function handleMessage(e) { } catch(ex) { #if ASSERTIONS err(`worker.js onmessage() captured an uncaught exception: ${ex}`); - if (ex && ex.stack) err(ex.stack); + if (ex?.stack) err(ex.stack); #endif - if (Module['__emscripten_thread_crashed']) { - Module['__emscripten_thread_crashed'](); - } + Module['__emscripten_thread_crashed']?.(); throw ex; } }; diff --git a/test/code_size/embind_val_wasm.json b/test/code_size/embind_val_wasm.json index e39498e113e16..16e68da20856e 100644 --- a/test/code_size/embind_val_wasm.json +++ b/test/code_size/embind_val_wasm.json @@ -1,10 +1,10 @@ { "a.html": 673, "a.html.gz": 431, - "a.js": 7498, - "a.js.gz": 3142, + "a.js": 7468, + "a.js.gz": 3137, "a.wasm": 11501, "a.wasm.gz": 5766, - "total": 19672, - "total_gz": 9339 + "total": 19642, + "total_gz": 9334 } diff --git a/test/code_size/hello_webgl2_wasm.json b/test/code_size/hello_webgl2_wasm.json index ab759aa8f560d..9787ed384d29d 100644 --- a/test/code_size/hello_webgl2_wasm.json +++ b/test/code_size/hello_webgl2_wasm.json @@ -1,10 +1,10 @@ { "a.html": 569, "a.html.gz": 379, - "a.js": 4699, + "a.js": 4697, "a.js.gz": 2419, "a.wasm": 10482, "a.wasm.gz": 6728, - "total": 15750, + "total": 15748, "total_gz": 9526 } diff --git a/test/code_size/hello_webgl2_wasm2js.json b/test/code_size/hello_webgl2_wasm2js.json index 53e4e8293c1a4..e08b0d88420f1 100644 --- a/test/code_size/hello_webgl2_wasm2js.json +++ b/test/code_size/hello_webgl2_wasm2js.json @@ -1,10 +1,10 @@ { "a.html": 567, "a.html.gz": 379, - "a.js": 18025, - "a.js.gz": 8138, + "a.js": 18022, + "a.js.gz": 8135, "a.mem": 3123, "a.mem.gz": 2693, - "total": 21715, - "total_gz": 11210 + "total": 21712, + "total_gz": 11207 } diff --git a/test/code_size/hello_webgl_wasm.json b/test/code_size/hello_webgl_wasm.json index 6f8993d4c0b93..2e4829eb0c443 100644 --- a/test/code_size/hello_webgl_wasm.json +++ b/test/code_size/hello_webgl_wasm.json @@ -1,10 +1,10 @@ { "a.html": 569, "a.html.gz": 379, - "a.js": 4185, - "a.js.gz": 2243, + "a.js": 4183, + "a.js.gz": 2241, "a.wasm": 10482, "a.wasm.gz": 6728, - "total": 15236, - "total_gz": 9350 + "total": 15234, + "total_gz": 9348 } diff --git a/test/code_size/hello_webgl_wasm2js.json b/test/code_size/hello_webgl_wasm2js.json index 6c5356eec9de9..cfb5f473586fd 100644 --- a/test/code_size/hello_webgl_wasm2js.json +++ b/test/code_size/hello_webgl_wasm2js.json @@ -1,10 +1,10 @@ { "a.html": 567, "a.html.gz": 379, - "a.js": 17502, - "a.js.gz": 7961, + "a.js": 17499, + "a.js.gz": 7958, "a.mem": 3123, "a.mem.gz": 2693, - "total": 21192, - "total_gz": 11033 + "total": 21189, + "total_gz": 11030 } diff --git a/test/common.py b/test/common.py index 2686cd392100f..4bd2c5d162a65 100644 --- a/test/common.py +++ b/test/common.py @@ -865,6 +865,7 @@ def setUp(self): ) if node_version < emcc_min_node_version: self.emcc_args += building.get_emcc_node_flags(node_version) + self.emcc_args.append('-Wno-transpile') self.v8_args = ['--wasm-staging'] self.env = {} diff --git a/test/other/metadce/test_metadce_cxx_ctors1.jssize b/test/other/metadce/test_metadce_cxx_ctors1.jssize index e202083536e21..f7de8c8f36813 100644 --- a/test/other/metadce/test_metadce_cxx_ctors1.jssize +++ b/test/other/metadce/test_metadce_cxx_ctors1.jssize @@ -1 +1 @@ -24942 +24852 diff --git a/test/other/metadce/test_metadce_cxx_ctors2.jssize b/test/other/metadce/test_metadce_cxx_ctors2.jssize index c0961f5ba509c..a3a77bab4ca90 100644 --- a/test/other/metadce/test_metadce_cxx_ctors2.jssize +++ b/test/other/metadce/test_metadce_cxx_ctors2.jssize @@ -1 +1 @@ -24910 +24820 diff --git a/test/other/metadce/test_metadce_cxx_except.jssize b/test/other/metadce/test_metadce_cxx_except.jssize index aebfd05dc8490..10dc0b8e36a77 100644 --- a/test/other/metadce/test_metadce_cxx_except.jssize +++ b/test/other/metadce/test_metadce_cxx_except.jssize @@ -1 +1 @@ -29072 +28982 diff --git a/test/other/metadce/test_metadce_cxx_except_wasm.jssize b/test/other/metadce/test_metadce_cxx_except_wasm.jssize index d4ee2d039b69d..ad0c2442ca532 100644 --- a/test/other/metadce/test_metadce_cxx_except_wasm.jssize +++ b/test/other/metadce/test_metadce_cxx_except_wasm.jssize @@ -1 +1 @@ -24717 +24627 diff --git a/test/other/metadce/test_metadce_cxx_mangle.jssize b/test/other/metadce/test_metadce_cxx_mangle.jssize index aebfd05dc8490..10dc0b8e36a77 100644 --- a/test/other/metadce/test_metadce_cxx_mangle.jssize +++ b/test/other/metadce/test_metadce_cxx_mangle.jssize @@ -1 +1 @@ -29072 +28982 diff --git a/test/other/metadce/test_metadce_cxx_noexcept.jssize b/test/other/metadce/test_metadce_cxx_noexcept.jssize index e202083536e21..f7de8c8f36813 100644 --- a/test/other/metadce/test_metadce_cxx_noexcept.jssize +++ b/test/other/metadce/test_metadce_cxx_noexcept.jssize @@ -1 +1 @@ -24942 +24852 diff --git a/test/other/metadce/test_metadce_cxx_wasmfs.jssize b/test/other/metadce/test_metadce_cxx_wasmfs.jssize index 7005e6285220e..ade9bcb31b6b1 100644 --- a/test/other/metadce/test_metadce_cxx_wasmfs.jssize +++ b/test/other/metadce/test_metadce_cxx_wasmfs.jssize @@ -1 +1 @@ -12373 +12302 diff --git a/test/other/metadce/test_metadce_files_js_fs.jssize b/test/other/metadce/test_metadce_files_js_fs.jssize index a73bbfeebbc02..57af5b62eb9f6 100644 --- a/test/other/metadce/test_metadce_files_js_fs.jssize +++ b/test/other/metadce/test_metadce_files_js_fs.jssize @@ -1 +1 @@ -19841 +19751 diff --git a/test/other/metadce/test_metadce_files_wasmfs.jssize b/test/other/metadce/test_metadce_files_wasmfs.jssize index a78151a823d6a..a05231e9dae55 100644 --- a/test/other/metadce/test_metadce_files_wasmfs.jssize +++ b/test/other/metadce/test_metadce_files_wasmfs.jssize @@ -1 +1 @@ -7003 +6931 diff --git a/test/other/metadce/test_metadce_hello_O0.jssize b/test/other/metadce/test_metadce_hello_O0.jssize index a468ec4926e81..827a89b5afc0a 100644 --- a/test/other/metadce/test_metadce_hello_O0.jssize +++ b/test/other/metadce/test_metadce_hello_O0.jssize @@ -1 +1 @@ -23303 +23185 diff --git a/test/other/metadce/test_metadce_hello_O1.jssize b/test/other/metadce/test_metadce_hello_O1.jssize index ee615ca7ce263..d01797194d005 100644 --- a/test/other/metadce/test_metadce_hello_O1.jssize +++ b/test/other/metadce/test_metadce_hello_O1.jssize @@ -1 +1 @@ -7996 +7840 diff --git a/test/other/metadce/test_metadce_hello_O2.jssize b/test/other/metadce/test_metadce_hello_O2.jssize index 2d096bf3ffb3b..7b6ceee2dc6b8 100644 --- a/test/other/metadce/test_metadce_hello_O2.jssize +++ b/test/other/metadce/test_metadce_hello_O2.jssize @@ -1 +1 @@ -5658 +5586 diff --git a/test/other/metadce/test_metadce_hello_O3.jssize b/test/other/metadce/test_metadce_hello_O3.jssize index 517210186167b..38627a6f04242 100644 --- a/test/other/metadce/test_metadce_hello_O3.jssize +++ b/test/other/metadce/test_metadce_hello_O3.jssize @@ -1 +1 @@ -5505 +5432 diff --git a/test/other/metadce/test_metadce_hello_Os.jssize b/test/other/metadce/test_metadce_hello_Os.jssize index 517210186167b..38627a6f04242 100644 --- a/test/other/metadce/test_metadce_hello_Os.jssize +++ b/test/other/metadce/test_metadce_hello_Os.jssize @@ -1 +1 @@ -5505 +5432 diff --git a/test/other/metadce/test_metadce_hello_Oz.jssize b/test/other/metadce/test_metadce_hello_Oz.jssize index 1e04daa79731f..f135ff2699136 100644 --- a/test/other/metadce/test_metadce_hello_Oz.jssize +++ b/test/other/metadce/test_metadce_hello_Oz.jssize @@ -1 +1 @@ -5472 +5399 diff --git a/test/other/metadce/test_metadce_hello_dylink.jssize b/test/other/metadce/test_metadce_hello_dylink.jssize index 25f6eae2ef9a2..90a82aebf3af2 100644 --- a/test/other/metadce/test_metadce_hello_dylink.jssize +++ b/test/other/metadce/test_metadce_hello_dylink.jssize @@ -1 +1 @@ -14652 +14602 diff --git a/test/other/metadce/test_metadce_hello_export_nothing.jssize b/test/other/metadce/test_metadce_hello_export_nothing.jssize index e3f38c7d9c1a7..31a1f807b4325 100644 --- a/test/other/metadce/test_metadce_hello_export_nothing.jssize +++ b/test/other/metadce/test_metadce_hello_export_nothing.jssize @@ -1 +1 @@ -4277 +4218 diff --git a/test/other/metadce/test_metadce_hello_wasmfs.jssize b/test/other/metadce/test_metadce_hello_wasmfs.jssize index 517210186167b..38627a6f04242 100644 --- a/test/other/metadce/test_metadce_hello_wasmfs.jssize +++ b/test/other/metadce/test_metadce_hello_wasmfs.jssize @@ -1 +1 @@ -5505 +5432 diff --git a/test/other/metadce/test_metadce_libcxxabi_message_O3.jssize b/test/other/metadce/test_metadce_libcxxabi_message_O3.jssize index 271c1c2767bb4..e36a980879169 100644 --- a/test/other/metadce/test_metadce_libcxxabi_message_O3.jssize +++ b/test/other/metadce/test_metadce_libcxxabi_message_O3.jssize @@ -1 +1 @@ -4785 +4714 diff --git a/test/other/metadce/test_metadce_libcxxabi_message_O3_standalone.jssize b/test/other/metadce/test_metadce_libcxxabi_message_O3_standalone.jssize index 1bb1968232739..9b27f33d6dc4b 100644 --- a/test/other/metadce/test_metadce_libcxxabi_message_O3_standalone.jssize +++ b/test/other/metadce/test_metadce_libcxxabi_message_O3_standalone.jssize @@ -1 +1 @@ -4836 +4765 diff --git a/test/other/metadce/test_metadce_mem_O3.jssize b/test/other/metadce/test_metadce_mem_O3.jssize index cbfc4b5f88368..59a313f153a2d 100644 --- a/test/other/metadce/test_metadce_mem_O3.jssize +++ b/test/other/metadce/test_metadce_mem_O3.jssize @@ -1 +1 @@ -5684 +5613 diff --git a/test/other/metadce/test_metadce_mem_O3_grow.jssize b/test/other/metadce/test_metadce_mem_O3_grow.jssize index 7a97c1e5f2e34..e939cbd4dee07 100644 --- a/test/other/metadce/test_metadce_mem_O3_grow.jssize +++ b/test/other/metadce/test_metadce_mem_O3_grow.jssize @@ -1 +1 @@ -6007 +5936 diff --git a/test/other/metadce/test_metadce_mem_O3_grow_standalone.jssize b/test/other/metadce/test_metadce_mem_O3_grow_standalone.jssize index 5e775da84e764..4a31c303ce865 100644 --- a/test/other/metadce/test_metadce_mem_O3_grow_standalone.jssize +++ b/test/other/metadce/test_metadce_mem_O3_grow_standalone.jssize @@ -1 +1 @@ -5401 +5329 diff --git a/test/other/metadce/test_metadce_mem_O3_standalone.jssize b/test/other/metadce/test_metadce_mem_O3_standalone.jssize index e650e5aa24adc..75f2c8da44d47 100644 --- a/test/other/metadce/test_metadce_mem_O3_standalone.jssize +++ b/test/other/metadce/test_metadce_mem_O3_standalone.jssize @@ -1 +1 @@ -5330 +5259 diff --git a/test/other/metadce/test_metadce_mem_O3_standalone_lib.jssize b/test/other/metadce/test_metadce_mem_O3_standalone_lib.jssize index 1bb1968232739..9b27f33d6dc4b 100644 --- a/test/other/metadce/test_metadce_mem_O3_standalone_lib.jssize +++ b/test/other/metadce/test_metadce_mem_O3_standalone_lib.jssize @@ -1 +1 @@ -4836 +4765 diff --git a/test/other/metadce/test_metadce_mem_O3_standalone_narg.jssize b/test/other/metadce/test_metadce_mem_O3_standalone_narg.jssize index 1bb1968232739..9b27f33d6dc4b 100644 --- a/test/other/metadce/test_metadce_mem_O3_standalone_narg.jssize +++ b/test/other/metadce/test_metadce_mem_O3_standalone_narg.jssize @@ -1 +1 @@ -4836 +4765 diff --git a/test/other/metadce/test_metadce_mem_O3_standalone_narg_flto.jssize b/test/other/metadce/test_metadce_mem_O3_standalone_narg_flto.jssize index 1bb1968232739..9b27f33d6dc4b 100644 --- a/test/other/metadce/test_metadce_mem_O3_standalone_narg_flto.jssize +++ b/test/other/metadce/test_metadce_mem_O3_standalone_narg_flto.jssize @@ -1 +1 @@ -4836 +4765 diff --git a/test/other/metadce/test_metadce_minimal_O0.jssize b/test/other/metadce/test_metadce_minimal_O0.jssize index 8b7498fd7a790..8fe0c3733cf5a 100644 --- a/test/other/metadce/test_metadce_minimal_O0.jssize +++ b/test/other/metadce/test_metadce_minimal_O0.jssize @@ -1 +1 @@ -19794 +19833 diff --git a/test/other/metadce/test_metadce_minimal_pthreads.jssize b/test/other/metadce/test_metadce_minimal_pthreads.jssize index 5504f32335c0b..afc579d041020 100644 --- a/test/other/metadce/test_metadce_minimal_pthreads.jssize +++ b/test/other/metadce/test_metadce_minimal_pthreads.jssize @@ -1 +1 @@ -13956 +13844 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index 76e26a7c5e517..232d2361b33b3 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -58578 +58453 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 b660d7809ac4f..54fb4a9a3cc50 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 @@ -31938 +31795 diff --git a/test/other/test_unoptimized_code_size_strict.js.size b/test/other/test_unoptimized_code_size_strict.js.size index a517e768780f3..8f19627af1dda 100644 --- a/test/other/test_unoptimized_code_size_strict.js.size +++ b/test/other/test_unoptimized_code_size_strict.js.size @@ -1 +1 @@ -57291 +57309 diff --git a/test/test_other.py b/test/test_other.py index 57167b2a2ce9a..55dbe46f05c61 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -12784,7 +12784,7 @@ def test_config_closure_compiler(self): def test_node_unhandled_rejection(self): create_file('pre.js', ''' async function foo() { - var a = missing; + abort("this error will become an unhandled rejection"); } async function doReject() { return foo(); @@ -12805,7 +12805,7 @@ def test_node_unhandled_rejection(self): self.build('main.c', emcc_args=['--pre-js=pre.js', '-sNODEJS_CATCH_REJECTION']) output = self.run_js('main.js', assert_returncode=NON_ZERO) self.assertContained('unhandledRejection', read_file('main.js')) - self.assertContained('ReferenceError: missing is not defined', output) + self.assertContained('RuntimeError: Aborted(this error will become an unhandled rejection)', output) self.assertContained('at foo (', output) # Without NODEJS_CATCH_REJECTION we expect node to log the unhandled rejection @@ -12818,7 +12818,7 @@ def test_node_unhandled_rejection(self): self.skipTest('old behaviour of node JS cannot be tested on node v15 or above') output = self.run_js('main.js') - self.assertContained('ReferenceError: missing is not defined', output) + self.assertContained('RuntimeError: Aborted(this error will become an unhandled rejection)', output) self.assertContained('at foo (', output) def test_default_pthread_stack_size(self): @@ -13652,10 +13652,10 @@ def test_reproduce(self): self.assertTextDataIdentical(expected, response) def test_min_browser_version(self): - err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Werror', '-sWASM_BIGINT', '-sMIN_SAFARI_VERSION=120000']) + err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Wno-transpile', '-Werror', '-sWASM_BIGINT', '-sMIN_SAFARI_VERSION=120000']) self.assertContained('emcc: error: MIN_SAFARI_VERSION=120000 is not compatible with WASM_BIGINT (150000 or above required)', err) - err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Werror', '-pthread', '-sMIN_CHROME_VERSION=73']) + err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Wno-transpile', '-Werror', '-pthread', '-sMIN_CHROME_VERSION=73']) self.assertContained('emcc: error: MIN_CHROME_VERSION=73 is not compatible with pthreads (74 or above required)', err) def test_signext_lowering(self): diff --git a/tools/link.py b/tools/link.py index ab0db3722e851..0212d07e4478e 100644 --- a/tools/link.py +++ b/tools/link.py @@ -1127,18 +1127,22 @@ def phase_linker_setup(options, state, newargs): setup_environment_settings() if options.use_closure_compiler != 0 and settings.POLYFILL: - # Emscripten requires certain ES6 constructs by default in library code - # - https://caniuse.com/let : EDGE:12 FF:44 CHROME:49 SAFARI:11 - # - https://caniuse.com/const : EDGE:12 FF:36 CHROME:49 SAFARI:11 - # - https://caniuse.com/arrow-functions: : EDGE:12 FF:22 CHROME:45 SAFARI:10 - # - https://caniuse.com/mdn-javascript_builtins_object_assign: - # EDGE:12 FF:34 CHROME:45 SAFARI:9 + # Emscripten requires certain ES6+ constructs by default in library code + # - (various ES6 operators available in all browsers listed below) + # - https://caniuse.com/mdn-javascript_operators_nullish_coalescing: + # EDGE:80 FF:72 CHROME:80 SAFARI:13.1 NODE:14 + # - https://caniuse.com/mdn-javascript_operators_optional_chaining: + # EDGE:80 FF:74 CHROME:80 SAFARI:13.1 NODE:14 + # - https://caniuse.com/mdn-javascript_operators_logical_or_assignment: + # EDGE:85 FF:79 CHROME:85 SAFARI:14 NODE:16 # Taking the highest requirements gives is our minimum: - # Max Version: EDGE:12 FF:44 CHROME:49 SAFARI:11 - settings.TRANSPILE_TO_ES5 = (settings.MIN_EDGE_VERSION < 12 or - settings.MIN_FIREFOX_VERSION < 44 or - settings.MIN_CHROME_VERSION < 49 or - settings.MIN_SAFARI_VERSION < 110000 or + # Max Version: EDGE:85 FF:79 CHROME:85 SAFARI:14 NODE:16 + # TODO: replace this with feature matrix in the future. + settings.TRANSPILE_TO_ES5 = (settings.MIN_EDGE_VERSION < 85 or + settings.MIN_FIREFOX_VERSION < 79 or + settings.MIN_CHROME_VERSION < 85 or + settings.MIN_SAFARI_VERSION < 140000 or + settings.MIN_NODE_VERSION < 160000 or settings.MIN_IE_VERSION != 0x7FFFFFFF) if options.use_closure_compiler is None and settings.TRANSPILE_TO_ES5: