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

  Changed paths:
    A JSTests/stress/regexp-once-through-advance-edge-cases.js
    A 
JSTests/stress/regexp-once-through-advance-tries-loop-alternatives-first.js
    A JSTests/stress/regexp-once-through-without-loop-alternatives.js
    M Source/JavaScriptCore/yarr/YarrInterpreter.cpp

  Log Message:
  -----------
  [YARR] Interpreter should skip every once-through alternative after advancing 
the start position
https://bugs.webkit.org/show_bug.cgi?id=321253

Reviewed by Yusuke Suzuki.

optimizeBOL() marks the body alternatives as once-through and appends copies of
the non-`^` ones as the looping set, so once-through alternatives must only be
tried at the initial start position.

When advancing the start position, the interpreter skipped only the first
once-through alternative and resumed at the second one, so a later alternative
could win over the first, e.g. /a|^x|aa/.exec("caa") returned "aa" instead of
"a". The JIT emits the two sets separately and is not affected.

Skip all once-through alternatives after advancing, and return NoMatch when
there is no looping alternative (e.g. /^a|^b/), matching the JIT.

Tests: JSTests/stress/regexp-once-through-advance-edge-cases.js
       
JSTests/stress/regexp-once-through-advance-tries-loop-alternatives-first.js
       JSTests/stress/regexp-once-through-without-loop-alternatives.js

* JSTests/stress/regexp-once-through-advance-edge-cases.js: Added.
(shouldBe):
(check):
* JSTests/stress/regexp-once-through-advance-tries-loop-alternatives-first.js: 
Added.
(shouldBe):
(check):
* JSTests/stress/regexp-once-through-without-loop-alternatives.js: Added.
(shouldBe):
(check):
* Source/JavaScriptCore/yarr/YarrInterpreter.cpp:
(JSC::Yarr::Interpreter::matchDisjunction):

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



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

Reply via email to