Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 089c67d2ead9aa2f3bae6677cba0698b1b7b529a
https://github.com/WebKit/WebKit/commit/089c67d2ead9aa2f3bae6677cba0698b1b7b529a
Author: Sosuke Suzuki <[email protected]>
Date: 2026-03-15 (Sun, 15 Mar 2026)
Changed paths:
A JSTests/microbenchmarks/compare-strict-eq-untyped-fast-only.js
A JSTests/microbenchmarks/compare-strict-eq-untyped-mixed.js
A JSTests/stress/compare-strict-eq-untyped-bit-trick-edges.js
A JSTests/stress/compare-strict-eq-untyped-verify-path.js
M Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
Log Message:
-----------
[JSC] FTL `CompareStrictEq(Untyped)` should use DFG's JSValue bit-trick fast
path
https://bugs.webkit.org/show_bug.cgi?id=309884
Reviewed by Yusuke Suzuki.
FTL's compileCompareStrictEq for UntypedUse went through genericJSValueCompare,
which only has a fast path for the Int32-vs-Int32 case and falls back to a C++
call (operationCompareStrictEq) for everything else. DFG's
genericJSValueNonPeepholeStrictEq has long had a smarter fast path that handles
most non-Double pairs inline using a JSValue tagging bit-trick:
1. (left + 1<<49) | (right + 1<<49) >= 1<<50 detects "either is Double" in
a single branch: Int32's NumberTag wraps to zero, Cell/Other gain only
bit 49, and the smallest encoded Double (0.0 = 0x0002...) lands exactly
at the 1<<50 threshold.
2. If the 64-bit JSValue encodings are equal, the result is true. This
covers Int32==Int32, true==true, null==null, undefined==undefined, and
same-Cell.
3. (left | right) is Cell detects "both are Cells", the only remaining case
where bit-unequal values can still be strictly equal (String content
compare, HeapBigInt content compare).
4. Otherwise false.
This patch ports that trick to FTL in B3 IR, replacing the genericJSValueCompare
call. The FTL code was previously slower than DFG for patterns like
`x === null`, `a === undefined`, or `obj === obj` when type prediction was
mixed enough to leave UntypedUse -- a tier-up regression.
TipOfTree Patched
compare-strict-eq-untyped-mixed 166.8733+-9.4982 ^
138.8151+-5.3950 ^ definitely 1.2021x faster
compare-strict-eq-untyped-fast-only 40.0483+-6.0252 ^
20.1260+-0.3528 ^ definitely 1.9899x faster
Tests: JSTests/microbenchmarks/compare-strict-eq-untyped-fast-only.js
JSTests/microbenchmarks/compare-strict-eq-untyped-mixed.js
JSTests/stress/compare-strict-eq-untyped-bit-trick-edges.js
JSTests/stress/compare-strict-eq-untyped-verify-path.js
* JSTests/microbenchmarks/compare-strict-eq-untyped-fast-only.js: Added.
(eq):
* JSTests/microbenchmarks/compare-strict-eq-untyped-mixed.js: Added.
(eq):
* JSTests/stress/compare-strict-eq-untyped-bit-trick-edges.js: Added.
(eq):
(makeString):
(fnA):
(fnB):
(neq):
(checkNeq):
* JSTests/stress/compare-strict-eq-untyped-verify-path.js: Added.
(eq):
(runMatrix):
(stressCheck):
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
Canonical link: https://commits.webkit.org/309285@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications