Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 016fcfbca076fd98152cf0ad5d3d65c1ec695237
      
https://github.com/WebKit/WebKit/commit/016fcfbca076fd98152cf0ad5d3d65c1ec695237
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-07-22 (Wed, 22 Jul 2026)

  Changed paths:
    A JSTests/microbenchmarks/regexp-unicode-bmp-above-latin.js
    A JSTests/microbenchmarks/regexp-unicode-bmp-hangul-and-fullwidth.js
    A JSTests/microbenchmarks/regexp-unicode-latin-before-surrogate.js
    A JSTests/microbenchmarks/regexp-unicode-surrogate-pairs.js
    A JSTests/stress/regexp-unicode-bmp-fast-path-code-points.js
    M Source/JavaScriptCore/yarr/YarrJIT.cpp

  Log Message:
  -----------
  [YARR] `tryReadUnicodeChar` should take the BMP fast path for any 
non-surrogate character
https://bugs.webkit.org/show_bug.cgi?id=319943

Reviewed by Yusuke Suzuki.

tryReadUnicodeChar loads two code units at once and masks the pair with
0xfc00fc00, taking the inline BMP path only when the result is zero, i.e. only
when both code units are below U+0400. That path returns just the first code
unit, so the second one should not gate it: a first code unit that is not a
surrogate is a BMP code point on its own, whatever follows it.

Surrogates are U+D800-U+DFFF, so a first code unit with bit 15 clear can never
be one. Branch on that bit before masking. It is a single tbz on ARM64, so
U+0000-U+7FFF reaches the BMP path in fewer instructions than the pair-is-zero
test used to take, and the mask is only computed on the paths that need it. This
also recovers U+2000-U+23FF, which was on the fast path until 317399@main
corrected the mask from 0xdc00 to 0xfc00.

Failing the surrogate pair test does not mean the read is a surrogate at all, so
check the first code unit against the surrogate tag there as well. U+8000-U+FFFF
then stops calling the slow thunk too, and since that test sits behind the pair
test it only runs where the thunk used to be called.

The BMP test is no longer against zero, so the ARM64 and32AndSetFlags special
case goes away.

                                            Baseline           Patched

regexp-unicode-bmp-hangul-and-fullwidth 62.2569+-0.8130    44.1657+-1.3399   
definitely 1.4096x faster
regexp-unicode-bmp-above-latin          61.6626+-0.8342    43.9289+-0.4469   
definitely 1.4037x faster
regexp-unicode-latin-before-surrogate   62.2440+-0.9320    53.3576+-1.1463   
definitely 1.1665x faster
regexp-unicode-surrogate-pairs          45.8066+-1.4352    44.0832+-1.2427   
neutral

Tests: JSTests/microbenchmarks/regexp-unicode-bmp-above-latin.js
       JSTests/microbenchmarks/regexp-unicode-latin-before-surrogate.js
       JSTests/microbenchmarks/regexp-unicode-surrogate-pairs.js
       JSTests/stress/regexp-unicode-bmp-fast-path-code-points.js

* JSTests/microbenchmarks/regexp-unicode-bmp-above-latin.js: Added.
(splitmix32):
(makeString):
* JSTests/microbenchmarks/regexp-unicode-latin-before-surrogate.js: Added.
(splitmix32):
(makeString):
* JSTests/microbenchmarks/regexp-unicode-surrogate-pairs.js: Added.
(splitmix32):
(makeString):
* JSTests/stress/regexp-unicode-bmp-fast-path-code-points.js: Added.
(shouldBe):
(codePointsOf):
(i.const.first.of.codeUnits.const.second.of.followers.first.toString):
* Source/JavaScriptCore/yarr/YarrJIT.cpp:
(JSC::Yarr::tryReadUnicodeCharImpl):

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



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

Reply via email to