Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 26fbddd98c897aae603469111a26507d626a2494
      
https://github.com/WebKit/WebKit/commit/26fbddd98c897aae603469111a26507d626a2494
  Author: Yusuke Suzuki <[email protected]>
  Date:   2026-10-02 (Fri, 02 Oct 2026)

  Changed paths:
    A JSTests/stress/json-parse-cached-property-name.js
    M Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
    M Source/JavaScriptCore/Sources.txt
    A Source/JavaScriptCore/runtime/JSONCache.cpp
    M Source/JavaScriptCore/runtime/JSONCache.h
    M Source/JavaScriptCore/runtime/JSONCacheInlines.h
    M Source/JavaScriptCore/runtime/LiteralParser.cpp
    M Source/JavaScriptCore/runtime/LiteralParser.h

  Log Message:
  -----------
  [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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to