You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 26fbddd
Browse filesBrowse the repository at this point in the historyBrowse files
[JSC] Add fast embedded transition cache for JSON.parse
rdar://188881915
https://bugs.webkit.org/show_bug.cgi?id=325901
Reviewed by Vassili Bykov.
We deployed transition cache and single-transition cache for JSON object
baking. But still loading a StringImpl from a Structure and comparing it
with lexed buffer is costly, largely due to dependent load.
This patch introduces layered cache mechanism on the top of that. Now we
have new Name cache and PrefixedName cache. Name cache covers quick fast
path for single-transition cache, and PrefixedName cache covers
transition cache pattern. By recording the actual JSON text content
directly into the entry, like `"type":`, lookup directly compares the
source's string sequence with this content. Also we cache this into the
cache's Entry directly (up to 32 characters) and we do comparison with
hard-coded optimized SIMD operation.
And still transition cache and single-transition cache covers failed
cases, and they populate the result to the front cache to accelerate the
next lookup.
This removes any constly load from Structure*, and keep lookup
sufficiently efficient and improves cache locality significantly.
Test: JSTests/stress/json-parse-cached-property-name.js
* JSTests/stress/json-parse-cached-property-name.js: Added.
(shouldBe):
(shouldThrow):
(roundTrip):
(iteration.const.name.of.names.shouldThrow.JSON.parse.shouldBe.roundTrip.i.shouldBe.roundTrip.JSON.stringify):
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/Sources.txt:
* Source/JavaScriptCore/runtime/JSONCache.cpp: Added.
(JSC::JSONCache::recordableName):
(JSC::JSONCache::NameTable<size>::insert):
(JSC::JSONCache::makeText):
(JSC::JSONCache::textPrefix):
(JSC::JSONCache::addPrefixedName):
(JSC::JSONCache::addName):
* Source/JavaScriptCore/runtime/JSONCache.h:
(JSC::JSONCache::clearStrings):
(JSC::JSONCache::reconcileTransitionsAtGCEnd):
(JSC::JSONCache::atomStringIndex):
(JSC::JSONCache::atomStringSlot):
(JSC::JSONCache::stringIndex): Deleted.
(JSC::JSONCache::stringSlot): Deleted.
* Source/JavaScriptCore/runtime/JSONCacheInlines.h:
(JSC::JSONCache::makeIdentifier):
(JSC::JSONCache::existingIdentifier):
(JSC::JSONCache::makeJSString):
(JSC::JSONCache::nameIndex):
(JSC::JSONCache::prefixedNameIndex):
(JSC::JSONCache::textMatches):
(JSC::JSONCache::NameTable<size>::match const):
(JSC::JSONCache::findName const):
(JSC::JSONCache::visitAggregate):
* Source/JavaScriptCore/runtime/LiteralParser.cpp:
(JSC::reviverMode>::existingIdentifier):
(JSC::reviverMode>::makeJSString):
(JSC::reviverMode>::Lexer::skipWhitespaceBeforeKey):
(JSC::reviverMode>::parsePrimitiveValue):
(JSC::requires):
* Source/JavaScriptCore/runtime/LiteralParser.h:
(JSC::LiteralParser::Lexer::remaining const):
(JSC::LiteralParser::Lexer::advance):
Canonical link: https://commits.webkit.org/322567@main
0 commit comments