Shrink size of PropertyCondition by packing UniquedStringImpl* and Kind
authoryusukesuzuki@slowstart.org <yusukesuzuki@slowstart.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Aug 2018 23:21:08 +0000 (23:21 +0000)
committeryusukesuzuki@slowstart.org <yusukesuzuki@slowstart.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Aug 2018 23:21:08 +0000 (23:21 +0000)
commit057ff6bb96c0fc1f69de3ca932f07a1d8a5e5610
tree1ab526abc6f5785380d469ebe725dbf4b74b14f8
parenta8f3b41d3d9dc194a005361d0318ceb0fade8ef8
Shrink size of PropertyCondition by packing UniquedStringImpl* and Kind
https://bugs.webkit.org/show_bug.cgi?id=188328

Reviewed by Saam Barati.

Source/JavaScriptCore:

Shrinking the size of PropertyCondition can improve memory consumption by a lot.
For example, cnn.com can show 7000 persistent StructureStubClearingWatchpoint
and 6000 LLIntPrototypeLoadAdaptiveStructureWatchpoint which have PropertyCondition
as a member field.

This patch shrinks the size of PropertyCondition by packing UniquedStringImpl* and
PropertyCondition::Kind into uint64_t data in 64bit architecture. Since our address
are within 48bit, we can put PropertyCondition::Kind in this unused bits.
To make it easy, we add WTF::CompactPointerTuple<PointerType, Type>, which automatically
folds a pointer and 1byte type into 64bit data.

This change shrinks PropertyCondition from 24bytes to 16bytes.

* bytecode/PropertyCondition.cpp:
(JSC::PropertyCondition::dumpInContext const):
(JSC::PropertyCondition::isStillValidAssumingImpurePropertyWatchpoint const):
(JSC::PropertyCondition::validityRequiresImpurePropertyWatchpoint const):
(JSC::PropertyCondition::isStillValid const):
(JSC::PropertyCondition::isWatchableWhenValid const):
* bytecode/PropertyCondition.h:
(JSC::PropertyCondition::PropertyCondition):
(JSC::PropertyCondition::presenceWithoutBarrier):
(JSC::PropertyCondition::absenceWithoutBarrier):
(JSC::PropertyCondition::absenceOfSetEffectWithoutBarrier):
(JSC::PropertyCondition::equivalenceWithoutBarrier):
(JSC::PropertyCondition::hasPrototypeWithoutBarrier):
(JSC::PropertyCondition::operator bool const):
(JSC::PropertyCondition::kind const):
(JSC::PropertyCondition::uid const):
(JSC::PropertyCondition::hasOffset const):
(JSC::PropertyCondition::hasAttributes const):
(JSC::PropertyCondition::hasPrototype const):
(JSC::PropertyCondition::hasRequiredValue const):
(JSC::PropertyCondition::hash const):
(JSC::PropertyCondition::operator== const):
(JSC::PropertyCondition::isHashTableDeletedValue const):
(JSC::PropertyCondition::watchingRequiresReplacementWatchpoint const):

Source/WTF:

This patch adds CompactPointerTuple, which can pack a pointer and 8bit value into 8bytes.
In 32bit architecture, it just has two fields for a pointer and 8bit value. In 64bit architecture,
we use upper 5bits (zeros because of the effective width of virtual address) and lower 3bits (zeros
because of the alignment ensured by static_assert) to pack 8bit value into the pointer data. Since
even the 5-level page tables use 57bit effective address, this strategy works well.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/CompactPointerTuple.h: Added.
(WTF::CompactPointerTuple::encodeType):
(WTF::CompactPointerTuple::decodeType):
(WTF::CompactPointerTuple::CompactPointerTuple):
(WTF::CompactPointerTuple::pointer const):
(WTF::CompactPointerTuple::setPointer):
(WTF::CompactPointerTuple::type const):
(WTF::CompactPointerTuple::setType):
* wtf/Platform.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234677 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/PropertyCondition.cpp
Source/JavaScriptCore/bytecode/PropertyCondition.h
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/CMakeLists.txt
Source/WTF/wtf/CompactPointerTuple.h [new file with mode: 0644]
Source/WTF/wtf/Platform.h