haikuwebkit/Source/WTF/wtf/RawPtrTraits.h

52 lines
2.1 KiB
C
Raw Permalink Normal View History

Enhance Ref and RefPtr to be able to work with smart pointers. https://bugs.webkit.org/show_bug.cgi?id=180762 <rdar://problem/36027122> Reviewed by JF Bastien and Darin Adler. Source/WTF: This is so we can use them with ConstExprPoisoned pointers to make PoisonedRef and PoisonedRefPtr. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: Added. (WTF::DumbPtrTraits::exchange): (WTF::DumbPtrTraits::swap): (WTF::DumbPtrTraits::unwrap): * wtf/Forward.h: * wtf/Poisoned.h: (WTF::ConstExprPoisonedPtrTraits::exchange): (WTF::ConstExprPoisonedPtrTraits::swap): (WTF::ConstExprPoisonedPtrTraits::unwrap): * wtf/Ref.h: (WTF::Ref::~Ref): (WTF::Ref::Ref): (WTF::Ref::ptrAllowingHashTableEmptyValue const): (WTF::Ref::ptrAllowingHashTableEmptyValue): (WTF::Ref::operator-> const): (WTF::Ref::get const): (WTF::Ref::operator T& const): (WTF::=): (WTF::U>::swap): (WTF::swap): (WTF::U>::replace): (WTF::static_reference_cast): (WTF::adoptRef): (WTF::is): (WTF::Ref<T>::swap): Deleted. (WTF::Ref<T>::replace): Deleted. (WTF::GetPtrHelper<Ref<T>>::getPtr): Deleted. * wtf/RefPtr.cpp: Added. * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): (WTF::RefPtr::~RefPtr): (WTF::RefPtr::get const): (WTF::RefPtr::operator* const): (WTF::RefPtr::operator-> const): (WTF::U>::RefPtr): (WTF::U>::leakRef): (WTF::=): (WTF::U>::swap): (WTF::swap): (WTF::operator==): (WTF::operator!=): (WTF::static_pointer_cast): (WTF::adoptRef): (WTF::is): (WTF::RefPtr<T>::RefPtr): Deleted. (WTF::RefPtr<T>::leakRef): Deleted. (WTF::RefPtr<T>::swap): Deleted. Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/ConstExprPoisoned.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Poisoned.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/PoisonedRef.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::passWithRef): (TestWebKitAPI::PoisonedRefCheckingRefLogger::PoisonedRefCheckingRefLogger): (TestWebKitAPI::PoisonedRefCheckingRefLogger::ref): (TestWebKitAPI::PoisonedRefCheckingRefLogger::deref): (TestWebKitAPI::DerivedPoisonedRefCheckingRefLogger::DerivedPoisonedRefCheckingRefLogger): * TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::f1): (TestWebKitAPI::ConstRefCounted::create): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::PoisonedRefPtrCheckingRefLogger): (TestWebKitAPI::loggerName): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::ref): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::deref): Canonical link: https://commits.webkit.org/196809@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226015 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-17 23:22:18 +00:00
/*
PoisonedWriteBarrier https://bugs.webkit.org/show_bug.cgi?id=181599 <rdar://problem/36474351> Reviewed by Mark Lam. Source/JavaScriptCore: Allow poisoning of WriteBarrier objects, and use this for WebAssembly because it is perf-neutral, at least on WasmBench on my MBP. If it indeed is perf-neutral according to the bots, start using it in more performance-sensitive places. * heap/HandleTypes.h: * heap/SlotVisitor.h: * heap/SlotVisitorInlines.h: (JSC::SlotVisitor::append): (JSC::SlotVisitor::appendHidden): * runtime/JSCJSValue.h: * runtime/JSCPoison.h: * runtime/Structure.h: * runtime/StructureInlines.h: (JSC::Structure::setPrototypeWithoutTransition): (JSC::Structure::setGlobalObject): (JSC::Structure::setPreviousID): * runtime/WriteBarrier.h: (JSC::WriteBarrierBase::copyFrom): (JSC::WriteBarrierBase::get const): (JSC::WriteBarrierBase::operator* const): (JSC::WriteBarrierBase::operator-> const): (JSC::WriteBarrierBase::clear): (JSC::WriteBarrierBase::slot): (JSC::WriteBarrierBase::operator bool const): (JSC::WriteBarrierBase::setWithoutWriteBarrier): (JSC::WriteBarrierBase::unvalidatedGet const): (JSC::operator==): * runtime/WriteBarrierInlines.h: (JSC::Traits>::set): (JSC::Traits>::setMayBeNull): (JSC::Traits>::setEarlyValue): (JSC::DumbValueTraits<Unknown>>::set): * wasm/WasmInstance.h: * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::JSWebAssemblyInstance): (JSC::JSWebAssemblyInstance::finishCreation): (JSC::JSWebAssemblyInstance::visitChildren): (JSC::JSWebAssemblyInstance::create): * wasm/js/JSWebAssemblyInstance.h: (JSC::JSWebAssemblyInstance::offsetOfPoisonedCallee): * wasm/js/JSWebAssemblyMemory.h: * wasm/js/JSWebAssemblyModule.h: * wasm/js/JSWebAssemblyTable.cpp: (JSC::JSWebAssemblyTable::JSWebAssemblyTable): (JSC::JSWebAssemblyTable::grow): (JSC::JSWebAssemblyTable::clearFunction): * wasm/js/JSWebAssemblyTable.h: * wasm/js/WasmToJS.cpp: (JSC::Wasm::materializeImportJSCell): (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WebAssemblyFunctionBase.h: * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): (JSC::WebAssemblyModuleRecord::evaluate): * wasm/js/WebAssemblyModuleRecord.h: * wasm/js/WebAssemblyToJSCallee.h: * wasm/js/WebAssemblyWrapperFunction.h: Source/WTF: Supporting changes needed to allow poisoning of WriteBarrier objects. * WTF.xcodeproj/project.pbxproj: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: Copied from Source/WTF/wtf/DumbPtrTraits.h. (WTF::DumbValueTraits::exchange): (WTF::DumbValueTraits::swap): (WTF::DumbValueTraits::unwrap): * wtf/Forward.h: * wtf/Poisoned.h: (WTF::ConstExprPoisonedValueTraits::exchange): (WTF::ConstExprPoisonedValueTraits::swap): (WTF::ConstExprPoisonedValueTraits::unwrap): Canonical link: https://commits.webkit.org/197477@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226920 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-12 23:47:58 +00:00
* Copyright (C) 2017-2018 Apple Inc. All rights reserved.
Enhance Ref and RefPtr to be able to work with smart pointers. https://bugs.webkit.org/show_bug.cgi?id=180762 <rdar://problem/36027122> Reviewed by JF Bastien and Darin Adler. Source/WTF: This is so we can use them with ConstExprPoisoned pointers to make PoisonedRef and PoisonedRefPtr. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: Added. (WTF::DumbPtrTraits::exchange): (WTF::DumbPtrTraits::swap): (WTF::DumbPtrTraits::unwrap): * wtf/Forward.h: * wtf/Poisoned.h: (WTF::ConstExprPoisonedPtrTraits::exchange): (WTF::ConstExprPoisonedPtrTraits::swap): (WTF::ConstExprPoisonedPtrTraits::unwrap): * wtf/Ref.h: (WTF::Ref::~Ref): (WTF::Ref::Ref): (WTF::Ref::ptrAllowingHashTableEmptyValue const): (WTF::Ref::ptrAllowingHashTableEmptyValue): (WTF::Ref::operator-> const): (WTF::Ref::get const): (WTF::Ref::operator T& const): (WTF::=): (WTF::U>::swap): (WTF::swap): (WTF::U>::replace): (WTF::static_reference_cast): (WTF::adoptRef): (WTF::is): (WTF::Ref<T>::swap): Deleted. (WTF::Ref<T>::replace): Deleted. (WTF::GetPtrHelper<Ref<T>>::getPtr): Deleted. * wtf/RefPtr.cpp: Added. * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): (WTF::RefPtr::~RefPtr): (WTF::RefPtr::get const): (WTF::RefPtr::operator* const): (WTF::RefPtr::operator-> const): (WTF::U>::RefPtr): (WTF::U>::leakRef): (WTF::=): (WTF::U>::swap): (WTF::swap): (WTF::operator==): (WTF::operator!=): (WTF::static_pointer_cast): (WTF::adoptRef): (WTF::is): (WTF::RefPtr<T>::RefPtr): Deleted. (WTF::RefPtr<T>::leakRef): Deleted. (WTF::RefPtr<T>::swap): Deleted. Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/ConstExprPoisoned.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Poisoned.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/PoisonedRef.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::passWithRef): (TestWebKitAPI::PoisonedRefCheckingRefLogger::PoisonedRefCheckingRefLogger): (TestWebKitAPI::PoisonedRefCheckingRefLogger::ref): (TestWebKitAPI::PoisonedRefCheckingRefLogger::deref): (TestWebKitAPI::DerivedPoisonedRefCheckingRefLogger::DerivedPoisonedRefCheckingRefLogger): * TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::f1): (TestWebKitAPI::ConstRefCounted::create): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::PoisonedRefPtrCheckingRefLogger): (TestWebKitAPI::loggerName): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::ref): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::deref): Canonical link: https://commits.webkit.org/196809@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226015 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-17 23:22:18 +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
PoisonedWriteBarrier https://bugs.webkit.org/show_bug.cgi?id=181599 <rdar://problem/36474351> Reviewed by Mark Lam. Source/JavaScriptCore: Allow poisoning of WriteBarrier objects, and use this for WebAssembly because it is perf-neutral, at least on WasmBench on my MBP. If it indeed is perf-neutral according to the bots, start using it in more performance-sensitive places. * heap/HandleTypes.h: * heap/SlotVisitor.h: * heap/SlotVisitorInlines.h: (JSC::SlotVisitor::append): (JSC::SlotVisitor::appendHidden): * runtime/JSCJSValue.h: * runtime/JSCPoison.h: * runtime/Structure.h: * runtime/StructureInlines.h: (JSC::Structure::setPrototypeWithoutTransition): (JSC::Structure::setGlobalObject): (JSC::Structure::setPreviousID): * runtime/WriteBarrier.h: (JSC::WriteBarrierBase::copyFrom): (JSC::WriteBarrierBase::get const): (JSC::WriteBarrierBase::operator* const): (JSC::WriteBarrierBase::operator-> const): (JSC::WriteBarrierBase::clear): (JSC::WriteBarrierBase::slot): (JSC::WriteBarrierBase::operator bool const): (JSC::WriteBarrierBase::setWithoutWriteBarrier): (JSC::WriteBarrierBase::unvalidatedGet const): (JSC::operator==): * runtime/WriteBarrierInlines.h: (JSC::Traits>::set): (JSC::Traits>::setMayBeNull): (JSC::Traits>::setEarlyValue): (JSC::DumbValueTraits<Unknown>>::set): * wasm/WasmInstance.h: * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::JSWebAssemblyInstance): (JSC::JSWebAssemblyInstance::finishCreation): (JSC::JSWebAssemblyInstance::visitChildren): (JSC::JSWebAssemblyInstance::create): * wasm/js/JSWebAssemblyInstance.h: (JSC::JSWebAssemblyInstance::offsetOfPoisonedCallee): * wasm/js/JSWebAssemblyMemory.h: * wasm/js/JSWebAssemblyModule.h: * wasm/js/JSWebAssemblyTable.cpp: (JSC::JSWebAssemblyTable::JSWebAssemblyTable): (JSC::JSWebAssemblyTable::grow): (JSC::JSWebAssemblyTable::clearFunction): * wasm/js/JSWebAssemblyTable.h: * wasm/js/WasmToJS.cpp: (JSC::Wasm::materializeImportJSCell): (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WebAssemblyFunctionBase.h: * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): (JSC::WebAssemblyModuleRecord::evaluate): * wasm/js/WebAssemblyModuleRecord.h: * wasm/js/WebAssemblyToJSCallee.h: * wasm/js/WebAssemblyWrapperFunction.h: Source/WTF: Supporting changes needed to allow poisoning of WriteBarrier objects. * WTF.xcodeproj/project.pbxproj: * wtf/DumbPtrTraits.h: * wtf/DumbValueTraits.h: Copied from Source/WTF/wtf/DumbPtrTraits.h. (WTF::DumbValueTraits::exchange): (WTF::DumbValueTraits::swap): (WTF::DumbValueTraits::unwrap): * wtf/Forward.h: * wtf/Poisoned.h: (WTF::ConstExprPoisonedValueTraits::exchange): (WTF::ConstExprPoisonedValueTraits::swap): (WTF::ConstExprPoisonedValueTraits::unwrap): Canonical link: https://commits.webkit.org/197477@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226920 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-12 23:47:58 +00:00
#include <cstdint>
Enhance Ref and RefPtr to be able to work with smart pointers. https://bugs.webkit.org/show_bug.cgi?id=180762 <rdar://problem/36027122> Reviewed by JF Bastien and Darin Adler. Source/WTF: This is so we can use them with ConstExprPoisoned pointers to make PoisonedRef and PoisonedRefPtr. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: Added. (WTF::DumbPtrTraits::exchange): (WTF::DumbPtrTraits::swap): (WTF::DumbPtrTraits::unwrap): * wtf/Forward.h: * wtf/Poisoned.h: (WTF::ConstExprPoisonedPtrTraits::exchange): (WTF::ConstExprPoisonedPtrTraits::swap): (WTF::ConstExprPoisonedPtrTraits::unwrap): * wtf/Ref.h: (WTF::Ref::~Ref): (WTF::Ref::Ref): (WTF::Ref::ptrAllowingHashTableEmptyValue const): (WTF::Ref::ptrAllowingHashTableEmptyValue): (WTF::Ref::operator-> const): (WTF::Ref::get const): (WTF::Ref::operator T& const): (WTF::=): (WTF::U>::swap): (WTF::swap): (WTF::U>::replace): (WTF::static_reference_cast): (WTF::adoptRef): (WTF::is): (WTF::Ref<T>::swap): Deleted. (WTF::Ref<T>::replace): Deleted. (WTF::GetPtrHelper<Ref<T>>::getPtr): Deleted. * wtf/RefPtr.cpp: Added. * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): (WTF::RefPtr::~RefPtr): (WTF::RefPtr::get const): (WTF::RefPtr::operator* const): (WTF::RefPtr::operator-> const): (WTF::U>::RefPtr): (WTF::U>::leakRef): (WTF::=): (WTF::U>::swap): (WTF::swap): (WTF::operator==): (WTF::operator!=): (WTF::static_pointer_cast): (WTF::adoptRef): (WTF::is): (WTF::RefPtr<T>::RefPtr): Deleted. (WTF::RefPtr<T>::leakRef): Deleted. (WTF::RefPtr<T>::swap): Deleted. Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/ConstExprPoisoned.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Poisoned.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/PoisonedRef.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::passWithRef): (TestWebKitAPI::PoisonedRefCheckingRefLogger::PoisonedRefCheckingRefLogger): (TestWebKitAPI::PoisonedRefCheckingRefLogger::ref): (TestWebKitAPI::PoisonedRefCheckingRefLogger::deref): (TestWebKitAPI::DerivedPoisonedRefCheckingRefLogger::DerivedPoisonedRefCheckingRefLogger): * TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::f1): (TestWebKitAPI::ConstRefCounted::create): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::PoisonedRefPtrCheckingRefLogger): (TestWebKitAPI::loggerName): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::ref): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::deref): Canonical link: https://commits.webkit.org/196809@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226015 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-17 23:22:18 +00:00
#include <utility>
namespace WTF {
template<typename T>
Inclusive software: Remove instances of "dumb" from the code https://bugs.webkit.org/show_bug.cgi?id=217778 Reviewed by Simon Fraser. Source/JavaScriptCore: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCallEval): (JSC::FTL::DFG::LowerDFGToB3::unboxBoolean): * heap/SlotVisitor.h: * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitVirtualCall): (JSC::AssemblyHelpers::emitDumbVirtualCall): Deleted. * jit/AssemblyHelpers.h: * jit/JITCall.cpp: (JSC::JIT::compileCallEvalSlowCase): * jit/JITCall32_64.cpp: (JSC::JIT::compileCallEvalSlowCase): * runtime/CachedTypes.cpp: * runtime/JSCJSValue.h: * runtime/WriteBarrier.h: * runtime/WriteBarrierInlines.h: (JSC::RawValueTraits<Unknown>>::set): (JSC::DumbValueTraits<Unknown>>::set): Deleted. * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::addCallIndirect): * wasm/generateWasm.py: (opcodeIterator): Source/WebCore: * Modules/webaudio/AudioNode.h: * dom/GCReachableRef.h: * page/EventHandler.cpp: (WebCore::EventHandler::handleDrag): * rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::addToLine): Source/WTF: * WTF.xcodeproj/project.pbxproj: * icu/unicode/caniter.h: * wtf/Bag.h: * wtf/CMakeLists.txt: * wtf/CagedPtr.h: * wtf/Forward.h: * wtf/NakedRef.h: * wtf/RawPtrTraits.h: Renamed from Source/WTF/wtf/DumbPtrTraits.h. * wtf/RawValueTraits.h: Renamed from Source/WTF/wtf/DumbValueTraits.h. * wtf/Ref.h: * wtf/RefCountedArray.h: * wtf/RefPtr.h: * wtf/SentinelLinkedList.h: Canonical link: https://commits.webkit.org/230896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268993 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-26 20:08:01 +00:00
struct RawPtrTraits {
template<typename U> using RebindTraits = RawPtrTraits<U>;
[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
Enhance Ref and RefPtr to be able to work with smart pointers. https://bugs.webkit.org/show_bug.cgi?id=180762 <rdar://problem/36027122> Reviewed by JF Bastien and Darin Adler. Source/WTF: This is so we can use them with ConstExprPoisoned pointers to make PoisonedRef and PoisonedRefPtr. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: Added. (WTF::DumbPtrTraits::exchange): (WTF::DumbPtrTraits::swap): (WTF::DumbPtrTraits::unwrap): * wtf/Forward.h: * wtf/Poisoned.h: (WTF::ConstExprPoisonedPtrTraits::exchange): (WTF::ConstExprPoisonedPtrTraits::swap): (WTF::ConstExprPoisonedPtrTraits::unwrap): * wtf/Ref.h: (WTF::Ref::~Ref): (WTF::Ref::Ref): (WTF::Ref::ptrAllowingHashTableEmptyValue const): (WTF::Ref::ptrAllowingHashTableEmptyValue): (WTF::Ref::operator-> const): (WTF::Ref::get const): (WTF::Ref::operator T& const): (WTF::=): (WTF::U>::swap): (WTF::swap): (WTF::U>::replace): (WTF::static_reference_cast): (WTF::adoptRef): (WTF::is): (WTF::Ref<T>::swap): Deleted. (WTF::Ref<T>::replace): Deleted. (WTF::GetPtrHelper<Ref<T>>::getPtr): Deleted. * wtf/RefPtr.cpp: Added. * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): (WTF::RefPtr::~RefPtr): (WTF::RefPtr::get const): (WTF::RefPtr::operator* const): (WTF::RefPtr::operator-> const): (WTF::U>::RefPtr): (WTF::U>::leakRef): (WTF::=): (WTF::U>::swap): (WTF::swap): (WTF::operator==): (WTF::operator!=): (WTF::static_pointer_cast): (WTF::adoptRef): (WTF::is): (WTF::RefPtr<T>::RefPtr): Deleted. (WTF::RefPtr<T>::leakRef): Deleted. (WTF::RefPtr<T>::swap): Deleted. Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/ConstExprPoisoned.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Poisoned.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/PoisonedRef.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::passWithRef): (TestWebKitAPI::PoisonedRefCheckingRefLogger::PoisonedRefCheckingRefLogger): (TestWebKitAPI::PoisonedRefCheckingRefLogger::ref): (TestWebKitAPI::PoisonedRefCheckingRefLogger::deref): (TestWebKitAPI::DerivedPoisonedRefCheckingRefLogger::DerivedPoisonedRefCheckingRefLogger): * TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::f1): (TestWebKitAPI::ConstRefCounted::create): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::PoisonedRefPtrCheckingRefLogger): (TestWebKitAPI::loggerName): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::ref): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::deref): Canonical link: https://commits.webkit.org/196809@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226015 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-17 23:22:18 +00:00
using StorageType = T*;
template<typename U>
static ALWAYS_INLINE T* exchange(StorageType& ptr, U&& newValue) { return std::exchange(ptr, newValue); }
static ALWAYS_INLINE void swap(StorageType& a, StorageType& b) { std::swap(a, b); }
static ALWAYS_INLINE T* unwrap(const StorageType& ptr) { return ptr; }
[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 StorageType hashTableDeletedValue() { return bitwise_cast<StorageType>(static_cast<uintptr_t>(-1)); }
static ALWAYS_INLINE bool isHashTableDeletedValue(const StorageType& ptr) { return ptr == hashTableDeletedValue(); }
Enhance Ref and RefPtr to be able to work with smart pointers. https://bugs.webkit.org/show_bug.cgi?id=180762 <rdar://problem/36027122> Reviewed by JF Bastien and Darin Adler. Source/WTF: This is so we can use them with ConstExprPoisoned pointers to make PoisonedRef and PoisonedRefPtr. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/DumbPtrTraits.h: Added. (WTF::DumbPtrTraits::exchange): (WTF::DumbPtrTraits::swap): (WTF::DumbPtrTraits::unwrap): * wtf/Forward.h: * wtf/Poisoned.h: (WTF::ConstExprPoisonedPtrTraits::exchange): (WTF::ConstExprPoisonedPtrTraits::swap): (WTF::ConstExprPoisonedPtrTraits::unwrap): * wtf/Ref.h: (WTF::Ref::~Ref): (WTF::Ref::Ref): (WTF::Ref::ptrAllowingHashTableEmptyValue const): (WTF::Ref::ptrAllowingHashTableEmptyValue): (WTF::Ref::operator-> const): (WTF::Ref::get const): (WTF::Ref::operator T& const): (WTF::=): (WTF::U>::swap): (WTF::swap): (WTF::U>::replace): (WTF::static_reference_cast): (WTF::adoptRef): (WTF::is): (WTF::Ref<T>::swap): Deleted. (WTF::Ref<T>::replace): Deleted. (WTF::GetPtrHelper<Ref<T>>::getPtr): Deleted. * wtf/RefPtr.cpp: Added. * wtf/RefPtr.h: (WTF::RefPtr::RefPtr): (WTF::RefPtr::~RefPtr): (WTF::RefPtr::get const): (WTF::RefPtr::operator* const): (WTF::RefPtr::operator-> const): (WTF::U>::RefPtr): (WTF::U>::leakRef): (WTF::=): (WTF::U>::swap): (WTF::swap): (WTF::operator==): (WTF::operator!=): (WTF::static_pointer_cast): (WTF::adoptRef): (WTF::is): (WTF::RefPtr<T>::RefPtr): Deleted. (WTF::RefPtr<T>::leakRef): Deleted. (WTF::RefPtr<T>::swap): Deleted. Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/ConstExprPoisoned.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Poisoned.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/PoisonedRef.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::passWithRef): (TestWebKitAPI::PoisonedRefCheckingRefLogger::PoisonedRefCheckingRefLogger): (TestWebKitAPI::PoisonedRefCheckingRefLogger::ref): (TestWebKitAPI::PoisonedRefCheckingRefLogger::deref): (TestWebKitAPI::DerivedPoisonedRefCheckingRefLogger::DerivedPoisonedRefCheckingRefLogger): * TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp: Added. (TestWebKitAPI::TEST): (TestWebKitAPI::f1): (TestWebKitAPI::ConstRefCounted::create): (TestWebKitAPI::returnConstRefCountedRef): (TestWebKitAPI::returnRefCountedRef): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::PoisonedRefPtrCheckingRefLogger): (TestWebKitAPI::loggerName): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::ref): (TestWebKitAPI::PoisonedRefPtrCheckingRefLogger::deref): Canonical link: https://commits.webkit.org/196809@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226015 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-17 23:22:18 +00:00
};
} // namespace WTF
Inclusive software: Remove instances of "dumb" from the code https://bugs.webkit.org/show_bug.cgi?id=217778 Reviewed by Simon Fraser. Source/JavaScriptCore: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCallEval): (JSC::FTL::DFG::LowerDFGToB3::unboxBoolean): * heap/SlotVisitor.h: * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitVirtualCall): (JSC::AssemblyHelpers::emitDumbVirtualCall): Deleted. * jit/AssemblyHelpers.h: * jit/JITCall.cpp: (JSC::JIT::compileCallEvalSlowCase): * jit/JITCall32_64.cpp: (JSC::JIT::compileCallEvalSlowCase): * runtime/CachedTypes.cpp: * runtime/JSCJSValue.h: * runtime/WriteBarrier.h: * runtime/WriteBarrierInlines.h: (JSC::RawValueTraits<Unknown>>::set): (JSC::DumbValueTraits<Unknown>>::set): Deleted. * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::addCallIndirect): * wasm/generateWasm.py: (opcodeIterator): Source/WebCore: * Modules/webaudio/AudioNode.h: * dom/GCReachableRef.h: * page/EventHandler.cpp: (WebCore::EventHandler::handleDrag): * rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::addToLine): Source/WTF: * WTF.xcodeproj/project.pbxproj: * icu/unicode/caniter.h: * wtf/Bag.h: * wtf/CMakeLists.txt: * wtf/CagedPtr.h: * wtf/Forward.h: * wtf/NakedRef.h: * wtf/RawPtrTraits.h: Renamed from Source/WTF/wtf/DumbPtrTraits.h. * wtf/RawValueTraits.h: Renamed from Source/WTF/wtf/DumbValueTraits.h. * wtf/Ref.h: * wtf/RefCountedArray.h: * wtf/RefPtr.h: * wtf/SentinelLinkedList.h: Canonical link: https://commits.webkit.org/230896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268993 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-26 20:08:01 +00:00
using WTF::RawPtrTraits;