Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3dfb0a4b80bec46492dede7339c6b72cbbba436e
      
https://github.com/WebKit/WebKit/commit/3dfb0a4b80bec46492dede7339c6b72cbbba436e
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-06-27 (Sat, 27 Jun 2026)

  Changed paths:
    A JSTests/microbenchmarks/global-atom-match-multi-chars-unicode-sets.js
    A JSTests/microbenchmarks/global-atom-match-multi-chars-unicode.js
    A JSTests/microbenchmarks/global-atom-match-one-char-unicode.js
    A JSTests/stress/regexp-unicode-atom-fast-path.js
    M Source/JavaScriptCore/yarr/YarrPattern.cpp

  Log Message:
  -----------
  [JSC] Enable RegExp atom fast path for unicode patterns
https://bugs.webkit.org/show_bug.cgi?id=317903

Reviewed by Yusuke Suzuki.

setupSpecificPattern() bails out early when the pattern has the /u or
/v flag, so a fixed-string pattern such as /ab/gu does not get its atom
extracted and hasValidAtom() stays false. This forces String#match,
String#split, String#replace and RegExp#exec/#test to call into Yarr
for every match instead of using the StringSearch / countMatchedCharacters
based fast paths in collectGlobalAtomMatches, stringSplitFast and
RegExp::matchInline.

Allow tryExtractAtom() to run for unicode patterns. The extracted atom
is restricted to non-surrogate BMP code units (U16_LENGTH == 1 and
!U_IS_SURROGATE), so a code-unit based StringSearch produces the same
matches as a unicode code-point based search: each atom character is a
single code point that can never overlap a surrogate pair in the input,
and the atom is non-empty so AdvanceStringIndex is never reached. V8
applies the same condition for its ATOM regexp type.

Keep the eitherUnicode() bail-out for the remaining SpecificPattern
kinds (leading/trailing spaces, newlines).

                                              Baseline                  Patched

global-atom-match-one-char-unicode          5.6361+-0.1098     ^      
0.5202+-0.0725        ^ definitely 10.8351x faster
global-atom-match-multi-chars-unicode       1.6494+-0.0645     ^      
0.8089+-0.0287        ^ definitely 2.0390x faster
global-atom-match-multi-chars-unicode-sets  1.6130+-0.0512     ^      
0.8415+-0.0447        ^ definitely 1.9169x faster

Tests: JSTests/microbenchmarks/global-atom-match-multi-chars-unicode-sets.js
       JSTests/microbenchmarks/global-atom-match-multi-chars-unicode.js
       JSTests/microbenchmarks/global-atom-match-one-char-unicode.js
       JSTests/stress/regexp-unicode-atom-fast-path.js

* JSTests/microbenchmarks/global-atom-match-multi-chars-unicode-sets.js: Added.
(test):
* JSTests/microbenchmarks/global-atom-match-multi-chars-unicode.js: Added.
(test):
* JSTests/microbenchmarks/global-atom-match-one-char-unicode.js: Added.
(test):
* JSTests/stress/regexp-unicode-atom-fast-path.js: Added.
(shouldBe):
(shouldBeArray):
(shouldBeArray.str.split):
(shouldBe.f):
* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::YarrPatternConstructor::extractSpecificPattern):

Canonical link: https://commits.webkit.org/315965@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to