Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3a21b755052629c9adea4138b7dceddba7dc686b
https://github.com/WebKit/WebKit/commit/3a21b755052629c9adea4138b7dceddba7dc686b
Author: Sosuke Suzuki <[email protected]>
Date: 2026-04-03 (Fri, 03 Apr 2026)
Changed paths:
A JSTests/microbenchmarks/string-indexof-flat-dynamic-onechar.js
A JSTests/microbenchmarks/string-indexof-rope-dynamic-onechar-hit.js
A JSTests/microbenchmarks/string-indexof-rope-dynamic-onechar.js
A JSTests/stress/string-indexof-rope-walk-dynamic-onechar.js
M Source/JavaScriptCore/dfg/DFGOperations.cpp
Log Message:
-----------
[JSC] Use `tryFindOneChar` for dynamic one-char search string in DFG/FTL
`String#indexOf` call
https://bugs.webkit.org/show_bug.cgi?id=311168
Reviewed by Yusuke Suzuki.
DFG/FTL pick operationStringIndexOfWithOneChar only when the search
string is a compile-time constant. A variable search string that is one
character at runtime falls into operationStringIndexOf and
operationStringIndexOfWithIndex, which resolve the rope base
unconditionally via view().
Check argument->length() == 1 at runtime and call tryFindOneChar,
matching what stringIndexOfImpl already does in the C++ slow path. The
WithIndex variant hoists length/pos computation above view() so the
early-out and rope-walk guard run before resolving the base; a side
effect is that indexOf(ch, str.length) on a rope now returns -1 without
flattening.
TipOfTree
Patched
string-indexof-rope-dynamic-onechar-hit 85.9583+-26.4181 ^
1.9109+-2.1950 ^ definitely 44.9820x faster
string-indexof-rope-dynamic-onechar 170.7843+-66.1731 ^
68.8757+-17.0792 ^ definitely 2.4796x faster
Tests: JSTests/microbenchmarks/string-indexof-flat-dynamic-onechar.js
JSTests/microbenchmarks/string-indexof-rope-dynamic-onechar-hit.js
JSTests/microbenchmarks/string-indexof-rope-dynamic-onechar.js
JSTests/stress/string-indexof-rope-walk-dynamic-onechar.js
* JSTests/microbenchmarks/string-indexof-flat-dynamic-onechar.js: Added.
(test):
* JSTests/microbenchmarks/string-indexof-rope-dynamic-onechar-hit.js: Added.
(test):
* JSTests/microbenchmarks/string-indexof-rope-dynamic-onechar.js: Added.
(test):
* JSTests/stress/string-indexof-rope-walk-dynamic-onechar.js: Added.
(shouldBe):
(flatten):
(mkShallowRope):
(mkWideRope):
(indexOf2):
(indexOf3):
(mkBoundRope):
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
Canonical link: https://commits.webkit.org/310511@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications