Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6846e1b56c4bc4ddd76bf051f21007aa18b45696
https://github.com/WebKit/WebKit/commit/6846e1b56c4bc4ddd76bf051f21007aa18b45696
Author: Sosuke Suzuki <[email protected]>
Date: 2026-05-09 (Sat, 09 May 2026)
Changed paths:
A JSTests/microbenchmarks/array-indexof-string-16bit-different-length.js
A JSTests/microbenchmarks/array-indexof-string-8bit-different-length.js
M Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
Log Message:
-----------
[JSC] Optimize FTL `Array#indexOf` / `Array#includes` string fast loop
https://bugs.webkit.org/show_bug.cgi?id=313904
Reviewed by Yusuke Suzuki.
The FTL StringUse loop in compileArrayIndexOfOrArrayIncludes used unsure()
for every branch in the per-element check chain. B3 ended up placing
loopNext / notFound / continuation between the element load and the cell /
string / rope checks, so the hot path took 2-3 taken forward branches per
iteration. This made the FTL inline loop ~1.5x slower than the DFG inline
loop and even slower than the operationArrayIndexOfString slow path.
This patch:
1. Adds usually()/rarely() hints so B3 lays out the per-element checks as
a straight-line fall-through sequence.
2. Compares lengths before testing the element's 8-bit flag (matching DFG),
so 16-bit elements with mismatching lengths stay in the fast loop
instead of bailing to the C++ slow path.
TipOfTree
Patched
array-indexof-string-8bit-different-length 573.6901+-21.8263 ^
340.6605+-21.3438 ^ definitely 1.6841x faster
array-indexof-string-16bit-different-length 404.8519+-3.2210 ^
347.9345+-23.4201 ^ definitely 1.1636x faster
Tests: JSTests/microbenchmarks/array-indexof-string-16bit-different-length.js
JSTests/microbenchmarks/array-indexof-string-8bit-different-length.js
* JSTests/microbenchmarks/array-indexof-string-16bit-different-length.js: Added.
(test):
* JSTests/microbenchmarks/array-indexof-string-8bit-different-length.js: Added.
(test):
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileArrayIndexOfOrArrayIncludes):
Canonical link: https://commits.webkit.org/312963@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications