Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 37f4628ab5fec6362ec0b39da1179445f7616dea
https://github.com/WebKit/WebKit/commit/37f4628ab5fec6362ec0b39da1179445f7616dea
Author: Sosuke Suzuki <[email protected]>
Date: 2026-08-04 (Tue, 04 Aug 2026)
Changed paths:
A JSTests/microbenchmarks/regexp-buffer-boundary-anchor-end.js
A JSTests/microbenchmarks/regexp-buffer-boundary-anchor-start.js
A JSTests/stress/regexp-buffer-boundaries-anchoring.js
M Source/JavaScriptCore/yarr/YarrPattern.cpp
Log Message:
-----------
[YARR] Let `\A` and `\z` use the anchoring optimizations of non-multiline `^`
and `$`
https://bugs.webkit.org/show_bug.cgi?id=320873
Reviewed by Yusuke Suzuki.
\A and \z were compiled into their own assertion terms without participating in
the
BOL/EOL anchoring machinery, so a failing /\Afoo/u or /foo\z/u scanned every
start
position of the input while /^foo/u and /foo$/u give up immediately.
1. assertionBOI() sets m_startsWithBOL/m_containsBOL like assertionBOL(), and
recomputeStartsWithBOL() treats AssertionBOI as an anchor, so optimizeBOL()
makes \A-anchored alternatives once-through.
2. computeEndAnchoredFixedSize() accepts alternatives ending with \z. Since \z
does not depend on the multiline flag, it no longer bails on multiline
patterns; a trailing $ still requires a non-multiline term.
3. The first-character bitmap builder treats \A/\z/\Z as zero-width and
accepts \A as the leading anchor.
Baseline Patched
regexp-buffer-boundary-anchor-start 130.5870+-4.7993 ^
0.4691+-0.0210 ^ definitely 278.3501x faster
regexp-buffer-boundary-anchor-end 9.0441+-0.2902 ^
3.7459+-0.4817 ^ definitely 2.4144x faster
Tests: JSTests/microbenchmarks/regexp-buffer-boundary-anchor-end.js
JSTests/microbenchmarks/regexp-buffer-boundary-anchor-start.js
JSTests/stress/regexp-buffer-boundaries-anchoring.js
* JSTests/microbenchmarks/regexp-buffer-boundary-anchor-end.js: Added.
* JSTests/microbenchmarks/regexp-buffer-boundary-anchor-start.js: Added.
* JSTests/stress/regexp-buffer-boundaries-anchoring.js: Added.
(shouldBe):
(checkEquivalent):
* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::YarrPatternConstructor::assertionBOI):
(JSC::Yarr::YarrPatternConstructor::recomputeStartsWithBOL):
(JSC::Yarr::YarrPatternConstructor::optimizeBOL):
(JSC::Yarr::YarrPatternConstructor::computeEndAnchoredFixedSize):
(JSC::Yarr::FirstCharacterBitmapBuilder::addTerm):
(JSC::Yarr::computeFirstCharacterBitmap):
Canonical link: https://commits.webkit.org/318540@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications