haikuwebkit/Source/WTF/wtf/Packed.h

289 lines
8.8 KiB
C
Raw Permalink Normal View History

[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
/*
* Copyright (C) 2019 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <array>
[WTF] AtomStringTable should be small https://bugs.webkit.org/show_bug.cgi?id=206400 Reviewed by Sam Weinig. Source/WebCore: * dom/GCReachableRef.h: (WebCore::GCReachableRef::GCReachableRef): * dom/QualifiedName.h: (WebCore::QualifiedName::hashTableDeletedValue): Source/WTF: AtomStringTable is the largest hashtable typically. It takes more than 256KB per WebProcess (sometimes, it took 1MB or more). This patch leverages PackedPtr to compact it from 8 bytes per entry to 6 bytes per entry. While this is still large, we should investigate how to compact C++ pointers in 4 bytes[1] to shrink memory footprint, since WebKit memory is used by Vector and HashTable fulfilled with pointers. [1]: https://bugs.webkit.org/show_bug.cgi?id=206469 * wtf/DumbPtrTraits.h: (WTF::DumbPtrTraits::hashTableDeletedValue): (WTF::DumbPtrTraits::isHashTableDeletedValue): * wtf/Forward.h: * wtf/HashTraits.h: * wtf/Packed.h: (WTF::Packed<T::Packed): (WTF::Packed<T::isHashTableDeletedValue const): (WTF::GetPtrHelper<PackedPtr<T>>::getPtr): (WTF::PackedPtrTraits::hashTableDeletedValue): (WTF::PackedPtrTraits::isHashTableDeletedValue): (WTF::alignof): Deleted. * wtf/Ref.h: (WTF::Ref::Ref): (WTF::Ref::isHashTableDeletedValue const): (WTF::Ref::hashTableDeletedValue): Deleted. * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): (WTF::RefPtr::isHashTableDeletedValue const): (WTF::RefPtr::hashTableDeletedValue): Deleted. * wtf/text/AtomStringImpl.cpp: (WTF::addToStringTable): (WTF::CStringTranslator::equal): (WTF::CStringTranslator::translate): (WTF::UCharBufferTranslator::equal): (WTF::UCharBufferTranslator::translate): (WTF::HashAndUTF8CharactersTranslator::equal): (WTF::HashAndUTF8CharactersTranslator::translate): (WTF::SubstringTranslator::translate): (WTF::SubstringTranslator8::equal): (WTF::SubstringTranslator16::equal): (WTF::LCharBufferTranslator::equal): (WTF::LCharBufferTranslator::translate): (WTF::BufferFromStaticDataTranslator::equal): (WTF::BufferFromStaticDataTranslator::translate): (WTF::AtomStringImpl::addSlowCase): (WTF::AtomStringImpl::remove): (WTF::AtomStringImpl::lookUpSlowCase): (WTF::AtomStringImpl::lookUp): * wtf/text/AtomStringTable.cpp: (WTF::AtomStringTable::~AtomStringTable): * wtf/text/AtomStringTable.h: (WTF::AtomStringTable::table): (): Deleted. * wtf/text/StringHash.h: (WTF::StringHash::hash): (WTF::StringHash::equal): (WTF::ASCIICaseInsensitiveHash::hash): (WTF::ASCIICaseInsensitiveHash::equal): * wtf/text/StringImpl.h: Tools: * TestWebKitAPI/Tests/WTF/HashMap.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/219616@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254881 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-21 22:05:43 +00:00
#include <wtf/Forward.h>
#include <wtf/GetPtr.h>
#include <wtf/HashFunctions.h>
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
#include <wtf/MathExtras.h>
#include <wtf/StdLibExtras.h>
#include <wtf/UnalignedAccess.h>
Define MacroAssemblerARM64E::numberOfPACBits based on OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH). https://bugs.webkit.org/show_bug.cgi?id=227147 rdar://78785309 Reviewed by Saam Barati. Source/bmalloc: For OS(DARWIN), define BOS_EFFECTIVE_ADDRESS_WIDTH in terms of MACH_VM_MAX_ADDRESS, which is provided by the SDK. This ensures that it is correct for each target OS(DARWIN) platform. * bmalloc/Algorithm.h: (bmalloc::clzConstexpr): (bmalloc::getMSBSetConstexpr): * bmalloc/BPlatform.h: * bmalloc/Gigacage.h: * bmalloc/ObjectTypeTable.h: * bmalloc/Packed.h: Source/JavaScriptCore: * assembler/MacroAssemblerARM64E.h: * bytecode/CodeOrigin.h: * runtime/JSString.h: * runtime/OptionsList.h: Source/WTF: For OS(DARWIN), define OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH) in terms of MACH_VM_MAX_ADDRESS, which is provided by the SDK. This ensures that it is correct for each target OS(DARWIN) platform. Also update an assertion in WTFAssertions.cpp to verify that address bits are less than 48. The purpose of this assertion is to ensure that our 64-bit NaN boxing encoding for JSValues will work. Hence, we should use the encoding limit for pointers of 48 bits. It no longer makes sense to assert based on OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH), because OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH) is defined in terms of MACH_VM_MAX_ADDRESS. * wtf/CagedPtr.h: * wtf/CompactPointerTuple.h: * wtf/PlatformOS.h: * wtf/WTFAssertions.cpp: * wtf/threads/Signals.cpp: Tools: * TestWebKitAPI/Tests/WTF/Packed.cpp: Canonical link: https://commits.webkit.org/238948@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279028 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-18 01:44:42 +00:00
#if OS(DARWIN)
#include <mach/vm_param.h>
#endif
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
namespace WTF {
template<typename T>
class Packed {
[WTF][JSC] Make JSC and WTF aggressively-fast-malloced https://bugs.webkit.org/show_bug.cgi?id=200611 Reviewed by Saam Barati. Source/JavaScriptCore: This patch aggressively puts many classes into FastMalloc. In JSC side, we grep `std::make_unique` etc. to find potentially system-malloc-allocated classes. After this patch, all the JSC related allocations in JetStream2 cli is done from bmalloc. In the future, it would be nice that we add `WTF::makeUnique<T>` helper function and throw a compile error if `T` is not FastMalloc annotated[1]. Putting WebKit classes in FastMalloc has many benefits. 1. Simply, it is fast. 2. vmmap can tell the amount of memory used for WebKit. 3. bmalloc can isolate WebKit memory allocation from the rest of the world. This is useful since we can know more about what component is corrupting the memory from the memory corruption crash. [1]: https://bugs.webkit.org/show_bug.cgi?id=200620 * API/ObjCCallbackFunction.mm: * assembler/AbstractMacroAssembler.h: * b3/B3PhiChildren.h: * b3/air/AirAllocateRegistersAndStackAndGenerateCode.h: * b3/air/AirDisassembler.h: * bytecode/AccessCaseSnippetParams.h: * bytecode/CallVariant.h: * bytecode/DeferredSourceDump.h: * bytecode/ExecutionCounter.h: * bytecode/GetByIdStatus.h: * bytecode/GetByIdVariant.h: * bytecode/InByIdStatus.h: * bytecode/InByIdVariant.h: * bytecode/InstanceOfStatus.h: * bytecode/InstanceOfVariant.h: * bytecode/PutByIdStatus.h: * bytecode/PutByIdVariant.h: * bytecode/ValueProfile.h: * dfg/DFGAbstractInterpreter.h: * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::newVariableAccessData): * dfg/DFGFlowIndexing.h: * dfg/DFGFlowMap.h: * dfg/DFGLiveCatchVariablePreservationPhase.cpp: (JSC::DFG::LiveCatchVariablePreservationPhase::newVariableAccessData): * dfg/DFGMaximalFlushInsertionPhase.cpp: (JSC::DFG::MaximalFlushInsertionPhase::newVariableAccessData): * dfg/DFGOSRExit.h: * dfg/DFGSpeculativeJIT.h: * dfg/DFGVariableAccessData.h: * disassembler/ARM64/A64DOpcode.h: * inspector/remote/socket/RemoteInspectorMessageParser.h: * inspector/remote/socket/RemoteInspectorSocket.h: * inspector/remote/socket/RemoteInspectorSocketEndpoint.h: * jit/PCToCodeOriginMap.h: * runtime/BasicBlockLocation.h: * runtime/DoublePredictionFuzzerAgent.h: * runtime/JSRunLoopTimer.h: * runtime/PromiseDeferredTimer.h: (JSC::PromiseDeferredTimer::create): PromiseDeferredTimer should be allocated as `Ref<>` instead of `std::unique_ptr` since it is inheriting ThreadSafeRefCounted<>. Holding such a class with std::unique_ptr could lead to potentially dangerous operations (like, someone holds it with Ref<> while it is deleted by std::unique_ptr<>). * runtime/RandomizingFuzzerAgent.h: * runtime/SymbolTable.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * tools/JSDollarVM.cpp: * tools/SigillCrashAnalyzer.cpp: * wasm/WasmFormat.h: * wasm/WasmMemory.cpp: * wasm/WasmSignature.h: * yarr/YarrJIT.h: Source/WebCore: Changed the accessor since we changed std::unique_ptr to Ref for this field. No behavior change. * bindings/js/WorkerScriptController.cpp: (WebCore::WorkerScriptController::addTimerSetNotification): (WebCore::WorkerScriptController::removeTimerSetNotification): Source/WTF: WTF has many data structures, in particular, containers. And these containers can be allocated like `std::make_unique<Container>()`. Without WTF_MAKE_FAST_ALLOCATED, this container itself is allocated from the system malloc. This patch attaches WTF_MAKE_FAST_ALLOCATED more aggressively not to allocate them from the system malloc. And we add some `final` to containers and classes that would be never inherited. * wtf/Assertions.cpp: * wtf/Atomics.h: * wtf/AutodrainedPool.h: * wtf/Bag.h: (WTF::Bag::Bag): Deleted. (WTF::Bag::~Bag): Deleted. (WTF::Bag::clear): Deleted. (WTF::Bag::add): Deleted. (WTF::Bag::iterator::iterator): Deleted. (WTF::Bag::iterator::operator! const): Deleted. (WTF::Bag::iterator::operator* const): Deleted. (WTF::Bag::iterator::operator++): Deleted. (WTF::Bag::iterator::operator== const): Deleted. (WTF::Bag::iterator::operator!= const): Deleted. (WTF::Bag::begin): Deleted. (WTF::Bag::begin const): Deleted. (WTF::Bag::end const): Deleted. (WTF::Bag::isEmpty const): Deleted. (WTF::Bag::unwrappedHead const): Deleted. * wtf/BitVector.h: (WTF::BitVector::BitVector): Deleted. (WTF::BitVector::~BitVector): Deleted. (WTF::BitVector::operator=): Deleted. (WTF::BitVector::size const): Deleted. (WTF::BitVector::ensureSize): Deleted. (WTF::BitVector::quickGet const): Deleted. (WTF::BitVector::quickSet): Deleted. (WTF::BitVector::quickClear): Deleted. (WTF::BitVector::get const): Deleted. (WTF::BitVector::contains const): Deleted. (WTF::BitVector::set): Deleted. (WTF::BitVector::add): Deleted. (WTF::BitVector::ensureSizeAndSet): Deleted. (WTF::BitVector::clear): Deleted. (WTF::BitVector::remove): Deleted. (WTF::BitVector::merge): Deleted. (WTF::BitVector::filter): Deleted. (WTF::BitVector::exclude): Deleted. (WTF::BitVector::bitCount const): Deleted. (WTF::BitVector::isEmpty const): Deleted. (WTF::BitVector::findBit const): Deleted. (WTF::BitVector::isEmptyValue const): Deleted. (WTF::BitVector::isDeletedValue const): Deleted. (WTF::BitVector::isEmptyOrDeletedValue const): Deleted. (WTF::BitVector::operator== const): Deleted. (WTF::BitVector::hash const): Deleted. (WTF::BitVector::iterator::iterator): Deleted. (WTF::BitVector::iterator::operator* const): Deleted. (WTF::BitVector::iterator::operator++): Deleted. (WTF::BitVector::iterator::isAtEnd const): Deleted. (WTF::BitVector::iterator::operator== const): Deleted. (WTF::BitVector::iterator::operator!= const): Deleted. (WTF::BitVector::begin const): Deleted. (WTF::BitVector::end const): Deleted. (WTF::BitVector::bitsInPointer): Deleted. (WTF::BitVector::maxInlineBits): Deleted. (WTF::BitVector::byteCount): Deleted. (WTF::BitVector::makeInlineBits): Deleted. (WTF::BitVector::cleanseInlineBits): Deleted. (WTF::BitVector::bitCount): Deleted. (WTF::BitVector::findBitFast const): Deleted. (WTF::BitVector::findBitSimple const): Deleted. (WTF::BitVector::OutOfLineBits::numBits const): Deleted. (WTF::BitVector::OutOfLineBits::numWords const): Deleted. (WTF::BitVector::OutOfLineBits::bits): Deleted. (WTF::BitVector::OutOfLineBits::bits const): Deleted. (WTF::BitVector::OutOfLineBits::OutOfLineBits): Deleted. (WTF::BitVector::isInline const): Deleted. (WTF::BitVector::outOfLineBits const): Deleted. (WTF::BitVector::outOfLineBits): Deleted. (WTF::BitVector::bits): Deleted. (WTF::BitVector::bits const): Deleted. * wtf/Bitmap.h: (WTF::Bitmap::size): Deleted. (WTF::Bitmap::iterator::iterator): Deleted. (WTF::Bitmap::iterator::operator* const): Deleted. (WTF::Bitmap::iterator::operator++): Deleted. (WTF::Bitmap::iterator::operator== const): Deleted. (WTF::Bitmap::iterator::operator!= const): Deleted. (WTF::Bitmap::begin const): Deleted. (WTF::Bitmap::end const): Deleted. * wtf/Box.h: * wtf/BumpPointerAllocator.h: * wtf/CPUTime.h: * wtf/CheckedBoolean.h: * wtf/CommaPrinter.h: (WTF::CommaPrinter::CommaPrinter): Deleted. (WTF::CommaPrinter::dump const): Deleted. (WTF::CommaPrinter::didPrint const): Deleted. * wtf/CompactPointerTuple.h: (WTF::CompactPointerTuple::encodeType): Deleted. (WTF::CompactPointerTuple::decodeType): Deleted. (WTF::CompactPointerTuple::CompactPointerTuple): Deleted. (WTF::CompactPointerTuple::pointer const): Deleted. (WTF::CompactPointerTuple::setPointer): Deleted. (WTF::CompactPointerTuple::type const): Deleted. (WTF::CompactPointerTuple::setType): Deleted. * wtf/CompilationThread.h: (WTF::CompilationScope::CompilationScope): Deleted. (WTF::CompilationScope::~CompilationScope): Deleted. (WTF::CompilationScope::leaveEarly): Deleted. * wtf/CompletionHandler.h: (WTF::CompletionHandler<Out): (WTF::Detail::CallableWrapper<CompletionHandler<Out): (WTF::CompletionHandlerCallingScope::CompletionHandlerCallingScope): Deleted. (WTF::CompletionHandlerCallingScope::~CompletionHandlerCallingScope): Deleted. (WTF::CompletionHandlerCallingScope::CompletionHandler<void): Deleted. * wtf/ConcurrentBuffer.h: (WTF::ConcurrentBuffer::ConcurrentBuffer): Deleted. (WTF::ConcurrentBuffer::~ConcurrentBuffer): Deleted. (WTF::ConcurrentBuffer::growExact): Deleted. (WTF::ConcurrentBuffer::grow): Deleted. (WTF::ConcurrentBuffer::array const): Deleted. (WTF::ConcurrentBuffer::operator[]): Deleted. (WTF::ConcurrentBuffer::operator[] const): Deleted. (WTF::ConcurrentBuffer::createArray): Deleted. * wtf/ConcurrentPtrHashSet.h: (WTF::ConcurrentPtrHashSet::contains): Deleted. (WTF::ConcurrentPtrHashSet::add): Deleted. (WTF::ConcurrentPtrHashSet::size const): Deleted. (WTF::ConcurrentPtrHashSet::Table::maxLoad const): Deleted. (WTF::ConcurrentPtrHashSet::hash): Deleted. (WTF::ConcurrentPtrHashSet::cast): Deleted. (WTF::ConcurrentPtrHashSet::containsImpl const): Deleted. (WTF::ConcurrentPtrHashSet::addImpl): Deleted. * wtf/ConcurrentVector.h: (WTF::ConcurrentVector::~ConcurrentVector): Deleted. (WTF::ConcurrentVector::size const): Deleted. (WTF::ConcurrentVector::isEmpty const): Deleted. (WTF::ConcurrentVector::at): Deleted. (WTF::ConcurrentVector::at const): Deleted. (WTF::ConcurrentVector::operator[]): Deleted. (WTF::ConcurrentVector::operator[] const): Deleted. (WTF::ConcurrentVector::first): Deleted. (WTF::ConcurrentVector::first const): Deleted. (WTF::ConcurrentVector::last): Deleted. (WTF::ConcurrentVector::last const): Deleted. (WTF::ConcurrentVector::takeLast): Deleted. (WTF::ConcurrentVector::append): Deleted. (WTF::ConcurrentVector::alloc): Deleted. (WTF::ConcurrentVector::removeLast): Deleted. (WTF::ConcurrentVector::grow): Deleted. (WTF::ConcurrentVector::begin): Deleted. (WTF::ConcurrentVector::end): Deleted. (WTF::ConcurrentVector::segmentExistsFor): Deleted. (WTF::ConcurrentVector::segmentFor): Deleted. (WTF::ConcurrentVector::subscriptFor): Deleted. (WTF::ConcurrentVector::ensureSegmentsFor): Deleted. (WTF::ConcurrentVector::ensureSegment): Deleted. (WTF::ConcurrentVector::allocateSegment): Deleted. * wtf/Condition.h: (WTF::Condition::waitUntil): Deleted. (WTF::Condition::waitFor): Deleted. (WTF::Condition::wait): Deleted. (WTF::Condition::notifyOne): Deleted. (WTF::Condition::notifyAll): Deleted. * wtf/CountingLock.h: (WTF::CountingLock::LockHooks::lockHook): Deleted. (WTF::CountingLock::LockHooks::unlockHook): Deleted. (WTF::CountingLock::LockHooks::parkHook): Deleted. (WTF::CountingLock::LockHooks::handoffHook): Deleted. (WTF::CountingLock::tryLock): Deleted. (WTF::CountingLock::lock): Deleted. (WTF::CountingLock::unlock): Deleted. (WTF::CountingLock::isHeld const): Deleted. (WTF::CountingLock::isLocked const): Deleted. (WTF::CountingLock::Count::operator bool const): Deleted. (WTF::CountingLock::Count::operator== const): Deleted. (WTF::CountingLock::Count::operator!= const): Deleted. (WTF::CountingLock::tryOptimisticRead): Deleted. (WTF::CountingLock::validate): Deleted. (WTF::CountingLock::doOptimizedRead): Deleted. (WTF::CountingLock::tryOptimisticFencelessRead): Deleted. (WTF::CountingLock::fencelessValidate): Deleted. (WTF::CountingLock::doOptimizedFencelessRead): Deleted. (WTF::CountingLock::getCount): Deleted. * wtf/CrossThreadQueue.h: * wtf/CrossThreadTask.h: * wtf/CryptographicallyRandomNumber.cpp: * wtf/DataMutex.h: * wtf/DateMath.h: * wtf/Deque.h: (WTF::Deque::size const): Deleted. (WTF::Deque::isEmpty const): Deleted. (WTF::Deque::begin): Deleted. (WTF::Deque::end): Deleted. (WTF::Deque::begin const): Deleted. (WTF::Deque::end const): Deleted. (WTF::Deque::rbegin): Deleted. (WTF::Deque::rend): Deleted. (WTF::Deque::rbegin const): Deleted. (WTF::Deque::rend const): Deleted. (WTF::Deque::first): Deleted. (WTF::Deque::first const): Deleted. (WTF::Deque::last): Deleted. (WTF::Deque::last const): Deleted. (WTF::Deque::append): Deleted. * wtf/Dominators.h: * wtf/DoublyLinkedList.h: * wtf/Expected.h: * wtf/FastBitVector.h: * wtf/FileMetadata.h: * wtf/FileSystem.h: * wtf/GraphNodeWorklist.h: * wtf/GregorianDateTime.h: (WTF::GregorianDateTime::GregorianDateTime): Deleted. (WTF::GregorianDateTime::year const): Deleted. (WTF::GregorianDateTime::month const): Deleted. (WTF::GregorianDateTime::yearDay const): Deleted. (WTF::GregorianDateTime::monthDay const): Deleted. (WTF::GregorianDateTime::weekDay const): Deleted. (WTF::GregorianDateTime::hour const): Deleted. (WTF::GregorianDateTime::minute const): Deleted. (WTF::GregorianDateTime::second const): Deleted. (WTF::GregorianDateTime::utcOffset const): Deleted. (WTF::GregorianDateTime::isDST const): Deleted. (WTF::GregorianDateTime::setYear): Deleted. (WTF::GregorianDateTime::setMonth): Deleted. (WTF::GregorianDateTime::setYearDay): Deleted. (WTF::GregorianDateTime::setMonthDay): Deleted. (WTF::GregorianDateTime::setWeekDay): Deleted. (WTF::GregorianDateTime::setHour): Deleted. (WTF::GregorianDateTime::setMinute): Deleted. (WTF::GregorianDateTime::setSecond): Deleted. (WTF::GregorianDateTime::setUtcOffset): Deleted. (WTF::GregorianDateTime::setIsDST): Deleted. (WTF::GregorianDateTime::operator tm const): Deleted. (WTF::GregorianDateTime::copyFrom): Deleted. * wtf/HashTable.h: * wtf/Hasher.h: * wtf/HexNumber.h: * wtf/Indenter.h: * wtf/IndexMap.h: * wtf/IndexSet.h: * wtf/IndexSparseSet.h: * wtf/IndexedContainerIterator.h: * wtf/Insertion.h: * wtf/IteratorAdaptors.h: * wtf/IteratorRange.h: * wtf/KeyValuePair.h: * wtf/ListHashSet.h: (WTF::ListHashSet::begin): Deleted. (WTF::ListHashSet::end): Deleted. (WTF::ListHashSet::begin const): Deleted. (WTF::ListHashSet::end const): Deleted. (WTF::ListHashSet::random): Deleted. (WTF::ListHashSet::random const): Deleted. (WTF::ListHashSet::rbegin): Deleted. (WTF::ListHashSet::rend): Deleted. (WTF::ListHashSet::rbegin const): Deleted. (WTF::ListHashSet::rend const): Deleted. * wtf/Liveness.h: * wtf/LocklessBag.h: (WTF::LocklessBag::LocklessBag): Deleted. (WTF::LocklessBag::add): Deleted. (WTF::LocklessBag::iterate): Deleted. (WTF::LocklessBag::consumeAll): Deleted. (WTF::LocklessBag::consumeAllWithNode): Deleted. (WTF::LocklessBag::~LocklessBag): Deleted. * wtf/LoggingHashID.h: * wtf/MD5.h: * wtf/MachSendRight.h: * wtf/MainThreadData.h: * wtf/Markable.h: * wtf/MediaTime.h: * wtf/MemoryPressureHandler.h: * wtf/MessageQueue.h: (WTF::MessageQueue::MessageQueue): Deleted. * wtf/MetaAllocator.h: * wtf/MonotonicTime.h: (WTF::MonotonicTime::MonotonicTime): Deleted. (WTF::MonotonicTime::fromRawSeconds): Deleted. (WTF::MonotonicTime::infinity): Deleted. (WTF::MonotonicTime::nan): Deleted. (WTF::MonotonicTime::secondsSinceEpoch const): Deleted. (WTF::MonotonicTime::approximateMonotonicTime const): Deleted. (WTF::MonotonicTime::operator bool const): Deleted. (WTF::MonotonicTime::operator+ const): Deleted. (WTF::MonotonicTime::operator- const): Deleted. (WTF::MonotonicTime::operator% const): Deleted. (WTF::MonotonicTime::operator+=): Deleted. (WTF::MonotonicTime::operator-=): Deleted. (WTF::MonotonicTime::operator== const): Deleted. (WTF::MonotonicTime::operator!= const): Deleted. (WTF::MonotonicTime::operator< const): Deleted. (WTF::MonotonicTime::operator> const): Deleted. (WTF::MonotonicTime::operator<= const): Deleted. (WTF::MonotonicTime::operator>= const): Deleted. (WTF::MonotonicTime::isolatedCopy const): Deleted. (WTF::MonotonicTime::encode const): Deleted. (WTF::MonotonicTime::decode): Deleted. * wtf/NaturalLoops.h: * wtf/NoLock.h: * wtf/OSAllocator.h: * wtf/OptionSet.h: * wtf/Optional.h: * wtf/OrderMaker.h: * wtf/Packed.h: (WTF::alignof): * wtf/PackedIntVector.h: (WTF::PackedIntVector::PackedIntVector): Deleted. (WTF::PackedIntVector::operator=): Deleted. (WTF::PackedIntVector::size const): Deleted. (WTF::PackedIntVector::ensureSize): Deleted. (WTF::PackedIntVector::resize): Deleted. (WTF::PackedIntVector::clearAll): Deleted. (WTF::PackedIntVector::get const): Deleted. (WTF::PackedIntVector::set): Deleted. (WTF::PackedIntVector::mask): Deleted. * wtf/PageBlock.h: * wtf/ParallelJobsOpenMP.h: * wtf/ParkingLot.h: * wtf/PriorityQueue.h: (WTF::PriorityQueue::size const): Deleted. (WTF::PriorityQueue::isEmpty const): Deleted. (WTF::PriorityQueue::enqueue): Deleted. (WTF::PriorityQueue::peek const): Deleted. (WTF::PriorityQueue::dequeue): Deleted. (WTF::PriorityQueue::decreaseKey): Deleted. (WTF::PriorityQueue::increaseKey): Deleted. (WTF::PriorityQueue::begin const): Deleted. (WTF::PriorityQueue::end const): Deleted. (WTF::PriorityQueue::isValidHeap const): Deleted. (WTF::PriorityQueue::parentOf): Deleted. (WTF::PriorityQueue::leftChildOf): Deleted. (WTF::PriorityQueue::rightChildOf): Deleted. (WTF::PriorityQueue::siftUp): Deleted. (WTF::PriorityQueue::siftDown): Deleted. * wtf/RandomDevice.h: * wtf/Range.h: * wtf/RangeSet.h: (WTF::RangeSet::RangeSet): Deleted. (WTF::RangeSet::~RangeSet): Deleted. (WTF::RangeSet::add): Deleted. (WTF::RangeSet::contains const): Deleted. (WTF::RangeSet::overlaps const): Deleted. (WTF::RangeSet::clear): Deleted. (WTF::RangeSet::dump const): Deleted. (WTF::RangeSet::dumpRaw const): Deleted. (WTF::RangeSet::begin const): Deleted. (WTF::RangeSet::end const): Deleted. (WTF::RangeSet::addAll): Deleted. (WTF::RangeSet::compact): Deleted. (WTF::RangeSet::overlapsNonEmpty): Deleted. (WTF::RangeSet::subsumesNonEmpty): Deleted. (WTF::RangeSet::findRange const): Deleted. * wtf/RecursableLambda.h: * wtf/RedBlackTree.h: (WTF::RedBlackTree::Node::successor const): Deleted. (WTF::RedBlackTree::Node::predecessor const): Deleted. (WTF::RedBlackTree::Node::successor): Deleted. (WTF::RedBlackTree::Node::predecessor): Deleted. (WTF::RedBlackTree::Node::reset): Deleted. (WTF::RedBlackTree::Node::parent const): Deleted. (WTF::RedBlackTree::Node::setParent): Deleted. (WTF::RedBlackTree::Node::left const): Deleted. (WTF::RedBlackTree::Node::setLeft): Deleted. (WTF::RedBlackTree::Node::right const): Deleted. (WTF::RedBlackTree::Node::setRight): Deleted. (WTF::RedBlackTree::Node::color const): Deleted. (WTF::RedBlackTree::Node::setColor): Deleted. (WTF::RedBlackTree::RedBlackTree): Deleted. (WTF::RedBlackTree::insert): Deleted. (WTF::RedBlackTree::remove): Deleted. (WTF::RedBlackTree::findExact const): Deleted. (WTF::RedBlackTree::findLeastGreaterThanOrEqual const): Deleted. (WTF::RedBlackTree::findGreatestLessThanOrEqual const): Deleted. (WTF::RedBlackTree::first const): Deleted. (WTF::RedBlackTree::last const): Deleted. (WTF::RedBlackTree::size): Deleted. (WTF::RedBlackTree::isEmpty): Deleted. (WTF::RedBlackTree::treeMinimum): Deleted. (WTF::RedBlackTree::treeMaximum): Deleted. (WTF::RedBlackTree::treeInsert): Deleted. (WTF::RedBlackTree::leftRotate): Deleted. (WTF::RedBlackTree::rightRotate): Deleted. (WTF::RedBlackTree::removeFixup): Deleted. * wtf/ResourceUsage.h: * wtf/RunLoop.cpp: * wtf/RunLoopTimer.h: * wtf/SHA1.h: * wtf/Seconds.h: (WTF::Seconds::Seconds): Deleted. (WTF::Seconds::value const): Deleted. (WTF::Seconds::minutes const): Deleted. (WTF::Seconds::seconds const): Deleted. (WTF::Seconds::milliseconds const): Deleted. (WTF::Seconds::microseconds const): Deleted. (WTF::Seconds::nanoseconds const): Deleted. (WTF::Seconds::minutesAs const): Deleted. (WTF::Seconds::secondsAs const): Deleted. (WTF::Seconds::millisecondsAs const): Deleted. (WTF::Seconds::microsecondsAs const): Deleted. (WTF::Seconds::nanosecondsAs const): Deleted. (WTF::Seconds::fromMinutes): Deleted. (WTF::Seconds::fromHours): Deleted. (WTF::Seconds::fromMilliseconds): Deleted. (WTF::Seconds::fromMicroseconds): Deleted. (WTF::Seconds::fromNanoseconds): Deleted. (WTF::Seconds::infinity): Deleted. (WTF::Seconds::nan): Deleted. (WTF::Seconds::operator bool const): Deleted. (WTF::Seconds::operator+ const): Deleted. (WTF::Seconds::operator- const): Deleted. (WTF::Seconds::operator* const): Deleted. (WTF::Seconds::operator/ const): Deleted. (WTF::Seconds::operator% const): Deleted. (WTF::Seconds::operator+=): Deleted. (WTF::Seconds::operator-=): Deleted. (WTF::Seconds::operator*=): Deleted. (WTF::Seconds::operator/=): Deleted. (WTF::Seconds::operator%=): Deleted. (WTF::Seconds::operator== const): Deleted. (WTF::Seconds::operator!= const): Deleted. (WTF::Seconds::operator< const): Deleted. (WTF::Seconds::operator> const): Deleted. (WTF::Seconds::operator<= const): Deleted. (WTF::Seconds::operator>= const): Deleted. (WTF::Seconds::isolatedCopy const): Deleted. (WTF::Seconds::encode const): Deleted. (WTF::Seconds::decode): Deleted. * wtf/SegmentedVector.h: (WTF::SegmentedVector::~SegmentedVector): Deleted. (WTF::SegmentedVector::size const): Deleted. (WTF::SegmentedVector::isEmpty const): Deleted. (WTF::SegmentedVector::at): Deleted. (WTF::SegmentedVector::at const): Deleted. (WTF::SegmentedVector::operator[]): Deleted. (WTF::SegmentedVector::operator[] const): Deleted. (WTF::SegmentedVector::first): Deleted. (WTF::SegmentedVector::first const): Deleted. (WTF::SegmentedVector::last): Deleted. (WTF::SegmentedVector::last const): Deleted. (WTF::SegmentedVector::takeLast): Deleted. (WTF::SegmentedVector::append): Deleted. (WTF::SegmentedVector::alloc): Deleted. (WTF::SegmentedVector::removeLast): Deleted. (WTF::SegmentedVector::grow): Deleted. (WTF::SegmentedVector::clear): Deleted. (WTF::SegmentedVector::begin): Deleted. (WTF::SegmentedVector::end): Deleted. (WTF::SegmentedVector::shrinkToFit): Deleted. (WTF::SegmentedVector::deleteAllSegments): Deleted. (WTF::SegmentedVector::segmentExistsFor): Deleted. (WTF::SegmentedVector::segmentFor): Deleted. (WTF::SegmentedVector::subscriptFor): Deleted. (WTF::SegmentedVector::ensureSegmentsFor): Deleted. (WTF::SegmentedVector::ensureSegment): Deleted. (WTF::SegmentedVector::allocateSegment): Deleted. * wtf/SetForScope.h: * wtf/SingleRootGraph.h: * wtf/SinglyLinkedList.h: * wtf/SmallPtrSet.h: * wtf/SpanningTree.h: * wtf/Spectrum.h: * wtf/StackBounds.h: * wtf/StackShot.h: * wtf/StackShotProfiler.h: * wtf/StackStats.h: * wtf/StackTrace.h: * wtf/StreamBuffer.h: * wtf/SynchronizedFixedQueue.h: (WTF::SynchronizedFixedQueue::create): Deleted. (WTF::SynchronizedFixedQueue::open): Deleted. (WTF::SynchronizedFixedQueue::close): Deleted. (WTF::SynchronizedFixedQueue::isOpen): Deleted. (WTF::SynchronizedFixedQueue::enqueue): Deleted. (WTF::SynchronizedFixedQueue::dequeue): Deleted. (WTF::SynchronizedFixedQueue::SynchronizedFixedQueue): Deleted. * wtf/SystemTracing.h: * wtf/ThreadGroup.h: (WTF::ThreadGroup::create): Deleted. (WTF::ThreadGroup::threads const): Deleted. (WTF::ThreadGroup::getLock): Deleted. (WTF::ThreadGroup::weakFromThis): Deleted. * wtf/ThreadSpecific.h: * wtf/ThreadingPrimitives.h: (WTF::Mutex::impl): Deleted. * wtf/TimeWithDynamicClockType.h: (WTF::TimeWithDynamicClockType::TimeWithDynamicClockType): Deleted. (WTF::TimeWithDynamicClockType::fromRawSeconds): Deleted. (WTF::TimeWithDynamicClockType::secondsSinceEpoch const): Deleted. (WTF::TimeWithDynamicClockType::clockType const): Deleted. (WTF::TimeWithDynamicClockType::withSameClockAndRawSeconds const): Deleted. (WTF::TimeWithDynamicClockType::operator bool const): Deleted. (WTF::TimeWithDynamicClockType::operator+ const): Deleted. (WTF::TimeWithDynamicClockType::operator- const): Deleted. (WTF::TimeWithDynamicClockType::operator+=): Deleted. (WTF::TimeWithDynamicClockType::operator-=): Deleted. (WTF::TimeWithDynamicClockType::operator== const): Deleted. (WTF::TimeWithDynamicClockType::operator!= const): Deleted. * wtf/TimingScope.h: * wtf/TinyLRUCache.h: * wtf/TinyPtrSet.h: * wtf/URLParser.cpp: * wtf/URLParser.h: * wtf/Unexpected.h: * wtf/Variant.h: * wtf/WTFSemaphore.h: (WTF::Semaphore::Semaphore): Deleted. (WTF::Semaphore::signal): Deleted. (WTF::Semaphore::waitUntil): Deleted. (WTF::Semaphore::waitFor): Deleted. (WTF::Semaphore::wait): Deleted. * wtf/WallTime.h: (WTF::WallTime::WallTime): Deleted. (WTF::WallTime::fromRawSeconds): Deleted. (WTF::WallTime::infinity): Deleted. (WTF::WallTime::nan): Deleted. (WTF::WallTime::secondsSinceEpoch const): Deleted. (WTF::WallTime::approximateWallTime const): Deleted. (WTF::WallTime::operator bool const): Deleted. (WTF::WallTime::operator+ const): Deleted. (WTF::WallTime::operator- const): Deleted. (WTF::WallTime::operator+=): Deleted. (WTF::WallTime::operator-=): Deleted. (WTF::WallTime::operator== const): Deleted. (WTF::WallTime::operator!= const): Deleted. (WTF::WallTime::operator< const): Deleted. (WTF::WallTime::operator> const): Deleted. (WTF::WallTime::operator<= const): Deleted. (WTF::WallTime::operator>= const): Deleted. (WTF::WallTime::isolatedCopy const): Deleted. * wtf/WeakHashSet.h: (WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::get const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator* const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator-> const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator++): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator== const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator!= const): Deleted. (WTF::WeakHashSet::WeakHashSet): Deleted. (WTF::WeakHashSet::begin const): Deleted. (WTF::WeakHashSet::end const): Deleted. (WTF::WeakHashSet::add): Deleted. (WTF::WeakHashSet::remove): Deleted. (WTF::WeakHashSet::contains const): Deleted. (WTF::WeakHashSet::capacity const): Deleted. (WTF::WeakHashSet::computesEmpty const): Deleted. (WTF::WeakHashSet::hasNullReferences const): Deleted. (WTF::WeakHashSet::computeSize const): Deleted. (WTF::WeakHashSet::checkConsistency const): Deleted. * wtf/WeakRandom.h: (WTF::WeakRandom::WeakRandom): Deleted. (WTF::WeakRandom::setSeed): Deleted. (WTF::WeakRandom::seed const): Deleted. (WTF::WeakRandom::get): Deleted. (WTF::WeakRandom::getUint32): Deleted. (WTF::WeakRandom::lowOffset): Deleted. (WTF::WeakRandom::highOffset): Deleted. (WTF::WeakRandom::nextState): Deleted. (WTF::WeakRandom::generate): Deleted. (WTF::WeakRandom::advance): Deleted. * wtf/WordLock.h: (WTF::WordLock::lock): Deleted. (WTF::WordLock::unlock): Deleted. (WTF::WordLock::isHeld const): Deleted. (WTF::WordLock::isLocked const): Deleted. (WTF::WordLock::isFullyReset const): Deleted. * wtf/generic/MainThreadGeneric.cpp: * wtf/glib/GMutexLocker.h: * wtf/linux/CurrentProcessMemoryStatus.h: * wtf/posix/ThreadingPOSIX.cpp: (WTF::Semaphore::Semaphore): Deleted. (WTF::Semaphore::~Semaphore): Deleted. (WTF::Semaphore::wait): Deleted. (WTF::Semaphore::post): Deleted. * wtf/text/ASCIILiteral.h: (WTF::ASCIILiteral::operator const char* const): Deleted. (WTF::ASCIILiteral::fromLiteralUnsafe): Deleted. (WTF::ASCIILiteral::null): Deleted. (WTF::ASCIILiteral::characters const): Deleted. (WTF::ASCIILiteral::ASCIILiteral): Deleted. * wtf/text/AtomString.h: (WTF::AtomString::operator=): Deleted. (WTF::AtomString::isHashTableDeletedValue const): Deleted. (WTF::AtomString::existingHash const): Deleted. (WTF::AtomString::operator const String& const): Deleted. (WTF::AtomString::string const): Deleted. (WTF::AtomString::impl const): Deleted. (WTF::AtomString::is8Bit const): Deleted. (WTF::AtomString::characters8 const): Deleted. (WTF::AtomString::characters16 const): Deleted. (WTF::AtomString::length const): Deleted. (WTF::AtomString::operator[] const): Deleted. (WTF::AtomString::contains const): Deleted. (WTF::AtomString::containsIgnoringASCIICase const): Deleted. (WTF::AtomString::find const): Deleted. (WTF::AtomString::findIgnoringASCIICase const): Deleted. (WTF::AtomString::startsWith const): Deleted. (WTF::AtomString::startsWithIgnoringASCIICase const): Deleted. (WTF::AtomString::endsWith const): Deleted. (WTF::AtomString::endsWithIgnoringASCIICase const): Deleted. (WTF::AtomString::toInt const): Deleted. (WTF::AtomString::toDouble const): Deleted. (WTF::AtomString::toFloat const): Deleted. (WTF::AtomString::percentage const): Deleted. (WTF::AtomString::isNull const): Deleted. (WTF::AtomString::isEmpty const): Deleted. (WTF::AtomString::operator NSString * const): Deleted. * wtf/text/AtomStringImpl.h: (WTF::AtomStringImpl::lookUp): Deleted. (WTF::AtomStringImpl::add): Deleted. (WTF::AtomStringImpl::addWithStringTableProvider): Deleted. * wtf/text/CString.h: (WTF::CStringBuffer::data): Deleted. (WTF::CStringBuffer::length const): Deleted. (WTF::CStringBuffer::CStringBuffer): Deleted. (WTF::CStringBuffer::mutableData): Deleted. (WTF::CString::CString): Deleted. (WTF::CString::data const): Deleted. (WTF::CString::length const): Deleted. (WTF::CString::isNull const): Deleted. (WTF::CString::buffer const): Deleted. (WTF::CString::isHashTableDeletedValue const): Deleted. * wtf/text/ExternalStringImpl.h: (WTF::ExternalStringImpl::freeExternalBuffer): Deleted. * wtf/text/LineBreakIteratorPoolICU.h: * wtf/text/NullTextBreakIterator.h: * wtf/text/OrdinalNumber.h: * wtf/text/StringBuffer.h: * wtf/text/StringBuilder.h: * wtf/text/StringConcatenateNumbers.h: * wtf/text/StringHasher.h: * wtf/text/StringImpl.h: * wtf/text/StringView.cpp: * wtf/text/StringView.h: (WTF::StringView::left const): Deleted. (WTF::StringView::right const): Deleted. (WTF::StringView::underlyingStringIsValid const): Deleted. (WTF::StringView::setUnderlyingString): Deleted. * wtf/text/SymbolImpl.h: (WTF::SymbolImpl::StaticSymbolImpl::StaticSymbolImpl): Deleted. (WTF::SymbolImpl::StaticSymbolImpl::operator SymbolImpl&): Deleted. (WTF::PrivateSymbolImpl::PrivateSymbolImpl): Deleted. (WTF::RegisteredSymbolImpl::symbolRegistry const): Deleted. (WTF::RegisteredSymbolImpl::clearSymbolRegistry): Deleted. (WTF::RegisteredSymbolImpl::RegisteredSymbolImpl): Deleted. * wtf/text/SymbolRegistry.h: * wtf/text/TextBreakIterator.h: * wtf/text/TextPosition.h: * wtf/text/TextStream.h: * wtf/text/WTFString.h: (WTF::String::swap): Deleted. (WTF::String::adopt): Deleted. (WTF::String::isNull const): Deleted. (WTF::String::isEmpty const): Deleted. (WTF::String::impl const): Deleted. (WTF::String::releaseImpl): Deleted. (WTF::String::length const): Deleted. (WTF::String::characters8 const): Deleted. (WTF::String::characters16 const): Deleted. (WTF::String::is8Bit const): Deleted. (WTF::String::sizeInBytes const): Deleted. (WTF::String::operator[] const): Deleted. (WTF::String::find const): Deleted. (WTF::String::findIgnoringASCIICase const): Deleted. (WTF::String::reverseFind const): Deleted. (WTF::String::contains const): Deleted. (WTF::String::containsIgnoringASCIICase const): Deleted. (WTF::String::startsWith const): Deleted. (WTF::String::startsWithIgnoringASCIICase const): Deleted. (WTF::String::hasInfixStartingAt const): Deleted. (WTF::String::endsWith const): Deleted. (WTF::String::endsWithIgnoringASCIICase const): Deleted. (WTF::String::hasInfixEndingAt const): Deleted. (WTF::String::append): Deleted. (WTF::String::left const): Deleted. (WTF::String::right const): Deleted. (WTF::String::createUninitialized): Deleted. (WTF::String::fromUTF8WithLatin1Fallback): Deleted. (WTF::String::isAllASCII const): Deleted. (WTF::String::isAllLatin1 const): Deleted. (WTF::String::isSpecialCharacter const): Deleted. (WTF::String::isHashTableDeletedValue const): Deleted. (WTF::String::hash const): Deleted. (WTF::String::existingHash const): Deleted. * wtf/text/cf/TextBreakIteratorCF.h: * wtf/text/icu/TextBreakIteratorICU.h: * wtf/text/icu/UTextProviderLatin1.h: * wtf/threads/BinarySemaphore.h: (WTF::BinarySemaphore::waitFor): Deleted. (WTF::BinarySemaphore::wait): Deleted. * wtf/unicode/Collator.h: * wtf/win/GDIObject.h: * wtf/win/PathWalker.h: * wtf/win/Win32Handle.h: Canonical link: https://commits.webkit.org/214396@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248546 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-08-12 20:57:15 +00:00
WTF_MAKE_FAST_ALLOCATED;
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
public:
static constexpr bool isPackedType = true;
Packed()
: Packed(T { })
{
}
Packed(const T& value)
{
unalignedStore<T>(m_storage.data(), value);
}
T get() const
{
return unalignedLoad<T>(m_storage.data());
}
void set(const T& value)
{
unalignedStore<T>(m_storage.data(), value);
}
Packed<T>& operator=(const T& value)
{
set(value);
return *this;
}
template<class U>
T exchange(U&& newValue)
{
T oldValue = get();
set(std::forward<U>(newValue));
return oldValue;
}
void swap(Packed& other)
{
m_storage.swap(other.m_storage);
}
template<typename Other, typename = std::enable_if_t<Other::isPackedType>>
void swap(Other& other)
{
T t1 = get();
T t2 = other.get();
set(t2);
other.set(t1);
}
void swap(T& t2)
{
T t1 = get();
std::swap(t1, t2);
set(t1);
}
private:
std::array<uint8_t, sizeof(T)> m_storage;
};
// PackedAlignedPtr can take alignment parameter too. PackedAlignedPtr only uses this alignment information if it is profitable: we use
// alignment information only when we can reduce the size of the storage.
[WTF] AtomStringTable should be small https://bugs.webkit.org/show_bug.cgi?id=206400 Reviewed by Sam Weinig. Source/WebCore: * dom/GCReachableRef.h: (WebCore::GCReachableRef::GCReachableRef): * dom/QualifiedName.h: (WebCore::QualifiedName::hashTableDeletedValue): Source/WTF: AtomStringTable is the largest hashtable typically. It takes more than 256KB per WebProcess (sometimes, it took 1MB or more). This patch leverages PackedPtr to compact it from 8 bytes per entry to 6 bytes per entry. While this is still large, we should investigate how to compact C++ pointers in 4 bytes[1] to shrink memory footprint, since WebKit memory is used by Vector and HashTable fulfilled with pointers. [1]: https://bugs.webkit.org/show_bug.cgi?id=206469 * wtf/DumbPtrTraits.h: (WTF::DumbPtrTraits::hashTableDeletedValue): (WTF::DumbPtrTraits::isHashTableDeletedValue): * wtf/Forward.h: * wtf/HashTraits.h: * wtf/Packed.h: (WTF::Packed<T::Packed): (WTF::Packed<T::isHashTableDeletedValue const): (WTF::GetPtrHelper<PackedPtr<T>>::getPtr): (WTF::PackedPtrTraits::hashTableDeletedValue): (WTF::PackedPtrTraits::isHashTableDeletedValue): (WTF::alignof): Deleted. * wtf/Ref.h: (WTF::Ref::Ref): (WTF::Ref::isHashTableDeletedValue const): (WTF::Ref::hashTableDeletedValue): Deleted. * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): (WTF::RefPtr::isHashTableDeletedValue const): (WTF::RefPtr::hashTableDeletedValue): Deleted. * wtf/text/AtomStringImpl.cpp: (WTF::addToStringTable): (WTF::CStringTranslator::equal): (WTF::CStringTranslator::translate): (WTF::UCharBufferTranslator::equal): (WTF::UCharBufferTranslator::translate): (WTF::HashAndUTF8CharactersTranslator::equal): (WTF::HashAndUTF8CharactersTranslator::translate): (WTF::SubstringTranslator::translate): (WTF::SubstringTranslator8::equal): (WTF::SubstringTranslator16::equal): (WTF::LCharBufferTranslator::equal): (WTF::LCharBufferTranslator::translate): (WTF::BufferFromStaticDataTranslator::equal): (WTF::BufferFromStaticDataTranslator::translate): (WTF::AtomStringImpl::addSlowCase): (WTF::AtomStringImpl::remove): (WTF::AtomStringImpl::lookUpSlowCase): (WTF::AtomStringImpl::lookUp): * wtf/text/AtomStringTable.cpp: (WTF::AtomStringTable::~AtomStringTable): * wtf/text/AtomStringTable.h: (WTF::AtomStringTable::table): (): Deleted. * wtf/text/StringHash.h: (WTF::StringHash::hash): (WTF::StringHash::equal): (WTF::ASCIICaseInsensitiveHash::hash): (WTF::ASCIICaseInsensitiveHash::equal): * wtf/text/StringImpl.h: Tools: * TestWebKitAPI/Tests/WTF/HashMap.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/219616@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254881 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-21 22:05:43 +00:00
template<typename T, size_t passedAlignment>
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
class PackedAlignedPtr {
[WTF][JSC] Make JSC and WTF aggressively-fast-malloced https://bugs.webkit.org/show_bug.cgi?id=200611 Reviewed by Saam Barati. Source/JavaScriptCore: This patch aggressively puts many classes into FastMalloc. In JSC side, we grep `std::make_unique` etc. to find potentially system-malloc-allocated classes. After this patch, all the JSC related allocations in JetStream2 cli is done from bmalloc. In the future, it would be nice that we add `WTF::makeUnique<T>` helper function and throw a compile error if `T` is not FastMalloc annotated[1]. Putting WebKit classes in FastMalloc has many benefits. 1. Simply, it is fast. 2. vmmap can tell the amount of memory used for WebKit. 3. bmalloc can isolate WebKit memory allocation from the rest of the world. This is useful since we can know more about what component is corrupting the memory from the memory corruption crash. [1]: https://bugs.webkit.org/show_bug.cgi?id=200620 * API/ObjCCallbackFunction.mm: * assembler/AbstractMacroAssembler.h: * b3/B3PhiChildren.h: * b3/air/AirAllocateRegistersAndStackAndGenerateCode.h: * b3/air/AirDisassembler.h: * bytecode/AccessCaseSnippetParams.h: * bytecode/CallVariant.h: * bytecode/DeferredSourceDump.h: * bytecode/ExecutionCounter.h: * bytecode/GetByIdStatus.h: * bytecode/GetByIdVariant.h: * bytecode/InByIdStatus.h: * bytecode/InByIdVariant.h: * bytecode/InstanceOfStatus.h: * bytecode/InstanceOfVariant.h: * bytecode/PutByIdStatus.h: * bytecode/PutByIdVariant.h: * bytecode/ValueProfile.h: * dfg/DFGAbstractInterpreter.h: * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::newVariableAccessData): * dfg/DFGFlowIndexing.h: * dfg/DFGFlowMap.h: * dfg/DFGLiveCatchVariablePreservationPhase.cpp: (JSC::DFG::LiveCatchVariablePreservationPhase::newVariableAccessData): * dfg/DFGMaximalFlushInsertionPhase.cpp: (JSC::DFG::MaximalFlushInsertionPhase::newVariableAccessData): * dfg/DFGOSRExit.h: * dfg/DFGSpeculativeJIT.h: * dfg/DFGVariableAccessData.h: * disassembler/ARM64/A64DOpcode.h: * inspector/remote/socket/RemoteInspectorMessageParser.h: * inspector/remote/socket/RemoteInspectorSocket.h: * inspector/remote/socket/RemoteInspectorSocketEndpoint.h: * jit/PCToCodeOriginMap.h: * runtime/BasicBlockLocation.h: * runtime/DoublePredictionFuzzerAgent.h: * runtime/JSRunLoopTimer.h: * runtime/PromiseDeferredTimer.h: (JSC::PromiseDeferredTimer::create): PromiseDeferredTimer should be allocated as `Ref<>` instead of `std::unique_ptr` since it is inheriting ThreadSafeRefCounted<>. Holding such a class with std::unique_ptr could lead to potentially dangerous operations (like, someone holds it with Ref<> while it is deleted by std::unique_ptr<>). * runtime/RandomizingFuzzerAgent.h: * runtime/SymbolTable.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * tools/JSDollarVM.cpp: * tools/SigillCrashAnalyzer.cpp: * wasm/WasmFormat.h: * wasm/WasmMemory.cpp: * wasm/WasmSignature.h: * yarr/YarrJIT.h: Source/WebCore: Changed the accessor since we changed std::unique_ptr to Ref for this field. No behavior change. * bindings/js/WorkerScriptController.cpp: (WebCore::WorkerScriptController::addTimerSetNotification): (WebCore::WorkerScriptController::removeTimerSetNotification): Source/WTF: WTF has many data structures, in particular, containers. And these containers can be allocated like `std::make_unique<Container>()`. Without WTF_MAKE_FAST_ALLOCATED, this container itself is allocated from the system malloc. This patch attaches WTF_MAKE_FAST_ALLOCATED more aggressively not to allocate them from the system malloc. And we add some `final` to containers and classes that would be never inherited. * wtf/Assertions.cpp: * wtf/Atomics.h: * wtf/AutodrainedPool.h: * wtf/Bag.h: (WTF::Bag::Bag): Deleted. (WTF::Bag::~Bag): Deleted. (WTF::Bag::clear): Deleted. (WTF::Bag::add): Deleted. (WTF::Bag::iterator::iterator): Deleted. (WTF::Bag::iterator::operator! const): Deleted. (WTF::Bag::iterator::operator* const): Deleted. (WTF::Bag::iterator::operator++): Deleted. (WTF::Bag::iterator::operator== const): Deleted. (WTF::Bag::iterator::operator!= const): Deleted. (WTF::Bag::begin): Deleted. (WTF::Bag::begin const): Deleted. (WTF::Bag::end const): Deleted. (WTF::Bag::isEmpty const): Deleted. (WTF::Bag::unwrappedHead const): Deleted. * wtf/BitVector.h: (WTF::BitVector::BitVector): Deleted. (WTF::BitVector::~BitVector): Deleted. (WTF::BitVector::operator=): Deleted. (WTF::BitVector::size const): Deleted. (WTF::BitVector::ensureSize): Deleted. (WTF::BitVector::quickGet const): Deleted. (WTF::BitVector::quickSet): Deleted. (WTF::BitVector::quickClear): Deleted. (WTF::BitVector::get const): Deleted. (WTF::BitVector::contains const): Deleted. (WTF::BitVector::set): Deleted. (WTF::BitVector::add): Deleted. (WTF::BitVector::ensureSizeAndSet): Deleted. (WTF::BitVector::clear): Deleted. (WTF::BitVector::remove): Deleted. (WTF::BitVector::merge): Deleted. (WTF::BitVector::filter): Deleted. (WTF::BitVector::exclude): Deleted. (WTF::BitVector::bitCount const): Deleted. (WTF::BitVector::isEmpty const): Deleted. (WTF::BitVector::findBit const): Deleted. (WTF::BitVector::isEmptyValue const): Deleted. (WTF::BitVector::isDeletedValue const): Deleted. (WTF::BitVector::isEmptyOrDeletedValue const): Deleted. (WTF::BitVector::operator== const): Deleted. (WTF::BitVector::hash const): Deleted. (WTF::BitVector::iterator::iterator): Deleted. (WTF::BitVector::iterator::operator* const): Deleted. (WTF::BitVector::iterator::operator++): Deleted. (WTF::BitVector::iterator::isAtEnd const): Deleted. (WTF::BitVector::iterator::operator== const): Deleted. (WTF::BitVector::iterator::operator!= const): Deleted. (WTF::BitVector::begin const): Deleted. (WTF::BitVector::end const): Deleted. (WTF::BitVector::bitsInPointer): Deleted. (WTF::BitVector::maxInlineBits): Deleted. (WTF::BitVector::byteCount): Deleted. (WTF::BitVector::makeInlineBits): Deleted. (WTF::BitVector::cleanseInlineBits): Deleted. (WTF::BitVector::bitCount): Deleted. (WTF::BitVector::findBitFast const): Deleted. (WTF::BitVector::findBitSimple const): Deleted. (WTF::BitVector::OutOfLineBits::numBits const): Deleted. (WTF::BitVector::OutOfLineBits::numWords const): Deleted. (WTF::BitVector::OutOfLineBits::bits): Deleted. (WTF::BitVector::OutOfLineBits::bits const): Deleted. (WTF::BitVector::OutOfLineBits::OutOfLineBits): Deleted. (WTF::BitVector::isInline const): Deleted. (WTF::BitVector::outOfLineBits const): Deleted. (WTF::BitVector::outOfLineBits): Deleted. (WTF::BitVector::bits): Deleted. (WTF::BitVector::bits const): Deleted. * wtf/Bitmap.h: (WTF::Bitmap::size): Deleted. (WTF::Bitmap::iterator::iterator): Deleted. (WTF::Bitmap::iterator::operator* const): Deleted. (WTF::Bitmap::iterator::operator++): Deleted. (WTF::Bitmap::iterator::operator== const): Deleted. (WTF::Bitmap::iterator::operator!= const): Deleted. (WTF::Bitmap::begin const): Deleted. (WTF::Bitmap::end const): Deleted. * wtf/Box.h: * wtf/BumpPointerAllocator.h: * wtf/CPUTime.h: * wtf/CheckedBoolean.h: * wtf/CommaPrinter.h: (WTF::CommaPrinter::CommaPrinter): Deleted. (WTF::CommaPrinter::dump const): Deleted. (WTF::CommaPrinter::didPrint const): Deleted. * wtf/CompactPointerTuple.h: (WTF::CompactPointerTuple::encodeType): Deleted. (WTF::CompactPointerTuple::decodeType): Deleted. (WTF::CompactPointerTuple::CompactPointerTuple): Deleted. (WTF::CompactPointerTuple::pointer const): Deleted. (WTF::CompactPointerTuple::setPointer): Deleted. (WTF::CompactPointerTuple::type const): Deleted. (WTF::CompactPointerTuple::setType): Deleted. * wtf/CompilationThread.h: (WTF::CompilationScope::CompilationScope): Deleted. (WTF::CompilationScope::~CompilationScope): Deleted. (WTF::CompilationScope::leaveEarly): Deleted. * wtf/CompletionHandler.h: (WTF::CompletionHandler<Out): (WTF::Detail::CallableWrapper<CompletionHandler<Out): (WTF::CompletionHandlerCallingScope::CompletionHandlerCallingScope): Deleted. (WTF::CompletionHandlerCallingScope::~CompletionHandlerCallingScope): Deleted. (WTF::CompletionHandlerCallingScope::CompletionHandler<void): Deleted. * wtf/ConcurrentBuffer.h: (WTF::ConcurrentBuffer::ConcurrentBuffer): Deleted. (WTF::ConcurrentBuffer::~ConcurrentBuffer): Deleted. (WTF::ConcurrentBuffer::growExact): Deleted. (WTF::ConcurrentBuffer::grow): Deleted. (WTF::ConcurrentBuffer::array const): Deleted. (WTF::ConcurrentBuffer::operator[]): Deleted. (WTF::ConcurrentBuffer::operator[] const): Deleted. (WTF::ConcurrentBuffer::createArray): Deleted. * wtf/ConcurrentPtrHashSet.h: (WTF::ConcurrentPtrHashSet::contains): Deleted. (WTF::ConcurrentPtrHashSet::add): Deleted. (WTF::ConcurrentPtrHashSet::size const): Deleted. (WTF::ConcurrentPtrHashSet::Table::maxLoad const): Deleted. (WTF::ConcurrentPtrHashSet::hash): Deleted. (WTF::ConcurrentPtrHashSet::cast): Deleted. (WTF::ConcurrentPtrHashSet::containsImpl const): Deleted. (WTF::ConcurrentPtrHashSet::addImpl): Deleted. * wtf/ConcurrentVector.h: (WTF::ConcurrentVector::~ConcurrentVector): Deleted. (WTF::ConcurrentVector::size const): Deleted. (WTF::ConcurrentVector::isEmpty const): Deleted. (WTF::ConcurrentVector::at): Deleted. (WTF::ConcurrentVector::at const): Deleted. (WTF::ConcurrentVector::operator[]): Deleted. (WTF::ConcurrentVector::operator[] const): Deleted. (WTF::ConcurrentVector::first): Deleted. (WTF::ConcurrentVector::first const): Deleted. (WTF::ConcurrentVector::last): Deleted. (WTF::ConcurrentVector::last const): Deleted. (WTF::ConcurrentVector::takeLast): Deleted. (WTF::ConcurrentVector::append): Deleted. (WTF::ConcurrentVector::alloc): Deleted. (WTF::ConcurrentVector::removeLast): Deleted. (WTF::ConcurrentVector::grow): Deleted. (WTF::ConcurrentVector::begin): Deleted. (WTF::ConcurrentVector::end): Deleted. (WTF::ConcurrentVector::segmentExistsFor): Deleted. (WTF::ConcurrentVector::segmentFor): Deleted. (WTF::ConcurrentVector::subscriptFor): Deleted. (WTF::ConcurrentVector::ensureSegmentsFor): Deleted. (WTF::ConcurrentVector::ensureSegment): Deleted. (WTF::ConcurrentVector::allocateSegment): Deleted. * wtf/Condition.h: (WTF::Condition::waitUntil): Deleted. (WTF::Condition::waitFor): Deleted. (WTF::Condition::wait): Deleted. (WTF::Condition::notifyOne): Deleted. (WTF::Condition::notifyAll): Deleted. * wtf/CountingLock.h: (WTF::CountingLock::LockHooks::lockHook): Deleted. (WTF::CountingLock::LockHooks::unlockHook): Deleted. (WTF::CountingLock::LockHooks::parkHook): Deleted. (WTF::CountingLock::LockHooks::handoffHook): Deleted. (WTF::CountingLock::tryLock): Deleted. (WTF::CountingLock::lock): Deleted. (WTF::CountingLock::unlock): Deleted. (WTF::CountingLock::isHeld const): Deleted. (WTF::CountingLock::isLocked const): Deleted. (WTF::CountingLock::Count::operator bool const): Deleted. (WTF::CountingLock::Count::operator== const): Deleted. (WTF::CountingLock::Count::operator!= const): Deleted. (WTF::CountingLock::tryOptimisticRead): Deleted. (WTF::CountingLock::validate): Deleted. (WTF::CountingLock::doOptimizedRead): Deleted. (WTF::CountingLock::tryOptimisticFencelessRead): Deleted. (WTF::CountingLock::fencelessValidate): Deleted. (WTF::CountingLock::doOptimizedFencelessRead): Deleted. (WTF::CountingLock::getCount): Deleted. * wtf/CrossThreadQueue.h: * wtf/CrossThreadTask.h: * wtf/CryptographicallyRandomNumber.cpp: * wtf/DataMutex.h: * wtf/DateMath.h: * wtf/Deque.h: (WTF::Deque::size const): Deleted. (WTF::Deque::isEmpty const): Deleted. (WTF::Deque::begin): Deleted. (WTF::Deque::end): Deleted. (WTF::Deque::begin const): Deleted. (WTF::Deque::end const): Deleted. (WTF::Deque::rbegin): Deleted. (WTF::Deque::rend): Deleted. (WTF::Deque::rbegin const): Deleted. (WTF::Deque::rend const): Deleted. (WTF::Deque::first): Deleted. (WTF::Deque::first const): Deleted. (WTF::Deque::last): Deleted. (WTF::Deque::last const): Deleted. (WTF::Deque::append): Deleted. * wtf/Dominators.h: * wtf/DoublyLinkedList.h: * wtf/Expected.h: * wtf/FastBitVector.h: * wtf/FileMetadata.h: * wtf/FileSystem.h: * wtf/GraphNodeWorklist.h: * wtf/GregorianDateTime.h: (WTF::GregorianDateTime::GregorianDateTime): Deleted. (WTF::GregorianDateTime::year const): Deleted. (WTF::GregorianDateTime::month const): Deleted. (WTF::GregorianDateTime::yearDay const): Deleted. (WTF::GregorianDateTime::monthDay const): Deleted. (WTF::GregorianDateTime::weekDay const): Deleted. (WTF::GregorianDateTime::hour const): Deleted. (WTF::GregorianDateTime::minute const): Deleted. (WTF::GregorianDateTime::second const): Deleted. (WTF::GregorianDateTime::utcOffset const): Deleted. (WTF::GregorianDateTime::isDST const): Deleted. (WTF::GregorianDateTime::setYear): Deleted. (WTF::GregorianDateTime::setMonth): Deleted. (WTF::GregorianDateTime::setYearDay): Deleted. (WTF::GregorianDateTime::setMonthDay): Deleted. (WTF::GregorianDateTime::setWeekDay): Deleted. (WTF::GregorianDateTime::setHour): Deleted. (WTF::GregorianDateTime::setMinute): Deleted. (WTF::GregorianDateTime::setSecond): Deleted. (WTF::GregorianDateTime::setUtcOffset): Deleted. (WTF::GregorianDateTime::setIsDST): Deleted. (WTF::GregorianDateTime::operator tm const): Deleted. (WTF::GregorianDateTime::copyFrom): Deleted. * wtf/HashTable.h: * wtf/Hasher.h: * wtf/HexNumber.h: * wtf/Indenter.h: * wtf/IndexMap.h: * wtf/IndexSet.h: * wtf/IndexSparseSet.h: * wtf/IndexedContainerIterator.h: * wtf/Insertion.h: * wtf/IteratorAdaptors.h: * wtf/IteratorRange.h: * wtf/KeyValuePair.h: * wtf/ListHashSet.h: (WTF::ListHashSet::begin): Deleted. (WTF::ListHashSet::end): Deleted. (WTF::ListHashSet::begin const): Deleted. (WTF::ListHashSet::end const): Deleted. (WTF::ListHashSet::random): Deleted. (WTF::ListHashSet::random const): Deleted. (WTF::ListHashSet::rbegin): Deleted. (WTF::ListHashSet::rend): Deleted. (WTF::ListHashSet::rbegin const): Deleted. (WTF::ListHashSet::rend const): Deleted. * wtf/Liveness.h: * wtf/LocklessBag.h: (WTF::LocklessBag::LocklessBag): Deleted. (WTF::LocklessBag::add): Deleted. (WTF::LocklessBag::iterate): Deleted. (WTF::LocklessBag::consumeAll): Deleted. (WTF::LocklessBag::consumeAllWithNode): Deleted. (WTF::LocklessBag::~LocklessBag): Deleted. * wtf/LoggingHashID.h: * wtf/MD5.h: * wtf/MachSendRight.h: * wtf/MainThreadData.h: * wtf/Markable.h: * wtf/MediaTime.h: * wtf/MemoryPressureHandler.h: * wtf/MessageQueue.h: (WTF::MessageQueue::MessageQueue): Deleted. * wtf/MetaAllocator.h: * wtf/MonotonicTime.h: (WTF::MonotonicTime::MonotonicTime): Deleted. (WTF::MonotonicTime::fromRawSeconds): Deleted. (WTF::MonotonicTime::infinity): Deleted. (WTF::MonotonicTime::nan): Deleted. (WTF::MonotonicTime::secondsSinceEpoch const): Deleted. (WTF::MonotonicTime::approximateMonotonicTime const): Deleted. (WTF::MonotonicTime::operator bool const): Deleted. (WTF::MonotonicTime::operator+ const): Deleted. (WTF::MonotonicTime::operator- const): Deleted. (WTF::MonotonicTime::operator% const): Deleted. (WTF::MonotonicTime::operator+=): Deleted. (WTF::MonotonicTime::operator-=): Deleted. (WTF::MonotonicTime::operator== const): Deleted. (WTF::MonotonicTime::operator!= const): Deleted. (WTF::MonotonicTime::operator< const): Deleted. (WTF::MonotonicTime::operator> const): Deleted. (WTF::MonotonicTime::operator<= const): Deleted. (WTF::MonotonicTime::operator>= const): Deleted. (WTF::MonotonicTime::isolatedCopy const): Deleted. (WTF::MonotonicTime::encode const): Deleted. (WTF::MonotonicTime::decode): Deleted. * wtf/NaturalLoops.h: * wtf/NoLock.h: * wtf/OSAllocator.h: * wtf/OptionSet.h: * wtf/Optional.h: * wtf/OrderMaker.h: * wtf/Packed.h: (WTF::alignof): * wtf/PackedIntVector.h: (WTF::PackedIntVector::PackedIntVector): Deleted. (WTF::PackedIntVector::operator=): Deleted. (WTF::PackedIntVector::size const): Deleted. (WTF::PackedIntVector::ensureSize): Deleted. (WTF::PackedIntVector::resize): Deleted. (WTF::PackedIntVector::clearAll): Deleted. (WTF::PackedIntVector::get const): Deleted. (WTF::PackedIntVector::set): Deleted. (WTF::PackedIntVector::mask): Deleted. * wtf/PageBlock.h: * wtf/ParallelJobsOpenMP.h: * wtf/ParkingLot.h: * wtf/PriorityQueue.h: (WTF::PriorityQueue::size const): Deleted. (WTF::PriorityQueue::isEmpty const): Deleted. (WTF::PriorityQueue::enqueue): Deleted. (WTF::PriorityQueue::peek const): Deleted. (WTF::PriorityQueue::dequeue): Deleted. (WTF::PriorityQueue::decreaseKey): Deleted. (WTF::PriorityQueue::increaseKey): Deleted. (WTF::PriorityQueue::begin const): Deleted. (WTF::PriorityQueue::end const): Deleted. (WTF::PriorityQueue::isValidHeap const): Deleted. (WTF::PriorityQueue::parentOf): Deleted. (WTF::PriorityQueue::leftChildOf): Deleted. (WTF::PriorityQueue::rightChildOf): Deleted. (WTF::PriorityQueue::siftUp): Deleted. (WTF::PriorityQueue::siftDown): Deleted. * wtf/RandomDevice.h: * wtf/Range.h: * wtf/RangeSet.h: (WTF::RangeSet::RangeSet): Deleted. (WTF::RangeSet::~RangeSet): Deleted. (WTF::RangeSet::add): Deleted. (WTF::RangeSet::contains const): Deleted. (WTF::RangeSet::overlaps const): Deleted. (WTF::RangeSet::clear): Deleted. (WTF::RangeSet::dump const): Deleted. (WTF::RangeSet::dumpRaw const): Deleted. (WTF::RangeSet::begin const): Deleted. (WTF::RangeSet::end const): Deleted. (WTF::RangeSet::addAll): Deleted. (WTF::RangeSet::compact): Deleted. (WTF::RangeSet::overlapsNonEmpty): Deleted. (WTF::RangeSet::subsumesNonEmpty): Deleted. (WTF::RangeSet::findRange const): Deleted. * wtf/RecursableLambda.h: * wtf/RedBlackTree.h: (WTF::RedBlackTree::Node::successor const): Deleted. (WTF::RedBlackTree::Node::predecessor const): Deleted. (WTF::RedBlackTree::Node::successor): Deleted. (WTF::RedBlackTree::Node::predecessor): Deleted. (WTF::RedBlackTree::Node::reset): Deleted. (WTF::RedBlackTree::Node::parent const): Deleted. (WTF::RedBlackTree::Node::setParent): Deleted. (WTF::RedBlackTree::Node::left const): Deleted. (WTF::RedBlackTree::Node::setLeft): Deleted. (WTF::RedBlackTree::Node::right const): Deleted. (WTF::RedBlackTree::Node::setRight): Deleted. (WTF::RedBlackTree::Node::color const): Deleted. (WTF::RedBlackTree::Node::setColor): Deleted. (WTF::RedBlackTree::RedBlackTree): Deleted. (WTF::RedBlackTree::insert): Deleted. (WTF::RedBlackTree::remove): Deleted. (WTF::RedBlackTree::findExact const): Deleted. (WTF::RedBlackTree::findLeastGreaterThanOrEqual const): Deleted. (WTF::RedBlackTree::findGreatestLessThanOrEqual const): Deleted. (WTF::RedBlackTree::first const): Deleted. (WTF::RedBlackTree::last const): Deleted. (WTF::RedBlackTree::size): Deleted. (WTF::RedBlackTree::isEmpty): Deleted. (WTF::RedBlackTree::treeMinimum): Deleted. (WTF::RedBlackTree::treeMaximum): Deleted. (WTF::RedBlackTree::treeInsert): Deleted. (WTF::RedBlackTree::leftRotate): Deleted. (WTF::RedBlackTree::rightRotate): Deleted. (WTF::RedBlackTree::removeFixup): Deleted. * wtf/ResourceUsage.h: * wtf/RunLoop.cpp: * wtf/RunLoopTimer.h: * wtf/SHA1.h: * wtf/Seconds.h: (WTF::Seconds::Seconds): Deleted. (WTF::Seconds::value const): Deleted. (WTF::Seconds::minutes const): Deleted. (WTF::Seconds::seconds const): Deleted. (WTF::Seconds::milliseconds const): Deleted. (WTF::Seconds::microseconds const): Deleted. (WTF::Seconds::nanoseconds const): Deleted. (WTF::Seconds::minutesAs const): Deleted. (WTF::Seconds::secondsAs const): Deleted. (WTF::Seconds::millisecondsAs const): Deleted. (WTF::Seconds::microsecondsAs const): Deleted. (WTF::Seconds::nanosecondsAs const): Deleted. (WTF::Seconds::fromMinutes): Deleted. (WTF::Seconds::fromHours): Deleted. (WTF::Seconds::fromMilliseconds): Deleted. (WTF::Seconds::fromMicroseconds): Deleted. (WTF::Seconds::fromNanoseconds): Deleted. (WTF::Seconds::infinity): Deleted. (WTF::Seconds::nan): Deleted. (WTF::Seconds::operator bool const): Deleted. (WTF::Seconds::operator+ const): Deleted. (WTF::Seconds::operator- const): Deleted. (WTF::Seconds::operator* const): Deleted. (WTF::Seconds::operator/ const): Deleted. (WTF::Seconds::operator% const): Deleted. (WTF::Seconds::operator+=): Deleted. (WTF::Seconds::operator-=): Deleted. (WTF::Seconds::operator*=): Deleted. (WTF::Seconds::operator/=): Deleted. (WTF::Seconds::operator%=): Deleted. (WTF::Seconds::operator== const): Deleted. (WTF::Seconds::operator!= const): Deleted. (WTF::Seconds::operator< const): Deleted. (WTF::Seconds::operator> const): Deleted. (WTF::Seconds::operator<= const): Deleted. (WTF::Seconds::operator>= const): Deleted. (WTF::Seconds::isolatedCopy const): Deleted. (WTF::Seconds::encode const): Deleted. (WTF::Seconds::decode): Deleted. * wtf/SegmentedVector.h: (WTF::SegmentedVector::~SegmentedVector): Deleted. (WTF::SegmentedVector::size const): Deleted. (WTF::SegmentedVector::isEmpty const): Deleted. (WTF::SegmentedVector::at): Deleted. (WTF::SegmentedVector::at const): Deleted. (WTF::SegmentedVector::operator[]): Deleted. (WTF::SegmentedVector::operator[] const): Deleted. (WTF::SegmentedVector::first): Deleted. (WTF::SegmentedVector::first const): Deleted. (WTF::SegmentedVector::last): Deleted. (WTF::SegmentedVector::last const): Deleted. (WTF::SegmentedVector::takeLast): Deleted. (WTF::SegmentedVector::append): Deleted. (WTF::SegmentedVector::alloc): Deleted. (WTF::SegmentedVector::removeLast): Deleted. (WTF::SegmentedVector::grow): Deleted. (WTF::SegmentedVector::clear): Deleted. (WTF::SegmentedVector::begin): Deleted. (WTF::SegmentedVector::end): Deleted. (WTF::SegmentedVector::shrinkToFit): Deleted. (WTF::SegmentedVector::deleteAllSegments): Deleted. (WTF::SegmentedVector::segmentExistsFor): Deleted. (WTF::SegmentedVector::segmentFor): Deleted. (WTF::SegmentedVector::subscriptFor): Deleted. (WTF::SegmentedVector::ensureSegmentsFor): Deleted. (WTF::SegmentedVector::ensureSegment): Deleted. (WTF::SegmentedVector::allocateSegment): Deleted. * wtf/SetForScope.h: * wtf/SingleRootGraph.h: * wtf/SinglyLinkedList.h: * wtf/SmallPtrSet.h: * wtf/SpanningTree.h: * wtf/Spectrum.h: * wtf/StackBounds.h: * wtf/StackShot.h: * wtf/StackShotProfiler.h: * wtf/StackStats.h: * wtf/StackTrace.h: * wtf/StreamBuffer.h: * wtf/SynchronizedFixedQueue.h: (WTF::SynchronizedFixedQueue::create): Deleted. (WTF::SynchronizedFixedQueue::open): Deleted. (WTF::SynchronizedFixedQueue::close): Deleted. (WTF::SynchronizedFixedQueue::isOpen): Deleted. (WTF::SynchronizedFixedQueue::enqueue): Deleted. (WTF::SynchronizedFixedQueue::dequeue): Deleted. (WTF::SynchronizedFixedQueue::SynchronizedFixedQueue): Deleted. * wtf/SystemTracing.h: * wtf/ThreadGroup.h: (WTF::ThreadGroup::create): Deleted. (WTF::ThreadGroup::threads const): Deleted. (WTF::ThreadGroup::getLock): Deleted. (WTF::ThreadGroup::weakFromThis): Deleted. * wtf/ThreadSpecific.h: * wtf/ThreadingPrimitives.h: (WTF::Mutex::impl): Deleted. * wtf/TimeWithDynamicClockType.h: (WTF::TimeWithDynamicClockType::TimeWithDynamicClockType): Deleted. (WTF::TimeWithDynamicClockType::fromRawSeconds): Deleted. (WTF::TimeWithDynamicClockType::secondsSinceEpoch const): Deleted. (WTF::TimeWithDynamicClockType::clockType const): Deleted. (WTF::TimeWithDynamicClockType::withSameClockAndRawSeconds const): Deleted. (WTF::TimeWithDynamicClockType::operator bool const): Deleted. (WTF::TimeWithDynamicClockType::operator+ const): Deleted. (WTF::TimeWithDynamicClockType::operator- const): Deleted. (WTF::TimeWithDynamicClockType::operator+=): Deleted. (WTF::TimeWithDynamicClockType::operator-=): Deleted. (WTF::TimeWithDynamicClockType::operator== const): Deleted. (WTF::TimeWithDynamicClockType::operator!= const): Deleted. * wtf/TimingScope.h: * wtf/TinyLRUCache.h: * wtf/TinyPtrSet.h: * wtf/URLParser.cpp: * wtf/URLParser.h: * wtf/Unexpected.h: * wtf/Variant.h: * wtf/WTFSemaphore.h: (WTF::Semaphore::Semaphore): Deleted. (WTF::Semaphore::signal): Deleted. (WTF::Semaphore::waitUntil): Deleted. (WTF::Semaphore::waitFor): Deleted. (WTF::Semaphore::wait): Deleted. * wtf/WallTime.h: (WTF::WallTime::WallTime): Deleted. (WTF::WallTime::fromRawSeconds): Deleted. (WTF::WallTime::infinity): Deleted. (WTF::WallTime::nan): Deleted. (WTF::WallTime::secondsSinceEpoch const): Deleted. (WTF::WallTime::approximateWallTime const): Deleted. (WTF::WallTime::operator bool const): Deleted. (WTF::WallTime::operator+ const): Deleted. (WTF::WallTime::operator- const): Deleted. (WTF::WallTime::operator+=): Deleted. (WTF::WallTime::operator-=): Deleted. (WTF::WallTime::operator== const): Deleted. (WTF::WallTime::operator!= const): Deleted. (WTF::WallTime::operator< const): Deleted. (WTF::WallTime::operator> const): Deleted. (WTF::WallTime::operator<= const): Deleted. (WTF::WallTime::operator>= const): Deleted. (WTF::WallTime::isolatedCopy const): Deleted. * wtf/WeakHashSet.h: (WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::get const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator* const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator-> const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator++): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator== const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator!= const): Deleted. (WTF::WeakHashSet::WeakHashSet): Deleted. (WTF::WeakHashSet::begin const): Deleted. (WTF::WeakHashSet::end const): Deleted. (WTF::WeakHashSet::add): Deleted. (WTF::WeakHashSet::remove): Deleted. (WTF::WeakHashSet::contains const): Deleted. (WTF::WeakHashSet::capacity const): Deleted. (WTF::WeakHashSet::computesEmpty const): Deleted. (WTF::WeakHashSet::hasNullReferences const): Deleted. (WTF::WeakHashSet::computeSize const): Deleted. (WTF::WeakHashSet::checkConsistency const): Deleted. * wtf/WeakRandom.h: (WTF::WeakRandom::WeakRandom): Deleted. (WTF::WeakRandom::setSeed): Deleted. (WTF::WeakRandom::seed const): Deleted. (WTF::WeakRandom::get): Deleted. (WTF::WeakRandom::getUint32): Deleted. (WTF::WeakRandom::lowOffset): Deleted. (WTF::WeakRandom::highOffset): Deleted. (WTF::WeakRandom::nextState): Deleted. (WTF::WeakRandom::generate): Deleted. (WTF::WeakRandom::advance): Deleted. * wtf/WordLock.h: (WTF::WordLock::lock): Deleted. (WTF::WordLock::unlock): Deleted. (WTF::WordLock::isHeld const): Deleted. (WTF::WordLock::isLocked const): Deleted. (WTF::WordLock::isFullyReset const): Deleted. * wtf/generic/MainThreadGeneric.cpp: * wtf/glib/GMutexLocker.h: * wtf/linux/CurrentProcessMemoryStatus.h: * wtf/posix/ThreadingPOSIX.cpp: (WTF::Semaphore::Semaphore): Deleted. (WTF::Semaphore::~Semaphore): Deleted. (WTF::Semaphore::wait): Deleted. (WTF::Semaphore::post): Deleted. * wtf/text/ASCIILiteral.h: (WTF::ASCIILiteral::operator const char* const): Deleted. (WTF::ASCIILiteral::fromLiteralUnsafe): Deleted. (WTF::ASCIILiteral::null): Deleted. (WTF::ASCIILiteral::characters const): Deleted. (WTF::ASCIILiteral::ASCIILiteral): Deleted. * wtf/text/AtomString.h: (WTF::AtomString::operator=): Deleted. (WTF::AtomString::isHashTableDeletedValue const): Deleted. (WTF::AtomString::existingHash const): Deleted. (WTF::AtomString::operator const String& const): Deleted. (WTF::AtomString::string const): Deleted. (WTF::AtomString::impl const): Deleted. (WTF::AtomString::is8Bit const): Deleted. (WTF::AtomString::characters8 const): Deleted. (WTF::AtomString::characters16 const): Deleted. (WTF::AtomString::length const): Deleted. (WTF::AtomString::operator[] const): Deleted. (WTF::AtomString::contains const): Deleted. (WTF::AtomString::containsIgnoringASCIICase const): Deleted. (WTF::AtomString::find const): Deleted. (WTF::AtomString::findIgnoringASCIICase const): Deleted. (WTF::AtomString::startsWith const): Deleted. (WTF::AtomString::startsWithIgnoringASCIICase const): Deleted. (WTF::AtomString::endsWith const): Deleted. (WTF::AtomString::endsWithIgnoringASCIICase const): Deleted. (WTF::AtomString::toInt const): Deleted. (WTF::AtomString::toDouble const): Deleted. (WTF::AtomString::toFloat const): Deleted. (WTF::AtomString::percentage const): Deleted. (WTF::AtomString::isNull const): Deleted. (WTF::AtomString::isEmpty const): Deleted. (WTF::AtomString::operator NSString * const): Deleted. * wtf/text/AtomStringImpl.h: (WTF::AtomStringImpl::lookUp): Deleted. (WTF::AtomStringImpl::add): Deleted. (WTF::AtomStringImpl::addWithStringTableProvider): Deleted. * wtf/text/CString.h: (WTF::CStringBuffer::data): Deleted. (WTF::CStringBuffer::length const): Deleted. (WTF::CStringBuffer::CStringBuffer): Deleted. (WTF::CStringBuffer::mutableData): Deleted. (WTF::CString::CString): Deleted. (WTF::CString::data const): Deleted. (WTF::CString::length const): Deleted. (WTF::CString::isNull const): Deleted. (WTF::CString::buffer const): Deleted. (WTF::CString::isHashTableDeletedValue const): Deleted. * wtf/text/ExternalStringImpl.h: (WTF::ExternalStringImpl::freeExternalBuffer): Deleted. * wtf/text/LineBreakIteratorPoolICU.h: * wtf/text/NullTextBreakIterator.h: * wtf/text/OrdinalNumber.h: * wtf/text/StringBuffer.h: * wtf/text/StringBuilder.h: * wtf/text/StringConcatenateNumbers.h: * wtf/text/StringHasher.h: * wtf/text/StringImpl.h: * wtf/text/StringView.cpp: * wtf/text/StringView.h: (WTF::StringView::left const): Deleted. (WTF::StringView::right const): Deleted. (WTF::StringView::underlyingStringIsValid const): Deleted. (WTF::StringView::setUnderlyingString): Deleted. * wtf/text/SymbolImpl.h: (WTF::SymbolImpl::StaticSymbolImpl::StaticSymbolImpl): Deleted. (WTF::SymbolImpl::StaticSymbolImpl::operator SymbolImpl&): Deleted. (WTF::PrivateSymbolImpl::PrivateSymbolImpl): Deleted. (WTF::RegisteredSymbolImpl::symbolRegistry const): Deleted. (WTF::RegisteredSymbolImpl::clearSymbolRegistry): Deleted. (WTF::RegisteredSymbolImpl::RegisteredSymbolImpl): Deleted. * wtf/text/SymbolRegistry.h: * wtf/text/TextBreakIterator.h: * wtf/text/TextPosition.h: * wtf/text/TextStream.h: * wtf/text/WTFString.h: (WTF::String::swap): Deleted. (WTF::String::adopt): Deleted. (WTF::String::isNull const): Deleted. (WTF::String::isEmpty const): Deleted. (WTF::String::impl const): Deleted. (WTF::String::releaseImpl): Deleted. (WTF::String::length const): Deleted. (WTF::String::characters8 const): Deleted. (WTF::String::characters16 const): Deleted. (WTF::String::is8Bit const): Deleted. (WTF::String::sizeInBytes const): Deleted. (WTF::String::operator[] const): Deleted. (WTF::String::find const): Deleted. (WTF::String::findIgnoringASCIICase const): Deleted. (WTF::String::reverseFind const): Deleted. (WTF::String::contains const): Deleted. (WTF::String::containsIgnoringASCIICase const): Deleted. (WTF::String::startsWith const): Deleted. (WTF::String::startsWithIgnoringASCIICase const): Deleted. (WTF::String::hasInfixStartingAt const): Deleted. (WTF::String::endsWith const): Deleted. (WTF::String::endsWithIgnoringASCIICase const): Deleted. (WTF::String::hasInfixEndingAt const): Deleted. (WTF::String::append): Deleted. (WTF::String::left const): Deleted. (WTF::String::right const): Deleted. (WTF::String::createUninitialized): Deleted. (WTF::String::fromUTF8WithLatin1Fallback): Deleted. (WTF::String::isAllASCII const): Deleted. (WTF::String::isAllLatin1 const): Deleted. (WTF::String::isSpecialCharacter const): Deleted. (WTF::String::isHashTableDeletedValue const): Deleted. (WTF::String::hash const): Deleted. (WTF::String::existingHash const): Deleted. * wtf/text/cf/TextBreakIteratorCF.h: * wtf/text/icu/TextBreakIteratorICU.h: * wtf/text/icu/UTextProviderLatin1.h: * wtf/threads/BinarySemaphore.h: (WTF::BinarySemaphore::waitFor): Deleted. (WTF::BinarySemaphore::wait): Deleted. * wtf/unicode/Collator.h: * wtf/win/GDIObject.h: * wtf/win/PathWalker.h: * wtf/win/Win32Handle.h: Canonical link: https://commits.webkit.org/214396@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248546 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-08-12 20:57:15 +00:00
WTF_MAKE_FAST_ALLOCATED;
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
public:
[WTF] AtomStringTable should be small https://bugs.webkit.org/show_bug.cgi?id=206400 Reviewed by Sam Weinig. Source/WebCore: * dom/GCReachableRef.h: (WebCore::GCReachableRef::GCReachableRef): * dom/QualifiedName.h: (WebCore::QualifiedName::hashTableDeletedValue): Source/WTF: AtomStringTable is the largest hashtable typically. It takes more than 256KB per WebProcess (sometimes, it took 1MB or more). This patch leverages PackedPtr to compact it from 8 bytes per entry to 6 bytes per entry. While this is still large, we should investigate how to compact C++ pointers in 4 bytes[1] to shrink memory footprint, since WebKit memory is used by Vector and HashTable fulfilled with pointers. [1]: https://bugs.webkit.org/show_bug.cgi?id=206469 * wtf/DumbPtrTraits.h: (WTF::DumbPtrTraits::hashTableDeletedValue): (WTF::DumbPtrTraits::isHashTableDeletedValue): * wtf/Forward.h: * wtf/HashTraits.h: * wtf/Packed.h: (WTF::Packed<T::Packed): (WTF::Packed<T::isHashTableDeletedValue const): (WTF::GetPtrHelper<PackedPtr<T>>::getPtr): (WTF::PackedPtrTraits::hashTableDeletedValue): (WTF::PackedPtrTraits::isHashTableDeletedValue): (WTF::alignof): Deleted. * wtf/Ref.h: (WTF::Ref::Ref): (WTF::Ref::isHashTableDeletedValue const): (WTF::Ref::hashTableDeletedValue): Deleted. * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): (WTF::RefPtr::isHashTableDeletedValue const): (WTF::RefPtr::hashTableDeletedValue): Deleted. * wtf/text/AtomStringImpl.cpp: (WTF::addToStringTable): (WTF::CStringTranslator::equal): (WTF::CStringTranslator::translate): (WTF::UCharBufferTranslator::equal): (WTF::UCharBufferTranslator::translate): (WTF::HashAndUTF8CharactersTranslator::equal): (WTF::HashAndUTF8CharactersTranslator::translate): (WTF::SubstringTranslator::translate): (WTF::SubstringTranslator8::equal): (WTF::SubstringTranslator16::equal): (WTF::LCharBufferTranslator::equal): (WTF::LCharBufferTranslator::translate): (WTF::BufferFromStaticDataTranslator::equal): (WTF::BufferFromStaticDataTranslator::translate): (WTF::AtomStringImpl::addSlowCase): (WTF::AtomStringImpl::remove): (WTF::AtomStringImpl::lookUpSlowCase): (WTF::AtomStringImpl::lookUp): * wtf/text/AtomStringTable.cpp: (WTF::AtomStringTable::~AtomStringTable): * wtf/text/AtomStringTable.h: (WTF::AtomStringTable::table): (): Deleted. * wtf/text/StringHash.h: (WTF::StringHash::hash): (WTF::StringHash::equal): (WTF::ASCIICaseInsensitiveHash::hash): (WTF::ASCIICaseInsensitiveHash::equal): * wtf/text/StringImpl.h: Tools: * TestWebKitAPI/Tests/WTF/HashMap.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/219616@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254881 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-21 22:05:43 +00:00
static_assert(hasOneBitSet(passedAlignment), "Alignment needs to be power-of-two");
static constexpr size_t alignment = passedAlignment;
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
static constexpr bool isPackedType = true;
static constexpr unsigned alignmentShiftSizeIfProfitable = getLSBSetConstexpr(alignment);
Platform.h is out of control Part 8: Macros are used inconsistently https://bugs.webkit.org/show_bug.cgi?id=206425 Reviewed by Darin Adler. Source/bmalloc: * bmalloc/BPlatform.h: Update OS_EFFECTIVE_ADDRESS_WIDTH to match WTF definition, add needed OS macros. Source/JavaScriptCore: * assembler/ARM64Assembler.h: (JSC::ARM64Assembler::cacheFlush): (JSC::ARM64Assembler::xOrSp): (JSC::ARM64Assembler::xOrZr): * assembler/ARM64Registers.h: * assembler/ARMv7Assembler.h: (JSC::ARMv7Assembler::cacheFlush): * assembler/ARMv7Registers.h: * assembler/AssemblerCommon.h: (JSC::isDarwin): * b3/air/AirCCallingConvention.cpp: * jit/ExecutableAllocator.h: * jit/ThunkGenerators.cpp: * jsc.cpp: * runtime/MathCommon.cpp: Use OS(DARWIN) more consistently for darwin level functionality. * bytecode/CodeOrigin.h: * runtime/JSString.h: Update to use OS_CONSTANT. * disassembler/ARM64/A64DOpcode.cpp: * disassembler/ARM64Disassembler.cpp: * disassembler/UDis86Disassembler.cpp: * disassembler/UDis86Disassembler.h: * disassembler/X86Disassembler.cpp: * disassembler/udis86/udis86.c: * disassembler/udis86/udis86_decode.c: * disassembler/udis86/udis86_itab_holder.c: * disassembler/udis86/udis86_syn-att.c: * disassembler/udis86/udis86_syn-intel.c: * disassembler/udis86/udis86_syn.c: * interpreter/Interpreter.cpp: * interpreter/Interpreter.h: * interpreter/InterpreterInlines.h: (JSC::Interpreter::getOpcodeID): * llint/LowLevelInterpreter.cpp: * tools/SigillCrashAnalyzer.cpp: Switch to using ENABLE rather than USE for features internal to WebKit Source/WTF: Start addressing FIXMEs added to Platform.h (and helper files) during previous cleanup work. - Renames WTF_CPU_EFFECTIVE_ADDRESS_WIDTH to WTF_OS_CONSTANT_EFFECTIVE_ADDRESS_WIDTH, making it available via new macro OS_CONSTANT(...), and syncs bmalloc redefinition. - Renames: USE_LLINT_EMBEDDED_OPCODE_ID to ENABLE_LLINT_EMBEDDED_OPCODE_ID USE_UDIS86 to ENABLE_UDIS86 USE_ARM64_DISASSEMBLER to ENABLE_ARM64_DISASSEMBLER Enable is more appropriate here as these enable functionality within webkit. - Removes undefs that are no longer needed due to only defining the macro once now. - Removes dead defined(__LP64__) check after PLATFORM(MAC) macOS is always 64-bit these days. * wtf/Packed.h: (WTF::alignof): * wtf/Platform.h: * wtf/PlatformEnable.h: * wtf/PlatformOS.h: * wtf/WTFAssertions.cpp: * wtf/text/StringCommon.h: Tools: * TestWebKitAPI/Tests/WTF/Packed.cpp: (TestWebKitAPI::TEST): Update to use OS_CONSTANT. Canonical link: https://commits.webkit.org/219580@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254843 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-21 04:01:50 +00:00
static constexpr unsigned storageSizeWithoutAlignmentShift = roundUpToMultipleOf<8>(OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH)) / 8;
static constexpr unsigned storageSizeWithAlignmentShift = roundUpToMultipleOf<8>(OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH) - alignmentShiftSizeIfProfitable) / 8;
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
static constexpr bool isAlignmentShiftProfitable = storageSizeWithoutAlignmentShift > storageSizeWithAlignmentShift;
static constexpr unsigned alignmentShiftSize = isAlignmentShiftProfitable ? alignmentShiftSizeIfProfitable : 0;
static constexpr unsigned storageSize = storageSizeWithAlignmentShift;
static_assert(storageSize <= sizeof(uintptr_t));
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
constexpr PackedAlignedPtr()
: m_storage()
{
}
constexpr PackedAlignedPtr(std::nullptr_t)
: m_storage()
{
}
PackedAlignedPtr(T* value)
{
set(value);
}
T* get() const
{
// FIXME: PackedPtr<> can load memory with one mov by checking page boundary.
// https://bugs.webkit.org/show_bug.cgi?id=197754
uintptr_t value = 0;
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
#if CPU(LITTLE_ENDIAN)
memcpy(&value, m_storage.data(), storageSize);
#else
memcpy(bitwise_cast<uint8_t*>(&value) + (sizeof(void*) - storageSize), m_storage.data(), storageSize);
#endif
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
if (isAlignmentShiftProfitable)
value <<= alignmentShiftSize;
#if CPU(X86_64) && !(OS(DARWIN) || OS(LINUX) || OS(WINDOWS))
// The AMD specification requires that the most significant 16
// bits of any virtual address, bits 48 through 63, must be
// copies of bit 47 (in a manner akin to sign extension).
//
// The above-named OSes will never allocate user space addresses
// with bit 47 set, thus are already in canonical form.
//
// Reference: https://en.wikipedia.org/wiki/X86-64#Virtual_address_space_details
constexpr unsigned shiftBits = countOfBits<uintptr_t> - OS_CONSTANT(EFFECTIVE_ADDRESS_WIDTH);
value = (bitwise_cast<intptr_t>(value) << shiftBits) >> shiftBits;
#endif
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
return bitwise_cast<T*>(value);
}
void set(T* passedValue)
{
uintptr_t value = bitwise_cast<uintptr_t>(passedValue);
if (isAlignmentShiftProfitable)
value >>= alignmentShiftSize;
#if CPU(LITTLE_ENDIAN)
memcpy(m_storage.data(), &value, storageSize);
#else
memcpy(m_storage.data(), bitwise_cast<uint8_t*>(&value) + (sizeof(void*) - storageSize), storageSize);
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
#endif
ASSERT(bitwise_cast<uintptr_t>(get()) == value);
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
}
void clear()
{
set(nullptr);
}
T* operator->() const { return get(); }
T& operator*() const { return *get(); }
bool operator!() const { return !get(); }
[JSC] Remove ArrayBufferNeuteringWatchpointSet https://bugs.webkit.org/show_bug.cgi?id=205194 Reviewed by Saam Barati. Source/JavaScriptCore: This patch removes ArrayBufferNeuteringWatchpointSet, and instead putting InlineWatchpointSet directly into ArrayBuffer, since this is much simpler. The main reason why we are using ArrayBufferNeuteringWatchpointSet is not to increase sizeof(ArrayBuffer). But this complicates the implementation. So, not to increase sizeof(ArrayBuffer), we use PackedRefPtr in ArrayBuffer, which is RefPtr while the pointer is packed. This gives us 8 bytes which is suitable for placing InlineWatchpointSet without increasing sizeof(ArrayBuffer). We also convert Function<> in ArrayBuffer to PackedRefPtr<SharedTask<>>, and share Gigacage::free destructor by multiple ArrayBuffer. This is memory efficient since this is the common case, and we can pack this field easily. * API/JSTypedArray.cpp: (JSObjectMakeTypedArrayWithBytesNoCopy): (JSObjectMakeArrayBufferWithBytesNoCopy): * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * dfg/DFGDesiredWatchpoints.cpp: (JSC::DFG::ArrayBufferViewWatchpointAdaptor::add): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::tryGetFoldableView): * runtime/ArrayBuffer.cpp: (JSC::ArrayBuffer::primitiveGigacageDestructor): (JSC::SharedArrayBufferContents::~SharedArrayBufferContents): (JSC::ArrayBufferContents::destroy): (JSC::ArrayBufferContents::reset): (JSC::ArrayBufferContents::tryAllocate): (JSC::ArrayBufferContents::makeShared): (JSC::ArrayBufferContents::shareWith): (JSC::ArrayBuffer::createAdopted): (JSC::ArrayBuffer::transferTo): (JSC::ArrayBuffer::neuter): (JSC::ArrayBuffer::notifyIncommingReferencesOfTransfer): * runtime/ArrayBuffer.h: (JSC::ArrayBuffer::neuteringWatchpointSet): * runtime/ArrayBufferNeuteringWatchpointSet.cpp: Removed. * runtime/FileBasedFuzzerAgent.cpp: (JSC::FileBasedFuzzerAgent::getPredictionInternal): * runtime/FileBasedFuzzerAgentBase.cpp: (JSC::FileBasedFuzzerAgentBase::createLookupKey): * runtime/PredictionFileCreatingFuzzerAgent.cpp: (JSC::PredictionFileCreatingFuzzerAgent::getPredictionInternal): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * wasm/js/JSWebAssemblyMemory.cpp: (JSC::JSWebAssemblyMemory::buffer): Source/WebCore: * bindings/js/SerializedScriptValue.h: (WebCore::SerializedScriptValue::decode): Source/WTF: This patch adds PackedRef and PackedRefPtr. They are Ref and RefPtr, but its internal pointer is packed. So we can represent them in 6 bytes with 1 byte alignment. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Packed.h: (WTF::alignof): * wtf/PackedRef.h: Copied from Source/JavaScriptCore/runtime/ArrayBufferNeuteringWatchpointSet.h. * wtf/PackedRefPtr.h: Renamed from Source/JavaScriptCore/runtime/ArrayBufferNeuteringWatchpointSet.h. * wtf/RefPtr.h: (WTF::RefPtr::operator UnspecifiedBoolType const): (WTF::RefPtr::unspecifiedBoolTypeInstance const): Tools: Add tests for PackedRef and PackedRefPtr. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/PackedRef.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::passWithRef): (TestWebKitAPI::PackedRefCheckingRefLogger::PackedRefCheckingRefLogger): (TestWebKitAPI::PackedRefCheckingRefLogger::ref): (TestWebKitAPI::PackedRefCheckingRefLogger::deref): (TestWebKitAPI::DerivedPackedRefCheckingRefLogger::DerivedPackedRefCheckingRefLogger): * TestWebKitAPI/Tests/WTF/PackedRefPtr.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/RefPtr.cpp. (TestWebKitAPI::TEST): (TestWebKitAPI::f1): (TestWebKitAPI::ConstRefCounted::create): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::PackedRefPtrCheckingRefLogger): (TestWebKitAPI::loggerName): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::ref): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::deref): * TestWebKitAPI/Tests/WTF/RefPtr.cpp: (TestWebKitAPI::f1): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): Canonical link: https://commits.webkit.org/218489@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-16 22:17:27 +00:00
// This conversion operator allows implicit conversion to bool but not to other integer types.
typedef T* (PackedAlignedPtr::*UnspecifiedBoolType);
operator UnspecifiedBoolType() const { return get() ? &PackedAlignedPtr::m_storage : nullptr; }
[JSC] Compress miscelaneous JIT related data structures with Packed<> https://bugs.webkit.org/show_bug.cgi?id=197830 Reviewed by Saam Barati. Source/JavaScriptCore: This patch leverages Packed<> to compress miscelaneous data structures related to JIT. 1. JIT IC data structures 2. ValueRecovery We use Packed<> for EncodedJSValue in ValueRecovery. This means that conservative GC cannot find these values. But this is OK anyway since ValueRecovery's constant should be already registered in DFG graph. From 16 (alignment 8) to 9 (alignment 1). 3. FTL::ExitValue We use Packed<> for EncodedJSValue in FTL::ExitValue. This is also OK since this constant should be already registered by DFG/FTL graph. From 16 (alignment 8) to 9 (alignment 1). * assembler/CodeLocation.h: * bytecode/ByValInfo.h: * bytecode/CallLinkInfo.cpp: (JSC::CallLinkInfo::CallLinkInfo): (JSC::CallLinkInfo::callReturnLocation): * bytecode/CallLinkInfo.h: (JSC::CallLinkInfo::nearCallMode const): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::addJITAddIC): (JSC::CodeBlock::addJITMulIC): (JSC::CodeBlock::addJITSubIC): (JSC::CodeBlock::addJITNegIC): * bytecode/CodeBlock.h: (JSC::CodeBlock::addMathIC): * bytecode/InlineCallFrame.h: (JSC::InlineCallFrame::InlineCallFrame): * bytecode/ValueRecovery.h: (JSC::ValueRecovery::inGPR): (JSC::ValueRecovery::inPair): (JSC::ValueRecovery::inFPR): (JSC::ValueRecovery::displacedInJSStack): (JSC::ValueRecovery::constant): (JSC::ValueRecovery::directArgumentsThatWereNotCreated): (JSC::ValueRecovery::clonedArgumentsThatWereNotCreated): (JSC::ValueRecovery::gpr const): (JSC::ValueRecovery::tagGPR const): (JSC::ValueRecovery::payloadGPR const): (JSC::ValueRecovery::fpr const): (JSC::ValueRecovery::virtualRegister const): (JSC::ValueRecovery::withLocalsOffset const): (JSC::ValueRecovery::constant const): (JSC::ValueRecovery::nodeID const): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileValueAdd): (JSC::DFG::SpeculativeJIT::compileValueSub): (JSC::DFG::SpeculativeJIT::compileValueNegate): (JSC::DFG::SpeculativeJIT::compileValueMul): * ftl/FTLExitValue.cpp: (JSC::FTL::ExitValue::materializeNewObject): * ftl/FTLExitValue.h: (JSC::FTL::ExitValue::inJSStack): (JSC::FTL::ExitValue::inJSStackAsInt32): (JSC::FTL::ExitValue::inJSStackAsInt52): (JSC::FTL::ExitValue::inJSStackAsDouble): (JSC::FTL::ExitValue::constant): (JSC::FTL::ExitValue::exitArgument): (JSC::FTL::ExitValue::exitArgument const): (JSC::FTL::ExitValue::adjustStackmapLocationsIndexByOffset): (JSC::FTL::ExitValue::constant const): (JSC::FTL::ExitValue::virtualRegister const): (JSC::FTL::ExitValue::objectMaterialization const): (JSC::FTL::ExitValue::withVirtualRegister const): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileValueAdd): (JSC::FTL::DFG::LowerDFGToB3::compileValueSub): (JSC::FTL::DFG::LowerDFGToB3::compileValueMul): (JSC::FTL::DFG::LowerDFGToB3::compileUnaryMathIC): (JSC::FTL::DFG::LowerDFGToB3::compileBinaryMathIC): (JSC::FTL::DFG::LowerDFGToB3::compileArithAddOrSub): (JSC::FTL::DFG::LowerDFGToB3::compileValueNegate): * jit/CachedRecovery.h: * jit/CallFrameShuffleData.h: * jit/JITArithmetic.cpp: (JSC::JIT::emit_op_negate): (JSC::JIT::emit_op_add): (JSC::JIT::emit_op_mul): (JSC::JIT::emit_op_sub): * jit/JITMathIC.h: (JSC::isProfileEmpty): (JSC::JITBinaryMathIC::JITBinaryMathIC): (JSC::JITUnaryMathIC::JITUnaryMathIC): * jit/PolymorphicCallStubRoutine.h: (JSC::PolymorphicCallNode::hasCallLinkInfo): * jit/SnippetOperand.h: (JSC::SnippetOperand::asRawBits const): (JSC::SnippetOperand::asConstInt32 const): (JSC::SnippetOperand::asConstDouble const): (JSC::SnippetOperand::setConstInt32): (JSC::SnippetOperand::setConstDouble): Source/WTF: * wtf/Packed.h: (WTF::alignof): Canonical link: https://commits.webkit.org/211966@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245239 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-13 17:32:31 +00:00
explicit operator bool() const { return get(); }
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
PackedAlignedPtr& operator=(T* value)
{
set(value);
return *this;
}
template<class U>
[JSC] Remove ArrayBufferNeuteringWatchpointSet https://bugs.webkit.org/show_bug.cgi?id=205194 Reviewed by Saam Barati. Source/JavaScriptCore: This patch removes ArrayBufferNeuteringWatchpointSet, and instead putting InlineWatchpointSet directly into ArrayBuffer, since this is much simpler. The main reason why we are using ArrayBufferNeuteringWatchpointSet is not to increase sizeof(ArrayBuffer). But this complicates the implementation. So, not to increase sizeof(ArrayBuffer), we use PackedRefPtr in ArrayBuffer, which is RefPtr while the pointer is packed. This gives us 8 bytes which is suitable for placing InlineWatchpointSet without increasing sizeof(ArrayBuffer). We also convert Function<> in ArrayBuffer to PackedRefPtr<SharedTask<>>, and share Gigacage::free destructor by multiple ArrayBuffer. This is memory efficient since this is the common case, and we can pack this field easily. * API/JSTypedArray.cpp: (JSObjectMakeTypedArrayWithBytesNoCopy): (JSObjectMakeArrayBufferWithBytesNoCopy): * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * dfg/DFGDesiredWatchpoints.cpp: (JSC::DFG::ArrayBufferViewWatchpointAdaptor::add): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::tryGetFoldableView): * runtime/ArrayBuffer.cpp: (JSC::ArrayBuffer::primitiveGigacageDestructor): (JSC::SharedArrayBufferContents::~SharedArrayBufferContents): (JSC::ArrayBufferContents::destroy): (JSC::ArrayBufferContents::reset): (JSC::ArrayBufferContents::tryAllocate): (JSC::ArrayBufferContents::makeShared): (JSC::ArrayBufferContents::shareWith): (JSC::ArrayBuffer::createAdopted): (JSC::ArrayBuffer::transferTo): (JSC::ArrayBuffer::neuter): (JSC::ArrayBuffer::notifyIncommingReferencesOfTransfer): * runtime/ArrayBuffer.h: (JSC::ArrayBuffer::neuteringWatchpointSet): * runtime/ArrayBufferNeuteringWatchpointSet.cpp: Removed. * runtime/FileBasedFuzzerAgent.cpp: (JSC::FileBasedFuzzerAgent::getPredictionInternal): * runtime/FileBasedFuzzerAgentBase.cpp: (JSC::FileBasedFuzzerAgentBase::createLookupKey): * runtime/PredictionFileCreatingFuzzerAgent.cpp: (JSC::PredictionFileCreatingFuzzerAgent::getPredictionInternal): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * wasm/js/JSWebAssemblyMemory.cpp: (JSC::JSWebAssemblyMemory::buffer): Source/WebCore: * bindings/js/SerializedScriptValue.h: (WebCore::SerializedScriptValue::decode): Source/WTF: This patch adds PackedRef and PackedRefPtr. They are Ref and RefPtr, but its internal pointer is packed. So we can represent them in 6 bytes with 1 byte alignment. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Packed.h: (WTF::alignof): * wtf/PackedRef.h: Copied from Source/JavaScriptCore/runtime/ArrayBufferNeuteringWatchpointSet.h. * wtf/PackedRefPtr.h: Renamed from Source/JavaScriptCore/runtime/ArrayBufferNeuteringWatchpointSet.h. * wtf/RefPtr.h: (WTF::RefPtr::operator UnspecifiedBoolType const): (WTF::RefPtr::unspecifiedBoolTypeInstance const): Tools: Add tests for PackedRef and PackedRefPtr. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/PackedRef.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::passWithRef): (TestWebKitAPI::PackedRefCheckingRefLogger::PackedRefCheckingRefLogger): (TestWebKitAPI::PackedRefCheckingRefLogger::ref): (TestWebKitAPI::PackedRefCheckingRefLogger::deref): (TestWebKitAPI::DerivedPackedRefCheckingRefLogger::DerivedPackedRefCheckingRefLogger): * TestWebKitAPI/Tests/WTF/PackedRefPtr.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/RefPtr.cpp. (TestWebKitAPI::TEST): (TestWebKitAPI::f1): (TestWebKitAPI::ConstRefCounted::create): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::PackedRefPtrCheckingRefLogger): (TestWebKitAPI::loggerName): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::ref): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::deref): * TestWebKitAPI/Tests/WTF/RefPtr.cpp: (TestWebKitAPI::f1): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): Canonical link: https://commits.webkit.org/218489@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-16 22:17:27 +00:00
T* exchange(U&& newValue)
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
{
[JSC] Remove ArrayBufferNeuteringWatchpointSet https://bugs.webkit.org/show_bug.cgi?id=205194 Reviewed by Saam Barati. Source/JavaScriptCore: This patch removes ArrayBufferNeuteringWatchpointSet, and instead putting InlineWatchpointSet directly into ArrayBuffer, since this is much simpler. The main reason why we are using ArrayBufferNeuteringWatchpointSet is not to increase sizeof(ArrayBuffer). But this complicates the implementation. So, not to increase sizeof(ArrayBuffer), we use PackedRefPtr in ArrayBuffer, which is RefPtr while the pointer is packed. This gives us 8 bytes which is suitable for placing InlineWatchpointSet without increasing sizeof(ArrayBuffer). We also convert Function<> in ArrayBuffer to PackedRefPtr<SharedTask<>>, and share Gigacage::free destructor by multiple ArrayBuffer. This is memory efficient since this is the common case, and we can pack this field easily. * API/JSTypedArray.cpp: (JSObjectMakeTypedArrayWithBytesNoCopy): (JSObjectMakeArrayBufferWithBytesNoCopy): * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * dfg/DFGDesiredWatchpoints.cpp: (JSC::DFG::ArrayBufferViewWatchpointAdaptor::add): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::tryGetFoldableView): * runtime/ArrayBuffer.cpp: (JSC::ArrayBuffer::primitiveGigacageDestructor): (JSC::SharedArrayBufferContents::~SharedArrayBufferContents): (JSC::ArrayBufferContents::destroy): (JSC::ArrayBufferContents::reset): (JSC::ArrayBufferContents::tryAllocate): (JSC::ArrayBufferContents::makeShared): (JSC::ArrayBufferContents::shareWith): (JSC::ArrayBuffer::createAdopted): (JSC::ArrayBuffer::transferTo): (JSC::ArrayBuffer::neuter): (JSC::ArrayBuffer::notifyIncommingReferencesOfTransfer): * runtime/ArrayBuffer.h: (JSC::ArrayBuffer::neuteringWatchpointSet): * runtime/ArrayBufferNeuteringWatchpointSet.cpp: Removed. * runtime/FileBasedFuzzerAgent.cpp: (JSC::FileBasedFuzzerAgent::getPredictionInternal): * runtime/FileBasedFuzzerAgentBase.cpp: (JSC::FileBasedFuzzerAgentBase::createLookupKey): * runtime/PredictionFileCreatingFuzzerAgent.cpp: (JSC::PredictionFileCreatingFuzzerAgent::getPredictionInternal): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * wasm/js/JSWebAssemblyMemory.cpp: (JSC::JSWebAssemblyMemory::buffer): Source/WebCore: * bindings/js/SerializedScriptValue.h: (WebCore::SerializedScriptValue::decode): Source/WTF: This patch adds PackedRef and PackedRefPtr. They are Ref and RefPtr, but its internal pointer is packed. So we can represent them in 6 bytes with 1 byte alignment. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Packed.h: (WTF::alignof): * wtf/PackedRef.h: Copied from Source/JavaScriptCore/runtime/ArrayBufferNeuteringWatchpointSet.h. * wtf/PackedRefPtr.h: Renamed from Source/JavaScriptCore/runtime/ArrayBufferNeuteringWatchpointSet.h. * wtf/RefPtr.h: (WTF::RefPtr::operator UnspecifiedBoolType const): (WTF::RefPtr::unspecifiedBoolTypeInstance const): Tools: Add tests for PackedRef and PackedRefPtr. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/PackedRef.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::passWithRef): (TestWebKitAPI::PackedRefCheckingRefLogger::PackedRefCheckingRefLogger): (TestWebKitAPI::PackedRefCheckingRefLogger::ref): (TestWebKitAPI::PackedRefCheckingRefLogger::deref): (TestWebKitAPI::DerivedPackedRefCheckingRefLogger::DerivedPackedRefCheckingRefLogger): * TestWebKitAPI/Tests/WTF/PackedRefPtr.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/RefPtr.cpp. (TestWebKitAPI::TEST): (TestWebKitAPI::f1): (TestWebKitAPI::ConstRefCounted::create): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::PackedRefPtrCheckingRefLogger): (TestWebKitAPI::loggerName): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::ref): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::deref): * TestWebKitAPI/Tests/WTF/RefPtr.cpp: (TestWebKitAPI::f1): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): Canonical link: https://commits.webkit.org/218489@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-16 22:17:27 +00:00
T* oldValue = get();
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
set(std::forward<U>(newValue));
return oldValue;
}
void swap(std::nullptr_t) { clear(); }
void swap(PackedAlignedPtr& other)
{
m_storage.swap(other.m_storage);
}
template<typename Other, typename = std::enable_if_t<Other::isPackedType>>
void swap(Other& other)
{
[JSC] Remove ArrayBufferNeuteringWatchpointSet https://bugs.webkit.org/show_bug.cgi?id=205194 Reviewed by Saam Barati. Source/JavaScriptCore: This patch removes ArrayBufferNeuteringWatchpointSet, and instead putting InlineWatchpointSet directly into ArrayBuffer, since this is much simpler. The main reason why we are using ArrayBufferNeuteringWatchpointSet is not to increase sizeof(ArrayBuffer). But this complicates the implementation. So, not to increase sizeof(ArrayBuffer), we use PackedRefPtr in ArrayBuffer, which is RefPtr while the pointer is packed. This gives us 8 bytes which is suitable for placing InlineWatchpointSet without increasing sizeof(ArrayBuffer). We also convert Function<> in ArrayBuffer to PackedRefPtr<SharedTask<>>, and share Gigacage::free destructor by multiple ArrayBuffer. This is memory efficient since this is the common case, and we can pack this field easily. * API/JSTypedArray.cpp: (JSObjectMakeTypedArrayWithBytesNoCopy): (JSObjectMakeArrayBufferWithBytesNoCopy): * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * dfg/DFGDesiredWatchpoints.cpp: (JSC::DFG::ArrayBufferViewWatchpointAdaptor::add): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::tryGetFoldableView): * runtime/ArrayBuffer.cpp: (JSC::ArrayBuffer::primitiveGigacageDestructor): (JSC::SharedArrayBufferContents::~SharedArrayBufferContents): (JSC::ArrayBufferContents::destroy): (JSC::ArrayBufferContents::reset): (JSC::ArrayBufferContents::tryAllocate): (JSC::ArrayBufferContents::makeShared): (JSC::ArrayBufferContents::shareWith): (JSC::ArrayBuffer::createAdopted): (JSC::ArrayBuffer::transferTo): (JSC::ArrayBuffer::neuter): (JSC::ArrayBuffer::notifyIncommingReferencesOfTransfer): * runtime/ArrayBuffer.h: (JSC::ArrayBuffer::neuteringWatchpointSet): * runtime/ArrayBufferNeuteringWatchpointSet.cpp: Removed. * runtime/FileBasedFuzzerAgent.cpp: (JSC::FileBasedFuzzerAgent::getPredictionInternal): * runtime/FileBasedFuzzerAgentBase.cpp: (JSC::FileBasedFuzzerAgentBase::createLookupKey): * runtime/PredictionFileCreatingFuzzerAgent.cpp: (JSC::PredictionFileCreatingFuzzerAgent::getPredictionInternal): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * wasm/js/JSWebAssemblyMemory.cpp: (JSC::JSWebAssemblyMemory::buffer): Source/WebCore: * bindings/js/SerializedScriptValue.h: (WebCore::SerializedScriptValue::decode): Source/WTF: This patch adds PackedRef and PackedRefPtr. They are Ref and RefPtr, but its internal pointer is packed. So we can represent them in 6 bytes with 1 byte alignment. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Packed.h: (WTF::alignof): * wtf/PackedRef.h: Copied from Source/JavaScriptCore/runtime/ArrayBufferNeuteringWatchpointSet.h. * wtf/PackedRefPtr.h: Renamed from Source/JavaScriptCore/runtime/ArrayBufferNeuteringWatchpointSet.h. * wtf/RefPtr.h: (WTF::RefPtr::operator UnspecifiedBoolType const): (WTF::RefPtr::unspecifiedBoolTypeInstance const): Tools: Add tests for PackedRef and PackedRefPtr. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/PackedRef.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::passWithRef): (TestWebKitAPI::PackedRefCheckingRefLogger::PackedRefCheckingRefLogger): (TestWebKitAPI::PackedRefCheckingRefLogger::ref): (TestWebKitAPI::PackedRefCheckingRefLogger::deref): (TestWebKitAPI::DerivedPackedRefCheckingRefLogger::DerivedPackedRefCheckingRefLogger): * TestWebKitAPI/Tests/WTF/PackedRefPtr.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/RefPtr.cpp. (TestWebKitAPI::TEST): (TestWebKitAPI::f1): (TestWebKitAPI::ConstRefCounted::create): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::PackedRefPtrCheckingRefLogger): (TestWebKitAPI::loggerName): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::ref): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::deref): * TestWebKitAPI/Tests/WTF/RefPtr.cpp: (TestWebKitAPI::f1): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): Canonical link: https://commits.webkit.org/218489@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-16 22:17:27 +00:00
T* t1 = get();
T* t2 = other.get();
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
set(t2);
other.set(t1);
}
[JSC] Remove ArrayBufferNeuteringWatchpointSet https://bugs.webkit.org/show_bug.cgi?id=205194 Reviewed by Saam Barati. Source/JavaScriptCore: This patch removes ArrayBufferNeuteringWatchpointSet, and instead putting InlineWatchpointSet directly into ArrayBuffer, since this is much simpler. The main reason why we are using ArrayBufferNeuteringWatchpointSet is not to increase sizeof(ArrayBuffer). But this complicates the implementation. So, not to increase sizeof(ArrayBuffer), we use PackedRefPtr in ArrayBuffer, which is RefPtr while the pointer is packed. This gives us 8 bytes which is suitable for placing InlineWatchpointSet without increasing sizeof(ArrayBuffer). We also convert Function<> in ArrayBuffer to PackedRefPtr<SharedTask<>>, and share Gigacage::free destructor by multiple ArrayBuffer. This is memory efficient since this is the common case, and we can pack this field easily. * API/JSTypedArray.cpp: (JSObjectMakeTypedArrayWithBytesNoCopy): (JSObjectMakeArrayBufferWithBytesNoCopy): * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * dfg/DFGDesiredWatchpoints.cpp: (JSC::DFG::ArrayBufferViewWatchpointAdaptor::add): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::tryGetFoldableView): * runtime/ArrayBuffer.cpp: (JSC::ArrayBuffer::primitiveGigacageDestructor): (JSC::SharedArrayBufferContents::~SharedArrayBufferContents): (JSC::ArrayBufferContents::destroy): (JSC::ArrayBufferContents::reset): (JSC::ArrayBufferContents::tryAllocate): (JSC::ArrayBufferContents::makeShared): (JSC::ArrayBufferContents::shareWith): (JSC::ArrayBuffer::createAdopted): (JSC::ArrayBuffer::transferTo): (JSC::ArrayBuffer::neuter): (JSC::ArrayBuffer::notifyIncommingReferencesOfTransfer): * runtime/ArrayBuffer.h: (JSC::ArrayBuffer::neuteringWatchpointSet): * runtime/ArrayBufferNeuteringWatchpointSet.cpp: Removed. * runtime/FileBasedFuzzerAgent.cpp: (JSC::FileBasedFuzzerAgent::getPredictionInternal): * runtime/FileBasedFuzzerAgentBase.cpp: (JSC::FileBasedFuzzerAgentBase::createLookupKey): * runtime/PredictionFileCreatingFuzzerAgent.cpp: (JSC::PredictionFileCreatingFuzzerAgent::getPredictionInternal): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * wasm/js/JSWebAssemblyMemory.cpp: (JSC::JSWebAssemblyMemory::buffer): Source/WebCore: * bindings/js/SerializedScriptValue.h: (WebCore::SerializedScriptValue::decode): Source/WTF: This patch adds PackedRef and PackedRefPtr. They are Ref and RefPtr, but its internal pointer is packed. So we can represent them in 6 bytes with 1 byte alignment. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Packed.h: (WTF::alignof): * wtf/PackedRef.h: Copied from Source/JavaScriptCore/runtime/ArrayBufferNeuteringWatchpointSet.h. * wtf/PackedRefPtr.h: Renamed from Source/JavaScriptCore/runtime/ArrayBufferNeuteringWatchpointSet.h. * wtf/RefPtr.h: (WTF::RefPtr::operator UnspecifiedBoolType const): (WTF::RefPtr::unspecifiedBoolTypeInstance const): Tools: Add tests for PackedRef and PackedRefPtr. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/PackedRef.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::passWithRef): (TestWebKitAPI::PackedRefCheckingRefLogger::PackedRefCheckingRefLogger): (TestWebKitAPI::PackedRefCheckingRefLogger::ref): (TestWebKitAPI::PackedRefCheckingRefLogger::deref): (TestWebKitAPI::DerivedPackedRefCheckingRefLogger::DerivedPackedRefCheckingRefLogger): * TestWebKitAPI/Tests/WTF/PackedRefPtr.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/RefPtr.cpp. (TestWebKitAPI::TEST): (TestWebKitAPI::f1): (TestWebKitAPI::ConstRefCounted::create): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::PackedRefPtrCheckingRefLogger): (TestWebKitAPI::loggerName): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::ref): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::deref): * TestWebKitAPI/Tests/WTF/RefPtr.cpp: (TestWebKitAPI::f1): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): Canonical link: https://commits.webkit.org/218489@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-16 22:17:27 +00:00
void swap(T* t2)
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
{
[JSC] Remove ArrayBufferNeuteringWatchpointSet https://bugs.webkit.org/show_bug.cgi?id=205194 Reviewed by Saam Barati. Source/JavaScriptCore: This patch removes ArrayBufferNeuteringWatchpointSet, and instead putting InlineWatchpointSet directly into ArrayBuffer, since this is much simpler. The main reason why we are using ArrayBufferNeuteringWatchpointSet is not to increase sizeof(ArrayBuffer). But this complicates the implementation. So, not to increase sizeof(ArrayBuffer), we use PackedRefPtr in ArrayBuffer, which is RefPtr while the pointer is packed. This gives us 8 bytes which is suitable for placing InlineWatchpointSet without increasing sizeof(ArrayBuffer). We also convert Function<> in ArrayBuffer to PackedRefPtr<SharedTask<>>, and share Gigacage::free destructor by multiple ArrayBuffer. This is memory efficient since this is the common case, and we can pack this field easily. * API/JSTypedArray.cpp: (JSObjectMakeTypedArrayWithBytesNoCopy): (JSObjectMakeArrayBufferWithBytesNoCopy): * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * dfg/DFGDesiredWatchpoints.cpp: (JSC::DFG::ArrayBufferViewWatchpointAdaptor::add): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::tryGetFoldableView): * runtime/ArrayBuffer.cpp: (JSC::ArrayBuffer::primitiveGigacageDestructor): (JSC::SharedArrayBufferContents::~SharedArrayBufferContents): (JSC::ArrayBufferContents::destroy): (JSC::ArrayBufferContents::reset): (JSC::ArrayBufferContents::tryAllocate): (JSC::ArrayBufferContents::makeShared): (JSC::ArrayBufferContents::shareWith): (JSC::ArrayBuffer::createAdopted): (JSC::ArrayBuffer::transferTo): (JSC::ArrayBuffer::neuter): (JSC::ArrayBuffer::notifyIncommingReferencesOfTransfer): * runtime/ArrayBuffer.h: (JSC::ArrayBuffer::neuteringWatchpointSet): * runtime/ArrayBufferNeuteringWatchpointSet.cpp: Removed. * runtime/FileBasedFuzzerAgent.cpp: (JSC::FileBasedFuzzerAgent::getPredictionInternal): * runtime/FileBasedFuzzerAgentBase.cpp: (JSC::FileBasedFuzzerAgentBase::createLookupKey): * runtime/PredictionFileCreatingFuzzerAgent.cpp: (JSC::PredictionFileCreatingFuzzerAgent::getPredictionInternal): * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * wasm/js/JSWebAssemblyMemory.cpp: (JSC::JSWebAssemblyMemory::buffer): Source/WebCore: * bindings/js/SerializedScriptValue.h: (WebCore::SerializedScriptValue::decode): Source/WTF: This patch adds PackedRef and PackedRefPtr. They are Ref and RefPtr, but its internal pointer is packed. So we can represent them in 6 bytes with 1 byte alignment. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Packed.h: (WTF::alignof): * wtf/PackedRef.h: Copied from Source/JavaScriptCore/runtime/ArrayBufferNeuteringWatchpointSet.h. * wtf/PackedRefPtr.h: Renamed from Source/JavaScriptCore/runtime/ArrayBufferNeuteringWatchpointSet.h. * wtf/RefPtr.h: (WTF::RefPtr::operator UnspecifiedBoolType const): (WTF::RefPtr::unspecifiedBoolTypeInstance const): Tools: Add tests for PackedRef and PackedRefPtr. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/PackedRef.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::passWithRef): (TestWebKitAPI::PackedRefCheckingRefLogger::PackedRefCheckingRefLogger): (TestWebKitAPI::PackedRefCheckingRefLogger::ref): (TestWebKitAPI::PackedRefCheckingRefLogger::deref): (TestWebKitAPI::DerivedPackedRefCheckingRefLogger::DerivedPackedRefCheckingRefLogger): * TestWebKitAPI/Tests/WTF/PackedRefPtr.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/RefPtr.cpp. (TestWebKitAPI::TEST): (TestWebKitAPI::f1): (TestWebKitAPI::ConstRefCounted::create): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::PackedRefPtrCheckingRefLogger): (TestWebKitAPI::loggerName): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::ref): (TestWebKitAPI::PackedRefPtrCheckingRefLogger::deref): * TestWebKitAPI/Tests/WTF/RefPtr.cpp: (TestWebKitAPI::f1): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): Canonical link: https://commits.webkit.org/218489@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-16 22:17:27 +00:00
T* t1 = get();
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
std::swap(t1, t2);
set(t1);
}
private:
std::array<uint8_t, storageSize> m_storage;
};
template<typename T>
class Packed<T*> : public PackedAlignedPtr<T, 1> {
public:
using Base = PackedAlignedPtr<T, 1>;
using Base::Base;
[WTF] AtomStringTable should be small https://bugs.webkit.org/show_bug.cgi?id=206400 Reviewed by Sam Weinig. Source/WebCore: * dom/GCReachableRef.h: (WebCore::GCReachableRef::GCReachableRef): * dom/QualifiedName.h: (WebCore::QualifiedName::hashTableDeletedValue): Source/WTF: AtomStringTable is the largest hashtable typically. It takes more than 256KB per WebProcess (sometimes, it took 1MB or more). This patch leverages PackedPtr to compact it from 8 bytes per entry to 6 bytes per entry. While this is still large, we should investigate how to compact C++ pointers in 4 bytes[1] to shrink memory footprint, since WebKit memory is used by Vector and HashTable fulfilled with pointers. [1]: https://bugs.webkit.org/show_bug.cgi?id=206469 * wtf/DumbPtrTraits.h: (WTF::DumbPtrTraits::hashTableDeletedValue): (WTF::DumbPtrTraits::isHashTableDeletedValue): * wtf/Forward.h: * wtf/HashTraits.h: * wtf/Packed.h: (WTF::Packed<T::Packed): (WTF::Packed<T::isHashTableDeletedValue const): (WTF::GetPtrHelper<PackedPtr<T>>::getPtr): (WTF::PackedPtrTraits::hashTableDeletedValue): (WTF::PackedPtrTraits::isHashTableDeletedValue): (WTF::alignof): Deleted. * wtf/Ref.h: (WTF::Ref::Ref): (WTF::Ref::isHashTableDeletedValue const): (WTF::Ref::hashTableDeletedValue): Deleted. * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): (WTF::RefPtr::isHashTableDeletedValue const): (WTF::RefPtr::hashTableDeletedValue): Deleted. * wtf/text/AtomStringImpl.cpp: (WTF::addToStringTable): (WTF::CStringTranslator::equal): (WTF::CStringTranslator::translate): (WTF::UCharBufferTranslator::equal): (WTF::UCharBufferTranslator::translate): (WTF::HashAndUTF8CharactersTranslator::equal): (WTF::HashAndUTF8CharactersTranslator::translate): (WTF::SubstringTranslator::translate): (WTF::SubstringTranslator8::equal): (WTF::SubstringTranslator16::equal): (WTF::LCharBufferTranslator::equal): (WTF::LCharBufferTranslator::translate): (WTF::BufferFromStaticDataTranslator::equal): (WTF::BufferFromStaticDataTranslator::translate): (WTF::AtomStringImpl::addSlowCase): (WTF::AtomStringImpl::remove): (WTF::AtomStringImpl::lookUpSlowCase): (WTF::AtomStringImpl::lookUp): * wtf/text/AtomStringTable.cpp: (WTF::AtomStringTable::~AtomStringTable): * wtf/text/AtomStringTable.h: (WTF::AtomStringTable::table): (): Deleted. * wtf/text/StringHash.h: (WTF::StringHash::hash): (WTF::StringHash::equal): (WTF::ASCIICaseInsensitiveHash::hash): (WTF::ASCIICaseInsensitiveHash::equal): * wtf/text/StringImpl.h: Tools: * TestWebKitAPI/Tests/WTF/HashMap.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/219616@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254881 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-21 22:05:43 +00:00
// Hash table deleted values, which are only constructed and never copied or destroyed.
Packed(HashTableDeletedValueType) : Base(bitwise_cast<T*>(static_cast<uintptr_t>(Base::alignment))) { }
bool isHashTableDeletedValue() const { return Base::get() == bitwise_cast<T*>(static_cast<uintptr_t>(Base::alignment)); }
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
};
template<typename T>
using PackedPtr = Packed<T*>;
[WTF] AtomStringTable should be small https://bugs.webkit.org/show_bug.cgi?id=206400 Reviewed by Sam Weinig. Source/WebCore: * dom/GCReachableRef.h: (WebCore::GCReachableRef::GCReachableRef): * dom/QualifiedName.h: (WebCore::QualifiedName::hashTableDeletedValue): Source/WTF: AtomStringTable is the largest hashtable typically. It takes more than 256KB per WebProcess (sometimes, it took 1MB or more). This patch leverages PackedPtr to compact it from 8 bytes per entry to 6 bytes per entry. While this is still large, we should investigate how to compact C++ pointers in 4 bytes[1] to shrink memory footprint, since WebKit memory is used by Vector and HashTable fulfilled with pointers. [1]: https://bugs.webkit.org/show_bug.cgi?id=206469 * wtf/DumbPtrTraits.h: (WTF::DumbPtrTraits::hashTableDeletedValue): (WTF::DumbPtrTraits::isHashTableDeletedValue): * wtf/Forward.h: * wtf/HashTraits.h: * wtf/Packed.h: (WTF::Packed<T::Packed): (WTF::Packed<T::isHashTableDeletedValue const): (WTF::GetPtrHelper<PackedPtr<T>>::getPtr): (WTF::PackedPtrTraits::hashTableDeletedValue): (WTF::PackedPtrTraits::isHashTableDeletedValue): (WTF::alignof): Deleted. * wtf/Ref.h: (WTF::Ref::Ref): (WTF::Ref::isHashTableDeletedValue const): (WTF::Ref::hashTableDeletedValue): Deleted. * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): (WTF::RefPtr::isHashTableDeletedValue const): (WTF::RefPtr::hashTableDeletedValue): Deleted. * wtf/text/AtomStringImpl.cpp: (WTF::addToStringTable): (WTF::CStringTranslator::equal): (WTF::CStringTranslator::translate): (WTF::UCharBufferTranslator::equal): (WTF::UCharBufferTranslator::translate): (WTF::HashAndUTF8CharactersTranslator::equal): (WTF::HashAndUTF8CharactersTranslator::translate): (WTF::SubstringTranslator::translate): (WTF::SubstringTranslator8::equal): (WTF::SubstringTranslator16::equal): (WTF::LCharBufferTranslator::equal): (WTF::LCharBufferTranslator::translate): (WTF::BufferFromStaticDataTranslator::equal): (WTF::BufferFromStaticDataTranslator::translate): (WTF::AtomStringImpl::addSlowCase): (WTF::AtomStringImpl::remove): (WTF::AtomStringImpl::lookUpSlowCase): (WTF::AtomStringImpl::lookUp): * wtf/text/AtomStringTable.cpp: (WTF::AtomStringTable::~AtomStringTable): * wtf/text/AtomStringTable.h: (WTF::AtomStringTable::table): (): Deleted. * wtf/text/StringHash.h: (WTF::StringHash::hash): (WTF::StringHash::equal): (WTF::ASCIICaseInsensitiveHash::hash): (WTF::ASCIICaseInsensitiveHash::equal): * wtf/text/StringImpl.h: Tools: * TestWebKitAPI/Tests/WTF/HashMap.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/219616@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254881 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-21 22:05:43 +00:00
template <typename T>
struct GetPtrHelper<PackedPtr<T>> {
using PtrType = T*;
static T* getPtr(const PackedPtr<T>& p) { return const_cast<T*>(p.get()); }
};
template <typename T>
struct IsSmartPtr<PackedPtr<T>> {
static constexpr bool value = true;
};
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
template<typename T>
struct PackedPtrTraits {
template<typename U> using RebindTraits = PackedPtrTraits<U>;
using StorageType = PackedPtr<T>;
template<class U> static ALWAYS_INLINE T* exchange(StorageType& ptr, U&& newValue) { return ptr.exchange(newValue); }
template<typename Other> static ALWAYS_INLINE void swap(PackedPtr<T>& a, Other& b) { a.swap(b); }
static ALWAYS_INLINE T* unwrap(const StorageType& ptr) { return ptr.get(); }
[WTF] AtomStringTable should be small https://bugs.webkit.org/show_bug.cgi?id=206400 Reviewed by Sam Weinig. Source/WebCore: * dom/GCReachableRef.h: (WebCore::GCReachableRef::GCReachableRef): * dom/QualifiedName.h: (WebCore::QualifiedName::hashTableDeletedValue): Source/WTF: AtomStringTable is the largest hashtable typically. It takes more than 256KB per WebProcess (sometimes, it took 1MB or more). This patch leverages PackedPtr to compact it from 8 bytes per entry to 6 bytes per entry. While this is still large, we should investigate how to compact C++ pointers in 4 bytes[1] to shrink memory footprint, since WebKit memory is used by Vector and HashTable fulfilled with pointers. [1]: https://bugs.webkit.org/show_bug.cgi?id=206469 * wtf/DumbPtrTraits.h: (WTF::DumbPtrTraits::hashTableDeletedValue): (WTF::DumbPtrTraits::isHashTableDeletedValue): * wtf/Forward.h: * wtf/HashTraits.h: * wtf/Packed.h: (WTF::Packed<T::Packed): (WTF::Packed<T::isHashTableDeletedValue const): (WTF::GetPtrHelper<PackedPtr<T>>::getPtr): (WTF::PackedPtrTraits::hashTableDeletedValue): (WTF::PackedPtrTraits::isHashTableDeletedValue): (WTF::alignof): Deleted. * wtf/Ref.h: (WTF::Ref::Ref): (WTF::Ref::isHashTableDeletedValue const): (WTF::Ref::hashTableDeletedValue): Deleted. * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): (WTF::RefPtr::isHashTableDeletedValue const): (WTF::RefPtr::hashTableDeletedValue): Deleted. * wtf/text/AtomStringImpl.cpp: (WTF::addToStringTable): (WTF::CStringTranslator::equal): (WTF::CStringTranslator::translate): (WTF::UCharBufferTranslator::equal): (WTF::UCharBufferTranslator::translate): (WTF::HashAndUTF8CharactersTranslator::equal): (WTF::HashAndUTF8CharactersTranslator::translate): (WTF::SubstringTranslator::translate): (WTF::SubstringTranslator8::equal): (WTF::SubstringTranslator16::equal): (WTF::LCharBufferTranslator::equal): (WTF::LCharBufferTranslator::translate): (WTF::BufferFromStaticDataTranslator::equal): (WTF::BufferFromStaticDataTranslator::translate): (WTF::AtomStringImpl::addSlowCase): (WTF::AtomStringImpl::remove): (WTF::AtomStringImpl::lookUpSlowCase): (WTF::AtomStringImpl::lookUp): * wtf/text/AtomStringTable.cpp: (WTF::AtomStringTable::~AtomStringTable): * wtf/text/AtomStringTable.h: (WTF::AtomStringTable::table): (): Deleted. * wtf/text/StringHash.h: (WTF::StringHash::hash): (WTF::StringHash::equal): (WTF::ASCIICaseInsensitiveHash::hash): (WTF::ASCIICaseInsensitiveHash::equal): * wtf/text/StringImpl.h: Tools: * TestWebKitAPI/Tests/WTF/HashMap.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/219616@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254881 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-21 22:05:43 +00:00
// We assume that,
// 1. The alignment is < 4KB. (It is tested by HashTraits).
// 2. The first page (including nullptr) is never mapped.
static StorageType hashTableDeletedValue() { return StorageType { bitwise_cast<T*>(static_cast<uintptr_t>(StorageType::alignment)) }; }
static ALWAYS_INLINE bool isHashTableDeletedValue(const StorageType& ptr) { return ptr.get() == bitwise_cast<T*>(static_cast<uintptr_t>(StorageType::alignment)); }
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
};
[WTF] Remove the unnecessary inner class DefaultHash<T>::Hash https://bugs.webkit.org/show_bug.cgi?id=214389 Reviewed by Darin Adler. Source/JavaScriptCore: * assembler/MacroAssemblerCodeRef.h: * b3/B3CheckSpecial.h: * b3/B3Kind.h: * b3/B3ValueKey.h: * b3/air/AirAllocateRegistersByGraphColoring.cpp: * b3/air/AirArg.h: * b3/air/AirTmp.h: * bytecode/BytecodeIndex.h: * bytecode/CallVariant.h: * bytecode/CodeOrigin.h: * bytecode/DFGExitProfile.h: * bytecode/LazyOperandValueProfile.h: * bytecode/ObjectPropertyCondition.h: * bytecode/PropertyCondition.h: * dfg/DFGAbstractHeap.h: * dfg/DFGArgumentsEliminationPhase.cpp: * dfg/DFGByteCodeParser.cpp: * dfg/DFGCSEPhase.cpp: * dfg/DFGCompilationKey.h: * dfg/DFGDesiredGlobalProperty.h: * dfg/DFGHeapLocation.h: * dfg/DFGLivenessAnalysisPhase.cpp: * dfg/DFGMinifiedID.h: * dfg/DFGNodeFlowProjection.h: * dfg/DFGPromotedHeapLocation.h: * dfg/DFGPropertyTypeKey.h: * dfg/DFGPureValue.h: * ftl/FTLLocation.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNewArrayWithSpread): (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargsSpread): (JSC::FTL::DFG::LowerDFGToB3::compileMaterializeNewObject): * ftl/FTLSlowPathCallKey.h: * heap/MarkedBlock.h: * heap/VisitRaceKey.h: * inspector/scripts/codegen/generate_cpp_protocol_types_header.py: * inspector/scripts/tests/expected/commands-with-async-attribute.json-result: * inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result: * inspector/scripts/tests/expected/enum-values.json-result: * inspector/scripts/tests/expected/type-declaration-array-type.json-result: * inspector/scripts/tests/expected/type-declaration-enum-type.json-result: * inspector/scripts/tests/expected/type-declaration-object-type.json-result: * inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result: * jit/ICStats.h: * jit/JITThunks.h: * jit/Reg.h: * jit/RegisterSet.h: * parser/VariableEnvironment.h: * profiler/ProfilerOrigin.h: * profiler/ProfilerOriginStack.h: * profiler/ProfilerUID.h: * runtime/CachedTypes.cpp: * runtime/ControlFlowProfiler.h: * runtime/NativeFunction.h: * runtime/PrototypeKey.h: * runtime/RegExpKey.h: * runtime/TemplateObjectDescriptor.h: * runtime/TypeProfiler.h: * runtime/VarOffset.h: * runtime/WeakGCMap.h: * wasm/WasmBBQPlan.h: * wasm/WasmCodeBlock.h: * wasm/WasmEntryPlan.h: * wasm/WasmLLIntPlan.h: * wasm/WasmSignature.h: Source/WebCore: * Modules/indexeddb/IDBDatabaseIdentifier.h: * Modules/indexeddb/shared/IDBResourceIdentifier.h: * Modules/webgpu/WHLSL/AST/WHLSLUnnamedTypeHash.h: * Modules/webgpu/WHLSL/WHLSLSemanticMatcher.cpp: (WebCore::WHLSL::matchResources): (WebCore::WHLSL::matchVertexAttributes): (WebCore::WHLSL::matchColorAttachments): * accessibility/AccessibilityObject.cpp: * accessibility/AccessibilityObject.h: * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::serializeActions): * contentextensions/ContentExtensionRule.h: (WebCore::ContentExtensions::TriggerHash::hash): * contentextensions/ContentExtensionStyleSheet.h: * contentextensions/DFA.cpp: (WebCore::ContentExtensions::printTransitions): * contentextensions/DFABytecodeInterpreter.h: * contentextensions/DFACombiner.cpp: (WebCore::ContentExtensions::DFAMerger::getOrCreateCombinedNode): * contentextensions/DFANode.cpp: (WebCore::ContentExtensions::DFANode::bestFallbackTarget const): * contentextensions/ImmutableNFANodeBuilder.h: * contentextensions/NFA.cpp: (WebCore::ContentExtensions::NFA::debugPrintDot const): * contentextensions/NFANode.h: * contentextensions/NFAToDFA.cpp: (WebCore::ContentExtensions::NodeIdSetToUniqueNodeIdSetSource::NodeIdSetToUniqueNodeIdSetSource): (WebCore::ContentExtensions::NodeIdSetToUniqueNodeIdSetTranslator::translate): * css/makeprop.pl: * css/parser/CSSParserContext.h: * dom/GCReachableRef.h: * dom/MessagePortIdentifier.h: * dom/NodeRareData.h: (WebCore::NodeListsNodeData::NodeListCacheMapEntryHash::hash): (WebCore::NodeListsNodeData::NodeListCacheMapEntryHash::equal): * dom/QualifiedName.h: * history/BackForwardItemIdentifier.h: * html/canvas/WebGLRenderingContextBase.h: * layout/LayoutUnits.h: * loader/AdClickAttribution.h: * loader/ResourceCryptographicDigest.h: (WTF::DefaultHash<WebCore::ResourceCryptographicDigest>::hash): (WTF::DefaultHash<WebCore::ResourceCryptographicDigest>::equal): (WTF::DefaultHash<WebCore::ResourceCryptographicDigest>::Hash::hash): Deleted. (WTF::DefaultHash<WebCore::ResourceCryptographicDigest>::Hash::equal): Deleted. * page/ClientOrigin.h: * page/GlobalWindowIdentifier.h: * page/SecurityOriginData.h: * page/SecurityOriginHash.h: * platform/Cookie.h: * platform/RegistrableDomain.h: * platform/graphics/ColorHash.h: * platform/graphics/FloatSizeHash.h: (WTF::FloatHash<WebCore::FloatSize>::hash): * platform/graphics/FontGenericFamilies.h: * platform/graphics/IntPointHash.h: * platform/graphics/IntRectHash.h: (WTF::IntHash<WebCore::IntRect>::hash): (WTF::IntHash<WebCore::IntRect>::equal): * platform/graphics/IntSizeHash.h: * platform/graphics/WidthCache.h: * platform/graphics/freetype/FontCacheFreeType.cpp: (WebCore::FallbackFontDescriptionKey::computeHash const): * platform/network/HTTPParsers.h: * platform/network/ProtectionSpaceHash.h: * platform/win/COMPtr.h: * platform/win/WindowsKeyNames.h: * rendering/CSSValueKey.h: * rendering/GridBaselineAlignment.h: * rendering/GridTrackSizingAlgorithm.h: * rendering/RenderGrid.cpp: (WebCore::RenderGrid::placeSpecifiedMajorAxisItemsOnGrid const): * rendering/RenderTheme.h: * style/RuleSet.cpp: (WebCore::Style::RuleSet::evaluateDynamicMediaQueryRules): * svg/SVGElement.h: (WebCore::SVGAttributeHashTranslator::hash): * workers/service/ServiceWorkerClientIdentifier.h: * workers/service/ServiceWorkerRegistrationKey.h: Source/WebCore/PAL: * pal/SessionID.h: Source/WebKit: * NetworkProcess/Downloads/DownloadID.h: * NetworkProcess/cache/NetworkCache.h: * NetworkProcess/cache/NetworkCacheKey.h: * Platform/IPC/MessageReceiverMap.h: * Platform/IPC/StringReference.h: * Shared/CallbackID.h: * UIProcess/API/cpp/WKRetainPtr.h: Source/WebKitLegacy/win: * COMPropertyBag.h: Source/WTF: DefaultHash<T> doesn't need to have a inner struct Hash. This can be a problem for forward declarations (Bug 214320 Comment 5). * wtf/BitVector.h: * wtf/Forward.h: * wtf/HashFunctions.h: (WTF::PairHash::hash): (WTF::PairHash::equal): (WTF::TupleHash::hash): (WTF::TupleHash::equal): * wtf/ListHashSet.h: * wtf/LoggingHashMap.h: * wtf/LoggingHashSet.h: * wtf/MetaAllocatorPtr.h: * wtf/ObjectIdentifier.h: * wtf/OptionSetHash.h: (WTF::DefaultHash<OptionSet<T>>::hash): (WTF::DefaultHash<OptionSet<T>>::equal): (WTF::DefaultHash<OptionSet<T>>::Hash::hash): Deleted. (WTF::DefaultHash<OptionSet<T>>::Hash::equal): Deleted. * wtf/Packed.h: * wtf/RetainPtr.h: * wtf/StackShot.h: * wtf/URLHash.h: * wtf/VectorHash.h: (WTF::VectorHash::hash): * wtf/text/AtomString.h: * wtf/text/AtomStringHash.h: * wtf/text/CString.h: * wtf/text/StringHash.h: * wtf/text/StringImpl.h: * wtf/text/SymbolRegistry.h: (WTF::DefaultHash<SymbolRegistryKey>::hash): (WTF::DefaultHash<SymbolRegistryKey>::equal): (WTF::DefaultHash<SymbolRegistryKey>::Hash::hash): Deleted. (WTF::DefaultHash<SymbolRegistryKey>::Hash::equal): Deleted. * wtf/text/WTFString.h: Tools: * TestWebKitAPI/Tests/WTF/DeletedAddressOfOperator.h: (WTF::DefaultHash<DeletedAddressOfOperator>::hash): (WTF::DefaultHash<DeletedAddressOfOperator>::equal): (WTF::DefaultHash<DeletedAddressOfOperator>::Hash::hash): Deleted. (WTF::DefaultHash<DeletedAddressOfOperator>::Hash::equal): Deleted. * TestWebKitAPI/Tests/WTF/HashCountedSet.cpp: (TestWebKitAPI::bucketForKey): * TestWebKitAPI/Tests/WTF/HashMap.cpp: (TestWebKitAPI::bucketForKey): (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::testInitialCapacity): * TestWebKitAPI/Tests/WTF/MoveOnly.h: (WTF::DefaultHash<MoveOnly>::hash): (WTF::DefaultHash<MoveOnly>::equal): (WTF::DefaultHash<MoveOnly>::Hash::hash): Deleted. (WTF::DefaultHash<MoveOnly>::Hash::equal): Deleted. Canonical link: https://commits.webkit.org/227236@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@264488 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-17 00:33:37 +00:00
template<typename P> struct DefaultHash<PackedPtr<P>> : PtrHash<PackedPtr<P>> { };
[WTF] AtomStringTable should be small https://bugs.webkit.org/show_bug.cgi?id=206400 Reviewed by Sam Weinig. Source/WebCore: * dom/GCReachableRef.h: (WebCore::GCReachableRef::GCReachableRef): * dom/QualifiedName.h: (WebCore::QualifiedName::hashTableDeletedValue): Source/WTF: AtomStringTable is the largest hashtable typically. It takes more than 256KB per WebProcess (sometimes, it took 1MB or more). This patch leverages PackedPtr to compact it from 8 bytes per entry to 6 bytes per entry. While this is still large, we should investigate how to compact C++ pointers in 4 bytes[1] to shrink memory footprint, since WebKit memory is used by Vector and HashTable fulfilled with pointers. [1]: https://bugs.webkit.org/show_bug.cgi?id=206469 * wtf/DumbPtrTraits.h: (WTF::DumbPtrTraits::hashTableDeletedValue): (WTF::DumbPtrTraits::isHashTableDeletedValue): * wtf/Forward.h: * wtf/HashTraits.h: * wtf/Packed.h: (WTF::Packed<T::Packed): (WTF::Packed<T::isHashTableDeletedValue const): (WTF::GetPtrHelper<PackedPtr<T>>::getPtr): (WTF::PackedPtrTraits::hashTableDeletedValue): (WTF::PackedPtrTraits::isHashTableDeletedValue): (WTF::alignof): Deleted. * wtf/Ref.h: (WTF::Ref::Ref): (WTF::Ref::isHashTableDeletedValue const): (WTF::Ref::hashTableDeletedValue): Deleted. * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): (WTF::RefPtr::isHashTableDeletedValue const): (WTF::RefPtr::hashTableDeletedValue): Deleted. * wtf/text/AtomStringImpl.cpp: (WTF::addToStringTable): (WTF::CStringTranslator::equal): (WTF::CStringTranslator::translate): (WTF::UCharBufferTranslator::equal): (WTF::UCharBufferTranslator::translate): (WTF::HashAndUTF8CharactersTranslator::equal): (WTF::HashAndUTF8CharactersTranslator::translate): (WTF::SubstringTranslator::translate): (WTF::SubstringTranslator8::equal): (WTF::SubstringTranslator16::equal): (WTF::LCharBufferTranslator::equal): (WTF::LCharBufferTranslator::translate): (WTF::BufferFromStaticDataTranslator::equal): (WTF::BufferFromStaticDataTranslator::translate): (WTF::AtomStringImpl::addSlowCase): (WTF::AtomStringImpl::remove): (WTF::AtomStringImpl::lookUpSlowCase): (WTF::AtomStringImpl::lookUp): * wtf/text/AtomStringTable.cpp: (WTF::AtomStringTable::~AtomStringTable): * wtf/text/AtomStringTable.h: (WTF::AtomStringTable::table): (): Deleted. * wtf/text/StringHash.h: (WTF::StringHash::hash): (WTF::StringHash::equal): (WTF::ASCIICaseInsensitiveHash::hash): (WTF::ASCIICaseInsensitiveHash::equal): * wtf/text/StringImpl.h: Tools: * TestWebKitAPI/Tests/WTF/HashMap.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/219616@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254881 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-21 22:05:43 +00:00
[JSC] Compress Watchpoint size by using enum type and Packed<> data structure https://bugs.webkit.org/show_bug.cgi?id=197730 Reviewed by Filip Pizlo. Source/JavaScriptCore: Watchpoint takes 5~ MB memory in Gmail (total memory starts with 400 - 500 MB), so 1~%. Since it is allocated massively, reducing each size of Watchpoint reduces memory footprint significantly. As a first step, this patch uses Packed<> and enum to reduce the size of Watchpoint. 1. Watchpoint should have enum type and should not use vtable. vtable takes one pointer, and it is too costly for such a memory sensitive objects. We perform downcast and dispatch the method of the derived classes based on this enum. Since the # of derived Watchpoint classes are limited (Only 8), we can list up them easily. One unfortunate thing is that we cannot do this for destructor so long as we use "delete" for deleting objects. If we dispatch the destructor of derived class in the destructor of the base class, we call the destructor of the base class multiple times. delete operator override does not help since custom delete operator is called after the destructor is called. While we can fix this issue by always using custom deleter, currently we do not since all the watchpoints do not have members which have non trivial destructor. Once it is strongly required, we can start using custom deleter, but for now, we do not need to do this. 2. We use Packed<> to compact pointers in Watchpoint. Since Watchpoint is a node of doubly linked list, each one has two pointers for prev and next. This is also too costly. PackedPtr reduces the size and makes alignment 1.S 3. We use PackedCellPtr<> for JSCells in Watchpoint. This leverages alignment information and makes pointers smaller in Darwin ARM64. One important thing to note here is that since this pointer is packed, it cannot be found by conservative GC scan. It is OK for watchpoint since they are allocated in the heap anyway. We applied this change to Watchpoint and get the following memory reduction. The highlight is that CodeBlockJettisoningWatchpoint in ARM64 only takes 2 pointers size. ORIGINAL X86_64 ARM64 WatchpointSet: 40 32 28 CodeBlockJettisoningWatchpoint: 32 19 15 StructureStubClearingWatchpoint: 56 48 40 AdaptiveInferredPropertyValueWatchpointBase::StructureWatchpoint: 24 13 11 AdaptiveInferredPropertyValueWatchpointBase::PropertyWatchpoint: 24 13 11 FunctionRareData::AllocationProfileClearingWatchpoint: 32 19 15 ObjectToStringAdaptiveStructureWatchpoint: 56 48 40 LLIntPrototypeLoadAdaptiveStructureWatchpoint: 64 48 48 DFG::AdaptiveStructureWatchpoint: 56 48 40 While we will re-architect the mechanism of Watchpoint, anyway Packed<> mechanism and enum types will be used too. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/AdaptiveInferredPropertyValueWatchpointBase.h: * bytecode/CodeBlockJettisoningWatchpoint.h: * bytecode/CodeOrigin.h: * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: * bytecode/StructureStubClearingWatchpoint.cpp: (JSC::StructureStubClearingWatchpoint::fireInternal): * bytecode/StructureStubClearingWatchpoint.h: * bytecode/Watchpoint.cpp: (JSC::Watchpoint::fire): * bytecode/Watchpoint.h: (JSC::Watchpoint::Watchpoint): * dfg/DFGAdaptiveStructureWatchpoint.cpp: (JSC::DFG::AdaptiveStructureWatchpoint::AdaptiveStructureWatchpoint): * dfg/DFGAdaptiveStructureWatchpoint.h: * heap/PackedCellPtr.h: Added. * runtime/FunctionRareData.h: * runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp: Added. (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): * runtime/ObjectToStringAdaptiveStructureWatchpoint.h: Added. * runtime/StructureRareData.cpp: (JSC::StructureRareData::clearObjectToStringValue): (JSC::ObjectToStringAdaptiveStructureWatchpoint::ObjectToStringAdaptiveStructureWatchpoint): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::install): Deleted. (JSC::ObjectToStringAdaptiveStructureWatchpoint::fireInternal): Deleted. * runtime/StructureRareData.h: Source/WTF: This patch introduces a new data structures, WTF::Packed, WTF::PackedPtr, and WTF::PackedAlignedPtr. - WTF::Packed WTF::Packed is data storage. We can read and write trivial (in C++ term [1]) data to this storage. The difference to the usual storage is that the alignment of this storage is always 1. We access the underlying data by using unalignedLoad/unalignedStore. This class offers alignment = 1 data structure instead of missing the following characteristics. 1. Load / Store are non atomic even if the data size is within a pointer width. We should not use this for a member which can be accessed in a racy way. (e.g. fields accessed optimistically from the concurrent compilers). 2. We cannot take reference / pointer to the underlying storage since they are unaligned. 3. Access to this storage is unaligned access. The code is using memcpy, and the compiler will convert to an appropriate unaligned access in certain architectures (x86_64 / ARM64). It could be slow. So use it for non performance sensitive & memory sensitive places. - WTF::PackedPtr WTF::PackedPtr is a specialization of WTF::Packed<T*>. And it is basically WTF::PackedAlignedPtr with alignment = 1. We further compact the pointer by leveraging the platform specific knowledge. In 64bit architectures, the effective width of pointers are less than 64 bit. In x86_64, it is 48 bits. And Darwin ARM64 is further smaller, 36 bits. This information allows us to compact the pointer to 6 bytes in x86_64 and 5 bytes in Darwin ARM64. - WTF::PackedAlignedPtr WTF::PackedAlignedPtr is the WTF::PackedPtr with alignment information of the T. If we use this alignment information, we could reduce the size of packed pointer further in some cases. For example, since we guarantee that JSCells are 16 byte aligned, low 4 bits are empty. Leveraging this information in Darwin ARM64 platform allows us to make packed JSCell pointer 4 bytes (36 - 4 bits). We do not use passed alignment information if it is not profitable. We also have PackedPtrTraits. This is new PtrTraits and use it for various data structures such as Bag<>. [1]: https://en.cppreference.com/w/cpp/types/is_trivial * WTF.xcodeproj/project.pbxproj: * wtf/Bag.h: (WTF::Bag::clear): (WTF::Bag::iterator::operator++): * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: * wtf/MathExtras.h: (WTF::clzConstexpr): (WTF::clz): (WTF::ctzConstexpr): (WTF::ctz): (WTF::getLSBSetConstexpr): (WTF::getMSBSetConstexpr): * wtf/Packed.h: Added. (WTF::Packed::Packed): (WTF::Packed::get const): (WTF::Packed::set): (WTF::Packed::operator=): (WTF::Packed::exchange): (WTF::Packed::swap): (WTF::alignof): (WTF::PackedPtrTraits::exchange): (WTF::PackedPtrTraits::swap): (WTF::PackedPtrTraits::unwrap): * wtf/Platform.h: * wtf/SentinelLinkedList.h: (WTF::BasicRawSentinelNode::BasicRawSentinelNode): (WTF::BasicRawSentinelNode::prev): (WTF::BasicRawSentinelNode::next): (WTF::PtrTraits>::remove): (WTF::PtrTraits>::prepend): (WTF::PtrTraits>::append): (WTF::RawNode>::SentinelLinkedList): (WTF::RawNode>::remove): (WTF::BasicRawSentinelNode<T>::remove): Deleted. (WTF::BasicRawSentinelNode<T>::prepend): Deleted. (WTF::BasicRawSentinelNode<T>::append): Deleted. * wtf/StdLibExtras.h: (WTF::roundUpToMultipleOfImpl): (WTF::roundUpToMultipleOfImpl0): Deleted. * wtf/UnalignedAccess.h: (WTF::unalignedLoad): (WTF::unalignedStore): Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/MathExtras.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Packed.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/211952@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-12 22:50:21 +00:00
} // namespace WTF
using WTF::Packed;
using WTF::PackedAlignedPtr;
using WTF::PackedPtr;