[webkit-changes] [WebKit/WebKit] 432199: [JSC] Add RegExpSubstringGlobalAtomCache
Yijia Huang
noreply at github.com
Tue Oct 8 16:23:52 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 43219930455072a522a32b1dee44857513991e3a
https://github.com/WebKit/WebKit/commit/43219930455072a522a32b1dee44857513991e3a
Author: Yijia Huang <yijia_huang at apple.com>
Date: 2024-10-08 (Tue, 08 Oct 2024)
Changed paths:
A JSTests/microbenchmarks/substring-match-global-atom.js
A JSTests/stress/substring-global-atom-cache.js
M Source/JavaScriptCore/CMakeLists.txt
M Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
M Source/JavaScriptCore/Sources.txt
M Source/JavaScriptCore/runtime/JSString.h
M Source/JavaScriptCore/runtime/RegExp.cpp
M Source/JavaScriptCore/runtime/RegExp.h
M Source/JavaScriptCore/runtime/RegExpGlobalData.cpp
M Source/JavaScriptCore/runtime/RegExpGlobalData.h
M Source/JavaScriptCore/runtime/RegExpObject.cpp
A Source/JavaScriptCore/runtime/RegExpSubstringGlobalAtomCache.cpp
A Source/JavaScriptCore/runtime/RegExpSubstringGlobalAtomCache.h
M Source/JavaScriptCore/yarr/YarrPattern.cpp
M Source/JavaScriptCore/yarr/YarrPattern.h
Log Message:
-----------
[JSC] Add RegExpSubstringGlobalAtomCache
https://bugs.webkit.org/show_bug.cgi?id=281012
rdar://137459855
Reviewed by Yusuke Suzuki.
Inspired by [1], this update adds a caching mechanism to optimize
repeated matching of global atomic regular expressions on growing
substrings. By caching results, we avoid redundant work and improve
performance, particularly in scenarios where the same RegExp is applied
to overlapping or incrementally growing substrings.
MicroBenchmark Result with `--inner 10 --outer 20`:
before after
substring-match-global-atom 3.1816+-0.0123 ^ 2.4063+-0.0082 ^ definitely 1.3222x faster
[1] https://chromium-review.googlesource.com/c/v8/v8/+/5886727
* JSTests/microbenchmarks/substring-match-global-atom.js: Added.
(test):
* Source/JavaScriptCore/CMakeLists.txt:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/Sources.txt:
* Source/JavaScriptCore/runtime/JSString.h:
(JSC::JSString::asRope):
* Source/JavaScriptCore/runtime/RegExp.cpp:
(JSC::RegExp::finishCreation):
(JSC::RegExp::byteCodeCompileIfNecessary):
(JSC::RegExp::compile):
(JSC::RegExp::compileMatchOnly):
(JSC::RegExp::deleteCode):
* Source/JavaScriptCore/runtime/RegExp.h:
* Source/JavaScriptCore/runtime/RegExpGlobalData.h:
(JSC::RegExpGlobalData::substringGlobalAtomCache):
* Source/JavaScriptCore/runtime/RegExpObject.cpp:
(JSC::RegExpObject::matchGlobal):
* Source/JavaScriptCore/runtime/RegExpSubstringGlobalAtomCache.cpp: Added.
(JSC::RegExpSubstringGlobalAtomCache::visitAggregateImpl):
(JSC::RegExpSubstringGlobalAtomCache::hasValidPattern):
(JSC::RegExpSubstringGlobalAtomCache::tryGet):
(JSC::RegExpSubstringGlobalAtomCache::record):
(JSC::RegExpSubstringGlobalAtomCache::collectMatches):
* Source/JavaScriptCore/runtime/RegExpSubstringGlobalAtomCache.h: Copied from Source/JavaScriptCore/runtime/RegExpGlobalData.h.
(JSC::RegExpSubstringGlobalAtomCache::lastRegExp):
* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::YarrPatternConstructor::extractAtom):
(JSC::Yarr::YarrPattern::compile):
* Source/JavaScriptCore/yarr/YarrPattern.h:
Canonical link: https://commits.webkit.org/284859@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