Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[JSC] Add StringSplitCache
https://bugs.webkit.org/show_bug.cgi?id=257530 rdar://problem/110053165 Reviewed by Justin Michaud. This patch adds String#split cache, inspired from V8's string split cache. It is common in the real world code that splitting a literal string with a literal separator because of readability, and it can be done multiple times instead of doing it globally. Instead of repeatedly splitting and re-generating strings again and again, we can safely cache the result. This patch caches result as JSImmutableButterfly when the both subject and separator are atom strings. In String#split operation, also, instead of generating substrings and extending butterfly, we just compute offset of substrings. And then finally generating JSImmutableButterfly / JSArray with repeated substrings. This avoids wasteful intermediate butterfly allocations. * Source/JavaScriptCore/CMakeLists.txt: * Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj: * Source/JavaScriptCore/heap/Heap.cpp: (JSC::Heap::finalize): * Source/JavaScriptCore/runtime/ArgList.h: (JSC::ArgList::ArgList): * Source/JavaScriptCore/runtime/StringPrototype.cpp: (JSC::splitStringByOneCharacterImpl): (JSC::JSC_DEFINE_HOST_FUNCTION): * Source/JavaScriptCore/runtime/StringSplitCache.h: Added. (JSC::StringSplitCache::clear): * Source/JavaScriptCore/runtime/StringSplitCacheInlines.h: Added. (JSC::StringSplitCache::get): (JSC::StringSplitCache::set): * Source/JavaScriptCore/runtime/VM.cpp: (JSC::VM::VM): * Source/JavaScriptCore/runtime/VM.h: Canonical link: https://commits.webkit.org/264749@main
- Loading branch information
1 parent
3539f60
commit e4568fa
Showing
9 changed files
with
271 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.