Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5fe4838cb7d14f80f57579bac4759e6d2bdcf34f
https://github.com/WebKit/WebKit/commit/5fe4838cb7d14f80f57579bac4759e6d2bdcf34f
Author: Yusuke Suzuki <[email protected]>
Date: 2026-06-05 (Fri, 05 Jun 2026)
Changed paths:
A JSTests/stress/regexp-greedy-varcount-reextend-after-content-backtrack.js
M Source/JavaScriptCore/yarr/YarrInterpreter.cpp
Log Message:
-----------
[Yarr] YarrInterpreter Greedy backtracking should finish its parentheses by
trying up to max count
https://bugs.webkit.org/show_bug.cgi?id=316378
rdar://178787974
Reviewed by Yijia Huang.
In Greedy Parentheses backtracking,
1. We do content-backtracking first. If it works, then we say it is
matched and return from the backtracking (continue to the subsequent
pattern). If it matches, then this iteration is completed. So we
should attempt to expand Greedy iterations as much as possible, then
we say this is matched and continue going to the subsequent pattern.
2. Otherwise, we need to restore the previous iteration's state since
this iteration failed. Then we do content-backtracking in this popped
iteration if we are not reaching to min count. If succeeds, then
refill up to min count, and then expand up to max count. And then
saying Greedy backtracking is completed.
3. If content-backtracking failed, we need to repeatedly pop the
iteration and try backtracking again. If it failed completely, then
we need to say that this parentheses is completely failed.
We were missing expand-to-max-count in (2). So we are saying the
parentheses completion as non-greedy manner. We need to expand it as it
is greedy.
Test: JSTests/stress/regexp-greedy-varcount-reextend-after-content-backtrack.js
* JSTests/stress/regexp-greedy-varcount-reextend-after-content-backtrack.js:
Added.
(eq):
(check):
* Source/JavaScriptCore/yarr/YarrInterpreter.cpp:
(JSC::Yarr::Interpreter::parenthesesDoBacktrack):
(JSC::Yarr::Interpreter::matchParentheses):
(JSC::Yarr::Interpreter::backtrackParentheses):
(JSC::Yarr::Interpreter::refillParenthesesContextsToMinCount):
(JSC::Yarr::Interpreter::extendParenthesesContextsToMaxCount):
(JSC::Yarr::Interpreter::matchDisjunction):
(JSC::Yarr::Interpreter::matchNonZeroDisjunction):
Canonical link: https://commits.webkit.org/314655@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications