Compute Math.sin/cos/tan/pow as the Windows CRT does

The last bit of these differs between glibc (or fdlibm) and the
Windows CRT, so one call told a page that a build claiming Windows ran
on Linux: against stock 152.0.4 on Windows, sin differed on 22, cos on
26 and tan on 30 of 1,670 inputs, pow on 45 of 1,410.

windows-crt-math.patch adds javascript.options.use_ucrt_math, which
routes them to ports of ucrtbase.dll's FMA3 code path
(browser/additions/js/src/builtin/UcrtMath*.c), keeping SpiderMonkey's
own pow fast paths. On 156 the pow hook sits in pow_libm_or_fdlibm, the
one place both callers already reach the platform pow. It is built
only for 64-bit non-Windows targets, without FP contraction. The
launcher turns it on for Windows identities on a non-Windows host,
where upstream did nothing; the TypeScript launcher does the same.

browser/tests/ucrt-math checks the C alone against ucrtbase.dll on
~127,000 results in the static job. The windows-crt-math guard checks
the browser against stock Windows Firefox cold, JIT-hot and constant
folded, with a pref-off control that must differ; a missing result
counts as a difference.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
coffeegrind123
2026-10-18 09:53:59 +03:00
co-authored by Claude Opus 5.5
parent 18604faea2
commit 580f4aee99
19 changed files with 1845 additions and 0 deletions
+10
View File
@@ -1289,6 +1289,16 @@ def launch_options(
else:
firefox_user_prefs.setdefault('ui.useOverlayScrollbars', 1)
# A Windows identity on another host: answers that come from the host
# build's platform code are set to what stock Windows Firefox gives. A
# Windows host already gives them, so nothing is set there.
if target_os == 'win' and _host_os_key() != 'win':
# Math.sin/cos/tan/pow: the last bit differs between glibc (or
# fdlibm) and the Windows CRT, so one call identifies the host OS.
# windows-crt-math.patch computes them as the CRT does; measured
# against stock 152.0.4 on Windows, 15,991 of 15,991 results match.
firefox_user_prefs.setdefault('javascript.options.use_ucrt_math', True)
# Per-character font fallback, LINUX ONLY. Gecko's GlobalFontFallback walks
# the shared font list for a family whose charmap covers the character; in a
# content process with async fallback on it hits the