[webkit-changes] [WebKit/WebKit] caa315: Positive look-behind RegExp doesn't match in JSC b...

Michael Saboff noreply at github.com
Tue Aug 15 08:59:08 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: caa31552bab4d322ec1ced2f059d93f2c2fd45b4
      https://github.com/WebKit/WebKit/commit/caa31552bab4d322ec1ced2f059d93f2c2fd45b4
  Author: Michael Saboff <msaboff at apple.com>
  Date:   2023-08-15 (Tue, 15 Aug 2023)

  Changed paths:
    M JSTests/stress/regexp-lookbehind.js
    M Source/JavaScriptCore/yarr/YarrInterpreter.cpp
    M Source/JavaScriptCore/yarr/YarrPattern.cpp

  Log Message:
  -----------
  Positive look-behind RegExp doesn't match in JSC but does match in V8
https://bugs.webkit.org/show_bug.cgi?id=259536
rdar://112952197

Reviewed by Yusuke Suzuki.

The reported bug indicated one issue.  We were performing the beginning of line / end of line assertion optimization
on lookbehinds that contain BOL's / EOL's.  Given that we match backwards for lookbehinds while doing soft
"do we have enough input" checks, we won't properly match such an assertion as the BOL assertion optimization
assumes that the BOL is at position 0 and not some prior location in the lookbehind.

After fixing that bug and adding more tests, discovered that we don't properly handle lookbehinds with alternatives
of different minimum lengths.  We emit a single HaveCheckedInput for the minimum size of the alternation.  Added a
check to emit a HaveCheckedInput for any alternative that had a minimum size larger that the minimum for the whole
alternation.

Updated tests accordingly.

* JSTests/stress/regexp-lookbehind.js:
(testRegExp.v):
(d.v):
(testRegExp.v.sv):
(testRegExp.v.sv.Rev):
* Source/JavaScriptCore/yarr/YarrInterpreter.cpp:
(JSC::Yarr::ByteCompiler::emitDisjunction):
* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::YarrPatternConstructor::assertionBOL):
(JSC::Yarr::YarrPatternConstructor::copyDisjunction):

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




More information about the webkit-changes mailing list