diff --git a/ChangeLog.md b/ChangeLog.md index 785f80d53087d..687277411713a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -48,6 +48,9 @@ See docs/process.md for more on how version tagging works. `--post-js` files will now be delayed until after module creation and after `main` runs. This matches the existing behaviour when using sync instantation (`-sWASM_ASYNC_COMPILATION=0`) but is an observable difference. (#23157) +- The `POLYFILL_OLD_MATH_FUNCTIONS` setting was removed. The browser versions + that require these polyfills are no longer supported by emscripten so the + polyfills should never be needed. (#23262) 3.1.74 - 12/14/24 ----------------- diff --git a/src/preamble.js b/src/preamble.js index 7ba3754e88051..6db7ff58b51a1 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -324,8 +324,6 @@ function addOnPostRun(cb) { __ATPOSTRUN__.unshift(cb); } -#include "runtime_math.js" - // A counter of dependencies for calling run(). If we need to // do asynchronous work before running, increment this and // decrement it. Incrementing must happen in a place like diff --git a/src/preamble_minimal.js b/src/preamble_minimal.js index a49ca40962d44..ab83b52cc90b7 100644 --- a/src/preamble_minimal.js +++ b/src/preamble_minimal.js @@ -85,7 +85,6 @@ var runtimeExited = false; var runtimeInitialized = false; #endif -#include "runtime_math.js" #include "memoryprofiler.js" #include "runtime_exceptions.js" #include "runtime_debug.js" diff --git a/src/runtime_math.js b/src/runtime_math.js deleted file mode 100644 index 999255167fae6..0000000000000 --- a/src/runtime_math.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright 2019 The Emscripten Authors - * SPDX-License-Identifier: MIT - */ - -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul -#if POLYFILL_OLD_MATH_FUNCTIONS || MIN_CHROME_VERSION < 28 || MIN_FIREFOX_VERSION < 20 || MIN_SAFARI_VERSION < 90000 // || MIN_NODE_VERSION < 0.12 -// || MIN_NODE_VERSION < 0.12 -// check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 ) -if (!Math.imul || Math.imul(0xffffffff, 5) !== -5) Math.imul = (a, b) => { - var ah = a >>> 16; - var al = a & 0xffff; - var bh = b >>> 16; - var bl = b & 0xffff; - return (al*bl + ((ah*bl + al*bh) << 16))|0; -}; -#endif - -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround -#if POLYFILL_OLD_MATH_FUNCTIONS || MIN_CHROME_VERSION < 38 || MIN_FIREFOX_VERSION < 26 || MIN_SAFARI_VERSION < 80000 // || MIN_NODE_VERSION < 0.12 -if (!Math.fround) { - var froundBuffer = new Float32Array(1); - Math.fround = (x) => { froundBuffer[0] = x; return froundBuffer[0] }; -} -#endif - -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 -#if POLYFILL_OLD_MATH_FUNCTIONS || MIN_CHROME_VERSION < 38 || MIN_FIREFOX_VERSION < 31 // || MIN_NODE_VERSION < 0.12 -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; } - y = x >> 4; if (y) { n -= 4; x = y; } - y = x >> 2; if (y) { n -= 2; x = y; } - y = x >> 1; if (y) return n - 2; - return n - x; -}; -#endif - -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc -#if POLYFILL_OLD_MATH_FUNCTIONS || MIN_CHROME_VERSION < 38 || MIN_FIREFOX_VERSION < 25 || MIN_SAFARI_VERSION < 80000 // || MIN_NODE_VERSION < 0.12 -Math.trunc ||= (x) => { - return x < 0 ? Math.ceil(x) : Math.floor(x); -}; -#endif - -#if ASSERTIONS -assert(Math.imul, 'This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'); -assert(Math.fround, 'This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'); -assert(Math.clz32, 'This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'); -assert(Math.trunc, 'This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'); -#endif diff --git a/test/test_other.py b/test/test_other.py index 59ef936fcbaea..192325d1468f9 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -4908,20 +4908,6 @@ def test_precompiled_headers(self, suffix): output = self.run_js('a.out.js') self.assertContained('|5|', output) - def test_LEGACY_VM_SUPPORT(self): - # when modern features are lacking, we can polyfill them or at least warn - create_file('pre.js', 'Math.imul = undefined;') - - def test(expected, opts): - print(opts) - self.run_process([EMCC, test_file('hello_world.c'), '--pre-js', 'pre.js'] + opts) - self.assertContained(expected, self.run_js('a.out.js', assert_returncode=0 if opts else NON_ZERO)) - - # when legacy is needed, we show an error indicating so - test('build with LEGACY_VM_SUPPORT', []) - # legacy + disabling wasm works - test('hello, world!', ['-sLEGACY_VM_SUPPORT', '-sWASM=0']) - @crossplatform def test_on_abort(self): expected_output = 'Module.onAbort was called' diff --git a/tools/link.py b/tools/link.py index 6c3ca352ff6d7..0f7888ee30a61 100644 --- a/tools/link.py +++ b/tools/link.py @@ -1157,9 +1157,6 @@ def phase_linker_setup(options, state, newargs): # noqa: C901, PLR0912, PLR0915 if settings.MINIMAL_RUNTIME and options.oformat == OFormat.HTML and not settings.PTHREADS: settings.USE_READY_PROMISE = 0 - if settings.WASM2JS and settings.LEGACY_VM_SUPPORT: - settings.POLYFILL_OLD_MATH_FUNCTIONS = 1 - check_browser_versions() if settings.MIN_NODE_VERSION >= 150000: @@ -1202,10 +1199,6 @@ def phase_linker_setup(options, state, newargs): # noqa: C901, PLR0912, PLR0915 diagnostics.warning('transpile', '-sEXCEPTION_STACK_TRACES requires an engine that support ES6 classes.') settings.EXCEPTION_STACK_TRACES = 0 - # Silently drop any individual backwards compatibility emulation flags that are known never to occur on browsers that support WebAssembly. - if not settings.WASM2JS: - settings.POLYFILL_OLD_MATH_FUNCTIONS = 0 - if settings.STB_IMAGE: state.append_link_flag('-lstb_image') settings.EXPORTED_FUNCTIONS += ['_stbi_load', '_stbi_load_from_memory', '_stbi_image_free']