haikuwebkit/Source/WTF/wtf/MetaAllocatorPtr.h

127 lines
4.4 KiB
C
Raw Permalink Normal View History

Apply PtrTags to the MetaAllocator and friends. https://bugs.webkit.org/show_bug.cgi?id=185110 <rdar://problem/39533895> Reviewed by Saam Barati. Source/JavaScriptCore: 1. LinkBuffer now takes a MacroAssemblerCodePtr instead of a void* pointer. 2. Apply pointer tagging to the boundary pointers of the FixedExecutableMemoryPool, and add a sanity check to verify that allocated code buffers are within those bounds. * assembler/LinkBuffer.cpp: (JSC::LinkBuffer::finalizeCodeWithoutDisassemblyImpl): (JSC::LinkBuffer::copyCompactAndLinkCode): (JSC::LinkBuffer::linkCode): (JSC::LinkBuffer::allocate): * assembler/LinkBuffer.h: (JSC::LinkBuffer::LinkBuffer): (JSC::LinkBuffer::debugAddress): (JSC::LinkBuffer::code): * assembler/MacroAssemblerCodeRef.h: (JSC::MacroAssemblerCodeRef::MacroAssemblerCodeRef): * bytecode/InlineAccess.cpp: (JSC::linkCodeInline): (JSC::InlineAccess::rewireStubAsJump): * dfg/DFGJITCode.cpp: (JSC::DFG::JITCode::findPC): * ftl/FTLJITCode.cpp: (JSC::FTL::JITCode::findPC): * jit/ExecutableAllocator.cpp: (JSC::FixedVMPoolExecutableAllocator::FixedVMPoolExecutableAllocator): (JSC::FixedVMPoolExecutableAllocator::jitWriteThunkGenerator): (JSC::ExecutableAllocator::allocate): * jit/ExecutableAllocator.h: (JSC::isJITPC): (JSC::performJITMemcpy): * jit/JIT.cpp: (JSC::JIT::link): * jit/JITMathIC.h: (JSC::isProfileEmpty): * runtime/JSCPtrTag.h: * wasm/WasmCallee.cpp: (JSC::Wasm::Callee::Callee): * wasm/WasmFaultSignalHandler.cpp: (JSC::Wasm::trapHandler): Source/WTF: 1. Introduce a MetaAllocatorPtr smart pointer to do pointer tagging. 2. Use MetaAllocatorPtr in MetaAllocator and MetaAllocatorHandle. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::release): (WTF::MetaAllocatorHandle::MetaAllocatorHandle): (WTF::MetaAllocatorHandle::shrink): (WTF::MetaAllocatorHandle::dump const): (WTF::MetaAllocator::allocate): (WTF::MetaAllocator::findAndRemoveFreeSpace): (WTF::MetaAllocator::addFreeSpaceFromReleasedHandle): (WTF::MetaAllocator::addFreshFreeSpace): (WTF::MetaAllocator::debugFreeSpaceSize): (WTF::MetaAllocator::addFreeSpace): (WTF::MetaAllocator::allocFreeSpaceNode): * wtf/MetaAllocator.h: (WTF::MetaAllocatorTracker::find): (WTF::MetaAllocator::FreeSpaceNode::FreeSpaceNode): (WTF::MetaAllocator::FreeSpaceNode::sizeInBytes): (WTF::MetaAllocator::FreeSpaceNode::key): * wtf/MetaAllocatorHandle.h: (WTF::MetaAllocatorHandle::start const): (WTF::MetaAllocatorHandle::end const): (WTF::MetaAllocatorHandle::startAsInteger const): (WTF::MetaAllocatorHandle::endAsInteger const): (WTF::MetaAllocatorHandle::sizeInBytes const): (WTF::MetaAllocatorHandle::containsIntegerAddress const): (WTF::MetaAllocatorHandle::key): * wtf/MetaAllocatorPtr.h: Added. (WTF::MetaAllocatorPtr::MetaAllocatorPtr): (WTF::MetaAllocatorPtr:: const): (WTF::MetaAllocatorPtr::operator bool const): (WTF::MetaAllocatorPtr::operator! const): (WTF::MetaAllocatorPtr::operator== const): (WTF::MetaAllocatorPtr::operator!= const): (WTF::MetaAllocatorPtr::operator+ const): (WTF::MetaAllocatorPtr::operator- const): (WTF::MetaAllocatorPtr::operator+=): (WTF::MetaAllocatorPtr::operator-=): (WTF::MetaAllocatorPtr::isEmptyValue const): (WTF::MetaAllocatorPtr::isDeletedValue const): (WTF::MetaAllocatorPtr::hash const): (WTF::MetaAllocatorPtr::emptyValue): (WTF::MetaAllocatorPtr::deletedValue): (WTF::MetaAllocatorPtrHash::hash): (WTF::MetaAllocatorPtrHash::equal): * wtf/PtrTag.h: Tools: Update the test to match MetaAllocator changes in WTF. * TestWebKitAPI/Tests/WTF/MetaAllocator.cpp: (TestWebKitAPI::TEST_F): (WTF::tagForPtr): (WTF::ptrTagName): Canonical link: https://commits.webkit.org/200634@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231175 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-04-30 22:29:21 +00:00
/*
* Copyright (C) 2018-2021 Apple Inc. All rights reserved.
Apply PtrTags to the MetaAllocator and friends. https://bugs.webkit.org/show_bug.cgi?id=185110 <rdar://problem/39533895> Reviewed by Saam Barati. Source/JavaScriptCore: 1. LinkBuffer now takes a MacroAssemblerCodePtr instead of a void* pointer. 2. Apply pointer tagging to the boundary pointers of the FixedExecutableMemoryPool, and add a sanity check to verify that allocated code buffers are within those bounds. * assembler/LinkBuffer.cpp: (JSC::LinkBuffer::finalizeCodeWithoutDisassemblyImpl): (JSC::LinkBuffer::copyCompactAndLinkCode): (JSC::LinkBuffer::linkCode): (JSC::LinkBuffer::allocate): * assembler/LinkBuffer.h: (JSC::LinkBuffer::LinkBuffer): (JSC::LinkBuffer::debugAddress): (JSC::LinkBuffer::code): * assembler/MacroAssemblerCodeRef.h: (JSC::MacroAssemblerCodeRef::MacroAssemblerCodeRef): * bytecode/InlineAccess.cpp: (JSC::linkCodeInline): (JSC::InlineAccess::rewireStubAsJump): * dfg/DFGJITCode.cpp: (JSC::DFG::JITCode::findPC): * ftl/FTLJITCode.cpp: (JSC::FTL::JITCode::findPC): * jit/ExecutableAllocator.cpp: (JSC::FixedVMPoolExecutableAllocator::FixedVMPoolExecutableAllocator): (JSC::FixedVMPoolExecutableAllocator::jitWriteThunkGenerator): (JSC::ExecutableAllocator::allocate): * jit/ExecutableAllocator.h: (JSC::isJITPC): (JSC::performJITMemcpy): * jit/JIT.cpp: (JSC::JIT::link): * jit/JITMathIC.h: (JSC::isProfileEmpty): * runtime/JSCPtrTag.h: * wasm/WasmCallee.cpp: (JSC::Wasm::Callee::Callee): * wasm/WasmFaultSignalHandler.cpp: (JSC::Wasm::trapHandler): Source/WTF: 1. Introduce a MetaAllocatorPtr smart pointer to do pointer tagging. 2. Use MetaAllocatorPtr in MetaAllocator and MetaAllocatorHandle. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::release): (WTF::MetaAllocatorHandle::MetaAllocatorHandle): (WTF::MetaAllocatorHandle::shrink): (WTF::MetaAllocatorHandle::dump const): (WTF::MetaAllocator::allocate): (WTF::MetaAllocator::findAndRemoveFreeSpace): (WTF::MetaAllocator::addFreeSpaceFromReleasedHandle): (WTF::MetaAllocator::addFreshFreeSpace): (WTF::MetaAllocator::debugFreeSpaceSize): (WTF::MetaAllocator::addFreeSpace): (WTF::MetaAllocator::allocFreeSpaceNode): * wtf/MetaAllocator.h: (WTF::MetaAllocatorTracker::find): (WTF::MetaAllocator::FreeSpaceNode::FreeSpaceNode): (WTF::MetaAllocator::FreeSpaceNode::sizeInBytes): (WTF::MetaAllocator::FreeSpaceNode::key): * wtf/MetaAllocatorHandle.h: (WTF::MetaAllocatorHandle::start const): (WTF::MetaAllocatorHandle::end const): (WTF::MetaAllocatorHandle::startAsInteger const): (WTF::MetaAllocatorHandle::endAsInteger const): (WTF::MetaAllocatorHandle::sizeInBytes const): (WTF::MetaAllocatorHandle::containsIntegerAddress const): (WTF::MetaAllocatorHandle::key): * wtf/MetaAllocatorPtr.h: Added. (WTF::MetaAllocatorPtr::MetaAllocatorPtr): (WTF::MetaAllocatorPtr:: const): (WTF::MetaAllocatorPtr::operator bool const): (WTF::MetaAllocatorPtr::operator! const): (WTF::MetaAllocatorPtr::operator== const): (WTF::MetaAllocatorPtr::operator!= const): (WTF::MetaAllocatorPtr::operator+ const): (WTF::MetaAllocatorPtr::operator- const): (WTF::MetaAllocatorPtr::operator+=): (WTF::MetaAllocatorPtr::operator-=): (WTF::MetaAllocatorPtr::isEmptyValue const): (WTF::MetaAllocatorPtr::isDeletedValue const): (WTF::MetaAllocatorPtr::hash const): (WTF::MetaAllocatorPtr::emptyValue): (WTF::MetaAllocatorPtr::deletedValue): (WTF::MetaAllocatorPtrHash::hash): (WTF::MetaAllocatorPtrHash::equal): * wtf/PtrTag.h: Tools: Update the test to match MetaAllocator changes in WTF. * TestWebKitAPI/Tests/WTF/MetaAllocator.cpp: (TestWebKitAPI::TEST_F): (WTF::tagForPtr): (WTF::ptrTagName): Canonical link: https://commits.webkit.org/200634@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231175 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-04-30 22:29:21 +00:00
*
* 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 <wtf/HashTraits.h>
#include <wtf/PtrTag.h>
#include <wtf/StdLibExtras.h>
namespace WTF {
template<PtrTag tag>
class MetaAllocatorPtr {
public:
MetaAllocatorPtr() = default;
MetaAllocatorPtr(std::nullptr_t) { }
static MetaAllocatorPtr makeFromRawPointer(void* ptr) { return MetaAllocatorPtr(ptr); }
template<PtrTag otherTag>
explicit MetaAllocatorPtr(MetaAllocatorPtr<otherTag> other)
: m_ptr(other.template retaggedPtr<tag>())
{ }
Apply PtrTags to the MetaAllocator and friends. https://bugs.webkit.org/show_bug.cgi?id=185110 <rdar://problem/39533895> Reviewed by Saam Barati. Source/JavaScriptCore: 1. LinkBuffer now takes a MacroAssemblerCodePtr instead of a void* pointer. 2. Apply pointer tagging to the boundary pointers of the FixedExecutableMemoryPool, and add a sanity check to verify that allocated code buffers are within those bounds. * assembler/LinkBuffer.cpp: (JSC::LinkBuffer::finalizeCodeWithoutDisassemblyImpl): (JSC::LinkBuffer::copyCompactAndLinkCode): (JSC::LinkBuffer::linkCode): (JSC::LinkBuffer::allocate): * assembler/LinkBuffer.h: (JSC::LinkBuffer::LinkBuffer): (JSC::LinkBuffer::debugAddress): (JSC::LinkBuffer::code): * assembler/MacroAssemblerCodeRef.h: (JSC::MacroAssemblerCodeRef::MacroAssemblerCodeRef): * bytecode/InlineAccess.cpp: (JSC::linkCodeInline): (JSC::InlineAccess::rewireStubAsJump): * dfg/DFGJITCode.cpp: (JSC::DFG::JITCode::findPC): * ftl/FTLJITCode.cpp: (JSC::FTL::JITCode::findPC): * jit/ExecutableAllocator.cpp: (JSC::FixedVMPoolExecutableAllocator::FixedVMPoolExecutableAllocator): (JSC::FixedVMPoolExecutableAllocator::jitWriteThunkGenerator): (JSC::ExecutableAllocator::allocate): * jit/ExecutableAllocator.h: (JSC::isJITPC): (JSC::performJITMemcpy): * jit/JIT.cpp: (JSC::JIT::link): * jit/JITMathIC.h: (JSC::isProfileEmpty): * runtime/JSCPtrTag.h: * wasm/WasmCallee.cpp: (JSC::Wasm::Callee::Callee): * wasm/WasmFaultSignalHandler.cpp: (JSC::Wasm::trapHandler): Source/WTF: 1. Introduce a MetaAllocatorPtr smart pointer to do pointer tagging. 2. Use MetaAllocatorPtr in MetaAllocator and MetaAllocatorHandle. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::release): (WTF::MetaAllocatorHandle::MetaAllocatorHandle): (WTF::MetaAllocatorHandle::shrink): (WTF::MetaAllocatorHandle::dump const): (WTF::MetaAllocator::allocate): (WTF::MetaAllocator::findAndRemoveFreeSpace): (WTF::MetaAllocator::addFreeSpaceFromReleasedHandle): (WTF::MetaAllocator::addFreshFreeSpace): (WTF::MetaAllocator::debugFreeSpaceSize): (WTF::MetaAllocator::addFreeSpace): (WTF::MetaAllocator::allocFreeSpaceNode): * wtf/MetaAllocator.h: (WTF::MetaAllocatorTracker::find): (WTF::MetaAllocator::FreeSpaceNode::FreeSpaceNode): (WTF::MetaAllocator::FreeSpaceNode::sizeInBytes): (WTF::MetaAllocator::FreeSpaceNode::key): * wtf/MetaAllocatorHandle.h: (WTF::MetaAllocatorHandle::start const): (WTF::MetaAllocatorHandle::end const): (WTF::MetaAllocatorHandle::startAsInteger const): (WTF::MetaAllocatorHandle::endAsInteger const): (WTF::MetaAllocatorHandle::sizeInBytes const): (WTF::MetaAllocatorHandle::containsIntegerAddress const): (WTF::MetaAllocatorHandle::key): * wtf/MetaAllocatorPtr.h: Added. (WTF::MetaAllocatorPtr::MetaAllocatorPtr): (WTF::MetaAllocatorPtr:: const): (WTF::MetaAllocatorPtr::operator bool const): (WTF::MetaAllocatorPtr::operator! const): (WTF::MetaAllocatorPtr::operator== const): (WTF::MetaAllocatorPtr::operator!= const): (WTF::MetaAllocatorPtr::operator+ const): (WTF::MetaAllocatorPtr::operator- const): (WTF::MetaAllocatorPtr::operator+=): (WTF::MetaAllocatorPtr::operator-=): (WTF::MetaAllocatorPtr::isEmptyValue const): (WTF::MetaAllocatorPtr::isDeletedValue const): (WTF::MetaAllocatorPtr::hash const): (WTF::MetaAllocatorPtr::emptyValue): (WTF::MetaAllocatorPtr::deletedValue): (WTF::MetaAllocatorPtrHash::hash): (WTF::MetaAllocatorPtrHash::equal): * wtf/PtrTag.h: Tools: Update the test to match MetaAllocator changes in WTF. * TestWebKitAPI/Tests/WTF/MetaAllocator.cpp: (TestWebKitAPI::TEST_F): (WTF::tagForPtr): (WTF::ptrTagName): Canonical link: https://commits.webkit.org/200634@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231175 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-04-30 22:29:21 +00:00
explicit MetaAllocatorPtr(uintptr_t ptrAsInt)
: MetaAllocatorPtr(reinterpret_cast<void*>(ptrAsInt))
{ }
template<typename T = void*>
T untaggedPtr() const { return bitwise_cast<T>(untagCodePtr<tag>(m_ptr)); }
template<PtrTag newTag, typename T = void*>
T retaggedPtr() const { return bitwise_cast<T>(retagCodePtr<tag, newTag>(m_ptr)); }
// Disallow any casting operations (except for booleans).
template<typename T, typename = std::enable_if_t<!std::is_same<T, bool>::value>>
operator T() = delete;
explicit operator bool() const { return !!m_ptr; }
bool operator!() const { return !m_ptr; }
bool operator==(MetaAllocatorPtr other) const { return m_ptr == other.m_ptr; }
bool operator!=(MetaAllocatorPtr other) const { return m_ptr != other.m_ptr; }
MetaAllocatorPtr operator+(size_t sizeInBytes) const { return MetaAllocatorPtr(untaggedPtr<uint8_t*>() + sizeInBytes); }
MetaAllocatorPtr operator-(size_t sizeInBytes) const { return MetaAllocatorPtr(untaggedPtr<uint8_t*>() - sizeInBytes); }
MetaAllocatorPtr& operator+=(size_t sizeInBytes)
{
return *this = *this + sizeInBytes;
}
MetaAllocatorPtr& operator-=(size_t sizeInBytes)
{
return *this = *this - sizeInBytes;
}
enum EmptyValueTag { EmptyValue };
enum DeletedValueTag { DeletedValue };
MetaAllocatorPtr(EmptyValueTag)
: m_ptr(emptyValue())
{ }
MetaAllocatorPtr(DeletedValueTag)
: m_ptr(deletedValue())
{ }
bool isEmptyValue() const { return m_ptr == emptyValue(); }
bool isDeletedValue() const { return m_ptr == deletedValue(); }
unsigned hash() const { return PtrHash<void*>::hash(m_ptr); }
private:
explicit MetaAllocatorPtr(void* ptr)
: m_ptr(tagCodePtr<tag>(ptr))
{
assertIsNotTagged(ptr);
}
Apply PtrTags to the MetaAllocator and friends. https://bugs.webkit.org/show_bug.cgi?id=185110 <rdar://problem/39533895> Reviewed by Saam Barati. Source/JavaScriptCore: 1. LinkBuffer now takes a MacroAssemblerCodePtr instead of a void* pointer. 2. Apply pointer tagging to the boundary pointers of the FixedExecutableMemoryPool, and add a sanity check to verify that allocated code buffers are within those bounds. * assembler/LinkBuffer.cpp: (JSC::LinkBuffer::finalizeCodeWithoutDisassemblyImpl): (JSC::LinkBuffer::copyCompactAndLinkCode): (JSC::LinkBuffer::linkCode): (JSC::LinkBuffer::allocate): * assembler/LinkBuffer.h: (JSC::LinkBuffer::LinkBuffer): (JSC::LinkBuffer::debugAddress): (JSC::LinkBuffer::code): * assembler/MacroAssemblerCodeRef.h: (JSC::MacroAssemblerCodeRef::MacroAssemblerCodeRef): * bytecode/InlineAccess.cpp: (JSC::linkCodeInline): (JSC::InlineAccess::rewireStubAsJump): * dfg/DFGJITCode.cpp: (JSC::DFG::JITCode::findPC): * ftl/FTLJITCode.cpp: (JSC::FTL::JITCode::findPC): * jit/ExecutableAllocator.cpp: (JSC::FixedVMPoolExecutableAllocator::FixedVMPoolExecutableAllocator): (JSC::FixedVMPoolExecutableAllocator::jitWriteThunkGenerator): (JSC::ExecutableAllocator::allocate): * jit/ExecutableAllocator.h: (JSC::isJITPC): (JSC::performJITMemcpy): * jit/JIT.cpp: (JSC::JIT::link): * jit/JITMathIC.h: (JSC::isProfileEmpty): * runtime/JSCPtrTag.h: * wasm/WasmCallee.cpp: (JSC::Wasm::Callee::Callee): * wasm/WasmFaultSignalHandler.cpp: (JSC::Wasm::trapHandler): Source/WTF: 1. Introduce a MetaAllocatorPtr smart pointer to do pointer tagging. 2. Use MetaAllocatorPtr in MetaAllocator and MetaAllocatorHandle. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::release): (WTF::MetaAllocatorHandle::MetaAllocatorHandle): (WTF::MetaAllocatorHandle::shrink): (WTF::MetaAllocatorHandle::dump const): (WTF::MetaAllocator::allocate): (WTF::MetaAllocator::findAndRemoveFreeSpace): (WTF::MetaAllocator::addFreeSpaceFromReleasedHandle): (WTF::MetaAllocator::addFreshFreeSpace): (WTF::MetaAllocator::debugFreeSpaceSize): (WTF::MetaAllocator::addFreeSpace): (WTF::MetaAllocator::allocFreeSpaceNode): * wtf/MetaAllocator.h: (WTF::MetaAllocatorTracker::find): (WTF::MetaAllocator::FreeSpaceNode::FreeSpaceNode): (WTF::MetaAllocator::FreeSpaceNode::sizeInBytes): (WTF::MetaAllocator::FreeSpaceNode::key): * wtf/MetaAllocatorHandle.h: (WTF::MetaAllocatorHandle::start const): (WTF::MetaAllocatorHandle::end const): (WTF::MetaAllocatorHandle::startAsInteger const): (WTF::MetaAllocatorHandle::endAsInteger const): (WTF::MetaAllocatorHandle::sizeInBytes const): (WTF::MetaAllocatorHandle::containsIntegerAddress const): (WTF::MetaAllocatorHandle::key): * wtf/MetaAllocatorPtr.h: Added. (WTF::MetaAllocatorPtr::MetaAllocatorPtr): (WTF::MetaAllocatorPtr:: const): (WTF::MetaAllocatorPtr::operator bool const): (WTF::MetaAllocatorPtr::operator! const): (WTF::MetaAllocatorPtr::operator== const): (WTF::MetaAllocatorPtr::operator!= const): (WTF::MetaAllocatorPtr::operator+ const): (WTF::MetaAllocatorPtr::operator- const): (WTF::MetaAllocatorPtr::operator+=): (WTF::MetaAllocatorPtr::operator-=): (WTF::MetaAllocatorPtr::isEmptyValue const): (WTF::MetaAllocatorPtr::isDeletedValue const): (WTF::MetaAllocatorPtr::hash const): (WTF::MetaAllocatorPtr::emptyValue): (WTF::MetaAllocatorPtr::deletedValue): (WTF::MetaAllocatorPtrHash::hash): (WTF::MetaAllocatorPtrHash::equal): * wtf/PtrTag.h: Tools: Update the test to match MetaAllocator changes in WTF. * TestWebKitAPI/Tests/WTF/MetaAllocator.cpp: (TestWebKitAPI::TEST_F): (WTF::tagForPtr): (WTF::ptrTagName): Canonical link: https://commits.webkit.org/200634@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231175 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-04-30 22:29:21 +00:00
static void* emptyValue() { return reinterpret_cast<void*>(1); }
static void* deletedValue() { return reinterpret_cast<void*>(2); }
void* m_ptr { nullptr };
};
template<PtrTag tag>
struct MetaAllocatorPtrHash {
static unsigned hash(const MetaAllocatorPtr<tag>& ptr) { return ptr.hash(); }
static bool equal(const MetaAllocatorPtr<tag>& a, const MetaAllocatorPtr<tag>& b)
{
return a == b;
}
Use constexpr instead of const in symbol definitions that are obviously constexpr. https://bugs.webkit.org/show_bug.cgi?id=201879 Rubber-stamped by Joseph Pecoraro. Source/bmalloc: * bmalloc/AvailableMemory.cpp: * bmalloc/IsoTLS.h: * bmalloc/Map.h: * bmalloc/Mutex.cpp: (bmalloc::Mutex::lockSlowCase): * bmalloc/PerThread.h: * bmalloc/Vector.h: * bmalloc/Zone.h: Source/JavaScriptCore: const may require external storage (at the compiler's whim) though these currently do not. constexpr makes it clear that the value is a literal constant that can be inlined. In most cases in the code, when we say static const, we actually mean static constexpr. I'm changing the code to reflect this. * API/JSAPIValueWrapper.h: * API/JSCallbackConstructor.h: * API/JSCallbackObject.h: * API/JSContextRef.cpp: * API/JSWrapperMap.mm: * API/tests/CompareAndSwapTest.cpp: * API/tests/TypedArrayCTest.cpp: * API/tests/testapi.mm: (testObjectiveCAPIMain): * KeywordLookupGenerator.py: (Trie.printAsC): * assembler/ARMv7Assembler.h: * assembler/AssemblerBuffer.h: * assembler/AssemblerCommon.h: * assembler/MacroAssembler.h: * assembler/MacroAssemblerARM64.h: * assembler/MacroAssemblerARM64E.h: * assembler/MacroAssemblerARMv7.h: * assembler/MacroAssemblerCodeRef.h: * assembler/MacroAssemblerMIPS.h: * assembler/MacroAssemblerX86.h: * assembler/MacroAssemblerX86Common.h: (JSC::MacroAssemblerX86Common::absDouble): (JSC::MacroAssemblerX86Common::negateDouble): * assembler/MacroAssemblerX86_64.h: * assembler/X86Assembler.h: * b3/B3Bank.h: * b3/B3CheckSpecial.h: * b3/B3DuplicateTails.cpp: * b3/B3EliminateCommonSubexpressions.cpp: * b3/B3FixSSA.cpp: * b3/B3FoldPathConstants.cpp: * b3/B3InferSwitches.cpp: * b3/B3Kind.h: * b3/B3LowerToAir.cpp: * b3/B3NativeTraits.h: * b3/B3ReduceDoubleToFloat.cpp: * b3/B3ReduceLoopStrength.cpp: * b3/B3ReduceStrength.cpp: * b3/B3ValueKey.h: * b3/air/AirAllocateRegistersByGraphColoring.cpp: * b3/air/AirAllocateStackByGraphColoring.cpp: * b3/air/AirArg.h: * b3/air/AirCCallSpecial.h: * b3/air/AirEmitShuffle.cpp: * b3/air/AirFixObviousSpills.cpp: * b3/air/AirFormTable.h: * b3/air/AirLowerAfterRegAlloc.cpp: * b3/air/AirPrintSpecial.h: * b3/air/AirStackAllocation.cpp: * b3/air/AirTmp.h: * b3/testb3_6.cpp: (testInterpreter): * bytecode/AccessCase.cpp: * bytecode/CallLinkStatus.cpp: * bytecode/CallVariant.h: * bytecode/CodeBlock.h: * bytecode/CodeOrigin.h: * bytecode/DFGExitProfile.h: * bytecode/DirectEvalCodeCache.h: * bytecode/ExecutableToCodeBlockEdge.h: * bytecode/GetterSetterAccessCase.cpp: * bytecode/LazyOperandValueProfile.h: * bytecode/ObjectPropertyCondition.h: * bytecode/ObjectPropertyConditionSet.cpp: * bytecode/PolymorphicAccess.cpp: * bytecode/PropertyCondition.h: * bytecode/SpeculatedType.h: * bytecode/StructureStubInfo.cpp: * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::typeProfilerExpressionInfoForBytecodeOffset): * bytecode/UnlinkedCodeBlock.h: * bytecode/UnlinkedEvalCodeBlock.h: * bytecode/UnlinkedFunctionCodeBlock.h: * bytecode/UnlinkedFunctionExecutable.h: * bytecode/UnlinkedModuleProgramCodeBlock.h: * bytecode/UnlinkedProgramCodeBlock.h: * bytecode/ValueProfile.h: * bytecode/VirtualRegister.h: * bytecode/Watchpoint.h: * bytecompiler/BytecodeGenerator.h: * bytecompiler/Label.h: * bytecompiler/NodesCodegen.cpp: (JSC::ThisNode::emitBytecode): * bytecompiler/RegisterID.h: * debugger/Breakpoint.h: * debugger/DebuggerParseData.cpp: * debugger/DebuggerPrimitives.h: * debugger/DebuggerScope.h: * dfg/DFGAbstractHeap.h: * dfg/DFGAbstractValue.h: * dfg/DFGArgumentsEliminationPhase.cpp: * dfg/DFGByteCodeParser.cpp: * dfg/DFGCSEPhase.cpp: * dfg/DFGCommon.h: * dfg/DFGCompilationKey.h: * dfg/DFGDesiredGlobalProperty.h: * dfg/DFGEdgeDominates.h: * dfg/DFGEpoch.h: * dfg/DFGForAllKills.h: (JSC::DFG::forAllKilledNodesAtNodeIndex): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::isLiveInBytecode): * dfg/DFGHeapLocation.h: * dfg/DFGInPlaceAbstractState.cpp: * dfg/DFGIntegerCheckCombiningPhase.cpp: * dfg/DFGIntegerRangeOptimizationPhase.cpp: * dfg/DFGInvalidationPointInjectionPhase.cpp: * dfg/DFGLICMPhase.cpp: * dfg/DFGLazyNode.h: * dfg/DFGMinifiedID.h: * dfg/DFGMovHintRemovalPhase.cpp: * dfg/DFGNodeFlowProjection.h: * dfg/DFGNodeType.h: * dfg/DFGObjectAllocationSinkingPhase.cpp: * dfg/DFGPhantomInsertionPhase.cpp: * dfg/DFGPromotedHeapLocation.h: * dfg/DFGPropertyTypeKey.h: * dfg/DFGPureValue.h: * dfg/DFGPutStackSinkingPhase.cpp: * dfg/DFGRegisterBank.h: * dfg/DFGSSAConversionPhase.cpp: * dfg/DFGSSALoweringPhase.cpp: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileDoubleRep): (JSC::DFG::compileClampDoubleToByte): (JSC::DFG::SpeculativeJIT::compileArithRounding): (JSC::DFG::compileArithPowIntegerFastPath): (JSC::DFG::SpeculativeJIT::compileArithPow): (JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse): * dfg/DFGStackLayoutPhase.cpp: * dfg/DFGStoreBarrierInsertionPhase.cpp: * dfg/DFGStrengthReductionPhase.cpp: * dfg/DFGStructureAbstractValue.h: * dfg/DFGVarargsForwardingPhase.cpp: * dfg/DFGVariableEventStream.cpp: (JSC::DFG::VariableEventStream::reconstruct const): * dfg/DFGWatchpointCollectionPhase.cpp: * disassembler/ARM64/A64DOpcode.h: * ftl/FTLLocation.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileArithRandom): * ftl/FTLSlowPathCall.cpp: * ftl/FTLSlowPathCallKey.h: * heap/CellContainer.h: * heap/CellState.h: * heap/ConservativeRoots.h: * heap/GCSegmentedArray.h: * heap/HandleBlock.h: * heap/Heap.cpp: (JSC::Heap::updateAllocationLimits): * heap/Heap.h: * heap/HeapSnapshot.h: * heap/HeapUtil.h: (JSC::HeapUtil::findGCObjectPointersForMarking): * heap/IncrementalSweeper.cpp: * heap/LargeAllocation.h: * heap/MarkedBlock.cpp: * heap/Strong.h: * heap/VisitRaceKey.h: * heap/Weak.h: * heap/WeakBlock.h: * inspector/JSInjectedScriptHost.h: * inspector/JSInjectedScriptHostPrototype.h: * inspector/JSJavaScriptCallFrame.h: * inspector/JSJavaScriptCallFramePrototype.h: * inspector/agents/InspectorConsoleAgent.cpp: * inspector/agents/InspectorRuntimeAgent.cpp: (Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets): * inspector/scripts/codegen/generate_cpp_protocol_types_header.py: (CppProtocolTypesHeaderGenerator._generate_versions): * inspector/scripts/tests/generic/expected/version.json-result: * interpreter/Interpreter.h: * interpreter/ShadowChicken.cpp: * jit/BinarySwitch.cpp: * jit/CallFrameShuffler.h: * jit/ExecutableAllocator.h: * jit/FPRInfo.h: * jit/GPRInfo.h: * jit/ICStats.h: * jit/JITThunks.h: * jit/Reg.h: * jit/RegisterSet.h: * jit/TempRegisterSet.h: * jsc.cpp: * parser/ASTBuilder.h: * parser/Nodes.h: * parser/SourceCodeKey.h: * parser/SyntaxChecker.h: * parser/VariableEnvironment.h: * profiler/ProfilerOrigin.h: * profiler/ProfilerOriginStack.h: * profiler/ProfilerUID.h: * runtime/AbstractModuleRecord.cpp: * runtime/ArrayBufferNeuteringWatchpointSet.h: * runtime/ArrayConstructor.h: * runtime/ArrayConventions.h: * runtime/ArrayIteratorPrototype.h: * runtime/ArrayPrototype.cpp: (JSC::setLength): * runtime/AsyncFromSyncIteratorPrototype.h: * runtime/AsyncGeneratorFunctionPrototype.h: * runtime/AsyncGeneratorPrototype.h: * runtime/AsyncIteratorPrototype.h: * runtime/AtomicsObject.cpp: * runtime/BigIntConstructor.h: * runtime/BigIntPrototype.h: * runtime/BooleanPrototype.h: * runtime/ClonedArguments.h: * runtime/CodeCache.h: * runtime/ControlFlowProfiler.h: * runtime/CustomGetterSetter.h: * runtime/DateConstructor.h: * runtime/DatePrototype.h: * runtime/DefinePropertyAttributes.h: * runtime/ErrorPrototype.h: * runtime/EvalExecutable.h: * runtime/Exception.h: * runtime/ExceptionHelpers.cpp: (JSC::invalidParameterInSourceAppender): (JSC::invalidParameterInstanceofSourceAppender): * runtime/ExceptionHelpers.h: * runtime/ExecutableBase.h: * runtime/FunctionExecutable.h: * runtime/FunctionRareData.h: * runtime/GeneratorPrototype.h: * runtime/GenericArguments.h: * runtime/GenericOffset.h: * runtime/GetPutInfo.h: * runtime/GetterSetter.h: * runtime/GlobalExecutable.h: * runtime/Identifier.h: * runtime/InspectorInstrumentationObject.h: * runtime/InternalFunction.h: * runtime/IntlCollatorConstructor.h: * runtime/IntlCollatorPrototype.h: * runtime/IntlDateTimeFormatConstructor.h: * runtime/IntlDateTimeFormatPrototype.h: * runtime/IntlNumberFormatConstructor.h: * runtime/IntlNumberFormatPrototype.h: * runtime/IntlObject.h: * runtime/IntlPluralRulesConstructor.h: * runtime/IntlPluralRulesPrototype.h: * runtime/IteratorPrototype.h: * runtime/JSArray.cpp: (JSC::JSArray::tryCreateUninitializedRestricted): * runtime/JSArray.h: * runtime/JSArrayBuffer.h: * runtime/JSArrayBufferView.h: * runtime/JSBigInt.h: * runtime/JSCJSValue.h: * runtime/JSCell.h: * runtime/JSCustomGetterSetterFunction.h: * runtime/JSDataView.h: * runtime/JSDataViewPrototype.h: * runtime/JSDestructibleObject.h: * runtime/JSFixedArray.h: * runtime/JSGenericTypedArrayView.h: * runtime/JSGlobalLexicalEnvironment.h: * runtime/JSGlobalObject.h: * runtime/JSImmutableButterfly.h: * runtime/JSInternalPromiseConstructor.h: * runtime/JSInternalPromiseDeferred.h: * runtime/JSInternalPromisePrototype.h: * runtime/JSLexicalEnvironment.h: * runtime/JSModuleEnvironment.h: * runtime/JSModuleLoader.h: * runtime/JSModuleNamespaceObject.h: * runtime/JSNonDestructibleProxy.h: * runtime/JSONObject.cpp: * runtime/JSONObject.h: * runtime/JSObject.h: * runtime/JSPromiseConstructor.h: * runtime/JSPromiseDeferred.h: * runtime/JSPromisePrototype.h: * runtime/JSPropertyNameEnumerator.h: * runtime/JSProxy.h: * runtime/JSScope.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/JSSegmentedVariableObject.h: * runtime/JSSourceCode.h: * runtime/JSString.cpp: * runtime/JSString.h: * runtime/JSSymbolTableObject.h: * runtime/JSTemplateObjectDescriptor.h: * runtime/JSTypeInfo.h: * runtime/MapPrototype.h: * runtime/MinimumReservedZoneSize.h: * runtime/ModuleProgramExecutable.h: * runtime/NativeExecutable.h: * runtime/NativeFunction.h: * runtime/NativeStdFunctionCell.h: * runtime/NumberConstructor.h: * runtime/NumberPrototype.h: * runtime/ObjectConstructor.h: * runtime/ObjectPrototype.h: * runtime/ProgramExecutable.h: * runtime/PromiseDeferredTimer.cpp: * runtime/PropertyMapHashTable.h: * runtime/PropertyNameArray.h: (JSC::PropertyNameArray::add): * runtime/PrototypeKey.h: * runtime/ProxyConstructor.h: * runtime/ProxyObject.cpp: (JSC::ProxyObject::performGetOwnPropertyNames): * runtime/ProxyRevoke.h: * runtime/ReflectObject.h: * runtime/RegExp.h: * runtime/RegExpCache.h: * runtime/RegExpConstructor.h: * runtime/RegExpKey.h: * runtime/RegExpObject.h: * runtime/RegExpPrototype.h: * runtime/RegExpStringIteratorPrototype.h: * runtime/SamplingProfiler.cpp: * runtime/ScopedArgumentsTable.h: * runtime/ScriptExecutable.h: * runtime/SetPrototype.h: * runtime/SmallStrings.h: * runtime/SparseArrayValueMap.h: * runtime/StringConstructor.h: * runtime/StringIteratorPrototype.h: * runtime/StringObject.h: * runtime/StringPrototype.h: * runtime/Structure.h: * runtime/StructureChain.h: * runtime/StructureRareData.h: * runtime/StructureTransitionTable.h: * runtime/Symbol.h: * runtime/SymbolConstructor.h: * runtime/SymbolPrototype.h: * runtime/SymbolTable.h: * runtime/TemplateObjectDescriptor.h: * runtime/TypeProfiler.cpp: * runtime/TypeProfiler.h: * runtime/TypeProfilerLog.cpp: * runtime/VarOffset.h: * testRegExp.cpp: * tools/HeapVerifier.cpp: (JSC::HeapVerifier::checkIfRecorded): * tools/JSDollarVM.cpp: * wasm/WasmB3IRGenerator.cpp: * wasm/WasmBBQPlan.cpp: * wasm/WasmFaultSignalHandler.cpp: * wasm/WasmFunctionParser.h: * wasm/WasmOMGForOSREntryPlan.cpp: * wasm/WasmOMGPlan.cpp: * wasm/WasmPlan.cpp: * wasm/WasmSignature.cpp: * wasm/WasmSignature.h: * wasm/WasmWorklist.cpp: * wasm/js/JSWebAssembly.h: * wasm/js/JSWebAssemblyCodeBlock.h: * wasm/js/WebAssemblyCompileErrorConstructor.h: * wasm/js/WebAssemblyCompileErrorPrototype.h: * wasm/js/WebAssemblyFunction.h: * wasm/js/WebAssemblyInstanceConstructor.h: * wasm/js/WebAssemblyInstancePrototype.h: * wasm/js/WebAssemblyLinkErrorConstructor.h: * wasm/js/WebAssemblyLinkErrorPrototype.h: * wasm/js/WebAssemblyMemoryConstructor.h: * wasm/js/WebAssemblyMemoryPrototype.h: * wasm/js/WebAssemblyModuleConstructor.h: * wasm/js/WebAssemblyModulePrototype.h: * wasm/js/WebAssemblyRuntimeErrorConstructor.h: * wasm/js/WebAssemblyRuntimeErrorPrototype.h: * wasm/js/WebAssemblyTableConstructor.h: * wasm/js/WebAssemblyTablePrototype.h: * wasm/js/WebAssemblyToJSCallee.h: * yarr/Yarr.h: * yarr/YarrParser.h: * yarr/generateYarrCanonicalizeUnicode: Source/WebCore: No new tests. Covered by existing tests. * bindings/js/JSDOMConstructorBase.h: * bindings/js/JSDOMWindowProperties.h: * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): (GeneratePrototypeDeclaration): * bindings/scripts/test/JS/JSTestActiveDOMObject.h: * bindings/scripts/test/JS/JSTestEnabledBySetting.h: * bindings/scripts/test/JS/JSTestEnabledForContext.h: * bindings/scripts/test/JS/JSTestEventTarget.h: * bindings/scripts/test/JS/JSTestGlobalObject.h: * bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.h: * bindings/scripts/test/JS/JSTestNamedGetterCallWith.h: * bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.h: * bindings/scripts/test/JS/JSTestNamedSetterWithOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestNamedSetterWithUnforgableProperties.h: * bindings/scripts/test/JS/JSTestNamedSetterWithUnforgablePropertiesAndOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestObj.h: * bindings/scripts/test/JS/JSTestOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestPluginInterface.h: * bindings/scripts/test/JS/JSTestTypedefs.h: * bridge/objc/objc_runtime.h: * bridge/runtime_array.h: * bridge/runtime_method.h: * bridge/runtime_object.h: Source/WebKit: * WebProcess/Plugins/Netscape/JSNPObject.h: Source/WTF: * wtf/Assertions.cpp: * wtf/AutomaticThread.cpp: * wtf/BitVector.h: * wtf/Bitmap.h: * wtf/BloomFilter.h: * wtf/Brigand.h: * wtf/CheckedArithmetic.h: * wtf/CrossThreadCopier.h: * wtf/CurrentTime.cpp: * wtf/DataLog.cpp: * wtf/DateMath.cpp: (WTF::daysFrom1970ToYear): * wtf/DeferrableRefCounted.h: * wtf/GetPtr.h: * wtf/HashFunctions.h: * wtf/HashMap.h: * wtf/HashTable.h: * wtf/HashTraits.h: * wtf/JSONValues.cpp: * wtf/JSONValues.h: * wtf/ListHashSet.h: * wtf/Lock.h: * wtf/LockAlgorithm.h: * wtf/LockAlgorithmInlines.h: (WTF::Hooks>::lockSlow): * wtf/Logger.h: * wtf/LoggerHelper.h: (WTF::LoggerHelper::childLogIdentifier const): * wtf/MainThread.cpp: * wtf/MetaAllocatorPtr.h: * wtf/MonotonicTime.h: * wtf/NaturalLoops.h: (WTF::NaturalLoops::NaturalLoops): * wtf/ObjectIdentifier.h: * wtf/RAMSize.cpp: * wtf/Ref.h: * wtf/RefPtr.h: * wtf/RetainPtr.h: * wtf/SchedulePair.h: * wtf/StackShot.h: * wtf/StdLibExtras.h: * wtf/TinyPtrSet.h: * wtf/URL.cpp: * wtf/URLHash.h: * wtf/URLParser.cpp: (WTF::URLParser::defaultPortForProtocol): * wtf/Vector.h: * wtf/VectorTraits.h: * wtf/WallTime.h: * wtf/WeakHashSet.h: * wtf/WordLock.h: * wtf/cocoa/CPUTimeCocoa.cpp: * wtf/cocoa/MemoryPressureHandlerCocoa.mm: * wtf/persistence/PersistentDecoder.h: * wtf/persistence/PersistentEncoder.h: * wtf/text/AtomStringHash.h: * wtf/text/CString.h: * wtf/text/StringBuilder.cpp: (WTF::expandedCapacity): * wtf/text/StringHash.h: * wtf/text/StringImpl.h: * wtf/text/StringToIntegerConversion.h: (WTF::toIntegralType): * wtf/text/SymbolRegistry.h: * wtf/text/TextStream.cpp: (WTF::hasFractions): * wtf/text/WTFString.h: * wtf/text/cocoa/TextBreakIteratorInternalICUCocoa.cpp: Canonical link: https://commits.webkit.org/215538@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250005 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-09-18 00:36:19 +00:00
static constexpr bool safeToCompareToEmptyOrDeleted = true;
Apply PtrTags to the MetaAllocator and friends. https://bugs.webkit.org/show_bug.cgi?id=185110 <rdar://problem/39533895> Reviewed by Saam Barati. Source/JavaScriptCore: 1. LinkBuffer now takes a MacroAssemblerCodePtr instead of a void* pointer. 2. Apply pointer tagging to the boundary pointers of the FixedExecutableMemoryPool, and add a sanity check to verify that allocated code buffers are within those bounds. * assembler/LinkBuffer.cpp: (JSC::LinkBuffer::finalizeCodeWithoutDisassemblyImpl): (JSC::LinkBuffer::copyCompactAndLinkCode): (JSC::LinkBuffer::linkCode): (JSC::LinkBuffer::allocate): * assembler/LinkBuffer.h: (JSC::LinkBuffer::LinkBuffer): (JSC::LinkBuffer::debugAddress): (JSC::LinkBuffer::code): * assembler/MacroAssemblerCodeRef.h: (JSC::MacroAssemblerCodeRef::MacroAssemblerCodeRef): * bytecode/InlineAccess.cpp: (JSC::linkCodeInline): (JSC::InlineAccess::rewireStubAsJump): * dfg/DFGJITCode.cpp: (JSC::DFG::JITCode::findPC): * ftl/FTLJITCode.cpp: (JSC::FTL::JITCode::findPC): * jit/ExecutableAllocator.cpp: (JSC::FixedVMPoolExecutableAllocator::FixedVMPoolExecutableAllocator): (JSC::FixedVMPoolExecutableAllocator::jitWriteThunkGenerator): (JSC::ExecutableAllocator::allocate): * jit/ExecutableAllocator.h: (JSC::isJITPC): (JSC::performJITMemcpy): * jit/JIT.cpp: (JSC::JIT::link): * jit/JITMathIC.h: (JSC::isProfileEmpty): * runtime/JSCPtrTag.h: * wasm/WasmCallee.cpp: (JSC::Wasm::Callee::Callee): * wasm/WasmFaultSignalHandler.cpp: (JSC::Wasm::trapHandler): Source/WTF: 1. Introduce a MetaAllocatorPtr smart pointer to do pointer tagging. 2. Use MetaAllocatorPtr in MetaAllocator and MetaAllocatorHandle. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::release): (WTF::MetaAllocatorHandle::MetaAllocatorHandle): (WTF::MetaAllocatorHandle::shrink): (WTF::MetaAllocatorHandle::dump const): (WTF::MetaAllocator::allocate): (WTF::MetaAllocator::findAndRemoveFreeSpace): (WTF::MetaAllocator::addFreeSpaceFromReleasedHandle): (WTF::MetaAllocator::addFreshFreeSpace): (WTF::MetaAllocator::debugFreeSpaceSize): (WTF::MetaAllocator::addFreeSpace): (WTF::MetaAllocator::allocFreeSpaceNode): * wtf/MetaAllocator.h: (WTF::MetaAllocatorTracker::find): (WTF::MetaAllocator::FreeSpaceNode::FreeSpaceNode): (WTF::MetaAllocator::FreeSpaceNode::sizeInBytes): (WTF::MetaAllocator::FreeSpaceNode::key): * wtf/MetaAllocatorHandle.h: (WTF::MetaAllocatorHandle::start const): (WTF::MetaAllocatorHandle::end const): (WTF::MetaAllocatorHandle::startAsInteger const): (WTF::MetaAllocatorHandle::endAsInteger const): (WTF::MetaAllocatorHandle::sizeInBytes const): (WTF::MetaAllocatorHandle::containsIntegerAddress const): (WTF::MetaAllocatorHandle::key): * wtf/MetaAllocatorPtr.h: Added. (WTF::MetaAllocatorPtr::MetaAllocatorPtr): (WTF::MetaAllocatorPtr:: const): (WTF::MetaAllocatorPtr::operator bool const): (WTF::MetaAllocatorPtr::operator! const): (WTF::MetaAllocatorPtr::operator== const): (WTF::MetaAllocatorPtr::operator!= const): (WTF::MetaAllocatorPtr::operator+ const): (WTF::MetaAllocatorPtr::operator- const): (WTF::MetaAllocatorPtr::operator+=): (WTF::MetaAllocatorPtr::operator-=): (WTF::MetaAllocatorPtr::isEmptyValue const): (WTF::MetaAllocatorPtr::isDeletedValue const): (WTF::MetaAllocatorPtr::hash const): (WTF::MetaAllocatorPtr::emptyValue): (WTF::MetaAllocatorPtr::deletedValue): (WTF::MetaAllocatorPtrHash::hash): (WTF::MetaAllocatorPtrHash::equal): * wtf/PtrTag.h: Tools: Update the test to match MetaAllocator changes in WTF. * TestWebKitAPI/Tests/WTF/MetaAllocator.cpp: (TestWebKitAPI::TEST_F): (WTF::tagForPtr): (WTF::ptrTagName): Canonical link: https://commits.webkit.org/200634@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231175 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-04-30 22:29: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> struct DefaultHash;
template<PtrTag tag> struct DefaultHash<MetaAllocatorPtr<tag>> : MetaAllocatorPtrHash<tag> { };
Apply PtrTags to the MetaAllocator and friends. https://bugs.webkit.org/show_bug.cgi?id=185110 <rdar://problem/39533895> Reviewed by Saam Barati. Source/JavaScriptCore: 1. LinkBuffer now takes a MacroAssemblerCodePtr instead of a void* pointer. 2. Apply pointer tagging to the boundary pointers of the FixedExecutableMemoryPool, and add a sanity check to verify that allocated code buffers are within those bounds. * assembler/LinkBuffer.cpp: (JSC::LinkBuffer::finalizeCodeWithoutDisassemblyImpl): (JSC::LinkBuffer::copyCompactAndLinkCode): (JSC::LinkBuffer::linkCode): (JSC::LinkBuffer::allocate): * assembler/LinkBuffer.h: (JSC::LinkBuffer::LinkBuffer): (JSC::LinkBuffer::debugAddress): (JSC::LinkBuffer::code): * assembler/MacroAssemblerCodeRef.h: (JSC::MacroAssemblerCodeRef::MacroAssemblerCodeRef): * bytecode/InlineAccess.cpp: (JSC::linkCodeInline): (JSC::InlineAccess::rewireStubAsJump): * dfg/DFGJITCode.cpp: (JSC::DFG::JITCode::findPC): * ftl/FTLJITCode.cpp: (JSC::FTL::JITCode::findPC): * jit/ExecutableAllocator.cpp: (JSC::FixedVMPoolExecutableAllocator::FixedVMPoolExecutableAllocator): (JSC::FixedVMPoolExecutableAllocator::jitWriteThunkGenerator): (JSC::ExecutableAllocator::allocate): * jit/ExecutableAllocator.h: (JSC::isJITPC): (JSC::performJITMemcpy): * jit/JIT.cpp: (JSC::JIT::link): * jit/JITMathIC.h: (JSC::isProfileEmpty): * runtime/JSCPtrTag.h: * wasm/WasmCallee.cpp: (JSC::Wasm::Callee::Callee): * wasm/WasmFaultSignalHandler.cpp: (JSC::Wasm::trapHandler): Source/WTF: 1. Introduce a MetaAllocatorPtr smart pointer to do pointer tagging. 2. Use MetaAllocatorPtr in MetaAllocator and MetaAllocatorHandle. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::release): (WTF::MetaAllocatorHandle::MetaAllocatorHandle): (WTF::MetaAllocatorHandle::shrink): (WTF::MetaAllocatorHandle::dump const): (WTF::MetaAllocator::allocate): (WTF::MetaAllocator::findAndRemoveFreeSpace): (WTF::MetaAllocator::addFreeSpaceFromReleasedHandle): (WTF::MetaAllocator::addFreshFreeSpace): (WTF::MetaAllocator::debugFreeSpaceSize): (WTF::MetaAllocator::addFreeSpace): (WTF::MetaAllocator::allocFreeSpaceNode): * wtf/MetaAllocator.h: (WTF::MetaAllocatorTracker::find): (WTF::MetaAllocator::FreeSpaceNode::FreeSpaceNode): (WTF::MetaAllocator::FreeSpaceNode::sizeInBytes): (WTF::MetaAllocator::FreeSpaceNode::key): * wtf/MetaAllocatorHandle.h: (WTF::MetaAllocatorHandle::start const): (WTF::MetaAllocatorHandle::end const): (WTF::MetaAllocatorHandle::startAsInteger const): (WTF::MetaAllocatorHandle::endAsInteger const): (WTF::MetaAllocatorHandle::sizeInBytes const): (WTF::MetaAllocatorHandle::containsIntegerAddress const): (WTF::MetaAllocatorHandle::key): * wtf/MetaAllocatorPtr.h: Added. (WTF::MetaAllocatorPtr::MetaAllocatorPtr): (WTF::MetaAllocatorPtr:: const): (WTF::MetaAllocatorPtr::operator bool const): (WTF::MetaAllocatorPtr::operator! const): (WTF::MetaAllocatorPtr::operator== const): (WTF::MetaAllocatorPtr::operator!= const): (WTF::MetaAllocatorPtr::operator+ const): (WTF::MetaAllocatorPtr::operator- const): (WTF::MetaAllocatorPtr::operator+=): (WTF::MetaAllocatorPtr::operator-=): (WTF::MetaAllocatorPtr::isEmptyValue const): (WTF::MetaAllocatorPtr::isDeletedValue const): (WTF::MetaAllocatorPtr::hash const): (WTF::MetaAllocatorPtr::emptyValue): (WTF::MetaAllocatorPtr::deletedValue): (WTF::MetaAllocatorPtrHash::hash): (WTF::MetaAllocatorPtrHash::equal): * wtf/PtrTag.h: Tools: Update the test to match MetaAllocator changes in WTF. * TestWebKitAPI/Tests/WTF/MetaAllocator.cpp: (TestWebKitAPI::TEST_F): (WTF::tagForPtr): (WTF::ptrTagName): Canonical link: https://commits.webkit.org/200634@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231175 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-04-30 22:29:21 +00:00
template<PtrTag tag> struct HashTraits<MetaAllocatorPtr<tag>> : public CustomHashTraits<MetaAllocatorPtr<tag>> { };
} // namespace WTF
using WTF::MetaAllocatorPtr;