Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ddf3655422ded3195d1f6f598a504cfcb2b1370c
      
https://github.com/WebKit/WebKit/commit/ddf3655422ded3195d1f6f598a504cfcb2b1370c
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-08-15 (Sat, 15 Aug 2026)

  Changed paths:
    A JSTests/microbenchmarks/regexp-lookbehind-unicode-bmp-body.js
    A JSTests/microbenchmarks/regexp-lookbehind-unicode-fixed.js
    A JSTests/microbenchmarks/regexp-lookbehind-unicode-variable.js
    A JSTests/microbenchmarks/regexp-u-flag-dotall-greedy.js
    A JSTests/stress/regexp-lookbehind-jit-unicode.js
    A JSTests/stress/regexp-unicode-any-character-inside-surrogate-pair.js
    M Source/JavaScriptCore/runtime/RegExp.cpp
    M Source/JavaScriptCore/yarr/YarrJIT.cpp

  Log Message:
  -----------
  [YARR] Compile lookbehinds in unicode patterns in the JIT
https://bugs.webkit.org/show_bug.cgi?id=321656

Reviewed by Daniel Liu.

319067@main still sent every pattern with a lookbehind and the u or v flag to 
the interpreter.

Two things were missing. reverseDisjunctionForBackward() now counts a fixed 
non-BMP character or
class as two code units, like setupAlternativeOffsets() does. A Backward term 
points at the last
code unit of its character, so on 16-bit subjects readCharacter() decodes it 
with the new
tryReadUnicodeCharBackward(). Inside a surrogate pair it reads errorCodePoint, 
like the forward
read does, so a lookbehind fails there as in V8; the interpreter is wrong at 
such positions and
in several other unicode lookbehinds (bug 317275), so the new test runs on the 
JIT only.

The any-character class (. with the s flag, [\s\S]) did not reject 
errorCodePoint, so it matched
half of a pair even before this patch, e.g. 
/(?!\u{1F600})./msu.exec("\u{1F600}") gave
[1, "\uDE00"]. It now gets the same test as an inverted class.

                                          Baseline           Patched

regexp-lookbehind-unicode-fixed          309.45+-1.91   ^   47.49+-0.66   ^ 
definitely 6.5161x faster
regexp-lookbehind-unicode-bmp-body       215.05+-3.01   ^   36.89+-0.69   ^ 
definitely 5.8299x faster
regexp-lookbehind-unicode-variable       186.04+-1.55   ^   35.13+-0.75   ^ 
definitely 5.2958x faster
regexp-lookbehind-variable                34.26+-0.19   ?   34.58+-0.54   ?
regexp-u-flag-dotall-greedy               40.03+-1.08       38.17+-3.94     
might be 1.0488x faster

Tests: JSTests/microbenchmarks/regexp-lookbehind-unicode-bmp-body.js
       JSTests/microbenchmarks/regexp-lookbehind-unicode-fixed.js
       JSTests/microbenchmarks/regexp-lookbehind-unicode-variable.js
       JSTests/microbenchmarks/regexp-u-flag-dotall-greedy.js
       JSTests/stress/regexp-lookbehind-jit-unicode.js
       JSTests/stress/regexp-unicode-any-character-inside-surrogate-pair.js

* JSTests/microbenchmarks/regexp-lookbehind-unicode-bmp-body.js: Added.
* JSTests/microbenchmarks/regexp-lookbehind-unicode-fixed.js: Added.
* JSTests/microbenchmarks/regexp-lookbehind-unicode-variable.js: Added.
* JSTests/microbenchmarks/regexp-u-flag-dotall-greedy.js: Added.
* JSTests/stress/regexp-lookbehind-jit-unicode.js: Added.
(shouldBe):
(matchOf):
(indicesOf):
(shouldBe.matchOf):
* JSTests/stress/regexp-unicode-any-character-inside-surrogate-pair.js: Added.
(shouldBe):
(matchOf):
(shouldBe.matchOf):
* Source/JavaScriptCore/runtime/RegExp.cpp:
(JSC::RegExp::compile):
(JSC::RegExp::compileMatchOnly):
* Source/JavaScriptCore/yarr/YarrJIT.cpp:

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



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

Reply via email to