Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: b80bcf43bdceb9913c30b5aa85a18b41e3547396
https://github.com/WebKit/WebKit/commit/b80bcf43bdceb9913c30b5aa85a18b41e3547396
Author: Yusuke Suzuki <[email protected]>
Date: 2026-06-30 (Tue, 30 Jun 2026)
Changed paths:
M Source/JavaScriptCore/dfg/DFGOperations.cpp
M Source/JavaScriptCore/runtime/JSArray.cpp
M Source/JavaScriptCore/runtime/JSObject.cpp
M Source/JavaScriptCore/runtime/JSObjectInlines.h
M Source/JavaScriptCore/runtime/PropertySlot.h
M Source/JavaScriptCore/runtime/SparseArrayValueMap.cpp
M Source/JavaScriptCore/runtime/SparseArrayValueMap.h
Log Message:
-----------
[JSC] Make SparseArrayValueMap 33% compact by using HashSet
https://bugs.webkit.org/show_bug.cgi?id=318223
rdar://181023846
Reviewed by Dan Hecht and Tadeu Zagallo.
We were using `UncheckedKeyHashMap<uint64_t, SparseArrayEntry, ...>` for
SparseArrayValueMap since its key range is [0, UINT32_MAX]. So we cannot
have a space for "empty" and "deleted", thus we were using uint64_t as a
key. However, this makes each KeyValuePair sizeof(uint64_t) * 3.
If we look into the value side, it is having `unsigned attributes`, but
it is not using all bits. We can convert this Map to
`UncheckedKeyHashSet<SparseArrayEntry, ...>` and we can store "empty" and
"deleted" as bit flags in attributes side. So we can make KeyValuePair
sizeof(uint64_t) * 2, so 33% reduction in size (and since it becomes
16bytes, it is good for index computation & cache efficacy).
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::getByValArrayStorageInt):
* Source/JavaScriptCore/runtime/JSArray.cpp:
(JSC::JSArray::setLengthWithArrayStorage):
* Source/JavaScriptCore/runtime/JSObject.cpp:
(JSC::JSObject::getOwnPropertySlotByIndex):
(JSC::JSObject::enterDictionaryIndexingModeWhenArrayStorageAlreadyExists):
(JSC::JSObject::deletePropertyByIndex):
(JSC::JSObject::getOwnIndexedPropertyNames):
(JSC::JSObject::defineOwnIndexedProperty):
(JSC::JSObject::attemptToInterceptPutByIndexOnHoleForPrototype):
(JSC::JSObject::putByIndexBeyondVectorLengthWithArrayStorage):
(JSC::JSObject::putDirectIndexBeyondVectorLengthWithArrayStorage):
* Source/JavaScriptCore/runtime/JSObjectInlines.h:
(JSC::JSObject::forEachOwnIndexedProperty):
* Source/JavaScriptCore/runtime/PropertySlot.h:
* Source/JavaScriptCore/runtime/SparseArrayValueMap.cpp:
(JSC::SparseArrayValueMap::add):
(JSC::SparseArrayValueMap::remove):
(JSC::SparseArrayValueMap::putEntry):
(JSC::SparseArrayValueMap::putDirect):
(JSC::SparseArrayValueMap::getConcurrently):
(JSC::SparseArrayEntry::forceSet):
(JSC::SparseArrayEntry::get const):
(JSC::SparseArrayEntry::getConcurrently const):
(JSC::SparseArrayEntry::put):
(JSC::SparseArrayEntry::getNonSparseMode const):
(JSC::SparseArrayValueMap::visitChildrenImpl):
* Source/JavaScriptCore/runtime/SparseArrayValueMap.h:
(JSC::SparseArrayEntry::SparseArrayEntry):
(JSC::SparseArrayEntry::index const):
(JSC::SparseArrayEntry::attributes const):
(JSC::SparseArrayEntry::isEmptyBucket const):
(JSC::SparseArrayEntry::isDeletedBucket const):
(JSC::SparseArrayEntry::asValue):
(JSC::SparseArrayEntry::asValue const):
(JSC::SparseArrayEntryHash::hash):
(JSC::SparseArrayEntryHash::equal):
(JSC::SparseArrayEntryHashTraits::emptyValue):
(JSC::SparseArrayEntryHashTraits::isEmptyValue):
(JSC::SparseArrayEntryHashTraits::constructDeletedValue):
(JSC::SparseArrayEntryHashTraits::isDeletedValue):
(JSC::SparseArrayEntryTranslator::hash):
(JSC::SparseArrayEntryTranslator::equal):
(JSC::SparseArrayEntry::forceSet): Deleted.
Canonical link: https://commits.webkit.org/316199@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications