Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 581f1d9583295898e8569aa01753b143356913f2
https://github.com/WebKit/WebKit/commit/581f1d9583295898e8569aa01753b143356913f2
Author: Sosuke Suzuki <[email protected]>
Date: 2026-07-31 (Fri, 31 Jul 2026)
Changed paths:
A JSTests/microbenchmarks/regexp-end-anchored-class-run.js
A JSTests/microbenchmarks/regexp-end-anchored-literal-suffix.js
A JSTests/stress/regexp-end-anchored-fixed-size.js
M Source/JavaScriptCore/yarr/YarrInterpreter.cpp
M Source/JavaScriptCore/yarr/YarrInterpreter.h
M Source/JavaScriptCore/yarr/YarrJIT.cpp
M Source/JavaScriptCore/yarr/YarrPattern.cpp
M Source/JavaScriptCore/yarr/YarrPattern.h
Log Message:
-----------
[YARR] Start matching end-anchored fixed-size regexps at the only possible
position
https://bugs.webkit.org/show_bug.cgi?id=320154
Reviewed by Yusuke Suzuki.
When every top-level alternative of a pattern ends with a non-multiline $
and consumes a fixed number of code units, a match can only start at
(input length - size). YARR nevertheless searched from the given start
offset, bumping along the whole subject (or scanning it with the
Boyer-Moore prefilter), so /\.js$/.test(url) and /[0-9a-f]{40}$/.test(line)
did work proportional to the input length.
Compute the maximum alternative size for such patterns in YarrPattern and
advance the start position to (length - size) at the entry of the JIT code
and the interpreter. The match body is untouched, so captures, lastIndex and
global iteration behave as before. Sticky, multiline and BOL-containing
patterns are left alone since they either do not search or are already
handled by optimizeBOL().
The new field fits into existing padding of both YarrPattern and
BytecodePattern, so neither structure grows (232 and 120 bytes, unchanged).
Baseline Patched
regexp-end-anchored-literal-suffix 8.9024+-0.1528 ^ 3.8347+-0.3205
^ definitely 2.3216x faster
regexp-end-anchored-class-run 16.7796+-0.4848 ^ 2.4783+-0.1510
^ definitely 6.7706x faster
Tests: JSTests/microbenchmarks/regexp-end-anchored-class-run.js
JSTests/microbenchmarks/regexp-end-anchored-literal-suffix.js
JSTests/microbenchmarks/regexp-unicode-bm-search-charclass.js
JSTests/microbenchmarks/regexp-unicode-bm-search-emoji-charclass.js
JSTests/microbenchmarks/regexp-unicode-bm-search-nomatch-charclass.js
JSTests/stress/regexp-end-anchored-fixed-size.js
* JSTests/microbenchmarks/regexp-end-anchored-class-run.js: Added.
* JSTests/microbenchmarks/regexp-end-anchored-literal-suffix.js: Added.
* JSTests/microbenchmarks/regexp-unicode-bm-search-charclass.js: Added.
* JSTests/microbenchmarks/regexp-unicode-bm-search-emoji-charclass.js: Added.
* JSTests/microbenchmarks/regexp-unicode-bm-search-nomatch-charclass.js: Added.
* JSTests/stress/regexp-end-anchored-fixed-size.js: Added.
(shouldBe):
(i.m.re.exec):
* Source/JavaScriptCore/yarr/YarrInterpreter.cpp:
* Source/JavaScriptCore/yarr/YarrInterpreter.h:
(JSC::Yarr::BytecodePattern::BytecodePattern):
(JSC::Yarr::BytecodePattern::hasEndAnchoredFixedSize const):
* Source/JavaScriptCore/yarr/YarrJIT.cpp:
* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::YarrPatternConstructor::computeEndAnchoredFixedSize):
(JSC::Yarr::YarrPattern::compile):
* Source/JavaScriptCore/yarr/YarrPattern.h:
(JSC::Yarr::YarrPattern::hasEndAnchoredFixedSize const):
Canonical link: https://commits.webkit.org/318325@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications