[webkit-changes] [WebKit/WebKit] 9206b1: [JSC] Simplify oneCharMatches
Yusuke Suzuki
noreply at github.com
Thu Dec 5 01:23:48 PST 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9206b1b5f74536e439a9ad6ecd50a25da0262de1
https://github.com/WebKit/WebKit/commit/9206b1b5f74536e439a9ad6ecd50a25da0262de1
Author: Yusuke Suzuki <ysuzuki at apple.com>
Date: 2024-12-05 (Thu, 05 Dec 2024)
Changed paths:
M JSTests/stress/substring-global-atom-cache.js
M Source/JavaScriptCore/runtime/RegExp.cpp
M Source/JavaScriptCore/runtime/RegExp.h
M Source/JavaScriptCore/runtime/RegExpGlobalData.h
M Source/JavaScriptCore/runtime/RegExpGlobalDataInlines.h
M Source/JavaScriptCore/runtime/RegExpInlines.h
M Source/JavaScriptCore/runtime/RegExpObjectInlines.h
M Source/JavaScriptCore/runtime/RegExpSubstringGlobalAtomCache.cpp
Log Message:
-----------
[JSC] Simplify oneCharMatches
https://bugs.webkit.org/show_bug.cgi?id=284078
rdar://140945275
Reviewed by Yijia Huang and Justin Michaud.
When performing oneCharMatches, we were collecting startIndex which is
the last match end cursor. This is necessary for RegExpSubstringGlobalAtomCache
since if the pattern is multiple string and substring is something like
this,
total string "testtesttest"
substring1 "testt"
substring2 "testtest"
pattern "test"
^
Then, when matching against substring1, we should start with the last
end (^) position instead of the end of the substring1 since the
remaining characters (in this case 't') can compose the pattern with the
rest of substrings.
But this does not happen for one-character-matches since pattern is
always one character. This means that we do not need to record last
match end cursor in oneCharMatches. This also means that oneCharMatches
is basically just counting matched characters.
This patch does refactoring.
1. We use StringView for subject strings for matches so that we can use
JSString::view instead of JSString::value.
2. We replace oneCharMatches with countMatchedCharacters. Significantly
simplify the code.
We will try some SIMD for countMatchedCharacters in a subsequent change.
* Source/JavaScriptCore/runtime/RegExp.cpp:
(JSC::RegExpFunctionalTestCollector::outputOneTest):
(JSC::RegExpFunctionalTestCollector::outputEscapedString):
(JSC::RegExp::match):
(JSC::RegExp::matchConcurrently):
(JSC::RegExp::matchCompareWithInterpreter):
* Source/JavaScriptCore/runtime/RegExp.h:
* Source/JavaScriptCore/runtime/RegExpGlobalData.h:
* Source/JavaScriptCore/runtime/RegExpGlobalDataInlines.h:
(JSC::RegExpGlobalData::performMatch):
* Source/JavaScriptCore/runtime/RegExpInlines.h:
(JSC::RegExp::matchInline):
* Source/JavaScriptCore/runtime/RegExpObjectInlines.h:
(JSC::countMatchedCharacters):
(JSC::genericMatches):
(JSC::collectGlobalAtomMatches):
(JSC::oneCharMatches): Deleted.
* Source/JavaScriptCore/runtime/RegExpSubstringGlobalAtomCache.cpp:
(JSC::RegExpSubstringGlobalAtomCache::collectMatches):
Canonical link: https://commits.webkit.org/287391@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list