2013-01-15 21:35:08 +00:00
|
|
|
/*
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
* Copyright (C) 2013 Google, Inc. All rights reserved.
|
|
|
|
* Copyright (C) 2015-2020 Apple Inc. All rights reserved.
|
2013-01-15 21:35:08 +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.
|
|
|
|
*/
|
|
|
|
|
2018-10-15 14:24:49 +00:00
|
|
|
#pragma once
|
2013-01-15 21:35:08 +00:00
|
|
|
|
2021-06-30 22:51:21 +00:00
|
|
|
#include <wtf/HashTraits.h>
|
2013-01-15 21:35:08 +00:00
|
|
|
#include <wtf/Threading.h>
|
|
|
|
|
|
|
|
namespace WTF {
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename, typename> class WeakHashSet;
|
|
|
|
template<typename, typename> class WeakPtrFactory;
|
WeakPtr breaks vtables when upcasting to base classes
https://bugs.webkit.org/show_bug.cgi?id=188799
Reviewed by Youenn Fablet.
Source/WebCore:
* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::MediaKeySession):
* Modules/encryptedmedia/MediaKeySession.h: Adopted modern WeakPtr APIs.
Removed redundant WeakPtrFactory.
* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::existingWrapper):
* css/CSSFontFace.h: Moved functions out of line to avoid #include
explosion for .get().
* dom/ContainerNode.h:
* dom/Document.h:
* dom/Element.h: Moved CanMakeWeakPtr to ContainerNode because all
subclasses except for DocumentFragment were already so, and we have
code that uses WeakPtr<ContainerNode>, which, now that WeakPtr is
type-safe, is awkward to do when ContainerNode isn't CanMakeWeakPtr.
* dom/FullscreenManager.cpp:
(WebCore::FullscreenManager::fullscreenRenderer const):
* dom/FullscreenManager.h:
(WebCore::FullscreenManager::fullscreenRenderer const): Deleted.
* html/FormAssociatedElement.cpp:
(WebCore::FormAssociatedElement::form const):
* html/FormAssociatedElement.h:
(WebCore::FormAssociatedElement::form const): Deleted. Moved functions
out of line to avoid #include explosion for .get().
* html/HTMLMediaElement.h: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
* loader/MediaResourceLoader.cpp:
(WebCore::MediaResourceLoader::requestResource): Removed redundant .get().
* page/DOMWindowProperty.cpp:
(WebCore::DOMWindowProperty::window const):
* page/DOMWindowProperty.h:
(WebCore::DOMWindowProperty::window const): Deleted.
* page/FrameViewLayoutContext.cpp:
(WebCore::FrameViewLayoutContext::subtreeLayoutRoot const):
* page/FrameViewLayoutContext.h:
(WebCore::FrameViewLayoutContext::subtreeLayoutRoot const): Deleted.
* page/UndoItem.cpp:
(WebCore::UndoItem::undoManager const):
* page/UndoItem.h:
(WebCore::UndoItem::undoManager const): Deleted. Moved functions out of
line to avoid #include explosion for .get().
* platform/ScrollView.h: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
* platform/Widget.cpp:
(WebCore::Widget::parent const):
* platform/Widget.h:
(WebCore::Widget::parent const): Deleted. Moved functions out of line to avoid #include
explosion for .get().
* platform/encryptedmedia/CDMInstanceSession.h: Made
CDMInstanceSessionClient CanMakeWeakPtr because we use WeakPtr<CDMInstanceSessionClient>.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
CanMakeWeakPtr is inherited now.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
(WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const): Deleted.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createWeakPtr): Deleted.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::CMTimebaseEffectiveRateChangedCallback):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::durationChanged):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled):
(WebCore::SourceBufferPrivateAVFObjC::setCDMSession):
(WebCore::SourceBufferPrivateAVFObjC::flushVideo):
(WebCore::SourceBufferPrivateAVFObjC::enqueueSample):
(WebCore::SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples):
(WebCore::SourceBufferPrivateAVFObjC::setVideoLayer):
(WebCore::SourceBufferPrivateAVFObjC::setDecompressionSession): Modernized WeakPtr API usage.
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::multiColumnFlowSlowCase const):
* rendering/RenderBlockFlow.h:
(WebCore::RenderBlockFlow::multiColumnFlow const):
* rendering/RenderMultiColumnFlow.cpp:
(WebCore::RenderMultiColumnFlow::findColumnSpannerPlaceholder const):
* rendering/RenderMultiColumnFlow.h:
* rendering/RenderTable.cpp:
(WebCore::RenderTable::header const):
(WebCore::RenderTable::footer const):
(WebCore::RenderTable::firstBody const):
(WebCore::RenderTable::topSection const):
* rendering/RenderTable.h:
(WebCore::RenderTable::header const): Deleted.
(WebCore::RenderTable::footer const): Deleted.
(WebCore::RenderTable::firstBody const): Deleted.
(WebCore::RenderTable::topSection const): Deleted. Moved functions out
of line to avoid #include explosion for .get().
Source/WebKit:
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::networkSession):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* Shared/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::suspendedPage const):
* Shared/WebBackForwardListItem.h:
(WebKit::WebBackForwardListItem::suspendedPage const): Deleted. Moved
functions out of line to avoid #include explosion for .get().
* UIProcess/Authentication/cocoa/SecKeyProxyStore.h:
(WebKit::SecKeyProxyStore::get const):
(WebKit::SecKeyProxyStore::weakPtrFactory const): Deleted. Adopted
CanMakeWeakPtr.
* UIProcess/WebAuthentication/AuthenticatorManager.h:
* UIProcess/WebProcessProxy.cpp: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
(WebKit::WebProcessProxy::processPool const):
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::processPool const): Deleted. Moved
functions out of line to avoid #include explosion for .get().
Source/WTF:
This patch switches from reinterpret_cast to static_cast when loading
from WeakReference storage.
We know which type to cast *to* because it's specified by the type of
the calling WeakPtr.
We know which type to cast *from* because it's specified by a typedef
in CanMakeWeakPtr.
(Our convention is that we store a pointer to the class that derives
from CanMakeWeakPtr. We cast from that pointer to derived pointers when
we get(). This means that #include of the derived type header is now
required in order to get() the pointer.)
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Definition
is now eagerly required because WeakReference is not a template anymore.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const):
(WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computesEmpty const):
(WTF::WeakHashSet::hasNullReferences const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference<T>>>::isReleasedWeakValue): Deleted.
Updated for new WeakReference get() API.
* wtf/WeakPtr.h: Use a macro for TestAPI support. We can't use template
specialization because WeakReference is not a class template anymore.
(Or maybe we could have kept it working with a dummy template argument?
Felt weird, so I switched.)
(WTF::WeakReference::create):
(WTF::WeakReference::~WeakReference):
(WTF::WeakReference::get const):
(WTF::WeakReference::operator bool const):
(WTF::WeakReference::WeakReference): WeakReference is just a void* now.
It's the caller's responsibility, when creating and getting, to use
a consistent storage type. We ensure a canonical storage type using a
typedef inside CanMakeWeakPtr.
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const): Adopted new WeakReference API.
(WTF::WeakPtrFactory::createWeakPtr const): No need for reinterpret_cast.
(WTF::weak_reference_cast): This isn't required for correctness, but it's
nice to show a complier error at WeakPtr construction sites when you know
that the types won't work. Otherwise, you get compiler errors at
dereference sites, which are slightly more mysterious ways of saying that
you constructed your WeakPtr incorrectly.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::weak_reference_upcast): Deleted.
(WTF::weak_reference_downcast): Deleted.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Adopt the new macro API instead
of template specialization for observing weak references.
(TestWebKitAPI::Int::Int):
(TestWebKitAPI::Int::operator int const):
(TestWebKitAPI::Int::operator== const): Use a class for integer tests
because WeakPtr doesn't naturally support pointing to non-class objects
now.
(TestWebKitAPI::Base::foo):
(TestWebKitAPI::Derived::foo): Inherit from CanMakeWeakPtr to enable
deduction of the weak pointer type.
(TestWebKitAPI::TEST): Updated to use Int.
(TestWebKitAPI::Base::weakPtrFactory const): Deleted.
(WTF::WeakReference<TestWebKitAPI::Base>::WeakReference): Deleted.
(WTF::WeakReference<TestWebKitAPI::Base>::~WeakReference): Deleted.
Canonical link: https://commits.webkit.org/212376@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-29 21:15:54 +00:00
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
struct EmptyCounter {
|
|
|
|
static void increment() { }
|
|
|
|
static void decrement() { }
|
|
|
|
};
|
WeakPtr functions crash when created with default constructor
https://bugs.webkit.org/show_bug.cgi?id=140479
Reviewed by Andreas Kling.
Source/WTF:
This patch rearranges how WeakPtr works, and has the following ideas behind it:
1. WeakPtr should use Ref internally. This solves the crash by always having a
valid WeakReference.
2. Clients should not be able to construct WeakReferences directly. Instead,
only WeakPtrFactory (and WeakPtr's default constructor) should be able to
construct them. They are considered an implementation detail of WeakPtr.
3. Except for the default constructor, clients should not be able to construct
WeakPtrs directly. Instead, the WeakPtrFactory must construct them. This
guarantees that the WeakPtrs all reference the same WeakReference.
4. Clients can construct a WeakPtr using its default constructor, and then
use the assignment operator to make it non-null. (Or they could use
WeakPtrFactory to make it non-null at creation-time.)
5. No one was using WeakReference::bindTo(), and it doesn't seem useful, so I
removed it.
Tests: WTF_WeakPtr API tests
* wtf/Ref.h:
(WTF::Ref::Ref): Added extra ASSERT()s, and explicitly deleted copy
constructors with a comment.
(WTF::Ref::operator=): Added extra ASSERT()s, and explicitly deleted copy
assignment operators with a comment.
* wtf/WeakPtr.h:
(WTF::WeakReference::clear): Used nullptr.
(WTF::WeakReference::create): Moved to private:
(WTF::WeakPtr::WeakPtr): For the default constructor, initialized the Ref with
a new WeakReference. For the other constructor, moved it to private:. Also added
copy constructors and copy assignment operators (since Ref doesn't have them but
RefPtr does). These constructors/operators are relied upon in various places
throughout WebCore.
(WTF::WeakPtr::operator bool): Made non-explicit.
(WTF::WeakReference::createUnbound): Deleted.
(WTF::WeakReference::bindTo): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::WeakPtrFactory::WeakPtrFactory): Deleted.
Tools:
Add WeakPtr API tests.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Added.
* TestWebKitAPI/Tests/WTF/Ref.cpp: Update to not use copy constructor.
Canonical link: https://commits.webkit.org/158549@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178615 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-17 00:39:57 +00:00
|
|
|
|
OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224279
Reviewed by Darin Adler.
Source/WebCore:
OfflineAudioContext objects were always leaking due to 2 reference cycles:
1. BaseAudioContext -> m_listener (AudioListener) -> m_positionX (AudioParam) -> m_context (BaseAudioContext)
2. BaseAudioContext -> m_destinationNode (AudioDestinationNode) -> m_context (BaseAudioContext)
For reference cycle 1, I made AudioSummingJunction (base class of AudioParam) hold a weak pointer to the
AudioContext instead of a Ref<>. I don't think there is a good reason for an AudioSummingJunction (AudioParam
or AudioNodeInput) to keep its AudioContext alive. AudioNodes already keep their AudioContext alive.
AudioNodeInputs and AudioParams are associated to AudioNodes.
For reference cycle 2, I made AudioDestinationNode not hold a strong pointer to its context but instead a
weak pointer. Since keeping an AudioDestinationNode alive should keep its AudioContext alive, I made it so
that ref'ing the AudioDestinationNode refs its BaseAudioContext. Also, BaseAudioContext::m_destinationNode
is now a UniqueRef<> instead of a RefPtr<> to avoid a cycle.
Tests: webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html
webaudio/OfflineAudioContext/offlineaudiocontext-leak.html
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::baseLatency):
(WebCore::AudioContext::getOutputTimestamp):
(WebCore::AudioContext::close):
(WebCore::AudioContext::destination):
(WebCore::AudioContext::destination const):
(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::mediaState const):
(WebCore::AudioContext::mayResumePlayback):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::pageMutedStateDidChange):
* Modules/webaudio/AudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::ref):
(WebCore::AudioDestinationNode::deref):
* Modules/webaudio/AudioDestinationNode.h:
Have AudioDestinationNode override AudioNode's ref() / deref() to forward the refcounting
to its BaseAudioContext, instead of using the AudioNode's internal refCount.
* Modules/webaudio/AudioListener.cpp:
(WebCore::AudioListener::updateValuesIfNeeded):
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::setOrientation):
Add some null-checks for AudioParam::context() now that AudioParam holds a WeakPtr to its
context.
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::toWeakOrStrongContext):
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::connect):
(WebCore::AudioNode::sampleRate const):
(WebCore::AudioNode::markNodeForDeletionIfNecessary):
(WebCore::AudioNode::contextForBindings):
(WebCore::AudioNode::context):
(WebCore::AudioNode::context const):
* Modules/webaudio/AudioNode.h:
- Hold the BaseAudioContext as a WeakPtr instead of a Ref<> if the AudioNode is an
AudioDestinationNode. This avoids a reference cycle since the BaseAudioContext owns the
AudioDestinationNode. Even though we are using a WeakPtr, it is safe to assume that
the context is not null because ref'ing an AudioDestinationNode refs its BaseAudioContext.
- Make sure markNodeForDeletionIfNecessary() has no effect for AudioDestinationNode since
BaseAudioContext now owns the AudioDestinationNode when we take care of destroying its
destination node when destroyed.
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::connect):
(WebCore::AudioNodeInput::disconnect):
(WebCore::AudioNodeInput::outputEnabledStateChanged):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::internalSummingBus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):
Add assertions that the context is not null. There were already assertions that we are the graph
owner, which means we are holding the BaseAudioContext's lock, which means that the audio context
is alive.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::value):
(WebCore::AudioParam::setValueForBindings):
(WebCore::AudioParam::smooth):
(WebCore::AudioParam::hasSampleAccurateValues const):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
(WebCore::AudioParam::calculateTimelineValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
Add null-checks for the AudioContext now that the AudioParam is only holding a WeakPtr to its
BaseAudioContext (to avoid a reference cycle).
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::AudioSummingJunction):
(WebCore::AudioSummingJunction::~AudioSummingJunction):
(WebCore::AudioSummingJunction::markRenderingStateAsDirty):
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
(WebCore::AudioSummingJunction::outputEnabledStateChanged):
* Modules/webaudio/AudioSummingJunction.h:
(WebCore::AudioSummingJunction::context):
(WebCore::AudioSummingJunction::context const):
- Hold a WeakPtr to the BaseAudioContext to avoid a reference cycle.
- Deal with the fact that the audio context may be null now that we're holding a WeakPtr
to it (except when holding the graph lock)
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
(WebCore::BaseAudioContext::~BaseAudioContext):
(WebCore::BaseAudioContext::numberOfInstances):
(WebCore::BaseAudioContext::lazyInitialize):
(WebCore::BaseAudioContext::clear):
(WebCore::BaseAudioContext::uninitialize):
(WebCore::BaseAudioContext::stop):
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::decodeAudioData):
(WebCore::BaseAudioContext::markForDeletion):
(WebCore::BaseAudioContext::deleteMarkedNodes):
(WebCore::BaseAudioContext::setPendingActivity):
(WebCore::BaseAudioContext::workletIsReady):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::destination):
(WebCore::BaseAudioContext::destination const):
(WebCore::BaseAudioContext::currentSampleFrame const):
(WebCore::BaseAudioContext::currentTime const):
- Switch m_destinationNode from RefPtr<> to UniqueRef<> since the AudioContext is now
the owner of the destinationNode and since refing the destination node actually refs
its BaseAudioContext.
- Drop some null checks now that m_destinationNode can no longer be null.
- Rename makePendingActivity() to setPendingActivity() to avoid a naming conflict with
ActiveDOMObject::makePendingActivity().
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/OfflineAudioDestinationNode.h:
- Drop create() factory functions and make the constructor public now that the BaseAudioContext owns
its destination node via a UniqueRef<>.
- Make some member functions public as they are virtual and they now called on the subclass instead of the
base class (and these functions are public in the base class).
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
(WebCore::OfflineAudioContext::resumeOfflineRendering):
* Modules/webaudio/OfflineAudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::close):
Drop null checks for the destination node now that it can never be null.
* dom/ShadowRoot.cpp:
* rendering/FloatingObjects.cpp:
* rendering/RootInlineBox.cpp:
Update classes used of size restrictions since the size of a WeakPtr is not longer the same as the size of a
pointer when debug assertions are enabled. As long as they are the same size in release builds, there is no
memory use concern.
* testing/Internals.cpp:
(WebCore::Internals::numberOfBaseAudioContexts const):
* testing/Internals.h:
* testing/Internals.idl:
Add testing function to check how many BaseAudioContexts are alive, so that we can write layout tests and check
for leaks.
Source/WTF:
Add flag that can be passed when constructing a WeakPtr to disable threading assertions.
This is useful for cases where we know it is safe due to locking but we'd like to use a
WeakPtr instead of a raw pointer because it is safer.
* wtf/WeakPtr.h:
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const):
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::=):
(WTF::makeWeakPtr):
LayoutTests:
Add layout test coverage.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak.html: Added.
Canonical link: https://commits.webkit.org/236304@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 18:41:23 +00:00
|
|
|
enum class EnableWeakPtrThreadingAssertions : bool { No, Yes };
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename Counter = EmptyCounter> class WeakPtrImpl : public ThreadSafeRefCounted<WeakPtrImpl<Counter>> {
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
WTF_MAKE_NONCOPYABLE(WeakPtrImpl);
|
2013-01-15 21:35:08 +00:00
|
|
|
WTF_MAKE_FAST_ALLOCATED;
|
|
|
|
public:
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
template<typename T> static Ref<WeakPtrImpl> create(T* ptr)
|
|
|
|
{
|
|
|
|
return adoptRef(*new WeakPtrImpl(ptr));
|
|
|
|
}
|
WeakPtr breaks vtables when upcasting to base classes
https://bugs.webkit.org/show_bug.cgi?id=188799
Reviewed by Youenn Fablet.
Source/WebCore:
* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::MediaKeySession):
* Modules/encryptedmedia/MediaKeySession.h: Adopted modern WeakPtr APIs.
Removed redundant WeakPtrFactory.
* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::existingWrapper):
* css/CSSFontFace.h: Moved functions out of line to avoid #include
explosion for .get().
* dom/ContainerNode.h:
* dom/Document.h:
* dom/Element.h: Moved CanMakeWeakPtr to ContainerNode because all
subclasses except for DocumentFragment were already so, and we have
code that uses WeakPtr<ContainerNode>, which, now that WeakPtr is
type-safe, is awkward to do when ContainerNode isn't CanMakeWeakPtr.
* dom/FullscreenManager.cpp:
(WebCore::FullscreenManager::fullscreenRenderer const):
* dom/FullscreenManager.h:
(WebCore::FullscreenManager::fullscreenRenderer const): Deleted.
* html/FormAssociatedElement.cpp:
(WebCore::FormAssociatedElement::form const):
* html/FormAssociatedElement.h:
(WebCore::FormAssociatedElement::form const): Deleted. Moved functions
out of line to avoid #include explosion for .get().
* html/HTMLMediaElement.h: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
* loader/MediaResourceLoader.cpp:
(WebCore::MediaResourceLoader::requestResource): Removed redundant .get().
* page/DOMWindowProperty.cpp:
(WebCore::DOMWindowProperty::window const):
* page/DOMWindowProperty.h:
(WebCore::DOMWindowProperty::window const): Deleted.
* page/FrameViewLayoutContext.cpp:
(WebCore::FrameViewLayoutContext::subtreeLayoutRoot const):
* page/FrameViewLayoutContext.h:
(WebCore::FrameViewLayoutContext::subtreeLayoutRoot const): Deleted.
* page/UndoItem.cpp:
(WebCore::UndoItem::undoManager const):
* page/UndoItem.h:
(WebCore::UndoItem::undoManager const): Deleted. Moved functions out of
line to avoid #include explosion for .get().
* platform/ScrollView.h: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
* platform/Widget.cpp:
(WebCore::Widget::parent const):
* platform/Widget.h:
(WebCore::Widget::parent const): Deleted. Moved functions out of line to avoid #include
explosion for .get().
* platform/encryptedmedia/CDMInstanceSession.h: Made
CDMInstanceSessionClient CanMakeWeakPtr because we use WeakPtr<CDMInstanceSessionClient>.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
CanMakeWeakPtr is inherited now.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
(WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const): Deleted.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createWeakPtr): Deleted.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::CMTimebaseEffectiveRateChangedCallback):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::durationChanged):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled):
(WebCore::SourceBufferPrivateAVFObjC::setCDMSession):
(WebCore::SourceBufferPrivateAVFObjC::flushVideo):
(WebCore::SourceBufferPrivateAVFObjC::enqueueSample):
(WebCore::SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples):
(WebCore::SourceBufferPrivateAVFObjC::setVideoLayer):
(WebCore::SourceBufferPrivateAVFObjC::setDecompressionSession): Modernized WeakPtr API usage.
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::multiColumnFlowSlowCase const):
* rendering/RenderBlockFlow.h:
(WebCore::RenderBlockFlow::multiColumnFlow const):
* rendering/RenderMultiColumnFlow.cpp:
(WebCore::RenderMultiColumnFlow::findColumnSpannerPlaceholder const):
* rendering/RenderMultiColumnFlow.h:
* rendering/RenderTable.cpp:
(WebCore::RenderTable::header const):
(WebCore::RenderTable::footer const):
(WebCore::RenderTable::firstBody const):
(WebCore::RenderTable::topSection const):
* rendering/RenderTable.h:
(WebCore::RenderTable::header const): Deleted.
(WebCore::RenderTable::footer const): Deleted.
(WebCore::RenderTable::firstBody const): Deleted.
(WebCore::RenderTable::topSection const): Deleted. Moved functions out
of line to avoid #include explosion for .get().
Source/WebKit:
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::networkSession):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* Shared/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::suspendedPage const):
* Shared/WebBackForwardListItem.h:
(WebKit::WebBackForwardListItem::suspendedPage const): Deleted. Moved
functions out of line to avoid #include explosion for .get().
* UIProcess/Authentication/cocoa/SecKeyProxyStore.h:
(WebKit::SecKeyProxyStore::get const):
(WebKit::SecKeyProxyStore::weakPtrFactory const): Deleted. Adopted
CanMakeWeakPtr.
* UIProcess/WebAuthentication/AuthenticatorManager.h:
* UIProcess/WebProcessProxy.cpp: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
(WebKit::WebProcessProxy::processPool const):
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::processPool const): Deleted. Moved
functions out of line to avoid #include explosion for .get().
Source/WTF:
This patch switches from reinterpret_cast to static_cast when loading
from WeakReference storage.
We know which type to cast *to* because it's specified by the type of
the calling WeakPtr.
We know which type to cast *from* because it's specified by a typedef
in CanMakeWeakPtr.
(Our convention is that we store a pointer to the class that derives
from CanMakeWeakPtr. We cast from that pointer to derived pointers when
we get(). This means that #include of the derived type header is now
required in order to get() the pointer.)
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Definition
is now eagerly required because WeakReference is not a template anymore.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const):
(WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computesEmpty const):
(WTF::WeakHashSet::hasNullReferences const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference<T>>>::isReleasedWeakValue): Deleted.
Updated for new WeakReference get() API.
* wtf/WeakPtr.h: Use a macro for TestAPI support. We can't use template
specialization because WeakReference is not a class template anymore.
(Or maybe we could have kept it working with a dummy template argument?
Felt weird, so I switched.)
(WTF::WeakReference::create):
(WTF::WeakReference::~WeakReference):
(WTF::WeakReference::get const):
(WTF::WeakReference::operator bool const):
(WTF::WeakReference::WeakReference): WeakReference is just a void* now.
It's the caller's responsibility, when creating and getting, to use
a consistent storage type. We ensure a canonical storage type using a
typedef inside CanMakeWeakPtr.
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const): Adopted new WeakReference API.
(WTF::WeakPtrFactory::createWeakPtr const): No need for reinterpret_cast.
(WTF::weak_reference_cast): This isn't required for correctness, but it's
nice to show a complier error at WeakPtr construction sites when you know
that the types won't work. Otherwise, you get compiler errors at
dereference sites, which are slightly more mysterious ways of saying that
you constructed your WeakPtr incorrectly.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::weak_reference_upcast): Deleted.
(WTF::weak_reference_downcast): Deleted.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Adopt the new macro API instead
of template specialization for observing weak references.
(TestWebKitAPI::Int::Int):
(TestWebKitAPI::Int::operator int const):
(TestWebKitAPI::Int::operator== const): Use a class for integer tests
because WeakPtr doesn't naturally support pointing to non-class objects
now.
(TestWebKitAPI::Base::foo):
(TestWebKitAPI::Derived::foo): Inherit from CanMakeWeakPtr to enable
deduction of the weak pointer type.
(TestWebKitAPI::TEST): Updated to use Int.
(TestWebKitAPI::Base::weakPtrFactory const): Deleted.
(WTF::WeakReference<TestWebKitAPI::Base>::WeakReference): Deleted.
(WTF::WeakReference<TestWebKitAPI::Base>::~WeakReference): Deleted.
Canonical link: https://commits.webkit.org/212376@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-29 21:15:54 +00:00
|
|
|
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
~WeakPtrImpl()
|
WeakPtr breaks vtables when upcasting to base classes
https://bugs.webkit.org/show_bug.cgi?id=188799
Reviewed by Youenn Fablet.
Source/WebCore:
* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::MediaKeySession):
* Modules/encryptedmedia/MediaKeySession.h: Adopted modern WeakPtr APIs.
Removed redundant WeakPtrFactory.
* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::existingWrapper):
* css/CSSFontFace.h: Moved functions out of line to avoid #include
explosion for .get().
* dom/ContainerNode.h:
* dom/Document.h:
* dom/Element.h: Moved CanMakeWeakPtr to ContainerNode because all
subclasses except for DocumentFragment were already so, and we have
code that uses WeakPtr<ContainerNode>, which, now that WeakPtr is
type-safe, is awkward to do when ContainerNode isn't CanMakeWeakPtr.
* dom/FullscreenManager.cpp:
(WebCore::FullscreenManager::fullscreenRenderer const):
* dom/FullscreenManager.h:
(WebCore::FullscreenManager::fullscreenRenderer const): Deleted.
* html/FormAssociatedElement.cpp:
(WebCore::FormAssociatedElement::form const):
* html/FormAssociatedElement.h:
(WebCore::FormAssociatedElement::form const): Deleted. Moved functions
out of line to avoid #include explosion for .get().
* html/HTMLMediaElement.h: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
* loader/MediaResourceLoader.cpp:
(WebCore::MediaResourceLoader::requestResource): Removed redundant .get().
* page/DOMWindowProperty.cpp:
(WebCore::DOMWindowProperty::window const):
* page/DOMWindowProperty.h:
(WebCore::DOMWindowProperty::window const): Deleted.
* page/FrameViewLayoutContext.cpp:
(WebCore::FrameViewLayoutContext::subtreeLayoutRoot const):
* page/FrameViewLayoutContext.h:
(WebCore::FrameViewLayoutContext::subtreeLayoutRoot const): Deleted.
* page/UndoItem.cpp:
(WebCore::UndoItem::undoManager const):
* page/UndoItem.h:
(WebCore::UndoItem::undoManager const): Deleted. Moved functions out of
line to avoid #include explosion for .get().
* platform/ScrollView.h: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
* platform/Widget.cpp:
(WebCore::Widget::parent const):
* platform/Widget.h:
(WebCore::Widget::parent const): Deleted. Moved functions out of line to avoid #include
explosion for .get().
* platform/encryptedmedia/CDMInstanceSession.h: Made
CDMInstanceSessionClient CanMakeWeakPtr because we use WeakPtr<CDMInstanceSessionClient>.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
CanMakeWeakPtr is inherited now.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
(WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const): Deleted.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createWeakPtr): Deleted.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::CMTimebaseEffectiveRateChangedCallback):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::durationChanged):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled):
(WebCore::SourceBufferPrivateAVFObjC::setCDMSession):
(WebCore::SourceBufferPrivateAVFObjC::flushVideo):
(WebCore::SourceBufferPrivateAVFObjC::enqueueSample):
(WebCore::SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples):
(WebCore::SourceBufferPrivateAVFObjC::setVideoLayer):
(WebCore::SourceBufferPrivateAVFObjC::setDecompressionSession): Modernized WeakPtr API usage.
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::multiColumnFlowSlowCase const):
* rendering/RenderBlockFlow.h:
(WebCore::RenderBlockFlow::multiColumnFlow const):
* rendering/RenderMultiColumnFlow.cpp:
(WebCore::RenderMultiColumnFlow::findColumnSpannerPlaceholder const):
* rendering/RenderMultiColumnFlow.h:
* rendering/RenderTable.cpp:
(WebCore::RenderTable::header const):
(WebCore::RenderTable::footer const):
(WebCore::RenderTable::firstBody const):
(WebCore::RenderTable::topSection const):
* rendering/RenderTable.h:
(WebCore::RenderTable::header const): Deleted.
(WebCore::RenderTable::footer const): Deleted.
(WebCore::RenderTable::firstBody const): Deleted.
(WebCore::RenderTable::topSection const): Deleted. Moved functions out
of line to avoid #include explosion for .get().
Source/WebKit:
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::networkSession):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* Shared/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::suspendedPage const):
* Shared/WebBackForwardListItem.h:
(WebKit::WebBackForwardListItem::suspendedPage const): Deleted. Moved
functions out of line to avoid #include explosion for .get().
* UIProcess/Authentication/cocoa/SecKeyProxyStore.h:
(WebKit::SecKeyProxyStore::get const):
(WebKit::SecKeyProxyStore::weakPtrFactory const): Deleted. Adopted
CanMakeWeakPtr.
* UIProcess/WebAuthentication/AuthenticatorManager.h:
* UIProcess/WebProcessProxy.cpp: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
(WebKit::WebProcessProxy::processPool const):
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::processPool const): Deleted. Moved
functions out of line to avoid #include explosion for .get().
Source/WTF:
This patch switches from reinterpret_cast to static_cast when loading
from WeakReference storage.
We know which type to cast *to* because it's specified by the type of
the calling WeakPtr.
We know which type to cast *from* because it's specified by a typedef
in CanMakeWeakPtr.
(Our convention is that we store a pointer to the class that derives
from CanMakeWeakPtr. We cast from that pointer to derived pointers when
we get(). This means that #include of the derived type header is now
required in order to get() the pointer.)
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Definition
is now eagerly required because WeakReference is not a template anymore.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const):
(WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computesEmpty const):
(WTF::WeakHashSet::hasNullReferences const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference<T>>>::isReleasedWeakValue): Deleted.
Updated for new WeakReference get() API.
* wtf/WeakPtr.h: Use a macro for TestAPI support. We can't use template
specialization because WeakReference is not a class template anymore.
(Or maybe we could have kept it working with a dummy template argument?
Felt weird, so I switched.)
(WTF::WeakReference::create):
(WTF::WeakReference::~WeakReference):
(WTF::WeakReference::get const):
(WTF::WeakReference::operator bool const):
(WTF::WeakReference::WeakReference): WeakReference is just a void* now.
It's the caller's responsibility, when creating and getting, to use
a consistent storage type. We ensure a canonical storage type using a
typedef inside CanMakeWeakPtr.
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const): Adopted new WeakReference API.
(WTF::WeakPtrFactory::createWeakPtr const): No need for reinterpret_cast.
(WTF::weak_reference_cast): This isn't required for correctness, but it's
nice to show a complier error at WeakPtr construction sites when you know
that the types won't work. Otherwise, you get compiler errors at
dereference sites, which are slightly more mysterious ways of saying that
you constructed your WeakPtr incorrectly.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::weak_reference_upcast): Deleted.
(WTF::weak_reference_downcast): Deleted.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Adopt the new macro API instead
of template specialization for observing weak references.
(TestWebKitAPI::Int::Int):
(TestWebKitAPI::Int::operator int const):
(TestWebKitAPI::Int::operator== const): Use a class for integer tests
because WeakPtr doesn't naturally support pointing to non-class objects
now.
(TestWebKitAPI::Base::foo):
(TestWebKitAPI::Derived::foo): Inherit from CanMakeWeakPtr to enable
deduction of the weak pointer type.
(TestWebKitAPI::TEST): Updated to use Int.
(TestWebKitAPI::Base::weakPtrFactory const): Deleted.
(WTF::WeakReference<TestWebKitAPI::Base>::WeakReference): Deleted.
(WTF::WeakReference<TestWebKitAPI::Base>::~WeakReference): Deleted.
Canonical link: https://commits.webkit.org/212376@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-29 21:15:54 +00:00
|
|
|
{
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
Counter::decrement();
|
WeakPtr breaks vtables when upcasting to base classes
https://bugs.webkit.org/show_bug.cgi?id=188799
Reviewed by Youenn Fablet.
Source/WebCore:
* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::MediaKeySession):
* Modules/encryptedmedia/MediaKeySession.h: Adopted modern WeakPtr APIs.
Removed redundant WeakPtrFactory.
* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::existingWrapper):
* css/CSSFontFace.h: Moved functions out of line to avoid #include
explosion for .get().
* dom/ContainerNode.h:
* dom/Document.h:
* dom/Element.h: Moved CanMakeWeakPtr to ContainerNode because all
subclasses except for DocumentFragment were already so, and we have
code that uses WeakPtr<ContainerNode>, which, now that WeakPtr is
type-safe, is awkward to do when ContainerNode isn't CanMakeWeakPtr.
* dom/FullscreenManager.cpp:
(WebCore::FullscreenManager::fullscreenRenderer const):
* dom/FullscreenManager.h:
(WebCore::FullscreenManager::fullscreenRenderer const): Deleted.
* html/FormAssociatedElement.cpp:
(WebCore::FormAssociatedElement::form const):
* html/FormAssociatedElement.h:
(WebCore::FormAssociatedElement::form const): Deleted. Moved functions
out of line to avoid #include explosion for .get().
* html/HTMLMediaElement.h: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
* loader/MediaResourceLoader.cpp:
(WebCore::MediaResourceLoader::requestResource): Removed redundant .get().
* page/DOMWindowProperty.cpp:
(WebCore::DOMWindowProperty::window const):
* page/DOMWindowProperty.h:
(WebCore::DOMWindowProperty::window const): Deleted.
* page/FrameViewLayoutContext.cpp:
(WebCore::FrameViewLayoutContext::subtreeLayoutRoot const):
* page/FrameViewLayoutContext.h:
(WebCore::FrameViewLayoutContext::subtreeLayoutRoot const): Deleted.
* page/UndoItem.cpp:
(WebCore::UndoItem::undoManager const):
* page/UndoItem.h:
(WebCore::UndoItem::undoManager const): Deleted. Moved functions out of
line to avoid #include explosion for .get().
* platform/ScrollView.h: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
* platform/Widget.cpp:
(WebCore::Widget::parent const):
* platform/Widget.h:
(WebCore::Widget::parent const): Deleted. Moved functions out of line to avoid #include
explosion for .get().
* platform/encryptedmedia/CDMInstanceSession.h: Made
CDMInstanceSessionClient CanMakeWeakPtr because we use WeakPtr<CDMInstanceSessionClient>.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
CanMakeWeakPtr is inherited now.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
(WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const): Deleted.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createWeakPtr): Deleted.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::CMTimebaseEffectiveRateChangedCallback):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::durationChanged):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled):
(WebCore::SourceBufferPrivateAVFObjC::setCDMSession):
(WebCore::SourceBufferPrivateAVFObjC::flushVideo):
(WebCore::SourceBufferPrivateAVFObjC::enqueueSample):
(WebCore::SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples):
(WebCore::SourceBufferPrivateAVFObjC::setVideoLayer):
(WebCore::SourceBufferPrivateAVFObjC::setDecompressionSession): Modernized WeakPtr API usage.
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::multiColumnFlowSlowCase const):
* rendering/RenderBlockFlow.h:
(WebCore::RenderBlockFlow::multiColumnFlow const):
* rendering/RenderMultiColumnFlow.cpp:
(WebCore::RenderMultiColumnFlow::findColumnSpannerPlaceholder const):
* rendering/RenderMultiColumnFlow.h:
* rendering/RenderTable.cpp:
(WebCore::RenderTable::header const):
(WebCore::RenderTable::footer const):
(WebCore::RenderTable::firstBody const):
(WebCore::RenderTable::topSection const):
* rendering/RenderTable.h:
(WebCore::RenderTable::header const): Deleted.
(WebCore::RenderTable::footer const): Deleted.
(WebCore::RenderTable::firstBody const): Deleted.
(WebCore::RenderTable::topSection const): Deleted. Moved functions out
of line to avoid #include explosion for .get().
Source/WebKit:
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::networkSession):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* Shared/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::suspendedPage const):
* Shared/WebBackForwardListItem.h:
(WebKit::WebBackForwardListItem::suspendedPage const): Deleted. Moved
functions out of line to avoid #include explosion for .get().
* UIProcess/Authentication/cocoa/SecKeyProxyStore.h:
(WebKit::SecKeyProxyStore::get const):
(WebKit::SecKeyProxyStore::weakPtrFactory const): Deleted. Adopted
CanMakeWeakPtr.
* UIProcess/WebAuthentication/AuthenticatorManager.h:
* UIProcess/WebProcessProxy.cpp: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
(WebKit::WebProcessProxy::processPool const):
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::processPool const): Deleted. Moved
functions out of line to avoid #include explosion for .get().
Source/WTF:
This patch switches from reinterpret_cast to static_cast when loading
from WeakReference storage.
We know which type to cast *to* because it's specified by the type of
the calling WeakPtr.
We know which type to cast *from* because it's specified by a typedef
in CanMakeWeakPtr.
(Our convention is that we store a pointer to the class that derives
from CanMakeWeakPtr. We cast from that pointer to derived pointers when
we get(). This means that #include of the derived type header is now
required in order to get() the pointer.)
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Definition
is now eagerly required because WeakReference is not a template anymore.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const):
(WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computesEmpty const):
(WTF::WeakHashSet::hasNullReferences const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference<T>>>::isReleasedWeakValue): Deleted.
Updated for new WeakReference get() API.
* wtf/WeakPtr.h: Use a macro for TestAPI support. We can't use template
specialization because WeakReference is not a class template anymore.
(Or maybe we could have kept it working with a dummy template argument?
Felt weird, so I switched.)
(WTF::WeakReference::create):
(WTF::WeakReference::~WeakReference):
(WTF::WeakReference::get const):
(WTF::WeakReference::operator bool const):
(WTF::WeakReference::WeakReference): WeakReference is just a void* now.
It's the caller's responsibility, when creating and getting, to use
a consistent storage type. We ensure a canonical storage type using a
typedef inside CanMakeWeakPtr.
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const): Adopted new WeakReference API.
(WTF::WeakPtrFactory::createWeakPtr const): No need for reinterpret_cast.
(WTF::weak_reference_cast): This isn't required for correctness, but it's
nice to show a complier error at WeakPtr construction sites when you know
that the types won't work. Otherwise, you get compiler errors at
dereference sites, which are slightly more mysterious ways of saying that
you constructed your WeakPtr incorrectly.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::weak_reference_upcast): Deleted.
(WTF::weak_reference_downcast): Deleted.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Adopt the new macro API instead
of template specialization for observing weak references.
(TestWebKitAPI::Int::Int):
(TestWebKitAPI::Int::operator int const):
(TestWebKitAPI::Int::operator== const): Use a class for integer tests
because WeakPtr doesn't naturally support pointing to non-class objects
now.
(TestWebKitAPI::Base::foo):
(TestWebKitAPI::Derived::foo): Inherit from CanMakeWeakPtr to enable
deduction of the weak pointer type.
(TestWebKitAPI::TEST): Updated to use Int.
(TestWebKitAPI::Base::weakPtrFactory const): Deleted.
(WTF::WeakReference<TestWebKitAPI::Base>::WeakReference): Deleted.
(WTF::WeakReference<TestWebKitAPI::Base>::~WeakReference): Deleted.
Canonical link: https://commits.webkit.org/212376@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-29 21:15:54 +00:00
|
|
|
}
|
Add WeakHashSet
https://bugs.webkit.org/show_bug.cgi?id=195152
Reviewed by Antti Koivisto.
Source/WTF:
Added WeakHashSet which is a HashSet of WeakPtr. When the object pointed by WeakPtr is deleted,
WeakHashSet treats the key to be no longer in the set. That is, WeakHashSet::contains returns false
and const_iterator skips such a WeakPtr in the set.
We decided not to make HashSet<WeahPtr<T>> work because it involves weird semantics such as making
find(X) delete the table entry as remove(find(X)) would be a no-op otherwise as find(X) would return
necessarily need to return HashSet<WeakPtr<T>>::end().
Furthermore, we cannot determine the true size of this set in O(1) because the objected pointed by
some of WeakPtr in the set may have already been deleted. This has implications that we can't have
size(), isEmpty(), random(), etc... as O(1) operation.
WeakHashSet is implemented as HashSet<WeakReference<T>>. HashTable::rehash has been updated to delete
WeakReference<T>'s whose m_ptr has become null, and HashTable::expand first deletes any such entry
before deciding an actual expansion is needed. This is accomplished via newly added hash trait,
hasIsReleasedWeakValueFunction, and HashTraits<Ref<WeakReference<T>>>::isReleasedWeakValue which
returns true for when WeakReference<T> pointed by Ref<WeakReference<T>> has null m_ptr, not to be
confused with Ref<WeakReference<T>> itself pointing to a null WeakReference<T>.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/Forward.h:
* wtf/HashSet.h:
(WTF::HashSet<T, U, V>::checkConsistency const): Added.
* wtf/HashTable.h:
(WTF::HashTable::isReleasedWeakBucket): Added.
(WTF::HashTable::expand): Delete WeakReference<T> with null m_ptr first. This updates m_keyCount
and may make mustRehashInPlace() return true.
(WTF::HashTable::deleteReleasedWeakBuckets): Added.
(WTF::HashTable::rehash): Delete WeakReference<T> with null m_ptr. Also refactored the code a bit
to avoid keep repeating oldTable[i].
* wtf/HashTraits.h:
(WTF::HashTraits<T>::isHashTraitsReleasedWeakValue): Added.
(WTF::RefHashTraits<T>): Extracted from HashTraits<Ref<P>> to share code with
HashTraits<Ref<WeakReference<T>>>.
(WTF::HashTraitsReleasedWeakValueChecker<Traits, hasIsReleasedWeakValueFunction>): Added.
(WTF::isHashTraitsReleasedWeakValue<Traits, hasIsReleasedWeakValueFunction>): Added.
* wtf/WeakHashSet.h: Added.
(WTF::WeakHashSet): Added.
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
(WTF::WeakHashSet::WeakHashSetConstIterator::get const):
(WTF::WeakHashSet::WeakHashSetConstIterator::operator* const):
(WTF::WeakHashSet::WeakHashSetConstIterator::operator-> const):
(WTF::WeakHashSet::WeakHashSetConstIterator::operator++):
(WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets):
(WTF::WeakHashSet::WeakHashSetConstIterator::operator== const):
(WTF::WeakHashSet::WeakHashSetConstIterator::operator!= const):
(WTF::WeakHashSet::WeakHashSet):
(WTF::WeakHashSet::begin const):
(WTF::WeakHashSet::end const):
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::capacity const):
(WTF::WeakHashSet::computeSize const): Deletes any WeakReference<T> with null m_ptr first.
(WTF::WeakHashSet::checkConsistency const):
(WTF::HashTraits<Ref<WeakReference<T>>>): Added. This hash traits triggers the new code in HashTable's
expand and rehash methods to delete WeakReference<T> with null m_ptr.
(WTF::HashTraits<Ref<WeakReference<T>>>::isReleasedWeakValue):
* wtf/WeakPtr.h:
(WTF::WeakReference::~WeakReference): Added so that we can keep track the number of live WeakReference
in API tests by template specializations.
Tools:
Added tests for WeakHashSet.
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
(TestWebKitAPI::Base::Base): Moved.
(TestWebKitAPI::Derived::foo): Moved.
(WTF::WeakReference<TestWebKitAPI::Base>): Added to track the number of live WeakReference.
(WTF::WeakReference<TestWebKitAPI::Base>::WeakReference):
(WTF::WeakReference<TestWebKitAPI::Base>::~WeakReference):
(TestWebKitAPI::computeSizeOfWeakHashSet): Added.
Canonical link: https://commits.webkit.org/209643@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242387 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-04 21:52:32 +00:00
|
|
|
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
template<typename T> typename T::WeakValueType* get()
|
|
|
|
{
|
|
|
|
return static_cast<typename T::WeakValueType*>(m_ptr);
|
|
|
|
}
|
2013-01-15 21:35:08 +00:00
|
|
|
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
explicit operator bool() const { return m_ptr; }
|
2017-09-23 04:38:45 +00:00
|
|
|
void clear() { m_ptr = nullptr; }
|
2013-02-08 19:30:54 +00:00
|
|
|
|
PerformanceTests:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* JetStream2/wasm/HashSet.cpp:
* StitchMarker/wtf/Assertions.h:
* StitchMarker/wtf/DateMath.cpp:
(WTF::initializeDates):
* StitchMarker/wtf/HashTable.h:
* StitchMarker/wtf/Hasher.h:
(WTF::StringHasher::addCharacters):
* StitchMarker/wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* StitchMarker/wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* StitchMarker/wtf/ValueCheck.h:
* StitchMarker/wtf/Vector.h:
(WTF::minCapacity>::checkConsistency):
* StitchMarker/wtf/text/AtomicStringImpl.cpp:
* StitchMarker/wtf/text/AtomicStringImpl.h:
* StitchMarker/wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* StitchMarker/wtf/text/StringImpl.h:
* StitchMarker/wtf/text/SymbolImpl.h:
* StitchMarker/wtf/text/UniquedStringImpl.h:
Source/JavaScriptCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* API/tests/testapi.c:
* assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::replaceWithLoad):
(JSC::ARM64Assembler::replaceWithAddressComputation):
* assembler/AssemblerBuffer.h:
(JSC::AssemblerBuffer::LocalWriter::LocalWriter):
* assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::copyCompactAndLinkCode):
* assembler/ProbeStack.cpp:
(JSC::Probe::Stack::Stack):
* assembler/ProbeStack.h:
* b3/B3FoldPathConstants.cpp:
* b3/B3LowerToAir.cpp:
* b3/B3MemoryValue.cpp:
(JSC::B3::MemoryValue::MemoryValue):
* b3/B3Opcode.cpp:
* b3/B3Type.h:
* b3/B3TypeMap.h:
* b3/B3Width.h:
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp:
(JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration):
(JSC::B3::Air::GenerateAndAllocateRegisters::generate):
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.h:
* b3/air/AirAllocateRegistersByGraphColoring.cpp:
* b3/air/AirArg.cpp:
* b3/air/AirArg.h:
* b3/air/AirCode.h:
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* bytecode/AccessCase.cpp:
* bytecode/AccessCase.h:
* bytecode/CallVariant.cpp:
(JSC::variantListWithVariant):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex):
* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::dump const):
* bytecode/StructureStubInfo.cpp:
* bytecode/StructureStubInfo.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionCallResolveNode::emitBytecode):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::RegisterID):
(JSC::RegisterID::setIndex):
* debugger/Debugger.cpp:
(JSC::Debugger::removeBreakpoint):
* debugger/DebuggerEvalEnabler.h:
(JSC::DebuggerEvalEnabler::DebuggerEvalEnabler):
(JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions):
* dfg/DFGAbstractValue.cpp:
* dfg/DFGAbstractValue.h:
(JSC::DFG::AbstractValue::merge):
(JSC::DFG::AbstractValue::checkConsistency const):
(JSC::DFG::AbstractValue::assertIsRegistered const):
* dfg/DFGArithMode.h:
(JSC::DFG::doesOverflow):
* dfg/DFGBasicBlock.cpp:
(JSC::DFG::BasicBlock::BasicBlock):
* dfg/DFGBasicBlock.h:
(JSC::DFG::BasicBlock::didLink):
* dfg/DFGCFAPhase.cpp:
(JSC::DFG::CFAPhase::performBlockCFA):
* dfg/DFGCommon.h:
(JSC::DFG::validationEnabled):
* dfg/DFGCommonData.cpp:
(JSC::DFG::CommonData::finalizeCatchEntrypoints):
* dfg/DFGDesiredWatchpoints.h:
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGEdge.h:
(JSC::DFG::Edge::makeWord):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::finalizeOSREntrypoints):
* dfg/DFGObjectAllocationSinkingPhase.cpp:
* dfg/DFGSSAConversionPhase.cpp:
(JSC::DFG::SSAConversionPhase::run):
* dfg/DFGScoreBoard.h:
(JSC::DFG::ScoreBoard::assertClear):
* dfg/DFGSlowPathGenerator.h:
(JSC::DFG::SlowPathGenerator::generate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
(JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse):
(JSC::DFG::SpeculativeJIT::emitAllocateButterfly):
(JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize):
(JSC::DFG::SpeculativeJIT::compileMakeRope):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
* dfg/DFGStructureAbstractValue.cpp:
* dfg/DFGStructureAbstractValue.h:
(JSC::DFG::StructureAbstractValue::assertIsRegistered const):
* dfg/DFGVarargsForwardingPhase.cpp:
* dfg/DFGVirtualRegisterAllocationPhase.cpp:
(JSC::DFG::VirtualRegisterAllocationPhase::run):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::callPreflight):
(JSC::FTL::DFG::LowerDFGToB3::callCheck):
(JSC::FTL::DFG::LowerDFGToB3::crash):
* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::assertNoUnswept):
* heap/GCSegmentedArray.h:
(JSC::GCArraySegment::GCArraySegment):
* heap/GCSegmentedArrayInlines.h:
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::validatePrevious):
* heap/HandleSet.cpp:
* heap/HandleSet.h:
* heap/Heap.cpp:
(JSC::Heap::updateAllocationLimits):
* heap/Heap.h:
* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::assertValidCell const):
(JSC::MarkedBlock::assertMarksNotStale):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::beginMarking):
(JSC::MarkedSpace::endMarking):
(JSC::MarkedSpace::assertNoUnswept):
* heap/PreciseAllocation.cpp:
* heap/PreciseAllocation.h:
(JSC::PreciseAllocation::assertValidCell const):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::appendJSCellOrAuxiliary):
* heap/SlotVisitor.h:
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
(CppProtocolTypesImplementationGenerator):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* interpreter/FrameTracers.h:
(JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::Interpreter):
* interpreter/Interpreter.h:
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::prepareCallOperation):
* jit/BinarySwitch.cpp:
(JSC::BinarySwitch::BinarySwitch):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupStubArgs):
* jit/CallFrameShuffler.cpp:
(JSC::CallFrameShuffler::emitDeltaCheck):
(JSC::CallFrameShuffler::prepareAny):
* jit/JIT.cpp:
(JSC::JIT::assertStackPointerOffset):
(JSC::JIT::compileWithoutLinking):
* jit/JITOpcodes.cpp:
(JSC::JIT::emitSlow_op_loop_hint):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
* jit/ThunkGenerators.cpp:
(JSC::emitPointerValidation):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LLIntOfflineAsmConfig.h:
* parser/Lexer.cpp:
* parser/Lexer.h:
(JSC::isSafeBuiltinIdentifier):
(JSC::Lexer<T>::lexExpectIdentifier):
* runtime/ArgList.h:
(JSC::MarkedArgumentBuffer::setNeedsOverflowCheck):
(JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck):
* runtime/Butterfly.h:
(JSC::ContiguousData::ContiguousData):
(JSC::ContiguousData::Data::Data):
* runtime/HashMapImpl.h:
(JSC::HashMapImpl::checkConsistency const):
(JSC::HashMapImpl::assertBufferIsEmpty const):
* runtime/JSCellInlines.h:
(JSC::JSCell::methodTable const):
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
(JSC::JSFunction::assertTypeInfoFlagInvariants):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren):
(JSC::JSFinalObject::visitChildren):
* runtime/JSObjectInlines.h:
(JSC::JSObject::validatePutOwnDataProperty):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::assertVariableIsInThisObject):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lex):
* runtime/LiteralParser.h:
* runtime/Operations.h:
(JSC::scribbleFreeCells):
* runtime/OptionsList.h:
* runtime/VM.cpp:
(JSC::VM::computeCanUseJIT):
* runtime/VM.h:
(JSC::VM::canUseJIT):
* runtime/VarOffset.h:
(JSC::VarOffset::checkSanity const):
* runtime/WeakMapImpl.h:
(JSC::WeakMapImpl::checkConsistency const):
(JSC::WeakMapImpl::assertBufferIsEmpty const):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::validateInst):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile):
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser::validationFail const):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::checkConsistency):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast):
* wasm/WasmSectionParser.h:
* wasm/WasmSections.h:
* wasm/WasmSignatureInlines.h:
(JSC::Wasm::SignatureInformation::get):
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::enqueue):
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::previousInstanceOffset const):
Source/WebCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::close):
* Modules/fetch/FetchBodySource.h:
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
(WebCore::DatabaseDetails::operator=):
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTask::performTask):
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::terminationRequested const):
* Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h:
(WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation):
* Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp:
(WebCore::WHLSL::findHighZombies):
* Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
(WebCore::WHLSL::matches):
* Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:
(WebCore::WHLSL::checkLiteralTypes):
* Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp:
(WebCore::WHLSL::FindAllTypes::appendNamedType):
* bindings/js/JSCallbackData.h:
* bindings/js/JSLazyEventListener.cpp:
* bindings/js/JSLazyEventListener.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcOperationNode::primitiveType const):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValue.cpp:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/CSSStyleSheet.cpp:
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::suspendIfNeeded):
(WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const):
* dom/ActiveDOMObject.h:
* dom/ContainerNode.cpp:
* dom/ContainerNodeAlgorithms.cpp:
* dom/ContainerNodeAlgorithms.h:
* dom/CustomElementReactionQueue.cpp:
* dom/CustomElementReactionQueue.h:
(WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope):
(WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope):
* dom/Document.cpp:
(WebCore::Document::hitTest):
* dom/Document.h:
(WebCore::Document::decrementReferencingNodeCount):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::getURLAttribute const):
(WebCore::Element::getNonEmptyURLAttribute const):
* dom/Element.h:
* dom/ElementAndTextDescendantIterator.h:
(WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator):
(WebCore::ElementAndTextDescendantIterator::dropAssertions):
(WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack):
(WebCore::ElementAndTextDescendantIterator::traverseNextSibling):
(WebCore::ElementAndTextDescendantIterator::traversePreviousSibling):
* dom/ElementDescendantIterator.h:
(WebCore::ElementDescendantIterator::ElementDescendantIterator):
(WebCore::ElementDescendantIterator::dropAssertions):
(WebCore::ElementDescendantIterator::operator++):
(WebCore::ElementDescendantIterator::operator--):
(WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator):
(WebCore::ElementDescendantConstIterator::dropAssertions):
(WebCore::ElementDescendantConstIterator::operator++):
* dom/ElementIterator.h:
(WebCore::ElementIterator<ElementType>::ElementIterator):
(WebCore::ElementIterator<ElementType>::traverseNext):
(WebCore::ElementIterator<ElementType>::traversePrevious):
(WebCore::ElementIterator<ElementType>::traverseNextSibling):
(WebCore::ElementIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementIterator<ElementType>::dropAssertions):
(WebCore::ElementIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::ElementConstIterator):
(WebCore::ElementConstIterator<ElementType>::traverseNext):
(WebCore::ElementConstIterator<ElementType>::traversePrevious):
(WebCore::ElementConstIterator<ElementType>::traverseNextSibling):
(WebCore::ElementConstIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementConstIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::dropAssertions):
* dom/EventContext.cpp:
* dom/EventContext.h:
* dom/EventListener.h:
* dom/EventPath.cpp:
* dom/EventSender.h:
* dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
(WebCore::EventTarget::setAttributeEventListener):
(WebCore::EventTarget::innerInvokeEventListeners):
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::moveNodeToNewDocument):
(WebCore::Node::removedLastRef):
* dom/Node.h:
(WebCore::Node::deref const):
* dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
* dom/ScriptExecutionContext.h:
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute const):
* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::removeSlotElementByName):
(WebCore::SlotAssignment::resolveSlotsAfterSlotMutation):
(WebCore::SlotAssignment::findFirstSlotElement):
* dom/SlotAssignment.h:
* dom/TreeScopeOrderedMap.cpp:
(WebCore::TreeScopeOrderedMap::add):
(WebCore::TreeScopeOrderedMap::get const):
* dom/TreeScopeOrderedMap.h:
* fileapi/Blob.cpp:
* fileapi/Blob.h:
* history/BackForwardCache.cpp:
(WebCore::BackForwardCache::removeAllItemsForPage):
* history/BackForwardCache.h:
* html/CanvasBase.cpp:
(WebCore::CanvasBase::notifyObserversCanvasDestroyed):
* html/CanvasBase.h:
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::didPopulate):
* html/HTMLSelectElement.cpp:
(WebCore:: const):
* html/HTMLTableRowsCollection.cpp:
(WebCore::assertRowIsInTable):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForPosition const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
* html/parser/HTMLParserScheduler.cpp:
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
(WebCore::HTMLParserScheduler::suspend):
(WebCore::HTMLParserScheduler::resume):
* html/parser/HTMLParserScheduler.h:
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::endAttribute):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::constructTree):
* html/parser/HTMLTreeBuilder.h:
(WebCore::HTMLTreeBuilder::~HTMLTreeBuilder):
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::geometryForBox const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
* layout/blockformatting/BlockFormattingContext.h:
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setTopLeft):
(WebCore::Display::Box::setTop):
(WebCore::Display::Box::setLeft):
(WebCore::Display::Box::setContentBoxHeight):
(WebCore::Display::Box::setContentBoxWidth):
(WebCore::Display::Box::setHorizontalMargin):
(WebCore::Display::Box::setVerticalMargin):
(WebCore::Display::Box::setHorizontalComputedMargin):
(WebCore::Display::Box::setBorder):
(WebCore::Display::Box::setPadding):
* layout/displaytree/DisplayInlineRect.h:
(WebCore::Display::InlineRect::InlineRect):
(WebCore::Display::InlineRect::setTopLeft):
(WebCore::Display::InlineRect::setTop):
(WebCore::Display::InlineRect::setBottom):
(WebCore::Display::InlineRect::setLeft):
(WebCore::Display::InlineRect::setWidth):
(WebCore::Display::InlineRect::setHeight):
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::LineBox):
(WebCore::Display::LineBox::setBaselineOffsetIfGreater):
(WebCore::Display::LineBox::resetBaseline):
(WebCore::Display::LineBox::Baseline::Baseline):
(WebCore::Display::LineBox::Baseline::setAscent):
(WebCore::Display::LineBox::Baseline::setDescent):
(WebCore::Display::LineBox::Baseline::reset):
* layout/displaytree/DisplayRect.h:
(WebCore::Display::Rect::Rect):
(WebCore::Display::Rect::setTopLeft):
(WebCore::Display::Rect::setTop):
(WebCore::Display::Rect::setLeft):
(WebCore::Display::Rect::setWidth):
(WebCore::Display::Rect::setHeight):
(WebCore::Display::Rect::setSize):
(WebCore::Display::Rect::clone const):
* layout/floats/FloatingContext.cpp:
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::CollapsibleContent::collapse):
* layout/tableformatting/TableGrid.cpp:
(WebCore::Layout::TableGrid::Column::setWidthConstraints):
(WebCore::Layout::TableGrid::Column::setLogicalWidth):
(WebCore::Layout::TableGrid::Column::setLogicalLeft):
* layout/tableformatting/TableGrid.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::attachToFrame):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::addSubresourceLoader):
* loader/DocumentLoader.h:
* loader/ImageLoader.cpp:
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::lruListFor):
(WebCore::MemoryCache::removeFromLRUList):
* page/FrameView.cpp:
(WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
* page/FrameViewLayoutContext.cpp:
* page/FrameViewLayoutContext.h:
* page/Page.cpp:
* page/Page.h:
* page/ViewportConfiguration.cpp:
* page/ViewportConfiguration.h:
* page/mac/EventHandlerMac.mm:
(WebCore::CurrentEventScope::CurrentEventScope):
* platform/DateComponents.cpp:
(WebCore::DateComponents::toStringForTime const):
* platform/ScrollableArea.cpp:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::combineIntoOneSegment const):
* platform/SharedBuffer.h:
* platform/Supplementable.h:
* platform/Timer.cpp:
(WebCore::TimerBase::checkHeapIndex const):
(WebCore::TimerBase::updateHeapIfNeeded):
* platform/graphics/BitmapImage.cpp:
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::ScratchBuffer):
(WebCore::ScratchBuffer::getScratchBuffer):
(WebCore::ScratchBuffer::scheduleScratchBufferPurge):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::setWindow):
* platform/graphics/ca/win/CACFLayerTreeHost.h:
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
* platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp:
(gstAllocatorFastMallocFree):
* platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp:
(Nicosia::PaintingContextCairo::ForPainting::ForPainting):
* platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp:
(Nicosia::BackingStoreTextureMapperImpl::createTile):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp:
(Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::fill):
* platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::appendGeometry):
(WebCore::Path::Path):
(WebCore::Path::operator=):
(WebCore::Path::strokeContains const):
(WebCore::Path::transform):
* platform/graphics/win/PlatformContextDirect2D.cpp:
(WebCore::PlatformContextDirect2D::setTags):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource):
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource):
* platform/network/HTTPParsers.cpp:
(WebCore::isCrossOriginSafeHeader):
* platform/sql/SQLiteDatabase.cpp:
* platform/sql/SQLiteDatabase.h:
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::SQLiteStatement):
(WebCore::SQLiteStatement::prepare):
(WebCore::SQLiteStatement::finalize):
* platform/sql/SQLiteStatement.h:
* platform/win/COMPtr.h:
* rendering/ComplexLineLayout.cpp:
(WebCore::ComplexLineLayout::removeInlineBox const):
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::FloatingObject):
(WebCore::FloatingObjects::addPlacedObject):
(WebCore::FloatingObjects::removePlacedObject):
* rendering/FloatingObjects.h:
* rendering/GridTrackSizingAlgorithm.cpp:
* rendering/GridTrackSizingAlgorithm.h:
* rendering/LayoutDisallowedScope.cpp:
* rendering/LayoutDisallowedScope.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlockChild):
(WebCore::RenderBlockFlow::removeFloatingObject):
(WebCore::RenderBlockFlow::ensureLineBoxes):
* rendering/RenderBoxModelObject.cpp:
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
* rendering/RenderElement.cpp:
* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::baselinePosition const):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):
* rendering/RenderLayer.cpp:
(WebCore::ClipRectsCache::ClipRectsCache):
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::updateClipRects):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::traverseVisibleNonCompositedDescendantLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const):
(WebCore::RenderLayerCompositor::recursiveRepaintLayer):
(WebCore::RenderLayerCompositor::layerHas3DContent const):
* rendering/RenderLayoutState.cpp:
(WebCore::RenderLayoutState::RenderLayoutState):
(WebCore::RenderLayoutState::computeOffsets):
(WebCore::RenderLayoutState::addLayoutDelta):
* rendering/RenderLayoutState.h:
(WebCore::RenderLayoutState::RenderLayoutState):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::RenderObject):
(WebCore::RenderObject::~RenderObject):
(WebCore::RenderObject::clearNeedsLayout):
* rendering/RenderObject.h:
* rendering/RenderQuote.cpp:
(WebCore::quotesForLanguage):
* rendering/RenderTableCell.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::computeOverflowFromCells):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::checkConsistency const):
* rendering/RenderTextLineBoxes.h:
* rendering/line/BreakingContext.h:
(WebCore::tryHyphenating):
* rendering/style/GridArea.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::~RenderStyle):
* rendering/style/RenderStyle.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::detach):
* rendering/updating/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):
* rendering/updating/RenderTreePosition.h:
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
(WebCore::SVGToOTFFontConverter::Placeholder::populate):
(WebCore::SVGToOTFFontConverter::appendCFFTable):
(WebCore::SVGToOTFFontConverter::firstGlyph const):
(WebCore::SVGToOTFFontConverter::appendKERNTable):
* svg/SVGTransformDistance.cpp:
(WebCore::SVGTransformDistance::SVGTransformDistance):
(WebCore::SVGTransformDistance::scaledDistance const):
(WebCore::SVGTransformDistance::addSVGTransforms):
(WebCore::SVGTransformDistance::addToSVGTransform const):
(WebCore::SVGTransformDistance::distance const):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
* testing/InternalSettings.cpp:
* workers/service/ServiceWorkerJob.h:
* worklets/PaintWorkletGlobalScope.h:
(WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope):
* xml/XPathStep.cpp:
Source/WebKit:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::invalidateAndCancel):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::setCapacity):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toNSURLSessionResponseDisposition):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* Platform/IPC/Connection.cpp:
(IPC::Connection::waitForMessage):
* Platform/IPC/MessageReceiver.h:
(IPC::MessageReceiver::willBeAddedToMessageReceiverMap):
(IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap):
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::readFromMachPort):
* Platform/mac/MachUtilities.cpp:
(setMachExceptionPort):
* Shared/API/APIClient.h:
(API::Client::Client):
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
* Shared/Cocoa/ArgumentCodersCocoa.h:
* Shared/SharedStringHashTableReadOnly.cpp:
* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/GenericCallback.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/PageLoadState.h:
(WebKit::PageLoadState::Transaction::Token::Token):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::~WebPageProxy):
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponse):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
(WebKit::NetscapePluginStream::notifyAndDestroyStream):
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runModal):
* WebProcess/WebProcess.cpp:
(WebKit::checkDocumentsCaptureStateConsistency):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateProcessName):
Source/WebKitLegacy:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Storage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::StorageAreaImpl):
(WebKit::StorageAreaImpl::close):
* Storage/StorageAreaImpl.h:
Source/WebKitLegacy/mac:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* History/WebHistory.mm:
(-[WebHistoryPrivate removeItemForURLString:]):
* WebView/WebFrame.mm:
Source/WebKitLegacy/win:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::CAD3DRenderer::swapChain):
(WKQCA::CAD3DRenderer::initialize):
* WebKitQuartzCoreAdditions/CAD3DRenderer.h:
* WebView.cpp:
(WebView::Release):
* WebView.h:
Source/WTF:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
This patch did the following changes:
1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away
with the need for the double negative !ASSERT_DISABLED test that is commonly
used all over the code, thereby improving code readability.
In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED,
ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and
RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents
as well. We'll do that in another patch. For now, they are left as is to
minimize the size of this patch.
See https://bugs.webkit.org/show_bug.cgi?id=205780.
2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be
guarded by "#if ASSERT_ENABLED" instead.
3. In cases where the change is minimal, we move some code around so that we can
test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED".
* wtf/Assertions.h:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/BitVector.h:
* wtf/BlockObjCExceptions.mm:
(ReportBlockedObjCException):
* wtf/BloomFilter.h:
* wtf/CallbackAggregator.h:
(WTF::CallbackAggregator::CallbackAggregator):
* wtf/CheckedArithmetic.h:
(WTF::observesOverflow<AssertNoOverflow>):
* wtf/CheckedBoolean.h:
(CheckedBoolean::CheckedBoolean):
(CheckedBoolean::operator bool):
* wtf/CompletionHandler.h:
(WTF::CompletionHandler<Out):
* wtf/DateMath.cpp:
(WTF::initializeDates):
* wtf/Gigacage.cpp:
(Gigacage::tryAllocateZeroedVirtualPages):
* wtf/HashTable.h:
(WTF::KeyTraits>::checkKey):
(WTF::KeyTraits>::checkTableConsistencyExceptSize const):
* wtf/LoggerHelper.h:
* wtf/NaturalLoops.h:
(WTF::NaturalLoops::headerOf const):
* wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):
* wtf/Platform.h:
* wtf/PtrTag.h:
* wtf/RefCounted.h:
(WTF::RefCountedBase::disableThreadingChecks):
(WTF::RefCountedBase::enableThreadingChecksGlobally):
(WTF::RefCountedBase::RefCountedBase):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):
* wtf/SingleRootGraph.h:
(WTF::SingleRootGraph::assertIsConsistent const):
* wtf/SizeLimits.cpp:
* wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* wtf/URLParser.cpp:
(WTF::URLParser::URLParser):
(WTF::URLParser::domainToASCII):
* wtf/ValueCheck.h:
* wtf/Vector.h:
(WTF::Malloc>::checkConsistency):
* wtf/WeakHashSet.h:
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::WeakPtrImpl):
(WTF::WeakPtrFactory::WeakPtrFactory):
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringImpl.h:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::reifyString const):
* wtf/text/StringBuilder.h:
* wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* wtf/text/StringHasher.h:
(WTF::StringHasher::addCharacters):
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:
Tools:
Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory
https://bugs.webkit.org/show_bug.cgi?id=205754
Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06
Reviewed by Youenn Fablet.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::websiteDataStore):
(WTR::TestController::platformAdjustContext):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
Canonical link: https://commits.webkit.org/218957@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
|
|
|
#if ASSERT_ENABLED
|
2019-08-07 20:35:11 +00:00
|
|
|
bool wasConstructedOnMainThread() const { return m_wasConstructedOnMainThread; }
|
|
|
|
#endif
|
|
|
|
|
2013-01-15 21:35:08 +00:00
|
|
|
private:
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
template<typename T> explicit WeakPtrImpl(T* ptr)
|
|
|
|
: m_ptr(static_cast<typename T::WeakValueType*>(ptr))
|
PerformanceTests:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* JetStream2/wasm/HashSet.cpp:
* StitchMarker/wtf/Assertions.h:
* StitchMarker/wtf/DateMath.cpp:
(WTF::initializeDates):
* StitchMarker/wtf/HashTable.h:
* StitchMarker/wtf/Hasher.h:
(WTF::StringHasher::addCharacters):
* StitchMarker/wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* StitchMarker/wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* StitchMarker/wtf/ValueCheck.h:
* StitchMarker/wtf/Vector.h:
(WTF::minCapacity>::checkConsistency):
* StitchMarker/wtf/text/AtomicStringImpl.cpp:
* StitchMarker/wtf/text/AtomicStringImpl.h:
* StitchMarker/wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* StitchMarker/wtf/text/StringImpl.h:
* StitchMarker/wtf/text/SymbolImpl.h:
* StitchMarker/wtf/text/UniquedStringImpl.h:
Source/JavaScriptCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* API/tests/testapi.c:
* assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::replaceWithLoad):
(JSC::ARM64Assembler::replaceWithAddressComputation):
* assembler/AssemblerBuffer.h:
(JSC::AssemblerBuffer::LocalWriter::LocalWriter):
* assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::copyCompactAndLinkCode):
* assembler/ProbeStack.cpp:
(JSC::Probe::Stack::Stack):
* assembler/ProbeStack.h:
* b3/B3FoldPathConstants.cpp:
* b3/B3LowerToAir.cpp:
* b3/B3MemoryValue.cpp:
(JSC::B3::MemoryValue::MemoryValue):
* b3/B3Opcode.cpp:
* b3/B3Type.h:
* b3/B3TypeMap.h:
* b3/B3Width.h:
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp:
(JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration):
(JSC::B3::Air::GenerateAndAllocateRegisters::generate):
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.h:
* b3/air/AirAllocateRegistersByGraphColoring.cpp:
* b3/air/AirArg.cpp:
* b3/air/AirArg.h:
* b3/air/AirCode.h:
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* bytecode/AccessCase.cpp:
* bytecode/AccessCase.h:
* bytecode/CallVariant.cpp:
(JSC::variantListWithVariant):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex):
* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::dump const):
* bytecode/StructureStubInfo.cpp:
* bytecode/StructureStubInfo.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionCallResolveNode::emitBytecode):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::RegisterID):
(JSC::RegisterID::setIndex):
* debugger/Debugger.cpp:
(JSC::Debugger::removeBreakpoint):
* debugger/DebuggerEvalEnabler.h:
(JSC::DebuggerEvalEnabler::DebuggerEvalEnabler):
(JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions):
* dfg/DFGAbstractValue.cpp:
* dfg/DFGAbstractValue.h:
(JSC::DFG::AbstractValue::merge):
(JSC::DFG::AbstractValue::checkConsistency const):
(JSC::DFG::AbstractValue::assertIsRegistered const):
* dfg/DFGArithMode.h:
(JSC::DFG::doesOverflow):
* dfg/DFGBasicBlock.cpp:
(JSC::DFG::BasicBlock::BasicBlock):
* dfg/DFGBasicBlock.h:
(JSC::DFG::BasicBlock::didLink):
* dfg/DFGCFAPhase.cpp:
(JSC::DFG::CFAPhase::performBlockCFA):
* dfg/DFGCommon.h:
(JSC::DFG::validationEnabled):
* dfg/DFGCommonData.cpp:
(JSC::DFG::CommonData::finalizeCatchEntrypoints):
* dfg/DFGDesiredWatchpoints.h:
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGEdge.h:
(JSC::DFG::Edge::makeWord):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::finalizeOSREntrypoints):
* dfg/DFGObjectAllocationSinkingPhase.cpp:
* dfg/DFGSSAConversionPhase.cpp:
(JSC::DFG::SSAConversionPhase::run):
* dfg/DFGScoreBoard.h:
(JSC::DFG::ScoreBoard::assertClear):
* dfg/DFGSlowPathGenerator.h:
(JSC::DFG::SlowPathGenerator::generate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
(JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse):
(JSC::DFG::SpeculativeJIT::emitAllocateButterfly):
(JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize):
(JSC::DFG::SpeculativeJIT::compileMakeRope):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
* dfg/DFGStructureAbstractValue.cpp:
* dfg/DFGStructureAbstractValue.h:
(JSC::DFG::StructureAbstractValue::assertIsRegistered const):
* dfg/DFGVarargsForwardingPhase.cpp:
* dfg/DFGVirtualRegisterAllocationPhase.cpp:
(JSC::DFG::VirtualRegisterAllocationPhase::run):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::callPreflight):
(JSC::FTL::DFG::LowerDFGToB3::callCheck):
(JSC::FTL::DFG::LowerDFGToB3::crash):
* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::assertNoUnswept):
* heap/GCSegmentedArray.h:
(JSC::GCArraySegment::GCArraySegment):
* heap/GCSegmentedArrayInlines.h:
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::validatePrevious):
* heap/HandleSet.cpp:
* heap/HandleSet.h:
* heap/Heap.cpp:
(JSC::Heap::updateAllocationLimits):
* heap/Heap.h:
* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::assertValidCell const):
(JSC::MarkedBlock::assertMarksNotStale):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::beginMarking):
(JSC::MarkedSpace::endMarking):
(JSC::MarkedSpace::assertNoUnswept):
* heap/PreciseAllocation.cpp:
* heap/PreciseAllocation.h:
(JSC::PreciseAllocation::assertValidCell const):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::appendJSCellOrAuxiliary):
* heap/SlotVisitor.h:
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
(CppProtocolTypesImplementationGenerator):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* interpreter/FrameTracers.h:
(JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::Interpreter):
* interpreter/Interpreter.h:
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::prepareCallOperation):
* jit/BinarySwitch.cpp:
(JSC::BinarySwitch::BinarySwitch):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupStubArgs):
* jit/CallFrameShuffler.cpp:
(JSC::CallFrameShuffler::emitDeltaCheck):
(JSC::CallFrameShuffler::prepareAny):
* jit/JIT.cpp:
(JSC::JIT::assertStackPointerOffset):
(JSC::JIT::compileWithoutLinking):
* jit/JITOpcodes.cpp:
(JSC::JIT::emitSlow_op_loop_hint):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
* jit/ThunkGenerators.cpp:
(JSC::emitPointerValidation):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LLIntOfflineAsmConfig.h:
* parser/Lexer.cpp:
* parser/Lexer.h:
(JSC::isSafeBuiltinIdentifier):
(JSC::Lexer<T>::lexExpectIdentifier):
* runtime/ArgList.h:
(JSC::MarkedArgumentBuffer::setNeedsOverflowCheck):
(JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck):
* runtime/Butterfly.h:
(JSC::ContiguousData::ContiguousData):
(JSC::ContiguousData::Data::Data):
* runtime/HashMapImpl.h:
(JSC::HashMapImpl::checkConsistency const):
(JSC::HashMapImpl::assertBufferIsEmpty const):
* runtime/JSCellInlines.h:
(JSC::JSCell::methodTable const):
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
(JSC::JSFunction::assertTypeInfoFlagInvariants):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren):
(JSC::JSFinalObject::visitChildren):
* runtime/JSObjectInlines.h:
(JSC::JSObject::validatePutOwnDataProperty):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::assertVariableIsInThisObject):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lex):
* runtime/LiteralParser.h:
* runtime/Operations.h:
(JSC::scribbleFreeCells):
* runtime/OptionsList.h:
* runtime/VM.cpp:
(JSC::VM::computeCanUseJIT):
* runtime/VM.h:
(JSC::VM::canUseJIT):
* runtime/VarOffset.h:
(JSC::VarOffset::checkSanity const):
* runtime/WeakMapImpl.h:
(JSC::WeakMapImpl::checkConsistency const):
(JSC::WeakMapImpl::assertBufferIsEmpty const):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::validateInst):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile):
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser::validationFail const):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::checkConsistency):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast):
* wasm/WasmSectionParser.h:
* wasm/WasmSections.h:
* wasm/WasmSignatureInlines.h:
(JSC::Wasm::SignatureInformation::get):
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::enqueue):
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::previousInstanceOffset const):
Source/WebCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::close):
* Modules/fetch/FetchBodySource.h:
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
(WebCore::DatabaseDetails::operator=):
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTask::performTask):
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::terminationRequested const):
* Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h:
(WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation):
* Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp:
(WebCore::WHLSL::findHighZombies):
* Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
(WebCore::WHLSL::matches):
* Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:
(WebCore::WHLSL::checkLiteralTypes):
* Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp:
(WebCore::WHLSL::FindAllTypes::appendNamedType):
* bindings/js/JSCallbackData.h:
* bindings/js/JSLazyEventListener.cpp:
* bindings/js/JSLazyEventListener.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcOperationNode::primitiveType const):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValue.cpp:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/CSSStyleSheet.cpp:
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::suspendIfNeeded):
(WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const):
* dom/ActiveDOMObject.h:
* dom/ContainerNode.cpp:
* dom/ContainerNodeAlgorithms.cpp:
* dom/ContainerNodeAlgorithms.h:
* dom/CustomElementReactionQueue.cpp:
* dom/CustomElementReactionQueue.h:
(WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope):
(WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope):
* dom/Document.cpp:
(WebCore::Document::hitTest):
* dom/Document.h:
(WebCore::Document::decrementReferencingNodeCount):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::getURLAttribute const):
(WebCore::Element::getNonEmptyURLAttribute const):
* dom/Element.h:
* dom/ElementAndTextDescendantIterator.h:
(WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator):
(WebCore::ElementAndTextDescendantIterator::dropAssertions):
(WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack):
(WebCore::ElementAndTextDescendantIterator::traverseNextSibling):
(WebCore::ElementAndTextDescendantIterator::traversePreviousSibling):
* dom/ElementDescendantIterator.h:
(WebCore::ElementDescendantIterator::ElementDescendantIterator):
(WebCore::ElementDescendantIterator::dropAssertions):
(WebCore::ElementDescendantIterator::operator++):
(WebCore::ElementDescendantIterator::operator--):
(WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator):
(WebCore::ElementDescendantConstIterator::dropAssertions):
(WebCore::ElementDescendantConstIterator::operator++):
* dom/ElementIterator.h:
(WebCore::ElementIterator<ElementType>::ElementIterator):
(WebCore::ElementIterator<ElementType>::traverseNext):
(WebCore::ElementIterator<ElementType>::traversePrevious):
(WebCore::ElementIterator<ElementType>::traverseNextSibling):
(WebCore::ElementIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementIterator<ElementType>::dropAssertions):
(WebCore::ElementIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::ElementConstIterator):
(WebCore::ElementConstIterator<ElementType>::traverseNext):
(WebCore::ElementConstIterator<ElementType>::traversePrevious):
(WebCore::ElementConstIterator<ElementType>::traverseNextSibling):
(WebCore::ElementConstIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementConstIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::dropAssertions):
* dom/EventContext.cpp:
* dom/EventContext.h:
* dom/EventListener.h:
* dom/EventPath.cpp:
* dom/EventSender.h:
* dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
(WebCore::EventTarget::setAttributeEventListener):
(WebCore::EventTarget::innerInvokeEventListeners):
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::moveNodeToNewDocument):
(WebCore::Node::removedLastRef):
* dom/Node.h:
(WebCore::Node::deref const):
* dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
* dom/ScriptExecutionContext.h:
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute const):
* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::removeSlotElementByName):
(WebCore::SlotAssignment::resolveSlotsAfterSlotMutation):
(WebCore::SlotAssignment::findFirstSlotElement):
* dom/SlotAssignment.h:
* dom/TreeScopeOrderedMap.cpp:
(WebCore::TreeScopeOrderedMap::add):
(WebCore::TreeScopeOrderedMap::get const):
* dom/TreeScopeOrderedMap.h:
* fileapi/Blob.cpp:
* fileapi/Blob.h:
* history/BackForwardCache.cpp:
(WebCore::BackForwardCache::removeAllItemsForPage):
* history/BackForwardCache.h:
* html/CanvasBase.cpp:
(WebCore::CanvasBase::notifyObserversCanvasDestroyed):
* html/CanvasBase.h:
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::didPopulate):
* html/HTMLSelectElement.cpp:
(WebCore:: const):
* html/HTMLTableRowsCollection.cpp:
(WebCore::assertRowIsInTable):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForPosition const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
* html/parser/HTMLParserScheduler.cpp:
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
(WebCore::HTMLParserScheduler::suspend):
(WebCore::HTMLParserScheduler::resume):
* html/parser/HTMLParserScheduler.h:
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::endAttribute):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::constructTree):
* html/parser/HTMLTreeBuilder.h:
(WebCore::HTMLTreeBuilder::~HTMLTreeBuilder):
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::geometryForBox const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
* layout/blockformatting/BlockFormattingContext.h:
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setTopLeft):
(WebCore::Display::Box::setTop):
(WebCore::Display::Box::setLeft):
(WebCore::Display::Box::setContentBoxHeight):
(WebCore::Display::Box::setContentBoxWidth):
(WebCore::Display::Box::setHorizontalMargin):
(WebCore::Display::Box::setVerticalMargin):
(WebCore::Display::Box::setHorizontalComputedMargin):
(WebCore::Display::Box::setBorder):
(WebCore::Display::Box::setPadding):
* layout/displaytree/DisplayInlineRect.h:
(WebCore::Display::InlineRect::InlineRect):
(WebCore::Display::InlineRect::setTopLeft):
(WebCore::Display::InlineRect::setTop):
(WebCore::Display::InlineRect::setBottom):
(WebCore::Display::InlineRect::setLeft):
(WebCore::Display::InlineRect::setWidth):
(WebCore::Display::InlineRect::setHeight):
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::LineBox):
(WebCore::Display::LineBox::setBaselineOffsetIfGreater):
(WebCore::Display::LineBox::resetBaseline):
(WebCore::Display::LineBox::Baseline::Baseline):
(WebCore::Display::LineBox::Baseline::setAscent):
(WebCore::Display::LineBox::Baseline::setDescent):
(WebCore::Display::LineBox::Baseline::reset):
* layout/displaytree/DisplayRect.h:
(WebCore::Display::Rect::Rect):
(WebCore::Display::Rect::setTopLeft):
(WebCore::Display::Rect::setTop):
(WebCore::Display::Rect::setLeft):
(WebCore::Display::Rect::setWidth):
(WebCore::Display::Rect::setHeight):
(WebCore::Display::Rect::setSize):
(WebCore::Display::Rect::clone const):
* layout/floats/FloatingContext.cpp:
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::CollapsibleContent::collapse):
* layout/tableformatting/TableGrid.cpp:
(WebCore::Layout::TableGrid::Column::setWidthConstraints):
(WebCore::Layout::TableGrid::Column::setLogicalWidth):
(WebCore::Layout::TableGrid::Column::setLogicalLeft):
* layout/tableformatting/TableGrid.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::attachToFrame):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::addSubresourceLoader):
* loader/DocumentLoader.h:
* loader/ImageLoader.cpp:
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::lruListFor):
(WebCore::MemoryCache::removeFromLRUList):
* page/FrameView.cpp:
(WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
* page/FrameViewLayoutContext.cpp:
* page/FrameViewLayoutContext.h:
* page/Page.cpp:
* page/Page.h:
* page/ViewportConfiguration.cpp:
* page/ViewportConfiguration.h:
* page/mac/EventHandlerMac.mm:
(WebCore::CurrentEventScope::CurrentEventScope):
* platform/DateComponents.cpp:
(WebCore::DateComponents::toStringForTime const):
* platform/ScrollableArea.cpp:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::combineIntoOneSegment const):
* platform/SharedBuffer.h:
* platform/Supplementable.h:
* platform/Timer.cpp:
(WebCore::TimerBase::checkHeapIndex const):
(WebCore::TimerBase::updateHeapIfNeeded):
* platform/graphics/BitmapImage.cpp:
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::ScratchBuffer):
(WebCore::ScratchBuffer::getScratchBuffer):
(WebCore::ScratchBuffer::scheduleScratchBufferPurge):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::setWindow):
* platform/graphics/ca/win/CACFLayerTreeHost.h:
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
* platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp:
(gstAllocatorFastMallocFree):
* platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp:
(Nicosia::PaintingContextCairo::ForPainting::ForPainting):
* platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp:
(Nicosia::BackingStoreTextureMapperImpl::createTile):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp:
(Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::fill):
* platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::appendGeometry):
(WebCore::Path::Path):
(WebCore::Path::operator=):
(WebCore::Path::strokeContains const):
(WebCore::Path::transform):
* platform/graphics/win/PlatformContextDirect2D.cpp:
(WebCore::PlatformContextDirect2D::setTags):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource):
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource):
* platform/network/HTTPParsers.cpp:
(WebCore::isCrossOriginSafeHeader):
* platform/sql/SQLiteDatabase.cpp:
* platform/sql/SQLiteDatabase.h:
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::SQLiteStatement):
(WebCore::SQLiteStatement::prepare):
(WebCore::SQLiteStatement::finalize):
* platform/sql/SQLiteStatement.h:
* platform/win/COMPtr.h:
* rendering/ComplexLineLayout.cpp:
(WebCore::ComplexLineLayout::removeInlineBox const):
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::FloatingObject):
(WebCore::FloatingObjects::addPlacedObject):
(WebCore::FloatingObjects::removePlacedObject):
* rendering/FloatingObjects.h:
* rendering/GridTrackSizingAlgorithm.cpp:
* rendering/GridTrackSizingAlgorithm.h:
* rendering/LayoutDisallowedScope.cpp:
* rendering/LayoutDisallowedScope.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlockChild):
(WebCore::RenderBlockFlow::removeFloatingObject):
(WebCore::RenderBlockFlow::ensureLineBoxes):
* rendering/RenderBoxModelObject.cpp:
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
* rendering/RenderElement.cpp:
* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::baselinePosition const):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):
* rendering/RenderLayer.cpp:
(WebCore::ClipRectsCache::ClipRectsCache):
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::updateClipRects):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::traverseVisibleNonCompositedDescendantLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const):
(WebCore::RenderLayerCompositor::recursiveRepaintLayer):
(WebCore::RenderLayerCompositor::layerHas3DContent const):
* rendering/RenderLayoutState.cpp:
(WebCore::RenderLayoutState::RenderLayoutState):
(WebCore::RenderLayoutState::computeOffsets):
(WebCore::RenderLayoutState::addLayoutDelta):
* rendering/RenderLayoutState.h:
(WebCore::RenderLayoutState::RenderLayoutState):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::RenderObject):
(WebCore::RenderObject::~RenderObject):
(WebCore::RenderObject::clearNeedsLayout):
* rendering/RenderObject.h:
* rendering/RenderQuote.cpp:
(WebCore::quotesForLanguage):
* rendering/RenderTableCell.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::computeOverflowFromCells):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::checkConsistency const):
* rendering/RenderTextLineBoxes.h:
* rendering/line/BreakingContext.h:
(WebCore::tryHyphenating):
* rendering/style/GridArea.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::~RenderStyle):
* rendering/style/RenderStyle.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::detach):
* rendering/updating/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):
* rendering/updating/RenderTreePosition.h:
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
(WebCore::SVGToOTFFontConverter::Placeholder::populate):
(WebCore::SVGToOTFFontConverter::appendCFFTable):
(WebCore::SVGToOTFFontConverter::firstGlyph const):
(WebCore::SVGToOTFFontConverter::appendKERNTable):
* svg/SVGTransformDistance.cpp:
(WebCore::SVGTransformDistance::SVGTransformDistance):
(WebCore::SVGTransformDistance::scaledDistance const):
(WebCore::SVGTransformDistance::addSVGTransforms):
(WebCore::SVGTransformDistance::addToSVGTransform const):
(WebCore::SVGTransformDistance::distance const):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
* testing/InternalSettings.cpp:
* workers/service/ServiceWorkerJob.h:
* worklets/PaintWorkletGlobalScope.h:
(WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope):
* xml/XPathStep.cpp:
Source/WebKit:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::invalidateAndCancel):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::setCapacity):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toNSURLSessionResponseDisposition):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* Platform/IPC/Connection.cpp:
(IPC::Connection::waitForMessage):
* Platform/IPC/MessageReceiver.h:
(IPC::MessageReceiver::willBeAddedToMessageReceiverMap):
(IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap):
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::readFromMachPort):
* Platform/mac/MachUtilities.cpp:
(setMachExceptionPort):
* Shared/API/APIClient.h:
(API::Client::Client):
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
* Shared/Cocoa/ArgumentCodersCocoa.h:
* Shared/SharedStringHashTableReadOnly.cpp:
* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/GenericCallback.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/PageLoadState.h:
(WebKit::PageLoadState::Transaction::Token::Token):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::~WebPageProxy):
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponse):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
(WebKit::NetscapePluginStream::notifyAndDestroyStream):
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runModal):
* WebProcess/WebProcess.cpp:
(WebKit::checkDocumentsCaptureStateConsistency):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateProcessName):
Source/WebKitLegacy:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Storage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::StorageAreaImpl):
(WebKit::StorageAreaImpl::close):
* Storage/StorageAreaImpl.h:
Source/WebKitLegacy/mac:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* History/WebHistory.mm:
(-[WebHistoryPrivate removeItemForURLString:]):
* WebView/WebFrame.mm:
Source/WebKitLegacy/win:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::CAD3DRenderer::swapChain):
(WKQCA::CAD3DRenderer::initialize):
* WebKitQuartzCoreAdditions/CAD3DRenderer.h:
* WebView.cpp:
(WebView::Release):
* WebView.h:
Source/WTF:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
This patch did the following changes:
1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away
with the need for the double negative !ASSERT_DISABLED test that is commonly
used all over the code, thereby improving code readability.
In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED,
ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and
RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents
as well. We'll do that in another patch. For now, they are left as is to
minimize the size of this patch.
See https://bugs.webkit.org/show_bug.cgi?id=205780.
2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be
guarded by "#if ASSERT_ENABLED" instead.
3. In cases where the change is minimal, we move some code around so that we can
test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED".
* wtf/Assertions.h:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/BitVector.h:
* wtf/BlockObjCExceptions.mm:
(ReportBlockedObjCException):
* wtf/BloomFilter.h:
* wtf/CallbackAggregator.h:
(WTF::CallbackAggregator::CallbackAggregator):
* wtf/CheckedArithmetic.h:
(WTF::observesOverflow<AssertNoOverflow>):
* wtf/CheckedBoolean.h:
(CheckedBoolean::CheckedBoolean):
(CheckedBoolean::operator bool):
* wtf/CompletionHandler.h:
(WTF::CompletionHandler<Out):
* wtf/DateMath.cpp:
(WTF::initializeDates):
* wtf/Gigacage.cpp:
(Gigacage::tryAllocateZeroedVirtualPages):
* wtf/HashTable.h:
(WTF::KeyTraits>::checkKey):
(WTF::KeyTraits>::checkTableConsistencyExceptSize const):
* wtf/LoggerHelper.h:
* wtf/NaturalLoops.h:
(WTF::NaturalLoops::headerOf const):
* wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):
* wtf/Platform.h:
* wtf/PtrTag.h:
* wtf/RefCounted.h:
(WTF::RefCountedBase::disableThreadingChecks):
(WTF::RefCountedBase::enableThreadingChecksGlobally):
(WTF::RefCountedBase::RefCountedBase):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):
* wtf/SingleRootGraph.h:
(WTF::SingleRootGraph::assertIsConsistent const):
* wtf/SizeLimits.cpp:
* wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* wtf/URLParser.cpp:
(WTF::URLParser::URLParser):
(WTF::URLParser::domainToASCII):
* wtf/ValueCheck.h:
* wtf/Vector.h:
(WTF::Malloc>::checkConsistency):
* wtf/WeakHashSet.h:
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::WeakPtrImpl):
(WTF::WeakPtrFactory::WeakPtrFactory):
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringImpl.h:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::reifyString const):
* wtf/text/StringBuilder.h:
* wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* wtf/text/StringHasher.h:
(WTF::StringHasher::addCharacters):
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:
Tools:
Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory
https://bugs.webkit.org/show_bug.cgi?id=205754
Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06
Reviewed by Youenn Fablet.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::websiteDataStore):
(WTR::TestController::platformAdjustContext):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
Canonical link: https://commits.webkit.org/218957@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
|
|
|
#if ASSERT_ENABLED
|
2019-08-01 18:38:40 +00:00
|
|
|
, m_wasConstructedOnMainThread(isMainThread())
|
|
|
|
#endif
|
2013-01-15 21:35:08 +00:00
|
|
|
{
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
Counter::increment();
|
2013-01-15 21:35:08 +00:00
|
|
|
}
|
|
|
|
|
WeakPtr breaks vtables when upcasting to base classes
https://bugs.webkit.org/show_bug.cgi?id=188799
Reviewed by Youenn Fablet.
Source/WebCore:
* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::MediaKeySession):
* Modules/encryptedmedia/MediaKeySession.h: Adopted modern WeakPtr APIs.
Removed redundant WeakPtrFactory.
* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::existingWrapper):
* css/CSSFontFace.h: Moved functions out of line to avoid #include
explosion for .get().
* dom/ContainerNode.h:
* dom/Document.h:
* dom/Element.h: Moved CanMakeWeakPtr to ContainerNode because all
subclasses except for DocumentFragment were already so, and we have
code that uses WeakPtr<ContainerNode>, which, now that WeakPtr is
type-safe, is awkward to do when ContainerNode isn't CanMakeWeakPtr.
* dom/FullscreenManager.cpp:
(WebCore::FullscreenManager::fullscreenRenderer const):
* dom/FullscreenManager.h:
(WebCore::FullscreenManager::fullscreenRenderer const): Deleted.
* html/FormAssociatedElement.cpp:
(WebCore::FormAssociatedElement::form const):
* html/FormAssociatedElement.h:
(WebCore::FormAssociatedElement::form const): Deleted. Moved functions
out of line to avoid #include explosion for .get().
* html/HTMLMediaElement.h: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
* loader/MediaResourceLoader.cpp:
(WebCore::MediaResourceLoader::requestResource): Removed redundant .get().
* page/DOMWindowProperty.cpp:
(WebCore::DOMWindowProperty::window const):
* page/DOMWindowProperty.h:
(WebCore::DOMWindowProperty::window const): Deleted.
* page/FrameViewLayoutContext.cpp:
(WebCore::FrameViewLayoutContext::subtreeLayoutRoot const):
* page/FrameViewLayoutContext.h:
(WebCore::FrameViewLayoutContext::subtreeLayoutRoot const): Deleted.
* page/UndoItem.cpp:
(WebCore::UndoItem::undoManager const):
* page/UndoItem.h:
(WebCore::UndoItem::undoManager const): Deleted. Moved functions out of
line to avoid #include explosion for .get().
* platform/ScrollView.h: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
* platform/Widget.cpp:
(WebCore::Widget::parent const):
* platform/Widget.h:
(WebCore::Widget::parent const): Deleted. Moved functions out of line to avoid #include
explosion for .get().
* platform/encryptedmedia/CDMInstanceSession.h: Made
CDMInstanceSessionClient CanMakeWeakPtr because we use WeakPtr<CDMInstanceSessionClient>.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
CanMakeWeakPtr is inherited now.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
(WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const): Deleted.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createWeakPtr): Deleted.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::CMTimebaseEffectiveRateChangedCallback):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::durationChanged):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled):
(WebCore::SourceBufferPrivateAVFObjC::setCDMSession):
(WebCore::SourceBufferPrivateAVFObjC::flushVideo):
(WebCore::SourceBufferPrivateAVFObjC::enqueueSample):
(WebCore::SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples):
(WebCore::SourceBufferPrivateAVFObjC::setVideoLayer):
(WebCore::SourceBufferPrivateAVFObjC::setDecompressionSession): Modernized WeakPtr API usage.
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::multiColumnFlowSlowCase const):
* rendering/RenderBlockFlow.h:
(WebCore::RenderBlockFlow::multiColumnFlow const):
* rendering/RenderMultiColumnFlow.cpp:
(WebCore::RenderMultiColumnFlow::findColumnSpannerPlaceholder const):
* rendering/RenderMultiColumnFlow.h:
* rendering/RenderTable.cpp:
(WebCore::RenderTable::header const):
(WebCore::RenderTable::footer const):
(WebCore::RenderTable::firstBody const):
(WebCore::RenderTable::topSection const):
* rendering/RenderTable.h:
(WebCore::RenderTable::header const): Deleted.
(WebCore::RenderTable::footer const): Deleted.
(WebCore::RenderTable::firstBody const): Deleted.
(WebCore::RenderTable::topSection const): Deleted. Moved functions out
of line to avoid #include explosion for .get().
Source/WebKit:
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::networkSession):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* Shared/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::suspendedPage const):
* Shared/WebBackForwardListItem.h:
(WebKit::WebBackForwardListItem::suspendedPage const): Deleted. Moved
functions out of line to avoid #include explosion for .get().
* UIProcess/Authentication/cocoa/SecKeyProxyStore.h:
(WebKit::SecKeyProxyStore::get const):
(WebKit::SecKeyProxyStore::weakPtrFactory const): Deleted. Adopted
CanMakeWeakPtr.
* UIProcess/WebAuthentication/AuthenticatorManager.h:
* UIProcess/WebProcessProxy.cpp: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
(WebKit::WebProcessProxy::processPool const):
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::processPool const): Deleted. Moved
functions out of line to avoid #include explosion for .get().
Source/WTF:
This patch switches from reinterpret_cast to static_cast when loading
from WeakReference storage.
We know which type to cast *to* because it's specified by the type of
the calling WeakPtr.
We know which type to cast *from* because it's specified by a typedef
in CanMakeWeakPtr.
(Our convention is that we store a pointer to the class that derives
from CanMakeWeakPtr. We cast from that pointer to derived pointers when
we get(). This means that #include of the derived type header is now
required in order to get() the pointer.)
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Definition
is now eagerly required because WeakReference is not a template anymore.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const):
(WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computesEmpty const):
(WTF::WeakHashSet::hasNullReferences const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference<T>>>::isReleasedWeakValue): Deleted.
Updated for new WeakReference get() API.
* wtf/WeakPtr.h: Use a macro for TestAPI support. We can't use template
specialization because WeakReference is not a class template anymore.
(Or maybe we could have kept it working with a dummy template argument?
Felt weird, so I switched.)
(WTF::WeakReference::create):
(WTF::WeakReference::~WeakReference):
(WTF::WeakReference::get const):
(WTF::WeakReference::operator bool const):
(WTF::WeakReference::WeakReference): WeakReference is just a void* now.
It's the caller's responsibility, when creating and getting, to use
a consistent storage type. We ensure a canonical storage type using a
typedef inside CanMakeWeakPtr.
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const): Adopted new WeakReference API.
(WTF::WeakPtrFactory::createWeakPtr const): No need for reinterpret_cast.
(WTF::weak_reference_cast): This isn't required for correctness, but it's
nice to show a complier error at WeakPtr construction sites when you know
that the types won't work. Otherwise, you get compiler errors at
dereference sites, which are slightly more mysterious ways of saying that
you constructed your WeakPtr incorrectly.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::weak_reference_upcast): Deleted.
(WTF::weak_reference_downcast): Deleted.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Adopt the new macro API instead
of template specialization for observing weak references.
(TestWebKitAPI::Int::Int):
(TestWebKitAPI::Int::operator int const):
(TestWebKitAPI::Int::operator== const): Use a class for integer tests
because WeakPtr doesn't naturally support pointing to non-class objects
now.
(TestWebKitAPI::Base::foo):
(TestWebKitAPI::Derived::foo): Inherit from CanMakeWeakPtr to enable
deduction of the weak pointer type.
(TestWebKitAPI::TEST): Updated to use Int.
(TestWebKitAPI::Base::weakPtrFactory const): Deleted.
(WTF::WeakReference<TestWebKitAPI::Base>::WeakReference): Deleted.
(WTF::WeakReference<TestWebKitAPI::Base>::~WeakReference): Deleted.
Canonical link: https://commits.webkit.org/212376@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-29 21:15:54 +00:00
|
|
|
void* m_ptr;
|
PerformanceTests:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* JetStream2/wasm/HashSet.cpp:
* StitchMarker/wtf/Assertions.h:
* StitchMarker/wtf/DateMath.cpp:
(WTF::initializeDates):
* StitchMarker/wtf/HashTable.h:
* StitchMarker/wtf/Hasher.h:
(WTF::StringHasher::addCharacters):
* StitchMarker/wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* StitchMarker/wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* StitchMarker/wtf/ValueCheck.h:
* StitchMarker/wtf/Vector.h:
(WTF::minCapacity>::checkConsistency):
* StitchMarker/wtf/text/AtomicStringImpl.cpp:
* StitchMarker/wtf/text/AtomicStringImpl.h:
* StitchMarker/wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* StitchMarker/wtf/text/StringImpl.h:
* StitchMarker/wtf/text/SymbolImpl.h:
* StitchMarker/wtf/text/UniquedStringImpl.h:
Source/JavaScriptCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* API/tests/testapi.c:
* assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::replaceWithLoad):
(JSC::ARM64Assembler::replaceWithAddressComputation):
* assembler/AssemblerBuffer.h:
(JSC::AssemblerBuffer::LocalWriter::LocalWriter):
* assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::copyCompactAndLinkCode):
* assembler/ProbeStack.cpp:
(JSC::Probe::Stack::Stack):
* assembler/ProbeStack.h:
* b3/B3FoldPathConstants.cpp:
* b3/B3LowerToAir.cpp:
* b3/B3MemoryValue.cpp:
(JSC::B3::MemoryValue::MemoryValue):
* b3/B3Opcode.cpp:
* b3/B3Type.h:
* b3/B3TypeMap.h:
* b3/B3Width.h:
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp:
(JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration):
(JSC::B3::Air::GenerateAndAllocateRegisters::generate):
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.h:
* b3/air/AirAllocateRegistersByGraphColoring.cpp:
* b3/air/AirArg.cpp:
* b3/air/AirArg.h:
* b3/air/AirCode.h:
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* bytecode/AccessCase.cpp:
* bytecode/AccessCase.h:
* bytecode/CallVariant.cpp:
(JSC::variantListWithVariant):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex):
* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::dump const):
* bytecode/StructureStubInfo.cpp:
* bytecode/StructureStubInfo.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionCallResolveNode::emitBytecode):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::RegisterID):
(JSC::RegisterID::setIndex):
* debugger/Debugger.cpp:
(JSC::Debugger::removeBreakpoint):
* debugger/DebuggerEvalEnabler.h:
(JSC::DebuggerEvalEnabler::DebuggerEvalEnabler):
(JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions):
* dfg/DFGAbstractValue.cpp:
* dfg/DFGAbstractValue.h:
(JSC::DFG::AbstractValue::merge):
(JSC::DFG::AbstractValue::checkConsistency const):
(JSC::DFG::AbstractValue::assertIsRegistered const):
* dfg/DFGArithMode.h:
(JSC::DFG::doesOverflow):
* dfg/DFGBasicBlock.cpp:
(JSC::DFG::BasicBlock::BasicBlock):
* dfg/DFGBasicBlock.h:
(JSC::DFG::BasicBlock::didLink):
* dfg/DFGCFAPhase.cpp:
(JSC::DFG::CFAPhase::performBlockCFA):
* dfg/DFGCommon.h:
(JSC::DFG::validationEnabled):
* dfg/DFGCommonData.cpp:
(JSC::DFG::CommonData::finalizeCatchEntrypoints):
* dfg/DFGDesiredWatchpoints.h:
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGEdge.h:
(JSC::DFG::Edge::makeWord):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::finalizeOSREntrypoints):
* dfg/DFGObjectAllocationSinkingPhase.cpp:
* dfg/DFGSSAConversionPhase.cpp:
(JSC::DFG::SSAConversionPhase::run):
* dfg/DFGScoreBoard.h:
(JSC::DFG::ScoreBoard::assertClear):
* dfg/DFGSlowPathGenerator.h:
(JSC::DFG::SlowPathGenerator::generate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
(JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse):
(JSC::DFG::SpeculativeJIT::emitAllocateButterfly):
(JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize):
(JSC::DFG::SpeculativeJIT::compileMakeRope):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
* dfg/DFGStructureAbstractValue.cpp:
* dfg/DFGStructureAbstractValue.h:
(JSC::DFG::StructureAbstractValue::assertIsRegistered const):
* dfg/DFGVarargsForwardingPhase.cpp:
* dfg/DFGVirtualRegisterAllocationPhase.cpp:
(JSC::DFG::VirtualRegisterAllocationPhase::run):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::callPreflight):
(JSC::FTL::DFG::LowerDFGToB3::callCheck):
(JSC::FTL::DFG::LowerDFGToB3::crash):
* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::assertNoUnswept):
* heap/GCSegmentedArray.h:
(JSC::GCArraySegment::GCArraySegment):
* heap/GCSegmentedArrayInlines.h:
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::validatePrevious):
* heap/HandleSet.cpp:
* heap/HandleSet.h:
* heap/Heap.cpp:
(JSC::Heap::updateAllocationLimits):
* heap/Heap.h:
* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::assertValidCell const):
(JSC::MarkedBlock::assertMarksNotStale):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::beginMarking):
(JSC::MarkedSpace::endMarking):
(JSC::MarkedSpace::assertNoUnswept):
* heap/PreciseAllocation.cpp:
* heap/PreciseAllocation.h:
(JSC::PreciseAllocation::assertValidCell const):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::appendJSCellOrAuxiliary):
* heap/SlotVisitor.h:
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
(CppProtocolTypesImplementationGenerator):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* interpreter/FrameTracers.h:
(JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::Interpreter):
* interpreter/Interpreter.h:
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::prepareCallOperation):
* jit/BinarySwitch.cpp:
(JSC::BinarySwitch::BinarySwitch):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupStubArgs):
* jit/CallFrameShuffler.cpp:
(JSC::CallFrameShuffler::emitDeltaCheck):
(JSC::CallFrameShuffler::prepareAny):
* jit/JIT.cpp:
(JSC::JIT::assertStackPointerOffset):
(JSC::JIT::compileWithoutLinking):
* jit/JITOpcodes.cpp:
(JSC::JIT::emitSlow_op_loop_hint):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
* jit/ThunkGenerators.cpp:
(JSC::emitPointerValidation):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LLIntOfflineAsmConfig.h:
* parser/Lexer.cpp:
* parser/Lexer.h:
(JSC::isSafeBuiltinIdentifier):
(JSC::Lexer<T>::lexExpectIdentifier):
* runtime/ArgList.h:
(JSC::MarkedArgumentBuffer::setNeedsOverflowCheck):
(JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck):
* runtime/Butterfly.h:
(JSC::ContiguousData::ContiguousData):
(JSC::ContiguousData::Data::Data):
* runtime/HashMapImpl.h:
(JSC::HashMapImpl::checkConsistency const):
(JSC::HashMapImpl::assertBufferIsEmpty const):
* runtime/JSCellInlines.h:
(JSC::JSCell::methodTable const):
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
(JSC::JSFunction::assertTypeInfoFlagInvariants):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren):
(JSC::JSFinalObject::visitChildren):
* runtime/JSObjectInlines.h:
(JSC::JSObject::validatePutOwnDataProperty):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::assertVariableIsInThisObject):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lex):
* runtime/LiteralParser.h:
* runtime/Operations.h:
(JSC::scribbleFreeCells):
* runtime/OptionsList.h:
* runtime/VM.cpp:
(JSC::VM::computeCanUseJIT):
* runtime/VM.h:
(JSC::VM::canUseJIT):
* runtime/VarOffset.h:
(JSC::VarOffset::checkSanity const):
* runtime/WeakMapImpl.h:
(JSC::WeakMapImpl::checkConsistency const):
(JSC::WeakMapImpl::assertBufferIsEmpty const):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::validateInst):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile):
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser::validationFail const):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::checkConsistency):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast):
* wasm/WasmSectionParser.h:
* wasm/WasmSections.h:
* wasm/WasmSignatureInlines.h:
(JSC::Wasm::SignatureInformation::get):
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::enqueue):
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::previousInstanceOffset const):
Source/WebCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::close):
* Modules/fetch/FetchBodySource.h:
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
(WebCore::DatabaseDetails::operator=):
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTask::performTask):
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::terminationRequested const):
* Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h:
(WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation):
* Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp:
(WebCore::WHLSL::findHighZombies):
* Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
(WebCore::WHLSL::matches):
* Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:
(WebCore::WHLSL::checkLiteralTypes):
* Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp:
(WebCore::WHLSL::FindAllTypes::appendNamedType):
* bindings/js/JSCallbackData.h:
* bindings/js/JSLazyEventListener.cpp:
* bindings/js/JSLazyEventListener.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcOperationNode::primitiveType const):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValue.cpp:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/CSSStyleSheet.cpp:
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::suspendIfNeeded):
(WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const):
* dom/ActiveDOMObject.h:
* dom/ContainerNode.cpp:
* dom/ContainerNodeAlgorithms.cpp:
* dom/ContainerNodeAlgorithms.h:
* dom/CustomElementReactionQueue.cpp:
* dom/CustomElementReactionQueue.h:
(WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope):
(WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope):
* dom/Document.cpp:
(WebCore::Document::hitTest):
* dom/Document.h:
(WebCore::Document::decrementReferencingNodeCount):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::getURLAttribute const):
(WebCore::Element::getNonEmptyURLAttribute const):
* dom/Element.h:
* dom/ElementAndTextDescendantIterator.h:
(WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator):
(WebCore::ElementAndTextDescendantIterator::dropAssertions):
(WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack):
(WebCore::ElementAndTextDescendantIterator::traverseNextSibling):
(WebCore::ElementAndTextDescendantIterator::traversePreviousSibling):
* dom/ElementDescendantIterator.h:
(WebCore::ElementDescendantIterator::ElementDescendantIterator):
(WebCore::ElementDescendantIterator::dropAssertions):
(WebCore::ElementDescendantIterator::operator++):
(WebCore::ElementDescendantIterator::operator--):
(WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator):
(WebCore::ElementDescendantConstIterator::dropAssertions):
(WebCore::ElementDescendantConstIterator::operator++):
* dom/ElementIterator.h:
(WebCore::ElementIterator<ElementType>::ElementIterator):
(WebCore::ElementIterator<ElementType>::traverseNext):
(WebCore::ElementIterator<ElementType>::traversePrevious):
(WebCore::ElementIterator<ElementType>::traverseNextSibling):
(WebCore::ElementIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementIterator<ElementType>::dropAssertions):
(WebCore::ElementIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::ElementConstIterator):
(WebCore::ElementConstIterator<ElementType>::traverseNext):
(WebCore::ElementConstIterator<ElementType>::traversePrevious):
(WebCore::ElementConstIterator<ElementType>::traverseNextSibling):
(WebCore::ElementConstIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementConstIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::dropAssertions):
* dom/EventContext.cpp:
* dom/EventContext.h:
* dom/EventListener.h:
* dom/EventPath.cpp:
* dom/EventSender.h:
* dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
(WebCore::EventTarget::setAttributeEventListener):
(WebCore::EventTarget::innerInvokeEventListeners):
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::moveNodeToNewDocument):
(WebCore::Node::removedLastRef):
* dom/Node.h:
(WebCore::Node::deref const):
* dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
* dom/ScriptExecutionContext.h:
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute const):
* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::removeSlotElementByName):
(WebCore::SlotAssignment::resolveSlotsAfterSlotMutation):
(WebCore::SlotAssignment::findFirstSlotElement):
* dom/SlotAssignment.h:
* dom/TreeScopeOrderedMap.cpp:
(WebCore::TreeScopeOrderedMap::add):
(WebCore::TreeScopeOrderedMap::get const):
* dom/TreeScopeOrderedMap.h:
* fileapi/Blob.cpp:
* fileapi/Blob.h:
* history/BackForwardCache.cpp:
(WebCore::BackForwardCache::removeAllItemsForPage):
* history/BackForwardCache.h:
* html/CanvasBase.cpp:
(WebCore::CanvasBase::notifyObserversCanvasDestroyed):
* html/CanvasBase.h:
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::didPopulate):
* html/HTMLSelectElement.cpp:
(WebCore:: const):
* html/HTMLTableRowsCollection.cpp:
(WebCore::assertRowIsInTable):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForPosition const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
* html/parser/HTMLParserScheduler.cpp:
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
(WebCore::HTMLParserScheduler::suspend):
(WebCore::HTMLParserScheduler::resume):
* html/parser/HTMLParserScheduler.h:
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::endAttribute):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::constructTree):
* html/parser/HTMLTreeBuilder.h:
(WebCore::HTMLTreeBuilder::~HTMLTreeBuilder):
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::geometryForBox const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
* layout/blockformatting/BlockFormattingContext.h:
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setTopLeft):
(WebCore::Display::Box::setTop):
(WebCore::Display::Box::setLeft):
(WebCore::Display::Box::setContentBoxHeight):
(WebCore::Display::Box::setContentBoxWidth):
(WebCore::Display::Box::setHorizontalMargin):
(WebCore::Display::Box::setVerticalMargin):
(WebCore::Display::Box::setHorizontalComputedMargin):
(WebCore::Display::Box::setBorder):
(WebCore::Display::Box::setPadding):
* layout/displaytree/DisplayInlineRect.h:
(WebCore::Display::InlineRect::InlineRect):
(WebCore::Display::InlineRect::setTopLeft):
(WebCore::Display::InlineRect::setTop):
(WebCore::Display::InlineRect::setBottom):
(WebCore::Display::InlineRect::setLeft):
(WebCore::Display::InlineRect::setWidth):
(WebCore::Display::InlineRect::setHeight):
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::LineBox):
(WebCore::Display::LineBox::setBaselineOffsetIfGreater):
(WebCore::Display::LineBox::resetBaseline):
(WebCore::Display::LineBox::Baseline::Baseline):
(WebCore::Display::LineBox::Baseline::setAscent):
(WebCore::Display::LineBox::Baseline::setDescent):
(WebCore::Display::LineBox::Baseline::reset):
* layout/displaytree/DisplayRect.h:
(WebCore::Display::Rect::Rect):
(WebCore::Display::Rect::setTopLeft):
(WebCore::Display::Rect::setTop):
(WebCore::Display::Rect::setLeft):
(WebCore::Display::Rect::setWidth):
(WebCore::Display::Rect::setHeight):
(WebCore::Display::Rect::setSize):
(WebCore::Display::Rect::clone const):
* layout/floats/FloatingContext.cpp:
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::CollapsibleContent::collapse):
* layout/tableformatting/TableGrid.cpp:
(WebCore::Layout::TableGrid::Column::setWidthConstraints):
(WebCore::Layout::TableGrid::Column::setLogicalWidth):
(WebCore::Layout::TableGrid::Column::setLogicalLeft):
* layout/tableformatting/TableGrid.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::attachToFrame):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::addSubresourceLoader):
* loader/DocumentLoader.h:
* loader/ImageLoader.cpp:
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::lruListFor):
(WebCore::MemoryCache::removeFromLRUList):
* page/FrameView.cpp:
(WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
* page/FrameViewLayoutContext.cpp:
* page/FrameViewLayoutContext.h:
* page/Page.cpp:
* page/Page.h:
* page/ViewportConfiguration.cpp:
* page/ViewportConfiguration.h:
* page/mac/EventHandlerMac.mm:
(WebCore::CurrentEventScope::CurrentEventScope):
* platform/DateComponents.cpp:
(WebCore::DateComponents::toStringForTime const):
* platform/ScrollableArea.cpp:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::combineIntoOneSegment const):
* platform/SharedBuffer.h:
* platform/Supplementable.h:
* platform/Timer.cpp:
(WebCore::TimerBase::checkHeapIndex const):
(WebCore::TimerBase::updateHeapIfNeeded):
* platform/graphics/BitmapImage.cpp:
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::ScratchBuffer):
(WebCore::ScratchBuffer::getScratchBuffer):
(WebCore::ScratchBuffer::scheduleScratchBufferPurge):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::setWindow):
* platform/graphics/ca/win/CACFLayerTreeHost.h:
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
* platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp:
(gstAllocatorFastMallocFree):
* platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp:
(Nicosia::PaintingContextCairo::ForPainting::ForPainting):
* platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp:
(Nicosia::BackingStoreTextureMapperImpl::createTile):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp:
(Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::fill):
* platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::appendGeometry):
(WebCore::Path::Path):
(WebCore::Path::operator=):
(WebCore::Path::strokeContains const):
(WebCore::Path::transform):
* platform/graphics/win/PlatformContextDirect2D.cpp:
(WebCore::PlatformContextDirect2D::setTags):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource):
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource):
* platform/network/HTTPParsers.cpp:
(WebCore::isCrossOriginSafeHeader):
* platform/sql/SQLiteDatabase.cpp:
* platform/sql/SQLiteDatabase.h:
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::SQLiteStatement):
(WebCore::SQLiteStatement::prepare):
(WebCore::SQLiteStatement::finalize):
* platform/sql/SQLiteStatement.h:
* platform/win/COMPtr.h:
* rendering/ComplexLineLayout.cpp:
(WebCore::ComplexLineLayout::removeInlineBox const):
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::FloatingObject):
(WebCore::FloatingObjects::addPlacedObject):
(WebCore::FloatingObjects::removePlacedObject):
* rendering/FloatingObjects.h:
* rendering/GridTrackSizingAlgorithm.cpp:
* rendering/GridTrackSizingAlgorithm.h:
* rendering/LayoutDisallowedScope.cpp:
* rendering/LayoutDisallowedScope.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlockChild):
(WebCore::RenderBlockFlow::removeFloatingObject):
(WebCore::RenderBlockFlow::ensureLineBoxes):
* rendering/RenderBoxModelObject.cpp:
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
* rendering/RenderElement.cpp:
* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::baselinePosition const):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):
* rendering/RenderLayer.cpp:
(WebCore::ClipRectsCache::ClipRectsCache):
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::updateClipRects):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::traverseVisibleNonCompositedDescendantLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const):
(WebCore::RenderLayerCompositor::recursiveRepaintLayer):
(WebCore::RenderLayerCompositor::layerHas3DContent const):
* rendering/RenderLayoutState.cpp:
(WebCore::RenderLayoutState::RenderLayoutState):
(WebCore::RenderLayoutState::computeOffsets):
(WebCore::RenderLayoutState::addLayoutDelta):
* rendering/RenderLayoutState.h:
(WebCore::RenderLayoutState::RenderLayoutState):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::RenderObject):
(WebCore::RenderObject::~RenderObject):
(WebCore::RenderObject::clearNeedsLayout):
* rendering/RenderObject.h:
* rendering/RenderQuote.cpp:
(WebCore::quotesForLanguage):
* rendering/RenderTableCell.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::computeOverflowFromCells):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::checkConsistency const):
* rendering/RenderTextLineBoxes.h:
* rendering/line/BreakingContext.h:
(WebCore::tryHyphenating):
* rendering/style/GridArea.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::~RenderStyle):
* rendering/style/RenderStyle.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::detach):
* rendering/updating/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):
* rendering/updating/RenderTreePosition.h:
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
(WebCore::SVGToOTFFontConverter::Placeholder::populate):
(WebCore::SVGToOTFFontConverter::appendCFFTable):
(WebCore::SVGToOTFFontConverter::firstGlyph const):
(WebCore::SVGToOTFFontConverter::appendKERNTable):
* svg/SVGTransformDistance.cpp:
(WebCore::SVGTransformDistance::SVGTransformDistance):
(WebCore::SVGTransformDistance::scaledDistance const):
(WebCore::SVGTransformDistance::addSVGTransforms):
(WebCore::SVGTransformDistance::addToSVGTransform const):
(WebCore::SVGTransformDistance::distance const):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
* testing/InternalSettings.cpp:
* workers/service/ServiceWorkerJob.h:
* worklets/PaintWorkletGlobalScope.h:
(WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope):
* xml/XPathStep.cpp:
Source/WebKit:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::invalidateAndCancel):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::setCapacity):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toNSURLSessionResponseDisposition):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* Platform/IPC/Connection.cpp:
(IPC::Connection::waitForMessage):
* Platform/IPC/MessageReceiver.h:
(IPC::MessageReceiver::willBeAddedToMessageReceiverMap):
(IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap):
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::readFromMachPort):
* Platform/mac/MachUtilities.cpp:
(setMachExceptionPort):
* Shared/API/APIClient.h:
(API::Client::Client):
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
* Shared/Cocoa/ArgumentCodersCocoa.h:
* Shared/SharedStringHashTableReadOnly.cpp:
* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/GenericCallback.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/PageLoadState.h:
(WebKit::PageLoadState::Transaction::Token::Token):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::~WebPageProxy):
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponse):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
(WebKit::NetscapePluginStream::notifyAndDestroyStream):
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runModal):
* WebProcess/WebProcess.cpp:
(WebKit::checkDocumentsCaptureStateConsistency):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateProcessName):
Source/WebKitLegacy:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Storage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::StorageAreaImpl):
(WebKit::StorageAreaImpl::close):
* Storage/StorageAreaImpl.h:
Source/WebKitLegacy/mac:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* History/WebHistory.mm:
(-[WebHistoryPrivate removeItemForURLString:]):
* WebView/WebFrame.mm:
Source/WebKitLegacy/win:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::CAD3DRenderer::swapChain):
(WKQCA::CAD3DRenderer::initialize):
* WebKitQuartzCoreAdditions/CAD3DRenderer.h:
* WebView.cpp:
(WebView::Release):
* WebView.h:
Source/WTF:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
This patch did the following changes:
1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away
with the need for the double negative !ASSERT_DISABLED test that is commonly
used all over the code, thereby improving code readability.
In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED,
ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and
RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents
as well. We'll do that in another patch. For now, they are left as is to
minimize the size of this patch.
See https://bugs.webkit.org/show_bug.cgi?id=205780.
2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be
guarded by "#if ASSERT_ENABLED" instead.
3. In cases where the change is minimal, we move some code around so that we can
test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED".
* wtf/Assertions.h:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/BitVector.h:
* wtf/BlockObjCExceptions.mm:
(ReportBlockedObjCException):
* wtf/BloomFilter.h:
* wtf/CallbackAggregator.h:
(WTF::CallbackAggregator::CallbackAggregator):
* wtf/CheckedArithmetic.h:
(WTF::observesOverflow<AssertNoOverflow>):
* wtf/CheckedBoolean.h:
(CheckedBoolean::CheckedBoolean):
(CheckedBoolean::operator bool):
* wtf/CompletionHandler.h:
(WTF::CompletionHandler<Out):
* wtf/DateMath.cpp:
(WTF::initializeDates):
* wtf/Gigacage.cpp:
(Gigacage::tryAllocateZeroedVirtualPages):
* wtf/HashTable.h:
(WTF::KeyTraits>::checkKey):
(WTF::KeyTraits>::checkTableConsistencyExceptSize const):
* wtf/LoggerHelper.h:
* wtf/NaturalLoops.h:
(WTF::NaturalLoops::headerOf const):
* wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):
* wtf/Platform.h:
* wtf/PtrTag.h:
* wtf/RefCounted.h:
(WTF::RefCountedBase::disableThreadingChecks):
(WTF::RefCountedBase::enableThreadingChecksGlobally):
(WTF::RefCountedBase::RefCountedBase):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):
* wtf/SingleRootGraph.h:
(WTF::SingleRootGraph::assertIsConsistent const):
* wtf/SizeLimits.cpp:
* wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* wtf/URLParser.cpp:
(WTF::URLParser::URLParser):
(WTF::URLParser::domainToASCII):
* wtf/ValueCheck.h:
* wtf/Vector.h:
(WTF::Malloc>::checkConsistency):
* wtf/WeakHashSet.h:
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::WeakPtrImpl):
(WTF::WeakPtrFactory::WeakPtrFactory):
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringImpl.h:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::reifyString const):
* wtf/text/StringBuilder.h:
* wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* wtf/text/StringHasher.h:
(WTF::StringHasher::addCharacters):
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:
Tools:
Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory
https://bugs.webkit.org/show_bug.cgi?id=205754
Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06
Reviewed by Youenn Fablet.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::websiteDataStore):
(WTR::TestController::platformAdjustContext):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
Canonical link: https://commits.webkit.org/218957@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
|
|
|
#if ASSERT_ENABLED
|
2019-08-01 18:38:40 +00:00
|
|
|
bool m_wasConstructedOnMainThread;
|
|
|
|
#endif
|
2013-01-15 21:35:08 +00:00
|
|
|
};
|
|
|
|
|
2021-06-30 22:51:21 +00:00
|
|
|
template<typename Counter> struct HashTraits<Ref<WeakPtrImpl<Counter>>> : RefHashTraits<WeakPtrImpl<Counter>> {
|
|
|
|
static constexpr bool hasIsReleasedWeakValueFunction = true;
|
|
|
|
static bool isReleasedWeakValue(const Ref<WeakPtrImpl<Counter>>& value)
|
|
|
|
{
|
|
|
|
return !value.isHashTableDeletedValue() && !value.isHashTableEmptyValue() && !value.get();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, typename Counter> class WeakPtr {
|
2013-01-15 21:35:08 +00:00
|
|
|
WTF_MAKE_FAST_ALLOCATED;
|
|
|
|
public:
|
2017-10-02 22:21:12 +00:00
|
|
|
WeakPtr() { }
|
|
|
|
WeakPtr(std::nullptr_t) { }
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename U> WeakPtr(const WeakPtr<U, Counter>&);
|
|
|
|
template<typename U> WeakPtr(WeakPtr<U, Counter>&&);
|
2013-01-15 21:35:08 +00:00
|
|
|
|
2019-08-07 20:35:11 +00:00
|
|
|
T* get() const
|
|
|
|
{
|
|
|
|
// FIXME: Our GC threads currently need to get opaque pointers from WeakPtrs and have to be special-cased.
|
OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224279
Reviewed by Darin Adler.
Source/WebCore:
OfflineAudioContext objects were always leaking due to 2 reference cycles:
1. BaseAudioContext -> m_listener (AudioListener) -> m_positionX (AudioParam) -> m_context (BaseAudioContext)
2. BaseAudioContext -> m_destinationNode (AudioDestinationNode) -> m_context (BaseAudioContext)
For reference cycle 1, I made AudioSummingJunction (base class of AudioParam) hold a weak pointer to the
AudioContext instead of a Ref<>. I don't think there is a good reason for an AudioSummingJunction (AudioParam
or AudioNodeInput) to keep its AudioContext alive. AudioNodes already keep their AudioContext alive.
AudioNodeInputs and AudioParams are associated to AudioNodes.
For reference cycle 2, I made AudioDestinationNode not hold a strong pointer to its context but instead a
weak pointer. Since keeping an AudioDestinationNode alive should keep its AudioContext alive, I made it so
that ref'ing the AudioDestinationNode refs its BaseAudioContext. Also, BaseAudioContext::m_destinationNode
is now a UniqueRef<> instead of a RefPtr<> to avoid a cycle.
Tests: webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html
webaudio/OfflineAudioContext/offlineaudiocontext-leak.html
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::baseLatency):
(WebCore::AudioContext::getOutputTimestamp):
(WebCore::AudioContext::close):
(WebCore::AudioContext::destination):
(WebCore::AudioContext::destination const):
(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::mediaState const):
(WebCore::AudioContext::mayResumePlayback):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::pageMutedStateDidChange):
* Modules/webaudio/AudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::ref):
(WebCore::AudioDestinationNode::deref):
* Modules/webaudio/AudioDestinationNode.h:
Have AudioDestinationNode override AudioNode's ref() / deref() to forward the refcounting
to its BaseAudioContext, instead of using the AudioNode's internal refCount.
* Modules/webaudio/AudioListener.cpp:
(WebCore::AudioListener::updateValuesIfNeeded):
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::setOrientation):
Add some null-checks for AudioParam::context() now that AudioParam holds a WeakPtr to its
context.
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::toWeakOrStrongContext):
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::connect):
(WebCore::AudioNode::sampleRate const):
(WebCore::AudioNode::markNodeForDeletionIfNecessary):
(WebCore::AudioNode::contextForBindings):
(WebCore::AudioNode::context):
(WebCore::AudioNode::context const):
* Modules/webaudio/AudioNode.h:
- Hold the BaseAudioContext as a WeakPtr instead of a Ref<> if the AudioNode is an
AudioDestinationNode. This avoids a reference cycle since the BaseAudioContext owns the
AudioDestinationNode. Even though we are using a WeakPtr, it is safe to assume that
the context is not null because ref'ing an AudioDestinationNode refs its BaseAudioContext.
- Make sure markNodeForDeletionIfNecessary() has no effect for AudioDestinationNode since
BaseAudioContext now owns the AudioDestinationNode when we take care of destroying its
destination node when destroyed.
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::connect):
(WebCore::AudioNodeInput::disconnect):
(WebCore::AudioNodeInput::outputEnabledStateChanged):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::internalSummingBus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):
Add assertions that the context is not null. There were already assertions that we are the graph
owner, which means we are holding the BaseAudioContext's lock, which means that the audio context
is alive.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::value):
(WebCore::AudioParam::setValueForBindings):
(WebCore::AudioParam::smooth):
(WebCore::AudioParam::hasSampleAccurateValues const):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
(WebCore::AudioParam::calculateTimelineValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
Add null-checks for the AudioContext now that the AudioParam is only holding a WeakPtr to its
BaseAudioContext (to avoid a reference cycle).
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::AudioSummingJunction):
(WebCore::AudioSummingJunction::~AudioSummingJunction):
(WebCore::AudioSummingJunction::markRenderingStateAsDirty):
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
(WebCore::AudioSummingJunction::outputEnabledStateChanged):
* Modules/webaudio/AudioSummingJunction.h:
(WebCore::AudioSummingJunction::context):
(WebCore::AudioSummingJunction::context const):
- Hold a WeakPtr to the BaseAudioContext to avoid a reference cycle.
- Deal with the fact that the audio context may be null now that we're holding a WeakPtr
to it (except when holding the graph lock)
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
(WebCore::BaseAudioContext::~BaseAudioContext):
(WebCore::BaseAudioContext::numberOfInstances):
(WebCore::BaseAudioContext::lazyInitialize):
(WebCore::BaseAudioContext::clear):
(WebCore::BaseAudioContext::uninitialize):
(WebCore::BaseAudioContext::stop):
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::decodeAudioData):
(WebCore::BaseAudioContext::markForDeletion):
(WebCore::BaseAudioContext::deleteMarkedNodes):
(WebCore::BaseAudioContext::setPendingActivity):
(WebCore::BaseAudioContext::workletIsReady):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::destination):
(WebCore::BaseAudioContext::destination const):
(WebCore::BaseAudioContext::currentSampleFrame const):
(WebCore::BaseAudioContext::currentTime const):
- Switch m_destinationNode from RefPtr<> to UniqueRef<> since the AudioContext is now
the owner of the destinationNode and since refing the destination node actually refs
its BaseAudioContext.
- Drop some null checks now that m_destinationNode can no longer be null.
- Rename makePendingActivity() to setPendingActivity() to avoid a naming conflict with
ActiveDOMObject::makePendingActivity().
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/OfflineAudioDestinationNode.h:
- Drop create() factory functions and make the constructor public now that the BaseAudioContext owns
its destination node via a UniqueRef<>.
- Make some member functions public as they are virtual and they now called on the subclass instead of the
base class (and these functions are public in the base class).
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
(WebCore::OfflineAudioContext::resumeOfflineRendering):
* Modules/webaudio/OfflineAudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::close):
Drop null checks for the destination node now that it can never be null.
* dom/ShadowRoot.cpp:
* rendering/FloatingObjects.cpp:
* rendering/RootInlineBox.cpp:
Update classes used of size restrictions since the size of a WeakPtr is not longer the same as the size of a
pointer when debug assertions are enabled. As long as they are the same size in release builds, there is no
memory use concern.
* testing/Internals.cpp:
(WebCore::Internals::numberOfBaseAudioContexts const):
* testing/Internals.h:
* testing/Internals.idl:
Add testing function to check how many BaseAudioContexts are alive, so that we can write layout tests and check
for leaks.
Source/WTF:
Add flag that can be passed when constructing a WeakPtr to disable threading assertions.
This is useful for cases where we know it is safe due to locking but we'd like to use a
WeakPtr instead of a raw pointer because it is safer.
* wtf/WeakPtr.h:
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const):
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::=):
(WTF::makeWeakPtr):
LayoutTests:
Add layout test coverage.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak.html: Added.
Canonical link: https://commits.webkit.org/236304@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 18:41:23 +00:00
|
|
|
ASSERT(!m_impl || !m_shouldEnableAssertions || Thread::mayBeGCThread() || m_impl->wasConstructedOnMainThread() == isMainThread());
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
return m_impl ? static_cast<T*>(m_impl->template get<T>()) : nullptr;
|
2019-08-07 20:35:11 +00:00
|
|
|
}
|
|
|
|
|
Improve some media code
https://bugs.webkit.org/show_bug.cgi?id=208322
Reviewed by Anders Carlsson.
Source/WebCore:
- TextTrack objects now take Document instead of ScriptExecutionContext.
- Made more TextTrack functions private and protected.
- Made TextTrack parsing functions use return values rather than out arguments.
- Use references rather than pointers and Ref rather than RefPtr for non-null things.
- Made MediaControlsHost use a WeakPtr instead of a raw pointer.
* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::alwaysOnKeyword): Made private to this file instead of exposed in header.
(WebCore::manualKeyword): Ditto.
(WebCore::MediaControlsHost::create): Take a reference instead of a pointer to
the media element.
(WebCore::MediaControlsHost::MediaControlsHost): Ditto, and make a weak pointer.
(WebCore::MediaControlsHost::sortedTrackListForMenu): Added null check.
(WebCore::MediaControlsHost::displayNameForTrack): Ditto.
(WebCore::MediaControlsHost::captionMenuOffItem): Ditto.
(WebCore::MediaControlsHost::captionMenuAutomaticItem): Ditto.
(WebCore::MediaControlsHost::captionDisplayMode const): Ditto.
(WebCore::MediaControlsHost::setSelectedTextTrack): Ditto.
(WebCore::MediaControlsHost::textTrackContainer): Ditto.
(WebCore::MediaControlsHost::allowsInlineMediaPlayback const): Ditto.
(WebCore::MediaControlsHost::supportsFullscreen const): Ditto.
(WebCore::MediaControlsHost::isVideoLayerInline const): Ditto.
(WebCore::MediaControlsHost::isInMediaDocument const): Ditto.
(WebCore::MediaControlsHost::setPreparedToReturnVideoLayerToInline): Ditto.
(WebCore::MediaControlsHost::userGestureRequired const): Ditto.
(WebCore::MediaControlsHost::shouldForceControlsDisplay const): Ditto.
(WebCore::MediaControlsHost::externalDeviceDisplayName const): Ditto.
(WebCore::MediaControlsHost::externalDeviceType const): Ditto.
(WebCore::MediaControlsHost::controlsDependOnPageScaleFactor const): Ditto.
(WebCore::MediaControlsHost::setControlsDependOnPageScaleFactor): Ditto.
(WebCore::MediaControlsHost::generateUUID): Made a static member.
(WebCore::MediaControlsHost::shadowRootCSSText): Ditto.
(WebCore::MediaControlsHost::base64StringForIconNameAndType): Ditto.
(WebCore::MediaControlsHost::formattedStringForDuration): Ditto.
(WebCore::MediaControlsHost::compactMode const): Tweaked logic a bit.
* Modules/mediacontrols/MediaControlsHost.h: Made various member functions
into static member functions, used references instead of pointers for
things that are never null, used WeakPtr for m_mediaElement.
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment):
Document instead of ScriptExecutionContext.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerDidAddTextTrack): Document instead of
ScriptExecutionContext.
(WebCore::HTMLMediaElement::updateCaptionContainer): Pass reference to
MediaControlsHost::create.
(WebCore::HTMLMediaElement::setSelectedTextTrack): Update since special items
are now references rather than pointers.
(WebCore::HTMLMediaElement::updateTextTrackDisplay): Pass reference.
(WebCore::HTMLMediaElement::didAddUserAgentShadowRoot): Ditto.
* html/HTMLTrackElement.cpp:
(WebCore::HTMLTrackElement::parseAttribute): Removed setIsDefault function
since the track can simply read the attribute out of the element instead.
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlClosedCaptionsTrackListElement::updateDisplay):
Update since special items are now referencse rather than pointers.
* html/track/DataCue.cpp:
(WebCore::DataCue::DataCue): Document instead of ScriptExecutionContext.
(WebCore::DataCue::create): Moved these functions out of the header.
* html/track/DataCue.h: Updated for the above.
* html/track/DataCue.idl: Ditto.
* html/track/InbandDataTextTrack.cpp:
(WebCore::InbandDataTextTrack::InbandDataTextTrack): Document instead
of ScriptExecutionContext.
(WebCore::InbandDataTextTrack::create): Ditto.
(WebCore::InbandDataTextTrack::addDataCue): Ditto. Also use reference
instead of pointer when calling hasCue.
* html/track/InbandDataTextTrack.h: Updated for the above.
* html/track/InbandGenericTextTrack.cpp:
(WebCore::InbandGenericTextTrack::InbandGenericTextTrack): Document
instead of ScriptExecutionContext.
(WebCore::InbandGenericTextTrack::create): Ditto.
(WebCore::InbandGenericTextTrack::addGenericCue): Ditto. Also use
reference instead of pointer when calling hasCue.
(WebCore::InbandGenericTextTrack::parser): Ditto.
(WebCore::InbandGenericTextTrack::newCuesParsed): Ditto. Also use
return value from takeCues instead of out arguenmt from getNewCues.
Also use reference instead of pointer when calling hasCue.
(WebCore::InbandGenericTextTrack::newRegionsParsed): Ditto.
* html/track/InbandGenericTextTrack.h: Update for above.
* html/track/InbandTextTrack.cpp:
(WebCore::InbandTextTrack::create): Document instead of
ScriptExecutionContext.
(WebCore::InbandTextTrack::InbandTextTrack): Ditto.
* html/track/InbandTextTrack.h: Update for above.
* html/track/InbandWebVTTTextTrack.cpp:
(WebCore::InbandWebVTTTextTrack::InbandWebVTTTextTrack): Document
instead of ScriptExecutionContext.
(WebCore::InbandWebVTTTextTrack::create): Ditto.
(WebCore::InbandWebVTTTextTrack::parser): Ditto.
(WebCore::InbandWebVTTTextTrack::newCuesParsed): Ditto. Also use
return value from takeCues instead of out arguenmt from getNewCues.
Also use reference instead of pointer when calling hasCue.
(WebCore::InbandWebVTTTextTrack::newRegionsParsed): Ditto.
* html/track/InbandWebVTTTextTrack.h: Update for above.
* html/track/LoadableTextTrack.cpp:
(WebCore::LoadableTextTrack::create): Moved here from header.
(WebCore::LoadableTextTrack::loadTimerFired): Document instead of
ScriptExecutionContext.
(WebCore::LoadableTextTrack::newRegionsAvailable): Use return value
from getNewRegions instead of out argument.
(WebCore::LoadableTextTrack::isDefault const): New implementation that
does not rely on a data member; checks attribute on video element.
* html/track/LoadableTextTrack.h: Updated for above changes.
* html/track/TextTrack.cpp:
(WebCore::TextTrack::captionMenuOffItem): Return a reference rather
than a pointer.
(WebCore::TextTrack::captionMenuAutomaticItem): Ditto.
(WebCore::TextTrack::create): Document rather than ScriptExecutionContext.
(WebCore::TextTrack::document const): Added. For use by derived classes.
(WebCore::TextTrack::addRegion): Ref rather than RefPtr.
(WebCore::TextTrack::removeRegion): Reference rather than pointer.
(WebCore::TextTrack::cueWillChange): Ditto.
(WebCore::TextTrack::cueDidChange): Ditto.
(WebCore::TextTrack::hasCue): Ditto.
* html/track/TextTrack.h: Removed declarations of non-existent
disabledKeyword, hiddenKeyword, and showingKeyword functions.
Made setKind, client, and hasCue protected. Made overrides of
eventTargetInterface, scriptExecutionContext, and logClassName
private. Removed setIsDefault. Updated for changes above.
* html/track/TextTrack.idl: Did what FIXME suggested, making the region
parameters non-nullable. Passing null silently did nothing before. There
is some small risk of website incompatibility if someone accidentally
relied on this WebKit-specific behavior.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::create): Document instead of ScriptExecutionContext.
(WebCore::TextTrackCue::TextTrackCue): Ditto.
(WebCore::TextTrackCue::willChange): Pass reference.
(WebCore::TextTrackCue::didChange): Ditto.
* html/track/TextTrackCue.h: Update for above changes.
* html/track/TextTrackCue.idl: Ditto.
* html/track/TextTrackCueGeneric.cpp:
(WebCore::TextTrackCueGeneric::TextTrackCueGeneric): Update since the base
class now takes an rvalue reference to the string.
(WebCore::TextTrackCueGeneric::isOrderedBefore const): Use auto.
(WebCore::TextTrackCueGeneric::isPositionedAbove const): Ditto.
* html/track/VTTCue.cpp:
(WebCore::VTTCue::create): Document instead of ScriptExecutionContext.
Also take String with an rvalue reference.
(WebCore::VTTCue::VTTCue): Ditto.
* html/track/VTTCue.h: Update for above changes.
* html/track/VTTCue.idl: Ditto.
* html/track/WebVTTParser.cpp:
(WebCore::WebVTTParser::WebVTTParser): Document instead of
ScriptExecutionContext. References instead of pointers. Initialize
m_state in class definition.
(WebCore::WebVTTParser::takeCues): Renamed from getNewCues and changed
to use a return value instead of an out argument.
(WebCore::WebVTTParser::takeRegions): Ditto.
(WebCore::WebVTTParser::takeStyleSheets): Ditto.
(WebCore::WebVTTParser::parseCueData): Remove null check of m_client.
(WebCore::WebVTTParser::parse): Ditto.
(WebCore::WebVTTParser::collectWebVTTBlock): Ditto.
(WebCore::WebVTTParser::checkAndCreateRegion): Pass document.
(WebCore::WebVTTParser::checkAndStoreRegion): Use
Vector::removeFirstMatching instead of Vector::removeFirst.
(WebCore::WebVTTParser::createNewCue): Remove null check of m_client.
* html/track/WebVTTParser.h: Update for above changes.
* loader/TextTrackLoader.cpp:
(WebCore::TextTrackLoader::TextTrackLoader): Document instead of
ScriptExecutionContext. References instead of pointers. Initialize
data members in in class definition.
(WebCore::TextTrackLoader::processNewCueData): Pass references.
(WebCore::TextTrackLoader::corsPolicyPreventedLoad): Use m_document.
(WebCore::TextTrackLoader::load): Ditto.
(WebCore::TextTrackLoader::getNewCues): Use takeCues.
(WebCore::TextTrackLoader::getNewRegions): Changed to return a vector
instead of using an out argument. Use takeRegions.
(WebCore::TextTrackLoader::getNewStyleSheets): Ditto.
* loader/TextTrackLoader.h: Updated for the above.
* page/CaptionUserPreferences.cpp:
(WebCore::trackDisplayName): Updated since these are references.
(WebCore::CaptionUserPreferences::mediaSelectionOptionForTrack const): Ditto.
(WebCore::CaptionUserPreferences::sortedTrackListForMenu): Ditto.
* page/CaptionUserPreferencesMediaAF.cpp:
(WebCore::trackDisplayName): Ditto.
(WebCore::CaptionUserPreferencesMediaAF::sortedTrackListForMenu): Ditto.
* platform/cocoa/PlaybackSessionModelMediaElement.mm:
(WebCore::PlaybackSessionModelMediaElement::selectLegibleMediaOption): Ditto.
(WebCore::PlaybackSessionModelMediaElement::legibleMediaSelectedIndex const):
Updated to use references rather than pointers. Refactored the logic to
use Optional and nested if statements to make the algorithm clearer.
Source/WTF:
* wtf/WeakPtr.h:
(WTF::WeakPtr::operator! const): Added.
Canonical link: https://commits.webkit.org/221612@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@257997 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-06 16:08:33 +00:00
|
|
|
bool operator!() const { return !m_impl || !*m_impl; }
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
explicit operator bool() const { return m_impl && *m_impl; }
|
WeakPtr functions crash when created with default constructor
https://bugs.webkit.org/show_bug.cgi?id=140479
Reviewed by Andreas Kling.
Source/WTF:
This patch rearranges how WeakPtr works, and has the following ideas behind it:
1. WeakPtr should use Ref internally. This solves the crash by always having a
valid WeakReference.
2. Clients should not be able to construct WeakReferences directly. Instead,
only WeakPtrFactory (and WeakPtr's default constructor) should be able to
construct them. They are considered an implementation detail of WeakPtr.
3. Except for the default constructor, clients should not be able to construct
WeakPtrs directly. Instead, the WeakPtrFactory must construct them. This
guarantees that the WeakPtrs all reference the same WeakReference.
4. Clients can construct a WeakPtr using its default constructor, and then
use the assignment operator to make it non-null. (Or they could use
WeakPtrFactory to make it non-null at creation-time.)
5. No one was using WeakReference::bindTo(), and it doesn't seem useful, so I
removed it.
Tests: WTF_WeakPtr API tests
* wtf/Ref.h:
(WTF::Ref::Ref): Added extra ASSERT()s, and explicitly deleted copy
constructors with a comment.
(WTF::Ref::operator=): Added extra ASSERT()s, and explicitly deleted copy
assignment operators with a comment.
* wtf/WeakPtr.h:
(WTF::WeakReference::clear): Used nullptr.
(WTF::WeakReference::create): Moved to private:
(WTF::WeakPtr::WeakPtr): For the default constructor, initialized the Ref with
a new WeakReference. For the other constructor, moved it to private:. Also added
copy constructors and copy assignment operators (since Ref doesn't have them but
RefPtr does). These constructors/operators are relied upon in various places
throughout WebCore.
(WTF::WeakPtr::operator bool): Made non-explicit.
(WTF::WeakReference::createUnbound): Deleted.
(WTF::WeakReference::bindTo): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::WeakPtrFactory::WeakPtrFactory): Deleted.
Tools:
Add WeakPtr API tests.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Added.
* TestWebKitAPI/Tests/WTF/Ref.cpp: Update to not use copy constructor.
Canonical link: https://commits.webkit.org/158549@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178615 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-17 00:39:57 +00:00
|
|
|
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
WeakPtr& operator=(std::nullptr_t) { m_impl = nullptr; return *this; }
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename U> WeakPtr& operator=(const WeakPtr<U, Counter>&);
|
|
|
|
template<typename U> WeakPtr& operator=(WeakPtr<U, Counter>&&);
|
2014-03-11 03:08:01 +00:00
|
|
|
|
2019-08-07 20:35:11 +00:00
|
|
|
T* operator->() const
|
|
|
|
{
|
OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224279
Reviewed by Darin Adler.
Source/WebCore:
OfflineAudioContext objects were always leaking due to 2 reference cycles:
1. BaseAudioContext -> m_listener (AudioListener) -> m_positionX (AudioParam) -> m_context (BaseAudioContext)
2. BaseAudioContext -> m_destinationNode (AudioDestinationNode) -> m_context (BaseAudioContext)
For reference cycle 1, I made AudioSummingJunction (base class of AudioParam) hold a weak pointer to the
AudioContext instead of a Ref<>. I don't think there is a good reason for an AudioSummingJunction (AudioParam
or AudioNodeInput) to keep its AudioContext alive. AudioNodes already keep their AudioContext alive.
AudioNodeInputs and AudioParams are associated to AudioNodes.
For reference cycle 2, I made AudioDestinationNode not hold a strong pointer to its context but instead a
weak pointer. Since keeping an AudioDestinationNode alive should keep its AudioContext alive, I made it so
that ref'ing the AudioDestinationNode refs its BaseAudioContext. Also, BaseAudioContext::m_destinationNode
is now a UniqueRef<> instead of a RefPtr<> to avoid a cycle.
Tests: webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html
webaudio/OfflineAudioContext/offlineaudiocontext-leak.html
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::baseLatency):
(WebCore::AudioContext::getOutputTimestamp):
(WebCore::AudioContext::close):
(WebCore::AudioContext::destination):
(WebCore::AudioContext::destination const):
(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::mediaState const):
(WebCore::AudioContext::mayResumePlayback):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::pageMutedStateDidChange):
* Modules/webaudio/AudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::ref):
(WebCore::AudioDestinationNode::deref):
* Modules/webaudio/AudioDestinationNode.h:
Have AudioDestinationNode override AudioNode's ref() / deref() to forward the refcounting
to its BaseAudioContext, instead of using the AudioNode's internal refCount.
* Modules/webaudio/AudioListener.cpp:
(WebCore::AudioListener::updateValuesIfNeeded):
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::setOrientation):
Add some null-checks for AudioParam::context() now that AudioParam holds a WeakPtr to its
context.
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::toWeakOrStrongContext):
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::connect):
(WebCore::AudioNode::sampleRate const):
(WebCore::AudioNode::markNodeForDeletionIfNecessary):
(WebCore::AudioNode::contextForBindings):
(WebCore::AudioNode::context):
(WebCore::AudioNode::context const):
* Modules/webaudio/AudioNode.h:
- Hold the BaseAudioContext as a WeakPtr instead of a Ref<> if the AudioNode is an
AudioDestinationNode. This avoids a reference cycle since the BaseAudioContext owns the
AudioDestinationNode. Even though we are using a WeakPtr, it is safe to assume that
the context is not null because ref'ing an AudioDestinationNode refs its BaseAudioContext.
- Make sure markNodeForDeletionIfNecessary() has no effect for AudioDestinationNode since
BaseAudioContext now owns the AudioDestinationNode when we take care of destroying its
destination node when destroyed.
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::connect):
(WebCore::AudioNodeInput::disconnect):
(WebCore::AudioNodeInput::outputEnabledStateChanged):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::internalSummingBus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):
Add assertions that the context is not null. There were already assertions that we are the graph
owner, which means we are holding the BaseAudioContext's lock, which means that the audio context
is alive.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::value):
(WebCore::AudioParam::setValueForBindings):
(WebCore::AudioParam::smooth):
(WebCore::AudioParam::hasSampleAccurateValues const):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
(WebCore::AudioParam::calculateTimelineValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
Add null-checks for the AudioContext now that the AudioParam is only holding a WeakPtr to its
BaseAudioContext (to avoid a reference cycle).
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::AudioSummingJunction):
(WebCore::AudioSummingJunction::~AudioSummingJunction):
(WebCore::AudioSummingJunction::markRenderingStateAsDirty):
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
(WebCore::AudioSummingJunction::outputEnabledStateChanged):
* Modules/webaudio/AudioSummingJunction.h:
(WebCore::AudioSummingJunction::context):
(WebCore::AudioSummingJunction::context const):
- Hold a WeakPtr to the BaseAudioContext to avoid a reference cycle.
- Deal with the fact that the audio context may be null now that we're holding a WeakPtr
to it (except when holding the graph lock)
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
(WebCore::BaseAudioContext::~BaseAudioContext):
(WebCore::BaseAudioContext::numberOfInstances):
(WebCore::BaseAudioContext::lazyInitialize):
(WebCore::BaseAudioContext::clear):
(WebCore::BaseAudioContext::uninitialize):
(WebCore::BaseAudioContext::stop):
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::decodeAudioData):
(WebCore::BaseAudioContext::markForDeletion):
(WebCore::BaseAudioContext::deleteMarkedNodes):
(WebCore::BaseAudioContext::setPendingActivity):
(WebCore::BaseAudioContext::workletIsReady):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::destination):
(WebCore::BaseAudioContext::destination const):
(WebCore::BaseAudioContext::currentSampleFrame const):
(WebCore::BaseAudioContext::currentTime const):
- Switch m_destinationNode from RefPtr<> to UniqueRef<> since the AudioContext is now
the owner of the destinationNode and since refing the destination node actually refs
its BaseAudioContext.
- Drop some null checks now that m_destinationNode can no longer be null.
- Rename makePendingActivity() to setPendingActivity() to avoid a naming conflict with
ActiveDOMObject::makePendingActivity().
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/OfflineAudioDestinationNode.h:
- Drop create() factory functions and make the constructor public now that the BaseAudioContext owns
its destination node via a UniqueRef<>.
- Make some member functions public as they are virtual and they now called on the subclass instead of the
base class (and these functions are public in the base class).
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
(WebCore::OfflineAudioContext::resumeOfflineRendering):
* Modules/webaudio/OfflineAudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::close):
Drop null checks for the destination node now that it can never be null.
* dom/ShadowRoot.cpp:
* rendering/FloatingObjects.cpp:
* rendering/RootInlineBox.cpp:
Update classes used of size restrictions since the size of a WeakPtr is not longer the same as the size of a
pointer when debug assertions are enabled. As long as they are the same size in release builds, there is no
memory use concern.
* testing/Internals.cpp:
(WebCore::Internals::numberOfBaseAudioContexts const):
* testing/Internals.h:
* testing/Internals.idl:
Add testing function to check how many BaseAudioContexts are alive, so that we can write layout tests and check
for leaks.
Source/WTF:
Add flag that can be passed when constructing a WeakPtr to disable threading assertions.
This is useful for cases where we know it is safe due to locking but we'd like to use a
WeakPtr instead of a raw pointer because it is safer.
* wtf/WeakPtr.h:
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const):
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::=):
(WTF::makeWeakPtr):
LayoutTests:
Add layout test coverage.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak.html: Added.
Canonical link: https://commits.webkit.org/236304@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 18:41:23 +00:00
|
|
|
ASSERT(!m_impl || !m_shouldEnableAssertions || m_impl->wasConstructedOnMainThread() == isMainThread());
|
2019-08-07 20:35:11 +00:00
|
|
|
return get();
|
|
|
|
}
|
|
|
|
|
|
|
|
T& operator*() const
|
|
|
|
{
|
OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224279
Reviewed by Darin Adler.
Source/WebCore:
OfflineAudioContext objects were always leaking due to 2 reference cycles:
1. BaseAudioContext -> m_listener (AudioListener) -> m_positionX (AudioParam) -> m_context (BaseAudioContext)
2. BaseAudioContext -> m_destinationNode (AudioDestinationNode) -> m_context (BaseAudioContext)
For reference cycle 1, I made AudioSummingJunction (base class of AudioParam) hold a weak pointer to the
AudioContext instead of a Ref<>. I don't think there is a good reason for an AudioSummingJunction (AudioParam
or AudioNodeInput) to keep its AudioContext alive. AudioNodes already keep their AudioContext alive.
AudioNodeInputs and AudioParams are associated to AudioNodes.
For reference cycle 2, I made AudioDestinationNode not hold a strong pointer to its context but instead a
weak pointer. Since keeping an AudioDestinationNode alive should keep its AudioContext alive, I made it so
that ref'ing the AudioDestinationNode refs its BaseAudioContext. Also, BaseAudioContext::m_destinationNode
is now a UniqueRef<> instead of a RefPtr<> to avoid a cycle.
Tests: webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html
webaudio/OfflineAudioContext/offlineaudiocontext-leak.html
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::baseLatency):
(WebCore::AudioContext::getOutputTimestamp):
(WebCore::AudioContext::close):
(WebCore::AudioContext::destination):
(WebCore::AudioContext::destination const):
(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::mediaState const):
(WebCore::AudioContext::mayResumePlayback):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::pageMutedStateDidChange):
* Modules/webaudio/AudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::ref):
(WebCore::AudioDestinationNode::deref):
* Modules/webaudio/AudioDestinationNode.h:
Have AudioDestinationNode override AudioNode's ref() / deref() to forward the refcounting
to its BaseAudioContext, instead of using the AudioNode's internal refCount.
* Modules/webaudio/AudioListener.cpp:
(WebCore::AudioListener::updateValuesIfNeeded):
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::setOrientation):
Add some null-checks for AudioParam::context() now that AudioParam holds a WeakPtr to its
context.
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::toWeakOrStrongContext):
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::connect):
(WebCore::AudioNode::sampleRate const):
(WebCore::AudioNode::markNodeForDeletionIfNecessary):
(WebCore::AudioNode::contextForBindings):
(WebCore::AudioNode::context):
(WebCore::AudioNode::context const):
* Modules/webaudio/AudioNode.h:
- Hold the BaseAudioContext as a WeakPtr instead of a Ref<> if the AudioNode is an
AudioDestinationNode. This avoids a reference cycle since the BaseAudioContext owns the
AudioDestinationNode. Even though we are using a WeakPtr, it is safe to assume that
the context is not null because ref'ing an AudioDestinationNode refs its BaseAudioContext.
- Make sure markNodeForDeletionIfNecessary() has no effect for AudioDestinationNode since
BaseAudioContext now owns the AudioDestinationNode when we take care of destroying its
destination node when destroyed.
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::connect):
(WebCore::AudioNodeInput::disconnect):
(WebCore::AudioNodeInput::outputEnabledStateChanged):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::internalSummingBus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):
Add assertions that the context is not null. There were already assertions that we are the graph
owner, which means we are holding the BaseAudioContext's lock, which means that the audio context
is alive.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::value):
(WebCore::AudioParam::setValueForBindings):
(WebCore::AudioParam::smooth):
(WebCore::AudioParam::hasSampleAccurateValues const):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
(WebCore::AudioParam::calculateTimelineValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
Add null-checks for the AudioContext now that the AudioParam is only holding a WeakPtr to its
BaseAudioContext (to avoid a reference cycle).
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::AudioSummingJunction):
(WebCore::AudioSummingJunction::~AudioSummingJunction):
(WebCore::AudioSummingJunction::markRenderingStateAsDirty):
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
(WebCore::AudioSummingJunction::outputEnabledStateChanged):
* Modules/webaudio/AudioSummingJunction.h:
(WebCore::AudioSummingJunction::context):
(WebCore::AudioSummingJunction::context const):
- Hold a WeakPtr to the BaseAudioContext to avoid a reference cycle.
- Deal with the fact that the audio context may be null now that we're holding a WeakPtr
to it (except when holding the graph lock)
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
(WebCore::BaseAudioContext::~BaseAudioContext):
(WebCore::BaseAudioContext::numberOfInstances):
(WebCore::BaseAudioContext::lazyInitialize):
(WebCore::BaseAudioContext::clear):
(WebCore::BaseAudioContext::uninitialize):
(WebCore::BaseAudioContext::stop):
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::decodeAudioData):
(WebCore::BaseAudioContext::markForDeletion):
(WebCore::BaseAudioContext::deleteMarkedNodes):
(WebCore::BaseAudioContext::setPendingActivity):
(WebCore::BaseAudioContext::workletIsReady):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::destination):
(WebCore::BaseAudioContext::destination const):
(WebCore::BaseAudioContext::currentSampleFrame const):
(WebCore::BaseAudioContext::currentTime const):
- Switch m_destinationNode from RefPtr<> to UniqueRef<> since the AudioContext is now
the owner of the destinationNode and since refing the destination node actually refs
its BaseAudioContext.
- Drop some null checks now that m_destinationNode can no longer be null.
- Rename makePendingActivity() to setPendingActivity() to avoid a naming conflict with
ActiveDOMObject::makePendingActivity().
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/OfflineAudioDestinationNode.h:
- Drop create() factory functions and make the constructor public now that the BaseAudioContext owns
its destination node via a UniqueRef<>.
- Make some member functions public as they are virtual and they now called on the subclass instead of the
base class (and these functions are public in the base class).
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
(WebCore::OfflineAudioContext::resumeOfflineRendering):
* Modules/webaudio/OfflineAudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::close):
Drop null checks for the destination node now that it can never be null.
* dom/ShadowRoot.cpp:
* rendering/FloatingObjects.cpp:
* rendering/RootInlineBox.cpp:
Update classes used of size restrictions since the size of a WeakPtr is not longer the same as the size of a
pointer when debug assertions are enabled. As long as they are the same size in release builds, there is no
memory use concern.
* testing/Internals.cpp:
(WebCore::Internals::numberOfBaseAudioContexts const):
* testing/Internals.h:
* testing/Internals.idl:
Add testing function to check how many BaseAudioContexts are alive, so that we can write layout tests and check
for leaks.
Source/WTF:
Add flag that can be passed when constructing a WeakPtr to disable threading assertions.
This is useful for cases where we know it is safe due to locking but we'd like to use a
WeakPtr instead of a raw pointer because it is safer.
* wtf/WeakPtr.h:
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const):
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::=):
(WTF::makeWeakPtr):
LayoutTests:
Add layout test coverage.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak.html: Added.
Canonical link: https://commits.webkit.org/236304@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 18:41:23 +00:00
|
|
|
ASSERT(!m_impl || !m_shouldEnableAssertions || m_impl->wasConstructedOnMainThread() == isMainThread());
|
2019-08-07 20:35:11 +00:00
|
|
|
return *get();
|
|
|
|
}
|
2013-01-15 21:35:08 +00:00
|
|
|
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
void clear() { m_impl = nullptr; }
|
2015-02-23 23:44:02 +00:00
|
|
|
|
2013-01-15 21:35:08 +00:00
|
|
|
private:
|
2021-06-12 01:42:09 +00:00
|
|
|
template<typename, typename, typename> friend class WeakHashMap;
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename, typename> friend class WeakHashSet;
|
|
|
|
template<typename, typename> friend class WeakPtr;
|
|
|
|
template<typename, typename> friend class WeakPtrFactory;
|
|
|
|
|
OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224279
Reviewed by Darin Adler.
Source/WebCore:
OfflineAudioContext objects were always leaking due to 2 reference cycles:
1. BaseAudioContext -> m_listener (AudioListener) -> m_positionX (AudioParam) -> m_context (BaseAudioContext)
2. BaseAudioContext -> m_destinationNode (AudioDestinationNode) -> m_context (BaseAudioContext)
For reference cycle 1, I made AudioSummingJunction (base class of AudioParam) hold a weak pointer to the
AudioContext instead of a Ref<>. I don't think there is a good reason for an AudioSummingJunction (AudioParam
or AudioNodeInput) to keep its AudioContext alive. AudioNodes already keep their AudioContext alive.
AudioNodeInputs and AudioParams are associated to AudioNodes.
For reference cycle 2, I made AudioDestinationNode not hold a strong pointer to its context but instead a
weak pointer. Since keeping an AudioDestinationNode alive should keep its AudioContext alive, I made it so
that ref'ing the AudioDestinationNode refs its BaseAudioContext. Also, BaseAudioContext::m_destinationNode
is now a UniqueRef<> instead of a RefPtr<> to avoid a cycle.
Tests: webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html
webaudio/OfflineAudioContext/offlineaudiocontext-leak.html
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::baseLatency):
(WebCore::AudioContext::getOutputTimestamp):
(WebCore::AudioContext::close):
(WebCore::AudioContext::destination):
(WebCore::AudioContext::destination const):
(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::mediaState const):
(WebCore::AudioContext::mayResumePlayback):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::pageMutedStateDidChange):
* Modules/webaudio/AudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::ref):
(WebCore::AudioDestinationNode::deref):
* Modules/webaudio/AudioDestinationNode.h:
Have AudioDestinationNode override AudioNode's ref() / deref() to forward the refcounting
to its BaseAudioContext, instead of using the AudioNode's internal refCount.
* Modules/webaudio/AudioListener.cpp:
(WebCore::AudioListener::updateValuesIfNeeded):
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::setOrientation):
Add some null-checks for AudioParam::context() now that AudioParam holds a WeakPtr to its
context.
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::toWeakOrStrongContext):
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::connect):
(WebCore::AudioNode::sampleRate const):
(WebCore::AudioNode::markNodeForDeletionIfNecessary):
(WebCore::AudioNode::contextForBindings):
(WebCore::AudioNode::context):
(WebCore::AudioNode::context const):
* Modules/webaudio/AudioNode.h:
- Hold the BaseAudioContext as a WeakPtr instead of a Ref<> if the AudioNode is an
AudioDestinationNode. This avoids a reference cycle since the BaseAudioContext owns the
AudioDestinationNode. Even though we are using a WeakPtr, it is safe to assume that
the context is not null because ref'ing an AudioDestinationNode refs its BaseAudioContext.
- Make sure markNodeForDeletionIfNecessary() has no effect for AudioDestinationNode since
BaseAudioContext now owns the AudioDestinationNode when we take care of destroying its
destination node when destroyed.
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::connect):
(WebCore::AudioNodeInput::disconnect):
(WebCore::AudioNodeInput::outputEnabledStateChanged):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::internalSummingBus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):
Add assertions that the context is not null. There were already assertions that we are the graph
owner, which means we are holding the BaseAudioContext's lock, which means that the audio context
is alive.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::value):
(WebCore::AudioParam::setValueForBindings):
(WebCore::AudioParam::smooth):
(WebCore::AudioParam::hasSampleAccurateValues const):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
(WebCore::AudioParam::calculateTimelineValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
Add null-checks for the AudioContext now that the AudioParam is only holding a WeakPtr to its
BaseAudioContext (to avoid a reference cycle).
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::AudioSummingJunction):
(WebCore::AudioSummingJunction::~AudioSummingJunction):
(WebCore::AudioSummingJunction::markRenderingStateAsDirty):
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
(WebCore::AudioSummingJunction::outputEnabledStateChanged):
* Modules/webaudio/AudioSummingJunction.h:
(WebCore::AudioSummingJunction::context):
(WebCore::AudioSummingJunction::context const):
- Hold a WeakPtr to the BaseAudioContext to avoid a reference cycle.
- Deal with the fact that the audio context may be null now that we're holding a WeakPtr
to it (except when holding the graph lock)
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
(WebCore::BaseAudioContext::~BaseAudioContext):
(WebCore::BaseAudioContext::numberOfInstances):
(WebCore::BaseAudioContext::lazyInitialize):
(WebCore::BaseAudioContext::clear):
(WebCore::BaseAudioContext::uninitialize):
(WebCore::BaseAudioContext::stop):
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::decodeAudioData):
(WebCore::BaseAudioContext::markForDeletion):
(WebCore::BaseAudioContext::deleteMarkedNodes):
(WebCore::BaseAudioContext::setPendingActivity):
(WebCore::BaseAudioContext::workletIsReady):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::destination):
(WebCore::BaseAudioContext::destination const):
(WebCore::BaseAudioContext::currentSampleFrame const):
(WebCore::BaseAudioContext::currentTime const):
- Switch m_destinationNode from RefPtr<> to UniqueRef<> since the AudioContext is now
the owner of the destinationNode and since refing the destination node actually refs
its BaseAudioContext.
- Drop some null checks now that m_destinationNode can no longer be null.
- Rename makePendingActivity() to setPendingActivity() to avoid a naming conflict with
ActiveDOMObject::makePendingActivity().
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/OfflineAudioDestinationNode.h:
- Drop create() factory functions and make the constructor public now that the BaseAudioContext owns
its destination node via a UniqueRef<>.
- Make some member functions public as they are virtual and they now called on the subclass instead of the
base class (and these functions are public in the base class).
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
(WebCore::OfflineAudioContext::resumeOfflineRendering):
* Modules/webaudio/OfflineAudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::close):
Drop null checks for the destination node now that it can never be null.
* dom/ShadowRoot.cpp:
* rendering/FloatingObjects.cpp:
* rendering/RootInlineBox.cpp:
Update classes used of size restrictions since the size of a WeakPtr is not longer the same as the size of a
pointer when debug assertions are enabled. As long as they are the same size in release builds, there is no
memory use concern.
* testing/Internals.cpp:
(WebCore::Internals::numberOfBaseAudioContexts const):
* testing/Internals.h:
* testing/Internals.idl:
Add testing function to check how many BaseAudioContexts are alive, so that we can write layout tests and check
for leaks.
Source/WTF:
Add flag that can be passed when constructing a WeakPtr to disable threading assertions.
This is useful for cases where we know it is safe due to locking but we'd like to use a
WeakPtr instead of a raw pointer because it is safer.
* wtf/WeakPtr.h:
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const):
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::=):
(WTF::makeWeakPtr):
LayoutTests:
Add layout test coverage.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak.html: Added.
Canonical link: https://commits.webkit.org/236304@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 18:41:23 +00:00
|
|
|
explicit WeakPtr(Ref<WeakPtrImpl<Counter>>&& ref, EnableWeakPtrThreadingAssertions shouldEnableAssertions)
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
: m_impl(WTFMove(ref))
|
OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224279
Reviewed by Darin Adler.
Source/WebCore:
OfflineAudioContext objects were always leaking due to 2 reference cycles:
1. BaseAudioContext -> m_listener (AudioListener) -> m_positionX (AudioParam) -> m_context (BaseAudioContext)
2. BaseAudioContext -> m_destinationNode (AudioDestinationNode) -> m_context (BaseAudioContext)
For reference cycle 1, I made AudioSummingJunction (base class of AudioParam) hold a weak pointer to the
AudioContext instead of a Ref<>. I don't think there is a good reason for an AudioSummingJunction (AudioParam
or AudioNodeInput) to keep its AudioContext alive. AudioNodes already keep their AudioContext alive.
AudioNodeInputs and AudioParams are associated to AudioNodes.
For reference cycle 2, I made AudioDestinationNode not hold a strong pointer to its context but instead a
weak pointer. Since keeping an AudioDestinationNode alive should keep its AudioContext alive, I made it so
that ref'ing the AudioDestinationNode refs its BaseAudioContext. Also, BaseAudioContext::m_destinationNode
is now a UniqueRef<> instead of a RefPtr<> to avoid a cycle.
Tests: webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html
webaudio/OfflineAudioContext/offlineaudiocontext-leak.html
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::baseLatency):
(WebCore::AudioContext::getOutputTimestamp):
(WebCore::AudioContext::close):
(WebCore::AudioContext::destination):
(WebCore::AudioContext::destination const):
(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::mediaState const):
(WebCore::AudioContext::mayResumePlayback):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::pageMutedStateDidChange):
* Modules/webaudio/AudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::ref):
(WebCore::AudioDestinationNode::deref):
* Modules/webaudio/AudioDestinationNode.h:
Have AudioDestinationNode override AudioNode's ref() / deref() to forward the refcounting
to its BaseAudioContext, instead of using the AudioNode's internal refCount.
* Modules/webaudio/AudioListener.cpp:
(WebCore::AudioListener::updateValuesIfNeeded):
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::setOrientation):
Add some null-checks for AudioParam::context() now that AudioParam holds a WeakPtr to its
context.
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::toWeakOrStrongContext):
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::connect):
(WebCore::AudioNode::sampleRate const):
(WebCore::AudioNode::markNodeForDeletionIfNecessary):
(WebCore::AudioNode::contextForBindings):
(WebCore::AudioNode::context):
(WebCore::AudioNode::context const):
* Modules/webaudio/AudioNode.h:
- Hold the BaseAudioContext as a WeakPtr instead of a Ref<> if the AudioNode is an
AudioDestinationNode. This avoids a reference cycle since the BaseAudioContext owns the
AudioDestinationNode. Even though we are using a WeakPtr, it is safe to assume that
the context is not null because ref'ing an AudioDestinationNode refs its BaseAudioContext.
- Make sure markNodeForDeletionIfNecessary() has no effect for AudioDestinationNode since
BaseAudioContext now owns the AudioDestinationNode when we take care of destroying its
destination node when destroyed.
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::connect):
(WebCore::AudioNodeInput::disconnect):
(WebCore::AudioNodeInput::outputEnabledStateChanged):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::internalSummingBus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):
Add assertions that the context is not null. There were already assertions that we are the graph
owner, which means we are holding the BaseAudioContext's lock, which means that the audio context
is alive.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::value):
(WebCore::AudioParam::setValueForBindings):
(WebCore::AudioParam::smooth):
(WebCore::AudioParam::hasSampleAccurateValues const):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
(WebCore::AudioParam::calculateTimelineValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
Add null-checks for the AudioContext now that the AudioParam is only holding a WeakPtr to its
BaseAudioContext (to avoid a reference cycle).
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::AudioSummingJunction):
(WebCore::AudioSummingJunction::~AudioSummingJunction):
(WebCore::AudioSummingJunction::markRenderingStateAsDirty):
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
(WebCore::AudioSummingJunction::outputEnabledStateChanged):
* Modules/webaudio/AudioSummingJunction.h:
(WebCore::AudioSummingJunction::context):
(WebCore::AudioSummingJunction::context const):
- Hold a WeakPtr to the BaseAudioContext to avoid a reference cycle.
- Deal with the fact that the audio context may be null now that we're holding a WeakPtr
to it (except when holding the graph lock)
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
(WebCore::BaseAudioContext::~BaseAudioContext):
(WebCore::BaseAudioContext::numberOfInstances):
(WebCore::BaseAudioContext::lazyInitialize):
(WebCore::BaseAudioContext::clear):
(WebCore::BaseAudioContext::uninitialize):
(WebCore::BaseAudioContext::stop):
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::decodeAudioData):
(WebCore::BaseAudioContext::markForDeletion):
(WebCore::BaseAudioContext::deleteMarkedNodes):
(WebCore::BaseAudioContext::setPendingActivity):
(WebCore::BaseAudioContext::workletIsReady):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::destination):
(WebCore::BaseAudioContext::destination const):
(WebCore::BaseAudioContext::currentSampleFrame const):
(WebCore::BaseAudioContext::currentTime const):
- Switch m_destinationNode from RefPtr<> to UniqueRef<> since the AudioContext is now
the owner of the destinationNode and since refing the destination node actually refs
its BaseAudioContext.
- Drop some null checks now that m_destinationNode can no longer be null.
- Rename makePendingActivity() to setPendingActivity() to avoid a naming conflict with
ActiveDOMObject::makePendingActivity().
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/OfflineAudioDestinationNode.h:
- Drop create() factory functions and make the constructor public now that the BaseAudioContext owns
its destination node via a UniqueRef<>.
- Make some member functions public as they are virtual and they now called on the subclass instead of the
base class (and these functions are public in the base class).
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
(WebCore::OfflineAudioContext::resumeOfflineRendering):
* Modules/webaudio/OfflineAudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::close):
Drop null checks for the destination node now that it can never be null.
* dom/ShadowRoot.cpp:
* rendering/FloatingObjects.cpp:
* rendering/RootInlineBox.cpp:
Update classes used of size restrictions since the size of a WeakPtr is not longer the same as the size of a
pointer when debug assertions are enabled. As long as they are the same size in release builds, there is no
memory use concern.
* testing/Internals.cpp:
(WebCore::Internals::numberOfBaseAudioContexts const):
* testing/Internals.h:
* testing/Internals.idl:
Add testing function to check how many BaseAudioContexts are alive, so that we can write layout tests and check
for leaks.
Source/WTF:
Add flag that can be passed when constructing a WeakPtr to disable threading assertions.
This is useful for cases where we know it is safe due to locking but we'd like to use a
WeakPtr instead of a raw pointer because it is safer.
* wtf/WeakPtr.h:
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const):
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::=):
(WTF::makeWeakPtr):
LayoutTests:
Add layout test coverage.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak.html: Added.
Canonical link: https://commits.webkit.org/236304@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 18:41:23 +00:00
|
|
|
#if ASSERT_ENABLED
|
|
|
|
, m_shouldEnableAssertions(shouldEnableAssertions == EnableWeakPtrThreadingAssertions::Yes)
|
|
|
|
#endif
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
{
|
OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224279
Reviewed by Darin Adler.
Source/WebCore:
OfflineAudioContext objects were always leaking due to 2 reference cycles:
1. BaseAudioContext -> m_listener (AudioListener) -> m_positionX (AudioParam) -> m_context (BaseAudioContext)
2. BaseAudioContext -> m_destinationNode (AudioDestinationNode) -> m_context (BaseAudioContext)
For reference cycle 1, I made AudioSummingJunction (base class of AudioParam) hold a weak pointer to the
AudioContext instead of a Ref<>. I don't think there is a good reason for an AudioSummingJunction (AudioParam
or AudioNodeInput) to keep its AudioContext alive. AudioNodes already keep their AudioContext alive.
AudioNodeInputs and AudioParams are associated to AudioNodes.
For reference cycle 2, I made AudioDestinationNode not hold a strong pointer to its context but instead a
weak pointer. Since keeping an AudioDestinationNode alive should keep its AudioContext alive, I made it so
that ref'ing the AudioDestinationNode refs its BaseAudioContext. Also, BaseAudioContext::m_destinationNode
is now a UniqueRef<> instead of a RefPtr<> to avoid a cycle.
Tests: webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html
webaudio/OfflineAudioContext/offlineaudiocontext-leak.html
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::baseLatency):
(WebCore::AudioContext::getOutputTimestamp):
(WebCore::AudioContext::close):
(WebCore::AudioContext::destination):
(WebCore::AudioContext::destination const):
(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::mediaState const):
(WebCore::AudioContext::mayResumePlayback):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::pageMutedStateDidChange):
* Modules/webaudio/AudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::ref):
(WebCore::AudioDestinationNode::deref):
* Modules/webaudio/AudioDestinationNode.h:
Have AudioDestinationNode override AudioNode's ref() / deref() to forward the refcounting
to its BaseAudioContext, instead of using the AudioNode's internal refCount.
* Modules/webaudio/AudioListener.cpp:
(WebCore::AudioListener::updateValuesIfNeeded):
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::setOrientation):
Add some null-checks for AudioParam::context() now that AudioParam holds a WeakPtr to its
context.
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::toWeakOrStrongContext):
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::connect):
(WebCore::AudioNode::sampleRate const):
(WebCore::AudioNode::markNodeForDeletionIfNecessary):
(WebCore::AudioNode::contextForBindings):
(WebCore::AudioNode::context):
(WebCore::AudioNode::context const):
* Modules/webaudio/AudioNode.h:
- Hold the BaseAudioContext as a WeakPtr instead of a Ref<> if the AudioNode is an
AudioDestinationNode. This avoids a reference cycle since the BaseAudioContext owns the
AudioDestinationNode. Even though we are using a WeakPtr, it is safe to assume that
the context is not null because ref'ing an AudioDestinationNode refs its BaseAudioContext.
- Make sure markNodeForDeletionIfNecessary() has no effect for AudioDestinationNode since
BaseAudioContext now owns the AudioDestinationNode when we take care of destroying its
destination node when destroyed.
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::connect):
(WebCore::AudioNodeInput::disconnect):
(WebCore::AudioNodeInput::outputEnabledStateChanged):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::internalSummingBus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):
Add assertions that the context is not null. There were already assertions that we are the graph
owner, which means we are holding the BaseAudioContext's lock, which means that the audio context
is alive.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::value):
(WebCore::AudioParam::setValueForBindings):
(WebCore::AudioParam::smooth):
(WebCore::AudioParam::hasSampleAccurateValues const):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
(WebCore::AudioParam::calculateTimelineValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
Add null-checks for the AudioContext now that the AudioParam is only holding a WeakPtr to its
BaseAudioContext (to avoid a reference cycle).
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::AudioSummingJunction):
(WebCore::AudioSummingJunction::~AudioSummingJunction):
(WebCore::AudioSummingJunction::markRenderingStateAsDirty):
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
(WebCore::AudioSummingJunction::outputEnabledStateChanged):
* Modules/webaudio/AudioSummingJunction.h:
(WebCore::AudioSummingJunction::context):
(WebCore::AudioSummingJunction::context const):
- Hold a WeakPtr to the BaseAudioContext to avoid a reference cycle.
- Deal with the fact that the audio context may be null now that we're holding a WeakPtr
to it (except when holding the graph lock)
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
(WebCore::BaseAudioContext::~BaseAudioContext):
(WebCore::BaseAudioContext::numberOfInstances):
(WebCore::BaseAudioContext::lazyInitialize):
(WebCore::BaseAudioContext::clear):
(WebCore::BaseAudioContext::uninitialize):
(WebCore::BaseAudioContext::stop):
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::decodeAudioData):
(WebCore::BaseAudioContext::markForDeletion):
(WebCore::BaseAudioContext::deleteMarkedNodes):
(WebCore::BaseAudioContext::setPendingActivity):
(WebCore::BaseAudioContext::workletIsReady):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::destination):
(WebCore::BaseAudioContext::destination const):
(WebCore::BaseAudioContext::currentSampleFrame const):
(WebCore::BaseAudioContext::currentTime const):
- Switch m_destinationNode from RefPtr<> to UniqueRef<> since the AudioContext is now
the owner of the destinationNode and since refing the destination node actually refs
its BaseAudioContext.
- Drop some null checks now that m_destinationNode can no longer be null.
- Rename makePendingActivity() to setPendingActivity() to avoid a naming conflict with
ActiveDOMObject::makePendingActivity().
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/OfflineAudioDestinationNode.h:
- Drop create() factory functions and make the constructor public now that the BaseAudioContext owns
its destination node via a UniqueRef<>.
- Make some member functions public as they are virtual and they now called on the subclass instead of the
base class (and these functions are public in the base class).
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
(WebCore::OfflineAudioContext::resumeOfflineRendering):
* Modules/webaudio/OfflineAudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::close):
Drop null checks for the destination node now that it can never be null.
* dom/ShadowRoot.cpp:
* rendering/FloatingObjects.cpp:
* rendering/RootInlineBox.cpp:
Update classes used of size restrictions since the size of a WeakPtr is not longer the same as the size of a
pointer when debug assertions are enabled. As long as they are the same size in release builds, there is no
memory use concern.
* testing/Internals.cpp:
(WebCore::Internals::numberOfBaseAudioContexts const):
* testing/Internals.h:
* testing/Internals.idl:
Add testing function to check how many BaseAudioContexts are alive, so that we can write layout tests and check
for leaks.
Source/WTF:
Add flag that can be passed when constructing a WeakPtr to disable threading assertions.
This is useful for cases where we know it is safe due to locking but we'd like to use a
WeakPtr instead of a raw pointer because it is safer.
* wtf/WeakPtr.h:
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const):
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::=):
(WTF::makeWeakPtr):
LayoutTests:
Add layout test coverage.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak.html: Added.
Canonical link: https://commits.webkit.org/236304@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 18:41:23 +00:00
|
|
|
UNUSED_PARAM(shouldEnableAssertions);
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
}
|
2017-10-03 18:48:57 +00:00
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
RefPtr<WeakPtrImpl<Counter>> m_impl;
|
OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224279
Reviewed by Darin Adler.
Source/WebCore:
OfflineAudioContext objects were always leaking due to 2 reference cycles:
1. BaseAudioContext -> m_listener (AudioListener) -> m_positionX (AudioParam) -> m_context (BaseAudioContext)
2. BaseAudioContext -> m_destinationNode (AudioDestinationNode) -> m_context (BaseAudioContext)
For reference cycle 1, I made AudioSummingJunction (base class of AudioParam) hold a weak pointer to the
AudioContext instead of a Ref<>. I don't think there is a good reason for an AudioSummingJunction (AudioParam
or AudioNodeInput) to keep its AudioContext alive. AudioNodes already keep their AudioContext alive.
AudioNodeInputs and AudioParams are associated to AudioNodes.
For reference cycle 2, I made AudioDestinationNode not hold a strong pointer to its context but instead a
weak pointer. Since keeping an AudioDestinationNode alive should keep its AudioContext alive, I made it so
that ref'ing the AudioDestinationNode refs its BaseAudioContext. Also, BaseAudioContext::m_destinationNode
is now a UniqueRef<> instead of a RefPtr<> to avoid a cycle.
Tests: webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html
webaudio/OfflineAudioContext/offlineaudiocontext-leak.html
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::baseLatency):
(WebCore::AudioContext::getOutputTimestamp):
(WebCore::AudioContext::close):
(WebCore::AudioContext::destination):
(WebCore::AudioContext::destination const):
(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::mediaState const):
(WebCore::AudioContext::mayResumePlayback):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::pageMutedStateDidChange):
* Modules/webaudio/AudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::ref):
(WebCore::AudioDestinationNode::deref):
* Modules/webaudio/AudioDestinationNode.h:
Have AudioDestinationNode override AudioNode's ref() / deref() to forward the refcounting
to its BaseAudioContext, instead of using the AudioNode's internal refCount.
* Modules/webaudio/AudioListener.cpp:
(WebCore::AudioListener::updateValuesIfNeeded):
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::setOrientation):
Add some null-checks for AudioParam::context() now that AudioParam holds a WeakPtr to its
context.
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::toWeakOrStrongContext):
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::connect):
(WebCore::AudioNode::sampleRate const):
(WebCore::AudioNode::markNodeForDeletionIfNecessary):
(WebCore::AudioNode::contextForBindings):
(WebCore::AudioNode::context):
(WebCore::AudioNode::context const):
* Modules/webaudio/AudioNode.h:
- Hold the BaseAudioContext as a WeakPtr instead of a Ref<> if the AudioNode is an
AudioDestinationNode. This avoids a reference cycle since the BaseAudioContext owns the
AudioDestinationNode. Even though we are using a WeakPtr, it is safe to assume that
the context is not null because ref'ing an AudioDestinationNode refs its BaseAudioContext.
- Make sure markNodeForDeletionIfNecessary() has no effect for AudioDestinationNode since
BaseAudioContext now owns the AudioDestinationNode when we take care of destroying its
destination node when destroyed.
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::connect):
(WebCore::AudioNodeInput::disconnect):
(WebCore::AudioNodeInput::outputEnabledStateChanged):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::internalSummingBus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):
Add assertions that the context is not null. There were already assertions that we are the graph
owner, which means we are holding the BaseAudioContext's lock, which means that the audio context
is alive.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::value):
(WebCore::AudioParam::setValueForBindings):
(WebCore::AudioParam::smooth):
(WebCore::AudioParam::hasSampleAccurateValues const):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
(WebCore::AudioParam::calculateTimelineValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
Add null-checks for the AudioContext now that the AudioParam is only holding a WeakPtr to its
BaseAudioContext (to avoid a reference cycle).
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::AudioSummingJunction):
(WebCore::AudioSummingJunction::~AudioSummingJunction):
(WebCore::AudioSummingJunction::markRenderingStateAsDirty):
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
(WebCore::AudioSummingJunction::outputEnabledStateChanged):
* Modules/webaudio/AudioSummingJunction.h:
(WebCore::AudioSummingJunction::context):
(WebCore::AudioSummingJunction::context const):
- Hold a WeakPtr to the BaseAudioContext to avoid a reference cycle.
- Deal with the fact that the audio context may be null now that we're holding a WeakPtr
to it (except when holding the graph lock)
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
(WebCore::BaseAudioContext::~BaseAudioContext):
(WebCore::BaseAudioContext::numberOfInstances):
(WebCore::BaseAudioContext::lazyInitialize):
(WebCore::BaseAudioContext::clear):
(WebCore::BaseAudioContext::uninitialize):
(WebCore::BaseAudioContext::stop):
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::decodeAudioData):
(WebCore::BaseAudioContext::markForDeletion):
(WebCore::BaseAudioContext::deleteMarkedNodes):
(WebCore::BaseAudioContext::setPendingActivity):
(WebCore::BaseAudioContext::workletIsReady):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::destination):
(WebCore::BaseAudioContext::destination const):
(WebCore::BaseAudioContext::currentSampleFrame const):
(WebCore::BaseAudioContext::currentTime const):
- Switch m_destinationNode from RefPtr<> to UniqueRef<> since the AudioContext is now
the owner of the destinationNode and since refing the destination node actually refs
its BaseAudioContext.
- Drop some null checks now that m_destinationNode can no longer be null.
- Rename makePendingActivity() to setPendingActivity() to avoid a naming conflict with
ActiveDOMObject::makePendingActivity().
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/OfflineAudioDestinationNode.h:
- Drop create() factory functions and make the constructor public now that the BaseAudioContext owns
its destination node via a UniqueRef<>.
- Make some member functions public as they are virtual and they now called on the subclass instead of the
base class (and these functions are public in the base class).
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
(WebCore::OfflineAudioContext::resumeOfflineRendering):
* Modules/webaudio/OfflineAudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::close):
Drop null checks for the destination node now that it can never be null.
* dom/ShadowRoot.cpp:
* rendering/FloatingObjects.cpp:
* rendering/RootInlineBox.cpp:
Update classes used of size restrictions since the size of a WeakPtr is not longer the same as the size of a
pointer when debug assertions are enabled. As long as they are the same size in release builds, there is no
memory use concern.
* testing/Internals.cpp:
(WebCore::Internals::numberOfBaseAudioContexts const):
* testing/Internals.h:
* testing/Internals.idl:
Add testing function to check how many BaseAudioContexts are alive, so that we can write layout tests and check
for leaks.
Source/WTF:
Add flag that can be passed when constructing a WeakPtr to disable threading assertions.
This is useful for cases where we know it is safe due to locking but we'd like to use a
WeakPtr instead of a raw pointer because it is safer.
* wtf/WeakPtr.h:
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const):
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::=):
(WTF::makeWeakPtr):
LayoutTests:
Add layout test coverage.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak.html: Added.
Canonical link: https://commits.webkit.org/236304@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 18:41:23 +00:00
|
|
|
#if ASSERT_ENABLED
|
|
|
|
bool m_shouldEnableAssertions { true };
|
|
|
|
#endif
|
2013-01-15 21:35:08 +00:00
|
|
|
};
|
|
|
|
|
2018-08-15 15:17:55 +00:00
|
|
|
// Note: you probably want to inherit from CanMakeWeakPtr rather than use this directly.
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, typename Counter = EmptyCounter> class WeakPtrFactory {
|
|
|
|
WTF_MAKE_NONCOPYABLE(WeakPtrFactory);
|
2013-01-15 21:35:08 +00:00
|
|
|
WTF_MAKE_FAST_ALLOCATED;
|
|
|
|
public:
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
using CounterType = Counter;
|
|
|
|
|
2019-07-14 22:18:03 +00:00
|
|
|
WeakPtrFactory()
|
PerformanceTests:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* JetStream2/wasm/HashSet.cpp:
* StitchMarker/wtf/Assertions.h:
* StitchMarker/wtf/DateMath.cpp:
(WTF::initializeDates):
* StitchMarker/wtf/HashTable.h:
* StitchMarker/wtf/Hasher.h:
(WTF::StringHasher::addCharacters):
* StitchMarker/wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* StitchMarker/wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* StitchMarker/wtf/ValueCheck.h:
* StitchMarker/wtf/Vector.h:
(WTF::minCapacity>::checkConsistency):
* StitchMarker/wtf/text/AtomicStringImpl.cpp:
* StitchMarker/wtf/text/AtomicStringImpl.h:
* StitchMarker/wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* StitchMarker/wtf/text/StringImpl.h:
* StitchMarker/wtf/text/SymbolImpl.h:
* StitchMarker/wtf/text/UniquedStringImpl.h:
Source/JavaScriptCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* API/tests/testapi.c:
* assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::replaceWithLoad):
(JSC::ARM64Assembler::replaceWithAddressComputation):
* assembler/AssemblerBuffer.h:
(JSC::AssemblerBuffer::LocalWriter::LocalWriter):
* assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::copyCompactAndLinkCode):
* assembler/ProbeStack.cpp:
(JSC::Probe::Stack::Stack):
* assembler/ProbeStack.h:
* b3/B3FoldPathConstants.cpp:
* b3/B3LowerToAir.cpp:
* b3/B3MemoryValue.cpp:
(JSC::B3::MemoryValue::MemoryValue):
* b3/B3Opcode.cpp:
* b3/B3Type.h:
* b3/B3TypeMap.h:
* b3/B3Width.h:
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp:
(JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration):
(JSC::B3::Air::GenerateAndAllocateRegisters::generate):
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.h:
* b3/air/AirAllocateRegistersByGraphColoring.cpp:
* b3/air/AirArg.cpp:
* b3/air/AirArg.h:
* b3/air/AirCode.h:
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* bytecode/AccessCase.cpp:
* bytecode/AccessCase.h:
* bytecode/CallVariant.cpp:
(JSC::variantListWithVariant):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex):
* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::dump const):
* bytecode/StructureStubInfo.cpp:
* bytecode/StructureStubInfo.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionCallResolveNode::emitBytecode):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::RegisterID):
(JSC::RegisterID::setIndex):
* debugger/Debugger.cpp:
(JSC::Debugger::removeBreakpoint):
* debugger/DebuggerEvalEnabler.h:
(JSC::DebuggerEvalEnabler::DebuggerEvalEnabler):
(JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions):
* dfg/DFGAbstractValue.cpp:
* dfg/DFGAbstractValue.h:
(JSC::DFG::AbstractValue::merge):
(JSC::DFG::AbstractValue::checkConsistency const):
(JSC::DFG::AbstractValue::assertIsRegistered const):
* dfg/DFGArithMode.h:
(JSC::DFG::doesOverflow):
* dfg/DFGBasicBlock.cpp:
(JSC::DFG::BasicBlock::BasicBlock):
* dfg/DFGBasicBlock.h:
(JSC::DFG::BasicBlock::didLink):
* dfg/DFGCFAPhase.cpp:
(JSC::DFG::CFAPhase::performBlockCFA):
* dfg/DFGCommon.h:
(JSC::DFG::validationEnabled):
* dfg/DFGCommonData.cpp:
(JSC::DFG::CommonData::finalizeCatchEntrypoints):
* dfg/DFGDesiredWatchpoints.h:
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGEdge.h:
(JSC::DFG::Edge::makeWord):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::finalizeOSREntrypoints):
* dfg/DFGObjectAllocationSinkingPhase.cpp:
* dfg/DFGSSAConversionPhase.cpp:
(JSC::DFG::SSAConversionPhase::run):
* dfg/DFGScoreBoard.h:
(JSC::DFG::ScoreBoard::assertClear):
* dfg/DFGSlowPathGenerator.h:
(JSC::DFG::SlowPathGenerator::generate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
(JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse):
(JSC::DFG::SpeculativeJIT::emitAllocateButterfly):
(JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize):
(JSC::DFG::SpeculativeJIT::compileMakeRope):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
* dfg/DFGStructureAbstractValue.cpp:
* dfg/DFGStructureAbstractValue.h:
(JSC::DFG::StructureAbstractValue::assertIsRegistered const):
* dfg/DFGVarargsForwardingPhase.cpp:
* dfg/DFGVirtualRegisterAllocationPhase.cpp:
(JSC::DFG::VirtualRegisterAllocationPhase::run):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::callPreflight):
(JSC::FTL::DFG::LowerDFGToB3::callCheck):
(JSC::FTL::DFG::LowerDFGToB3::crash):
* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::assertNoUnswept):
* heap/GCSegmentedArray.h:
(JSC::GCArraySegment::GCArraySegment):
* heap/GCSegmentedArrayInlines.h:
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::validatePrevious):
* heap/HandleSet.cpp:
* heap/HandleSet.h:
* heap/Heap.cpp:
(JSC::Heap::updateAllocationLimits):
* heap/Heap.h:
* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::assertValidCell const):
(JSC::MarkedBlock::assertMarksNotStale):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::beginMarking):
(JSC::MarkedSpace::endMarking):
(JSC::MarkedSpace::assertNoUnswept):
* heap/PreciseAllocation.cpp:
* heap/PreciseAllocation.h:
(JSC::PreciseAllocation::assertValidCell const):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::appendJSCellOrAuxiliary):
* heap/SlotVisitor.h:
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
(CppProtocolTypesImplementationGenerator):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* interpreter/FrameTracers.h:
(JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::Interpreter):
* interpreter/Interpreter.h:
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::prepareCallOperation):
* jit/BinarySwitch.cpp:
(JSC::BinarySwitch::BinarySwitch):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupStubArgs):
* jit/CallFrameShuffler.cpp:
(JSC::CallFrameShuffler::emitDeltaCheck):
(JSC::CallFrameShuffler::prepareAny):
* jit/JIT.cpp:
(JSC::JIT::assertStackPointerOffset):
(JSC::JIT::compileWithoutLinking):
* jit/JITOpcodes.cpp:
(JSC::JIT::emitSlow_op_loop_hint):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
* jit/ThunkGenerators.cpp:
(JSC::emitPointerValidation):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LLIntOfflineAsmConfig.h:
* parser/Lexer.cpp:
* parser/Lexer.h:
(JSC::isSafeBuiltinIdentifier):
(JSC::Lexer<T>::lexExpectIdentifier):
* runtime/ArgList.h:
(JSC::MarkedArgumentBuffer::setNeedsOverflowCheck):
(JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck):
* runtime/Butterfly.h:
(JSC::ContiguousData::ContiguousData):
(JSC::ContiguousData::Data::Data):
* runtime/HashMapImpl.h:
(JSC::HashMapImpl::checkConsistency const):
(JSC::HashMapImpl::assertBufferIsEmpty const):
* runtime/JSCellInlines.h:
(JSC::JSCell::methodTable const):
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
(JSC::JSFunction::assertTypeInfoFlagInvariants):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren):
(JSC::JSFinalObject::visitChildren):
* runtime/JSObjectInlines.h:
(JSC::JSObject::validatePutOwnDataProperty):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::assertVariableIsInThisObject):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lex):
* runtime/LiteralParser.h:
* runtime/Operations.h:
(JSC::scribbleFreeCells):
* runtime/OptionsList.h:
* runtime/VM.cpp:
(JSC::VM::computeCanUseJIT):
* runtime/VM.h:
(JSC::VM::canUseJIT):
* runtime/VarOffset.h:
(JSC::VarOffset::checkSanity const):
* runtime/WeakMapImpl.h:
(JSC::WeakMapImpl::checkConsistency const):
(JSC::WeakMapImpl::assertBufferIsEmpty const):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::validateInst):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile):
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser::validationFail const):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::checkConsistency):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast):
* wasm/WasmSectionParser.h:
* wasm/WasmSections.h:
* wasm/WasmSignatureInlines.h:
(JSC::Wasm::SignatureInformation::get):
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::enqueue):
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::previousInstanceOffset const):
Source/WebCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::close):
* Modules/fetch/FetchBodySource.h:
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
(WebCore::DatabaseDetails::operator=):
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTask::performTask):
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::terminationRequested const):
* Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h:
(WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation):
* Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp:
(WebCore::WHLSL::findHighZombies):
* Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
(WebCore::WHLSL::matches):
* Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:
(WebCore::WHLSL::checkLiteralTypes):
* Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp:
(WebCore::WHLSL::FindAllTypes::appendNamedType):
* bindings/js/JSCallbackData.h:
* bindings/js/JSLazyEventListener.cpp:
* bindings/js/JSLazyEventListener.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcOperationNode::primitiveType const):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValue.cpp:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/CSSStyleSheet.cpp:
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::suspendIfNeeded):
(WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const):
* dom/ActiveDOMObject.h:
* dom/ContainerNode.cpp:
* dom/ContainerNodeAlgorithms.cpp:
* dom/ContainerNodeAlgorithms.h:
* dom/CustomElementReactionQueue.cpp:
* dom/CustomElementReactionQueue.h:
(WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope):
(WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope):
* dom/Document.cpp:
(WebCore::Document::hitTest):
* dom/Document.h:
(WebCore::Document::decrementReferencingNodeCount):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::getURLAttribute const):
(WebCore::Element::getNonEmptyURLAttribute const):
* dom/Element.h:
* dom/ElementAndTextDescendantIterator.h:
(WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator):
(WebCore::ElementAndTextDescendantIterator::dropAssertions):
(WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack):
(WebCore::ElementAndTextDescendantIterator::traverseNextSibling):
(WebCore::ElementAndTextDescendantIterator::traversePreviousSibling):
* dom/ElementDescendantIterator.h:
(WebCore::ElementDescendantIterator::ElementDescendantIterator):
(WebCore::ElementDescendantIterator::dropAssertions):
(WebCore::ElementDescendantIterator::operator++):
(WebCore::ElementDescendantIterator::operator--):
(WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator):
(WebCore::ElementDescendantConstIterator::dropAssertions):
(WebCore::ElementDescendantConstIterator::operator++):
* dom/ElementIterator.h:
(WebCore::ElementIterator<ElementType>::ElementIterator):
(WebCore::ElementIterator<ElementType>::traverseNext):
(WebCore::ElementIterator<ElementType>::traversePrevious):
(WebCore::ElementIterator<ElementType>::traverseNextSibling):
(WebCore::ElementIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementIterator<ElementType>::dropAssertions):
(WebCore::ElementIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::ElementConstIterator):
(WebCore::ElementConstIterator<ElementType>::traverseNext):
(WebCore::ElementConstIterator<ElementType>::traversePrevious):
(WebCore::ElementConstIterator<ElementType>::traverseNextSibling):
(WebCore::ElementConstIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementConstIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::dropAssertions):
* dom/EventContext.cpp:
* dom/EventContext.h:
* dom/EventListener.h:
* dom/EventPath.cpp:
* dom/EventSender.h:
* dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
(WebCore::EventTarget::setAttributeEventListener):
(WebCore::EventTarget::innerInvokeEventListeners):
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::moveNodeToNewDocument):
(WebCore::Node::removedLastRef):
* dom/Node.h:
(WebCore::Node::deref const):
* dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
* dom/ScriptExecutionContext.h:
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute const):
* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::removeSlotElementByName):
(WebCore::SlotAssignment::resolveSlotsAfterSlotMutation):
(WebCore::SlotAssignment::findFirstSlotElement):
* dom/SlotAssignment.h:
* dom/TreeScopeOrderedMap.cpp:
(WebCore::TreeScopeOrderedMap::add):
(WebCore::TreeScopeOrderedMap::get const):
* dom/TreeScopeOrderedMap.h:
* fileapi/Blob.cpp:
* fileapi/Blob.h:
* history/BackForwardCache.cpp:
(WebCore::BackForwardCache::removeAllItemsForPage):
* history/BackForwardCache.h:
* html/CanvasBase.cpp:
(WebCore::CanvasBase::notifyObserversCanvasDestroyed):
* html/CanvasBase.h:
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::didPopulate):
* html/HTMLSelectElement.cpp:
(WebCore:: const):
* html/HTMLTableRowsCollection.cpp:
(WebCore::assertRowIsInTable):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForPosition const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
* html/parser/HTMLParserScheduler.cpp:
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
(WebCore::HTMLParserScheduler::suspend):
(WebCore::HTMLParserScheduler::resume):
* html/parser/HTMLParserScheduler.h:
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::endAttribute):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::constructTree):
* html/parser/HTMLTreeBuilder.h:
(WebCore::HTMLTreeBuilder::~HTMLTreeBuilder):
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::geometryForBox const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
* layout/blockformatting/BlockFormattingContext.h:
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setTopLeft):
(WebCore::Display::Box::setTop):
(WebCore::Display::Box::setLeft):
(WebCore::Display::Box::setContentBoxHeight):
(WebCore::Display::Box::setContentBoxWidth):
(WebCore::Display::Box::setHorizontalMargin):
(WebCore::Display::Box::setVerticalMargin):
(WebCore::Display::Box::setHorizontalComputedMargin):
(WebCore::Display::Box::setBorder):
(WebCore::Display::Box::setPadding):
* layout/displaytree/DisplayInlineRect.h:
(WebCore::Display::InlineRect::InlineRect):
(WebCore::Display::InlineRect::setTopLeft):
(WebCore::Display::InlineRect::setTop):
(WebCore::Display::InlineRect::setBottom):
(WebCore::Display::InlineRect::setLeft):
(WebCore::Display::InlineRect::setWidth):
(WebCore::Display::InlineRect::setHeight):
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::LineBox):
(WebCore::Display::LineBox::setBaselineOffsetIfGreater):
(WebCore::Display::LineBox::resetBaseline):
(WebCore::Display::LineBox::Baseline::Baseline):
(WebCore::Display::LineBox::Baseline::setAscent):
(WebCore::Display::LineBox::Baseline::setDescent):
(WebCore::Display::LineBox::Baseline::reset):
* layout/displaytree/DisplayRect.h:
(WebCore::Display::Rect::Rect):
(WebCore::Display::Rect::setTopLeft):
(WebCore::Display::Rect::setTop):
(WebCore::Display::Rect::setLeft):
(WebCore::Display::Rect::setWidth):
(WebCore::Display::Rect::setHeight):
(WebCore::Display::Rect::setSize):
(WebCore::Display::Rect::clone const):
* layout/floats/FloatingContext.cpp:
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::CollapsibleContent::collapse):
* layout/tableformatting/TableGrid.cpp:
(WebCore::Layout::TableGrid::Column::setWidthConstraints):
(WebCore::Layout::TableGrid::Column::setLogicalWidth):
(WebCore::Layout::TableGrid::Column::setLogicalLeft):
* layout/tableformatting/TableGrid.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::attachToFrame):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::addSubresourceLoader):
* loader/DocumentLoader.h:
* loader/ImageLoader.cpp:
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::lruListFor):
(WebCore::MemoryCache::removeFromLRUList):
* page/FrameView.cpp:
(WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
* page/FrameViewLayoutContext.cpp:
* page/FrameViewLayoutContext.h:
* page/Page.cpp:
* page/Page.h:
* page/ViewportConfiguration.cpp:
* page/ViewportConfiguration.h:
* page/mac/EventHandlerMac.mm:
(WebCore::CurrentEventScope::CurrentEventScope):
* platform/DateComponents.cpp:
(WebCore::DateComponents::toStringForTime const):
* platform/ScrollableArea.cpp:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::combineIntoOneSegment const):
* platform/SharedBuffer.h:
* platform/Supplementable.h:
* platform/Timer.cpp:
(WebCore::TimerBase::checkHeapIndex const):
(WebCore::TimerBase::updateHeapIfNeeded):
* platform/graphics/BitmapImage.cpp:
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::ScratchBuffer):
(WebCore::ScratchBuffer::getScratchBuffer):
(WebCore::ScratchBuffer::scheduleScratchBufferPurge):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::setWindow):
* platform/graphics/ca/win/CACFLayerTreeHost.h:
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
* platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp:
(gstAllocatorFastMallocFree):
* platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp:
(Nicosia::PaintingContextCairo::ForPainting::ForPainting):
* platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp:
(Nicosia::BackingStoreTextureMapperImpl::createTile):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp:
(Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::fill):
* platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::appendGeometry):
(WebCore::Path::Path):
(WebCore::Path::operator=):
(WebCore::Path::strokeContains const):
(WebCore::Path::transform):
* platform/graphics/win/PlatformContextDirect2D.cpp:
(WebCore::PlatformContextDirect2D::setTags):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource):
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource):
* platform/network/HTTPParsers.cpp:
(WebCore::isCrossOriginSafeHeader):
* platform/sql/SQLiteDatabase.cpp:
* platform/sql/SQLiteDatabase.h:
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::SQLiteStatement):
(WebCore::SQLiteStatement::prepare):
(WebCore::SQLiteStatement::finalize):
* platform/sql/SQLiteStatement.h:
* platform/win/COMPtr.h:
* rendering/ComplexLineLayout.cpp:
(WebCore::ComplexLineLayout::removeInlineBox const):
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::FloatingObject):
(WebCore::FloatingObjects::addPlacedObject):
(WebCore::FloatingObjects::removePlacedObject):
* rendering/FloatingObjects.h:
* rendering/GridTrackSizingAlgorithm.cpp:
* rendering/GridTrackSizingAlgorithm.h:
* rendering/LayoutDisallowedScope.cpp:
* rendering/LayoutDisallowedScope.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlockChild):
(WebCore::RenderBlockFlow::removeFloatingObject):
(WebCore::RenderBlockFlow::ensureLineBoxes):
* rendering/RenderBoxModelObject.cpp:
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
* rendering/RenderElement.cpp:
* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::baselinePosition const):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):
* rendering/RenderLayer.cpp:
(WebCore::ClipRectsCache::ClipRectsCache):
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::updateClipRects):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::traverseVisibleNonCompositedDescendantLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const):
(WebCore::RenderLayerCompositor::recursiveRepaintLayer):
(WebCore::RenderLayerCompositor::layerHas3DContent const):
* rendering/RenderLayoutState.cpp:
(WebCore::RenderLayoutState::RenderLayoutState):
(WebCore::RenderLayoutState::computeOffsets):
(WebCore::RenderLayoutState::addLayoutDelta):
* rendering/RenderLayoutState.h:
(WebCore::RenderLayoutState::RenderLayoutState):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::RenderObject):
(WebCore::RenderObject::~RenderObject):
(WebCore::RenderObject::clearNeedsLayout):
* rendering/RenderObject.h:
* rendering/RenderQuote.cpp:
(WebCore::quotesForLanguage):
* rendering/RenderTableCell.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::computeOverflowFromCells):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::checkConsistency const):
* rendering/RenderTextLineBoxes.h:
* rendering/line/BreakingContext.h:
(WebCore::tryHyphenating):
* rendering/style/GridArea.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::~RenderStyle):
* rendering/style/RenderStyle.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::detach):
* rendering/updating/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):
* rendering/updating/RenderTreePosition.h:
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
(WebCore::SVGToOTFFontConverter::Placeholder::populate):
(WebCore::SVGToOTFFontConverter::appendCFFTable):
(WebCore::SVGToOTFFontConverter::firstGlyph const):
(WebCore::SVGToOTFFontConverter::appendKERNTable):
* svg/SVGTransformDistance.cpp:
(WebCore::SVGTransformDistance::SVGTransformDistance):
(WebCore::SVGTransformDistance::scaledDistance const):
(WebCore::SVGTransformDistance::addSVGTransforms):
(WebCore::SVGTransformDistance::addToSVGTransform const):
(WebCore::SVGTransformDistance::distance const):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
* testing/InternalSettings.cpp:
* workers/service/ServiceWorkerJob.h:
* worklets/PaintWorkletGlobalScope.h:
(WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope):
* xml/XPathStep.cpp:
Source/WebKit:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::invalidateAndCancel):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::setCapacity):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toNSURLSessionResponseDisposition):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* Platform/IPC/Connection.cpp:
(IPC::Connection::waitForMessage):
* Platform/IPC/MessageReceiver.h:
(IPC::MessageReceiver::willBeAddedToMessageReceiverMap):
(IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap):
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::readFromMachPort):
* Platform/mac/MachUtilities.cpp:
(setMachExceptionPort):
* Shared/API/APIClient.h:
(API::Client::Client):
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
* Shared/Cocoa/ArgumentCodersCocoa.h:
* Shared/SharedStringHashTableReadOnly.cpp:
* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/GenericCallback.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/PageLoadState.h:
(WebKit::PageLoadState::Transaction::Token::Token):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::~WebPageProxy):
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponse):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
(WebKit::NetscapePluginStream::notifyAndDestroyStream):
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runModal):
* WebProcess/WebProcess.cpp:
(WebKit::checkDocumentsCaptureStateConsistency):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateProcessName):
Source/WebKitLegacy:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Storage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::StorageAreaImpl):
(WebKit::StorageAreaImpl::close):
* Storage/StorageAreaImpl.h:
Source/WebKitLegacy/mac:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* History/WebHistory.mm:
(-[WebHistoryPrivate removeItemForURLString:]):
* WebView/WebFrame.mm:
Source/WebKitLegacy/win:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::CAD3DRenderer::swapChain):
(WKQCA::CAD3DRenderer::initialize):
* WebKitQuartzCoreAdditions/CAD3DRenderer.h:
* WebView.cpp:
(WebView::Release):
* WebView.h:
Source/WTF:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
This patch did the following changes:
1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away
with the need for the double negative !ASSERT_DISABLED test that is commonly
used all over the code, thereby improving code readability.
In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED,
ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and
RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents
as well. We'll do that in another patch. For now, they are left as is to
minimize the size of this patch.
See https://bugs.webkit.org/show_bug.cgi?id=205780.
2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be
guarded by "#if ASSERT_ENABLED" instead.
3. In cases where the change is minimal, we move some code around so that we can
test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED".
* wtf/Assertions.h:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/BitVector.h:
* wtf/BlockObjCExceptions.mm:
(ReportBlockedObjCException):
* wtf/BloomFilter.h:
* wtf/CallbackAggregator.h:
(WTF::CallbackAggregator::CallbackAggregator):
* wtf/CheckedArithmetic.h:
(WTF::observesOverflow<AssertNoOverflow>):
* wtf/CheckedBoolean.h:
(CheckedBoolean::CheckedBoolean):
(CheckedBoolean::operator bool):
* wtf/CompletionHandler.h:
(WTF::CompletionHandler<Out):
* wtf/DateMath.cpp:
(WTF::initializeDates):
* wtf/Gigacage.cpp:
(Gigacage::tryAllocateZeroedVirtualPages):
* wtf/HashTable.h:
(WTF::KeyTraits>::checkKey):
(WTF::KeyTraits>::checkTableConsistencyExceptSize const):
* wtf/LoggerHelper.h:
* wtf/NaturalLoops.h:
(WTF::NaturalLoops::headerOf const):
* wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):
* wtf/Platform.h:
* wtf/PtrTag.h:
* wtf/RefCounted.h:
(WTF::RefCountedBase::disableThreadingChecks):
(WTF::RefCountedBase::enableThreadingChecksGlobally):
(WTF::RefCountedBase::RefCountedBase):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):
* wtf/SingleRootGraph.h:
(WTF::SingleRootGraph::assertIsConsistent const):
* wtf/SizeLimits.cpp:
* wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* wtf/URLParser.cpp:
(WTF::URLParser::URLParser):
(WTF::URLParser::domainToASCII):
* wtf/ValueCheck.h:
* wtf/Vector.h:
(WTF::Malloc>::checkConsistency):
* wtf/WeakHashSet.h:
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::WeakPtrImpl):
(WTF::WeakPtrFactory::WeakPtrFactory):
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringImpl.h:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::reifyString const):
* wtf/text/StringBuilder.h:
* wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* wtf/text/StringHasher.h:
(WTF::StringHasher::addCharacters):
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:
Tools:
Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory
https://bugs.webkit.org/show_bug.cgi?id=205754
Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06
Reviewed by Youenn Fablet.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::websiteDataStore):
(WTR::TestController::platformAdjustContext):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
Canonical link: https://commits.webkit.org/218957@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
|
|
|
#if ASSERT_ENABLED
|
2019-07-14 22:18:03 +00:00
|
|
|
: m_wasConstructedOnMainThread(isMainThread())
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-09-23 04:38:45 +00:00
|
|
|
~WeakPtrFactory()
|
|
|
|
{
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
if (!m_impl)
|
2017-09-23 04:38:45 +00:00
|
|
|
return;
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
m_impl->clear();
|
2017-09-23 04:38:45 +00:00
|
|
|
}
|
2013-01-15 21:35:08 +00:00
|
|
|
|
2019-08-20 22:18:23 +00:00
|
|
|
void initializeIfNeeded(const T& object) const
|
2017-09-23 04:38:45 +00:00
|
|
|
{
|
2019-08-20 22:18:23 +00:00
|
|
|
if (m_impl)
|
|
|
|
return;
|
|
|
|
|
2019-07-14 22:18:03 +00:00
|
|
|
ASSERT(m_wasConstructedOnMainThread == isMainThread());
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
m_impl = WeakPtrImpl<Counter>::create(const_cast<T*>(&object));
|
2017-09-23 04:38:45 +00:00
|
|
|
}
|
2013-01-15 21:35:08 +00:00
|
|
|
|
OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224279
Reviewed by Darin Adler.
Source/WebCore:
OfflineAudioContext objects were always leaking due to 2 reference cycles:
1. BaseAudioContext -> m_listener (AudioListener) -> m_positionX (AudioParam) -> m_context (BaseAudioContext)
2. BaseAudioContext -> m_destinationNode (AudioDestinationNode) -> m_context (BaseAudioContext)
For reference cycle 1, I made AudioSummingJunction (base class of AudioParam) hold a weak pointer to the
AudioContext instead of a Ref<>. I don't think there is a good reason for an AudioSummingJunction (AudioParam
or AudioNodeInput) to keep its AudioContext alive. AudioNodes already keep their AudioContext alive.
AudioNodeInputs and AudioParams are associated to AudioNodes.
For reference cycle 2, I made AudioDestinationNode not hold a strong pointer to its context but instead a
weak pointer. Since keeping an AudioDestinationNode alive should keep its AudioContext alive, I made it so
that ref'ing the AudioDestinationNode refs its BaseAudioContext. Also, BaseAudioContext::m_destinationNode
is now a UniqueRef<> instead of a RefPtr<> to avoid a cycle.
Tests: webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html
webaudio/OfflineAudioContext/offlineaudiocontext-leak.html
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::baseLatency):
(WebCore::AudioContext::getOutputTimestamp):
(WebCore::AudioContext::close):
(WebCore::AudioContext::destination):
(WebCore::AudioContext::destination const):
(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::mediaState const):
(WebCore::AudioContext::mayResumePlayback):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::pageMutedStateDidChange):
* Modules/webaudio/AudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::ref):
(WebCore::AudioDestinationNode::deref):
* Modules/webaudio/AudioDestinationNode.h:
Have AudioDestinationNode override AudioNode's ref() / deref() to forward the refcounting
to its BaseAudioContext, instead of using the AudioNode's internal refCount.
* Modules/webaudio/AudioListener.cpp:
(WebCore::AudioListener::updateValuesIfNeeded):
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::setOrientation):
Add some null-checks for AudioParam::context() now that AudioParam holds a WeakPtr to its
context.
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::toWeakOrStrongContext):
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::connect):
(WebCore::AudioNode::sampleRate const):
(WebCore::AudioNode::markNodeForDeletionIfNecessary):
(WebCore::AudioNode::contextForBindings):
(WebCore::AudioNode::context):
(WebCore::AudioNode::context const):
* Modules/webaudio/AudioNode.h:
- Hold the BaseAudioContext as a WeakPtr instead of a Ref<> if the AudioNode is an
AudioDestinationNode. This avoids a reference cycle since the BaseAudioContext owns the
AudioDestinationNode. Even though we are using a WeakPtr, it is safe to assume that
the context is not null because ref'ing an AudioDestinationNode refs its BaseAudioContext.
- Make sure markNodeForDeletionIfNecessary() has no effect for AudioDestinationNode since
BaseAudioContext now owns the AudioDestinationNode when we take care of destroying its
destination node when destroyed.
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::connect):
(WebCore::AudioNodeInput::disconnect):
(WebCore::AudioNodeInput::outputEnabledStateChanged):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::internalSummingBus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):
Add assertions that the context is not null. There were already assertions that we are the graph
owner, which means we are holding the BaseAudioContext's lock, which means that the audio context
is alive.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::value):
(WebCore::AudioParam::setValueForBindings):
(WebCore::AudioParam::smooth):
(WebCore::AudioParam::hasSampleAccurateValues const):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
(WebCore::AudioParam::calculateTimelineValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
Add null-checks for the AudioContext now that the AudioParam is only holding a WeakPtr to its
BaseAudioContext (to avoid a reference cycle).
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::AudioSummingJunction):
(WebCore::AudioSummingJunction::~AudioSummingJunction):
(WebCore::AudioSummingJunction::markRenderingStateAsDirty):
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
(WebCore::AudioSummingJunction::outputEnabledStateChanged):
* Modules/webaudio/AudioSummingJunction.h:
(WebCore::AudioSummingJunction::context):
(WebCore::AudioSummingJunction::context const):
- Hold a WeakPtr to the BaseAudioContext to avoid a reference cycle.
- Deal with the fact that the audio context may be null now that we're holding a WeakPtr
to it (except when holding the graph lock)
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
(WebCore::BaseAudioContext::~BaseAudioContext):
(WebCore::BaseAudioContext::numberOfInstances):
(WebCore::BaseAudioContext::lazyInitialize):
(WebCore::BaseAudioContext::clear):
(WebCore::BaseAudioContext::uninitialize):
(WebCore::BaseAudioContext::stop):
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::decodeAudioData):
(WebCore::BaseAudioContext::markForDeletion):
(WebCore::BaseAudioContext::deleteMarkedNodes):
(WebCore::BaseAudioContext::setPendingActivity):
(WebCore::BaseAudioContext::workletIsReady):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::destination):
(WebCore::BaseAudioContext::destination const):
(WebCore::BaseAudioContext::currentSampleFrame const):
(WebCore::BaseAudioContext::currentTime const):
- Switch m_destinationNode from RefPtr<> to UniqueRef<> since the AudioContext is now
the owner of the destinationNode and since refing the destination node actually refs
its BaseAudioContext.
- Drop some null checks now that m_destinationNode can no longer be null.
- Rename makePendingActivity() to setPendingActivity() to avoid a naming conflict with
ActiveDOMObject::makePendingActivity().
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/OfflineAudioDestinationNode.h:
- Drop create() factory functions and make the constructor public now that the BaseAudioContext owns
its destination node via a UniqueRef<>.
- Make some member functions public as they are virtual and they now called on the subclass instead of the
base class (and these functions are public in the base class).
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
(WebCore::OfflineAudioContext::resumeOfflineRendering):
* Modules/webaudio/OfflineAudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::close):
Drop null checks for the destination node now that it can never be null.
* dom/ShadowRoot.cpp:
* rendering/FloatingObjects.cpp:
* rendering/RootInlineBox.cpp:
Update classes used of size restrictions since the size of a WeakPtr is not longer the same as the size of a
pointer when debug assertions are enabled. As long as they are the same size in release builds, there is no
memory use concern.
* testing/Internals.cpp:
(WebCore::Internals::numberOfBaseAudioContexts const):
* testing/Internals.h:
* testing/Internals.idl:
Add testing function to check how many BaseAudioContexts are alive, so that we can write layout tests and check
for leaks.
Source/WTF:
Add flag that can be passed when constructing a WeakPtr to disable threading assertions.
This is useful for cases where we know it is safe due to locking but we'd like to use a
WeakPtr instead of a raw pointer because it is safer.
* wtf/WeakPtr.h:
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const):
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::=):
(WTF::makeWeakPtr):
LayoutTests:
Add layout test coverage.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak.html: Added.
Canonical link: https://commits.webkit.org/236304@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 18:41:23 +00:00
|
|
|
template<typename U> WeakPtr<U, Counter> createWeakPtr(U& object, EnableWeakPtrThreadingAssertions enableWeakPtrThreadingAssertions = EnableWeakPtrThreadingAssertions::Yes) const
|
2018-08-24 09:30:52 +00:00
|
|
|
{
|
2019-08-20 22:18:23 +00:00
|
|
|
initializeIfNeeded(object);
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
ASSERT(&object == m_impl->template get<T>());
|
OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224279
Reviewed by Darin Adler.
Source/WebCore:
OfflineAudioContext objects were always leaking due to 2 reference cycles:
1. BaseAudioContext -> m_listener (AudioListener) -> m_positionX (AudioParam) -> m_context (BaseAudioContext)
2. BaseAudioContext -> m_destinationNode (AudioDestinationNode) -> m_context (BaseAudioContext)
For reference cycle 1, I made AudioSummingJunction (base class of AudioParam) hold a weak pointer to the
AudioContext instead of a Ref<>. I don't think there is a good reason for an AudioSummingJunction (AudioParam
or AudioNodeInput) to keep its AudioContext alive. AudioNodes already keep their AudioContext alive.
AudioNodeInputs and AudioParams are associated to AudioNodes.
For reference cycle 2, I made AudioDestinationNode not hold a strong pointer to its context but instead a
weak pointer. Since keeping an AudioDestinationNode alive should keep its AudioContext alive, I made it so
that ref'ing the AudioDestinationNode refs its BaseAudioContext. Also, BaseAudioContext::m_destinationNode
is now a UniqueRef<> instead of a RefPtr<> to avoid a cycle.
Tests: webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html
webaudio/OfflineAudioContext/offlineaudiocontext-leak.html
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::baseLatency):
(WebCore::AudioContext::getOutputTimestamp):
(WebCore::AudioContext::close):
(WebCore::AudioContext::destination):
(WebCore::AudioContext::destination const):
(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::mediaState const):
(WebCore::AudioContext::mayResumePlayback):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::pageMutedStateDidChange):
* Modules/webaudio/AudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::ref):
(WebCore::AudioDestinationNode::deref):
* Modules/webaudio/AudioDestinationNode.h:
Have AudioDestinationNode override AudioNode's ref() / deref() to forward the refcounting
to its BaseAudioContext, instead of using the AudioNode's internal refCount.
* Modules/webaudio/AudioListener.cpp:
(WebCore::AudioListener::updateValuesIfNeeded):
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::setOrientation):
Add some null-checks for AudioParam::context() now that AudioParam holds a WeakPtr to its
context.
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::toWeakOrStrongContext):
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::connect):
(WebCore::AudioNode::sampleRate const):
(WebCore::AudioNode::markNodeForDeletionIfNecessary):
(WebCore::AudioNode::contextForBindings):
(WebCore::AudioNode::context):
(WebCore::AudioNode::context const):
* Modules/webaudio/AudioNode.h:
- Hold the BaseAudioContext as a WeakPtr instead of a Ref<> if the AudioNode is an
AudioDestinationNode. This avoids a reference cycle since the BaseAudioContext owns the
AudioDestinationNode. Even though we are using a WeakPtr, it is safe to assume that
the context is not null because ref'ing an AudioDestinationNode refs its BaseAudioContext.
- Make sure markNodeForDeletionIfNecessary() has no effect for AudioDestinationNode since
BaseAudioContext now owns the AudioDestinationNode when we take care of destroying its
destination node when destroyed.
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::connect):
(WebCore::AudioNodeInput::disconnect):
(WebCore::AudioNodeInput::outputEnabledStateChanged):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::internalSummingBus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):
Add assertions that the context is not null. There were already assertions that we are the graph
owner, which means we are holding the BaseAudioContext's lock, which means that the audio context
is alive.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::value):
(WebCore::AudioParam::setValueForBindings):
(WebCore::AudioParam::smooth):
(WebCore::AudioParam::hasSampleAccurateValues const):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
(WebCore::AudioParam::calculateTimelineValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
Add null-checks for the AudioContext now that the AudioParam is only holding a WeakPtr to its
BaseAudioContext (to avoid a reference cycle).
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::AudioSummingJunction):
(WebCore::AudioSummingJunction::~AudioSummingJunction):
(WebCore::AudioSummingJunction::markRenderingStateAsDirty):
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
(WebCore::AudioSummingJunction::outputEnabledStateChanged):
* Modules/webaudio/AudioSummingJunction.h:
(WebCore::AudioSummingJunction::context):
(WebCore::AudioSummingJunction::context const):
- Hold a WeakPtr to the BaseAudioContext to avoid a reference cycle.
- Deal with the fact that the audio context may be null now that we're holding a WeakPtr
to it (except when holding the graph lock)
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
(WebCore::BaseAudioContext::~BaseAudioContext):
(WebCore::BaseAudioContext::numberOfInstances):
(WebCore::BaseAudioContext::lazyInitialize):
(WebCore::BaseAudioContext::clear):
(WebCore::BaseAudioContext::uninitialize):
(WebCore::BaseAudioContext::stop):
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::decodeAudioData):
(WebCore::BaseAudioContext::markForDeletion):
(WebCore::BaseAudioContext::deleteMarkedNodes):
(WebCore::BaseAudioContext::setPendingActivity):
(WebCore::BaseAudioContext::workletIsReady):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::destination):
(WebCore::BaseAudioContext::destination const):
(WebCore::BaseAudioContext::currentSampleFrame const):
(WebCore::BaseAudioContext::currentTime const):
- Switch m_destinationNode from RefPtr<> to UniqueRef<> since the AudioContext is now
the owner of the destinationNode and since refing the destination node actually refs
its BaseAudioContext.
- Drop some null checks now that m_destinationNode can no longer be null.
- Rename makePendingActivity() to setPendingActivity() to avoid a naming conflict with
ActiveDOMObject::makePendingActivity().
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/OfflineAudioDestinationNode.h:
- Drop create() factory functions and make the constructor public now that the BaseAudioContext owns
its destination node via a UniqueRef<>.
- Make some member functions public as they are virtual and they now called on the subclass instead of the
base class (and these functions are public in the base class).
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
(WebCore::OfflineAudioContext::resumeOfflineRendering):
* Modules/webaudio/OfflineAudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::close):
Drop null checks for the destination node now that it can never be null.
* dom/ShadowRoot.cpp:
* rendering/FloatingObjects.cpp:
* rendering/RootInlineBox.cpp:
Update classes used of size restrictions since the size of a WeakPtr is not longer the same as the size of a
pointer when debug assertions are enabled. As long as they are the same size in release builds, there is no
memory use concern.
* testing/Internals.cpp:
(WebCore::Internals::numberOfBaseAudioContexts const):
* testing/Internals.h:
* testing/Internals.idl:
Add testing function to check how many BaseAudioContexts are alive, so that we can write layout tests and check
for leaks.
Source/WTF:
Add flag that can be passed when constructing a WeakPtr to disable threading assertions.
This is useful for cases where we know it is safe due to locking but we'd like to use a
WeakPtr instead of a raw pointer because it is safer.
* wtf/WeakPtr.h:
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const):
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::=):
(WTF::makeWeakPtr):
LayoutTests:
Add layout test coverage.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak.html: Added.
Canonical link: https://commits.webkit.org/236304@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 18:41:23 +00:00
|
|
|
return WeakPtr<U, Counter>(makeRef(*m_impl), enableWeakPtrThreadingAssertions);
|
2018-08-24 09:30:52 +00:00
|
|
|
}
|
|
|
|
|
2013-01-23 22:15:54 +00:00
|
|
|
void revokeAll()
|
|
|
|
{
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
if (!m_impl)
|
2017-09-23 04:38:45 +00:00
|
|
|
return;
|
|
|
|
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
m_impl->clear();
|
|
|
|
m_impl = nullptr;
|
2013-01-23 22:15:54 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 00:29:50 +00:00
|
|
|
unsigned weakPtrCount() const { return m_impl ? m_impl->refCount() - 1 : 0; }
|
|
|
|
|
2021-02-11 03:18:46 +00:00
|
|
|
#if ASSERT_ENABLED
|
|
|
|
bool isInitialized() const { return m_impl; }
|
|
|
|
#endif
|
|
|
|
|
2013-01-15 21:35:08 +00:00
|
|
|
private:
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename, typename> friend class WeakHashSet;
|
2021-06-12 01:42:09 +00:00
|
|
|
template<typename, typename, typename> friend class WeakHashMap;
|
Add WeakHashSet
https://bugs.webkit.org/show_bug.cgi?id=195152
Reviewed by Antti Koivisto.
Source/WTF:
Added WeakHashSet which is a HashSet of WeakPtr. When the object pointed by WeakPtr is deleted,
WeakHashSet treats the key to be no longer in the set. That is, WeakHashSet::contains returns false
and const_iterator skips such a WeakPtr in the set.
We decided not to make HashSet<WeahPtr<T>> work because it involves weird semantics such as making
find(X) delete the table entry as remove(find(X)) would be a no-op otherwise as find(X) would return
necessarily need to return HashSet<WeakPtr<T>>::end().
Furthermore, we cannot determine the true size of this set in O(1) because the objected pointed by
some of WeakPtr in the set may have already been deleted. This has implications that we can't have
size(), isEmpty(), random(), etc... as O(1) operation.
WeakHashSet is implemented as HashSet<WeakReference<T>>. HashTable::rehash has been updated to delete
WeakReference<T>'s whose m_ptr has become null, and HashTable::expand first deletes any such entry
before deciding an actual expansion is needed. This is accomplished via newly added hash trait,
hasIsReleasedWeakValueFunction, and HashTraits<Ref<WeakReference<T>>>::isReleasedWeakValue which
returns true for when WeakReference<T> pointed by Ref<WeakReference<T>> has null m_ptr, not to be
confused with Ref<WeakReference<T>> itself pointing to a null WeakReference<T>.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/Forward.h:
* wtf/HashSet.h:
(WTF::HashSet<T, U, V>::checkConsistency const): Added.
* wtf/HashTable.h:
(WTF::HashTable::isReleasedWeakBucket): Added.
(WTF::HashTable::expand): Delete WeakReference<T> with null m_ptr first. This updates m_keyCount
and may make mustRehashInPlace() return true.
(WTF::HashTable::deleteReleasedWeakBuckets): Added.
(WTF::HashTable::rehash): Delete WeakReference<T> with null m_ptr. Also refactored the code a bit
to avoid keep repeating oldTable[i].
* wtf/HashTraits.h:
(WTF::HashTraits<T>::isHashTraitsReleasedWeakValue): Added.
(WTF::RefHashTraits<T>): Extracted from HashTraits<Ref<P>> to share code with
HashTraits<Ref<WeakReference<T>>>.
(WTF::HashTraitsReleasedWeakValueChecker<Traits, hasIsReleasedWeakValueFunction>): Added.
(WTF::isHashTraitsReleasedWeakValue<Traits, hasIsReleasedWeakValueFunction>): Added.
* wtf/WeakHashSet.h: Added.
(WTF::WeakHashSet): Added.
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
(WTF::WeakHashSet::WeakHashSetConstIterator::get const):
(WTF::WeakHashSet::WeakHashSetConstIterator::operator* const):
(WTF::WeakHashSet::WeakHashSetConstIterator::operator-> const):
(WTF::WeakHashSet::WeakHashSetConstIterator::operator++):
(WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets):
(WTF::WeakHashSet::WeakHashSetConstIterator::operator== const):
(WTF::WeakHashSet::WeakHashSetConstIterator::operator!= const):
(WTF::WeakHashSet::WeakHashSet):
(WTF::WeakHashSet::begin const):
(WTF::WeakHashSet::end const):
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::capacity const):
(WTF::WeakHashSet::computeSize const): Deletes any WeakReference<T> with null m_ptr first.
(WTF::WeakHashSet::checkConsistency const):
(WTF::HashTraits<Ref<WeakReference<T>>>): Added. This hash traits triggers the new code in HashTable's
expand and rehash methods to delete WeakReference<T> with null m_ptr.
(WTF::HashTraits<Ref<WeakReference<T>>>::isReleasedWeakValue):
* wtf/WeakPtr.h:
(WTF::WeakReference::~WeakReference): Added so that we can keep track the number of live WeakReference
in API tests by template specializations.
Tools:
Added tests for WeakHashSet.
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
(TestWebKitAPI::Base::Base): Moved.
(TestWebKitAPI::Derived::foo): Moved.
(WTF::WeakReference<TestWebKitAPI::Base>): Added to track the number of live WeakReference.
(WTF::WeakReference<TestWebKitAPI::Base>::WeakReference):
(WTF::WeakReference<TestWebKitAPI::Base>::~WeakReference):
(TestWebKitAPI::computeSizeOfWeakHashSet): Added.
Canonical link: https://commits.webkit.org/209643@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242387 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-04 21:52:32 +00:00
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
mutable RefPtr<WeakPtrImpl<Counter>> m_impl;
|
PerformanceTests:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* JetStream2/wasm/HashSet.cpp:
* StitchMarker/wtf/Assertions.h:
* StitchMarker/wtf/DateMath.cpp:
(WTF::initializeDates):
* StitchMarker/wtf/HashTable.h:
* StitchMarker/wtf/Hasher.h:
(WTF::StringHasher::addCharacters):
* StitchMarker/wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* StitchMarker/wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* StitchMarker/wtf/ValueCheck.h:
* StitchMarker/wtf/Vector.h:
(WTF::minCapacity>::checkConsistency):
* StitchMarker/wtf/text/AtomicStringImpl.cpp:
* StitchMarker/wtf/text/AtomicStringImpl.h:
* StitchMarker/wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* StitchMarker/wtf/text/StringImpl.h:
* StitchMarker/wtf/text/SymbolImpl.h:
* StitchMarker/wtf/text/UniquedStringImpl.h:
Source/JavaScriptCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* API/tests/testapi.c:
* assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::replaceWithLoad):
(JSC::ARM64Assembler::replaceWithAddressComputation):
* assembler/AssemblerBuffer.h:
(JSC::AssemblerBuffer::LocalWriter::LocalWriter):
* assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::copyCompactAndLinkCode):
* assembler/ProbeStack.cpp:
(JSC::Probe::Stack::Stack):
* assembler/ProbeStack.h:
* b3/B3FoldPathConstants.cpp:
* b3/B3LowerToAir.cpp:
* b3/B3MemoryValue.cpp:
(JSC::B3::MemoryValue::MemoryValue):
* b3/B3Opcode.cpp:
* b3/B3Type.h:
* b3/B3TypeMap.h:
* b3/B3Width.h:
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp:
(JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration):
(JSC::B3::Air::GenerateAndAllocateRegisters::generate):
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.h:
* b3/air/AirAllocateRegistersByGraphColoring.cpp:
* b3/air/AirArg.cpp:
* b3/air/AirArg.h:
* b3/air/AirCode.h:
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* bytecode/AccessCase.cpp:
* bytecode/AccessCase.h:
* bytecode/CallVariant.cpp:
(JSC::variantListWithVariant):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex):
* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::dump const):
* bytecode/StructureStubInfo.cpp:
* bytecode/StructureStubInfo.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionCallResolveNode::emitBytecode):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::RegisterID):
(JSC::RegisterID::setIndex):
* debugger/Debugger.cpp:
(JSC::Debugger::removeBreakpoint):
* debugger/DebuggerEvalEnabler.h:
(JSC::DebuggerEvalEnabler::DebuggerEvalEnabler):
(JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions):
* dfg/DFGAbstractValue.cpp:
* dfg/DFGAbstractValue.h:
(JSC::DFG::AbstractValue::merge):
(JSC::DFG::AbstractValue::checkConsistency const):
(JSC::DFG::AbstractValue::assertIsRegistered const):
* dfg/DFGArithMode.h:
(JSC::DFG::doesOverflow):
* dfg/DFGBasicBlock.cpp:
(JSC::DFG::BasicBlock::BasicBlock):
* dfg/DFGBasicBlock.h:
(JSC::DFG::BasicBlock::didLink):
* dfg/DFGCFAPhase.cpp:
(JSC::DFG::CFAPhase::performBlockCFA):
* dfg/DFGCommon.h:
(JSC::DFG::validationEnabled):
* dfg/DFGCommonData.cpp:
(JSC::DFG::CommonData::finalizeCatchEntrypoints):
* dfg/DFGDesiredWatchpoints.h:
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGEdge.h:
(JSC::DFG::Edge::makeWord):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::finalizeOSREntrypoints):
* dfg/DFGObjectAllocationSinkingPhase.cpp:
* dfg/DFGSSAConversionPhase.cpp:
(JSC::DFG::SSAConversionPhase::run):
* dfg/DFGScoreBoard.h:
(JSC::DFG::ScoreBoard::assertClear):
* dfg/DFGSlowPathGenerator.h:
(JSC::DFG::SlowPathGenerator::generate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
(JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse):
(JSC::DFG::SpeculativeJIT::emitAllocateButterfly):
(JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize):
(JSC::DFG::SpeculativeJIT::compileMakeRope):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
* dfg/DFGStructureAbstractValue.cpp:
* dfg/DFGStructureAbstractValue.h:
(JSC::DFG::StructureAbstractValue::assertIsRegistered const):
* dfg/DFGVarargsForwardingPhase.cpp:
* dfg/DFGVirtualRegisterAllocationPhase.cpp:
(JSC::DFG::VirtualRegisterAllocationPhase::run):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::callPreflight):
(JSC::FTL::DFG::LowerDFGToB3::callCheck):
(JSC::FTL::DFG::LowerDFGToB3::crash):
* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::assertNoUnswept):
* heap/GCSegmentedArray.h:
(JSC::GCArraySegment::GCArraySegment):
* heap/GCSegmentedArrayInlines.h:
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::validatePrevious):
* heap/HandleSet.cpp:
* heap/HandleSet.h:
* heap/Heap.cpp:
(JSC::Heap::updateAllocationLimits):
* heap/Heap.h:
* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::assertValidCell const):
(JSC::MarkedBlock::assertMarksNotStale):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::beginMarking):
(JSC::MarkedSpace::endMarking):
(JSC::MarkedSpace::assertNoUnswept):
* heap/PreciseAllocation.cpp:
* heap/PreciseAllocation.h:
(JSC::PreciseAllocation::assertValidCell const):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::appendJSCellOrAuxiliary):
* heap/SlotVisitor.h:
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
(CppProtocolTypesImplementationGenerator):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* interpreter/FrameTracers.h:
(JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::Interpreter):
* interpreter/Interpreter.h:
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::prepareCallOperation):
* jit/BinarySwitch.cpp:
(JSC::BinarySwitch::BinarySwitch):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupStubArgs):
* jit/CallFrameShuffler.cpp:
(JSC::CallFrameShuffler::emitDeltaCheck):
(JSC::CallFrameShuffler::prepareAny):
* jit/JIT.cpp:
(JSC::JIT::assertStackPointerOffset):
(JSC::JIT::compileWithoutLinking):
* jit/JITOpcodes.cpp:
(JSC::JIT::emitSlow_op_loop_hint):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
* jit/ThunkGenerators.cpp:
(JSC::emitPointerValidation):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LLIntOfflineAsmConfig.h:
* parser/Lexer.cpp:
* parser/Lexer.h:
(JSC::isSafeBuiltinIdentifier):
(JSC::Lexer<T>::lexExpectIdentifier):
* runtime/ArgList.h:
(JSC::MarkedArgumentBuffer::setNeedsOverflowCheck):
(JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck):
* runtime/Butterfly.h:
(JSC::ContiguousData::ContiguousData):
(JSC::ContiguousData::Data::Data):
* runtime/HashMapImpl.h:
(JSC::HashMapImpl::checkConsistency const):
(JSC::HashMapImpl::assertBufferIsEmpty const):
* runtime/JSCellInlines.h:
(JSC::JSCell::methodTable const):
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
(JSC::JSFunction::assertTypeInfoFlagInvariants):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren):
(JSC::JSFinalObject::visitChildren):
* runtime/JSObjectInlines.h:
(JSC::JSObject::validatePutOwnDataProperty):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::assertVariableIsInThisObject):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lex):
* runtime/LiteralParser.h:
* runtime/Operations.h:
(JSC::scribbleFreeCells):
* runtime/OptionsList.h:
* runtime/VM.cpp:
(JSC::VM::computeCanUseJIT):
* runtime/VM.h:
(JSC::VM::canUseJIT):
* runtime/VarOffset.h:
(JSC::VarOffset::checkSanity const):
* runtime/WeakMapImpl.h:
(JSC::WeakMapImpl::checkConsistency const):
(JSC::WeakMapImpl::assertBufferIsEmpty const):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::validateInst):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile):
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser::validationFail const):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::checkConsistency):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast):
* wasm/WasmSectionParser.h:
* wasm/WasmSections.h:
* wasm/WasmSignatureInlines.h:
(JSC::Wasm::SignatureInformation::get):
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::enqueue):
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::previousInstanceOffset const):
Source/WebCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::close):
* Modules/fetch/FetchBodySource.h:
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
(WebCore::DatabaseDetails::operator=):
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTask::performTask):
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::terminationRequested const):
* Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h:
(WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation):
* Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp:
(WebCore::WHLSL::findHighZombies):
* Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
(WebCore::WHLSL::matches):
* Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:
(WebCore::WHLSL::checkLiteralTypes):
* Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp:
(WebCore::WHLSL::FindAllTypes::appendNamedType):
* bindings/js/JSCallbackData.h:
* bindings/js/JSLazyEventListener.cpp:
* bindings/js/JSLazyEventListener.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcOperationNode::primitiveType const):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValue.cpp:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/CSSStyleSheet.cpp:
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::suspendIfNeeded):
(WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const):
* dom/ActiveDOMObject.h:
* dom/ContainerNode.cpp:
* dom/ContainerNodeAlgorithms.cpp:
* dom/ContainerNodeAlgorithms.h:
* dom/CustomElementReactionQueue.cpp:
* dom/CustomElementReactionQueue.h:
(WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope):
(WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope):
* dom/Document.cpp:
(WebCore::Document::hitTest):
* dom/Document.h:
(WebCore::Document::decrementReferencingNodeCount):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::getURLAttribute const):
(WebCore::Element::getNonEmptyURLAttribute const):
* dom/Element.h:
* dom/ElementAndTextDescendantIterator.h:
(WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator):
(WebCore::ElementAndTextDescendantIterator::dropAssertions):
(WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack):
(WebCore::ElementAndTextDescendantIterator::traverseNextSibling):
(WebCore::ElementAndTextDescendantIterator::traversePreviousSibling):
* dom/ElementDescendantIterator.h:
(WebCore::ElementDescendantIterator::ElementDescendantIterator):
(WebCore::ElementDescendantIterator::dropAssertions):
(WebCore::ElementDescendantIterator::operator++):
(WebCore::ElementDescendantIterator::operator--):
(WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator):
(WebCore::ElementDescendantConstIterator::dropAssertions):
(WebCore::ElementDescendantConstIterator::operator++):
* dom/ElementIterator.h:
(WebCore::ElementIterator<ElementType>::ElementIterator):
(WebCore::ElementIterator<ElementType>::traverseNext):
(WebCore::ElementIterator<ElementType>::traversePrevious):
(WebCore::ElementIterator<ElementType>::traverseNextSibling):
(WebCore::ElementIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementIterator<ElementType>::dropAssertions):
(WebCore::ElementIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::ElementConstIterator):
(WebCore::ElementConstIterator<ElementType>::traverseNext):
(WebCore::ElementConstIterator<ElementType>::traversePrevious):
(WebCore::ElementConstIterator<ElementType>::traverseNextSibling):
(WebCore::ElementConstIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementConstIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::dropAssertions):
* dom/EventContext.cpp:
* dom/EventContext.h:
* dom/EventListener.h:
* dom/EventPath.cpp:
* dom/EventSender.h:
* dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
(WebCore::EventTarget::setAttributeEventListener):
(WebCore::EventTarget::innerInvokeEventListeners):
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::moveNodeToNewDocument):
(WebCore::Node::removedLastRef):
* dom/Node.h:
(WebCore::Node::deref const):
* dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
* dom/ScriptExecutionContext.h:
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute const):
* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::removeSlotElementByName):
(WebCore::SlotAssignment::resolveSlotsAfterSlotMutation):
(WebCore::SlotAssignment::findFirstSlotElement):
* dom/SlotAssignment.h:
* dom/TreeScopeOrderedMap.cpp:
(WebCore::TreeScopeOrderedMap::add):
(WebCore::TreeScopeOrderedMap::get const):
* dom/TreeScopeOrderedMap.h:
* fileapi/Blob.cpp:
* fileapi/Blob.h:
* history/BackForwardCache.cpp:
(WebCore::BackForwardCache::removeAllItemsForPage):
* history/BackForwardCache.h:
* html/CanvasBase.cpp:
(WebCore::CanvasBase::notifyObserversCanvasDestroyed):
* html/CanvasBase.h:
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::didPopulate):
* html/HTMLSelectElement.cpp:
(WebCore:: const):
* html/HTMLTableRowsCollection.cpp:
(WebCore::assertRowIsInTable):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForPosition const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
* html/parser/HTMLParserScheduler.cpp:
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
(WebCore::HTMLParserScheduler::suspend):
(WebCore::HTMLParserScheduler::resume):
* html/parser/HTMLParserScheduler.h:
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::endAttribute):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::constructTree):
* html/parser/HTMLTreeBuilder.h:
(WebCore::HTMLTreeBuilder::~HTMLTreeBuilder):
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::geometryForBox const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
* layout/blockformatting/BlockFormattingContext.h:
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setTopLeft):
(WebCore::Display::Box::setTop):
(WebCore::Display::Box::setLeft):
(WebCore::Display::Box::setContentBoxHeight):
(WebCore::Display::Box::setContentBoxWidth):
(WebCore::Display::Box::setHorizontalMargin):
(WebCore::Display::Box::setVerticalMargin):
(WebCore::Display::Box::setHorizontalComputedMargin):
(WebCore::Display::Box::setBorder):
(WebCore::Display::Box::setPadding):
* layout/displaytree/DisplayInlineRect.h:
(WebCore::Display::InlineRect::InlineRect):
(WebCore::Display::InlineRect::setTopLeft):
(WebCore::Display::InlineRect::setTop):
(WebCore::Display::InlineRect::setBottom):
(WebCore::Display::InlineRect::setLeft):
(WebCore::Display::InlineRect::setWidth):
(WebCore::Display::InlineRect::setHeight):
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::LineBox):
(WebCore::Display::LineBox::setBaselineOffsetIfGreater):
(WebCore::Display::LineBox::resetBaseline):
(WebCore::Display::LineBox::Baseline::Baseline):
(WebCore::Display::LineBox::Baseline::setAscent):
(WebCore::Display::LineBox::Baseline::setDescent):
(WebCore::Display::LineBox::Baseline::reset):
* layout/displaytree/DisplayRect.h:
(WebCore::Display::Rect::Rect):
(WebCore::Display::Rect::setTopLeft):
(WebCore::Display::Rect::setTop):
(WebCore::Display::Rect::setLeft):
(WebCore::Display::Rect::setWidth):
(WebCore::Display::Rect::setHeight):
(WebCore::Display::Rect::setSize):
(WebCore::Display::Rect::clone const):
* layout/floats/FloatingContext.cpp:
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::CollapsibleContent::collapse):
* layout/tableformatting/TableGrid.cpp:
(WebCore::Layout::TableGrid::Column::setWidthConstraints):
(WebCore::Layout::TableGrid::Column::setLogicalWidth):
(WebCore::Layout::TableGrid::Column::setLogicalLeft):
* layout/tableformatting/TableGrid.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::attachToFrame):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::addSubresourceLoader):
* loader/DocumentLoader.h:
* loader/ImageLoader.cpp:
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::lruListFor):
(WebCore::MemoryCache::removeFromLRUList):
* page/FrameView.cpp:
(WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
* page/FrameViewLayoutContext.cpp:
* page/FrameViewLayoutContext.h:
* page/Page.cpp:
* page/Page.h:
* page/ViewportConfiguration.cpp:
* page/ViewportConfiguration.h:
* page/mac/EventHandlerMac.mm:
(WebCore::CurrentEventScope::CurrentEventScope):
* platform/DateComponents.cpp:
(WebCore::DateComponents::toStringForTime const):
* platform/ScrollableArea.cpp:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::combineIntoOneSegment const):
* platform/SharedBuffer.h:
* platform/Supplementable.h:
* platform/Timer.cpp:
(WebCore::TimerBase::checkHeapIndex const):
(WebCore::TimerBase::updateHeapIfNeeded):
* platform/graphics/BitmapImage.cpp:
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::ScratchBuffer):
(WebCore::ScratchBuffer::getScratchBuffer):
(WebCore::ScratchBuffer::scheduleScratchBufferPurge):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::setWindow):
* platform/graphics/ca/win/CACFLayerTreeHost.h:
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
* platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp:
(gstAllocatorFastMallocFree):
* platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp:
(Nicosia::PaintingContextCairo::ForPainting::ForPainting):
* platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp:
(Nicosia::BackingStoreTextureMapperImpl::createTile):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp:
(Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::fill):
* platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::appendGeometry):
(WebCore::Path::Path):
(WebCore::Path::operator=):
(WebCore::Path::strokeContains const):
(WebCore::Path::transform):
* platform/graphics/win/PlatformContextDirect2D.cpp:
(WebCore::PlatformContextDirect2D::setTags):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource):
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource):
* platform/network/HTTPParsers.cpp:
(WebCore::isCrossOriginSafeHeader):
* platform/sql/SQLiteDatabase.cpp:
* platform/sql/SQLiteDatabase.h:
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::SQLiteStatement):
(WebCore::SQLiteStatement::prepare):
(WebCore::SQLiteStatement::finalize):
* platform/sql/SQLiteStatement.h:
* platform/win/COMPtr.h:
* rendering/ComplexLineLayout.cpp:
(WebCore::ComplexLineLayout::removeInlineBox const):
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::FloatingObject):
(WebCore::FloatingObjects::addPlacedObject):
(WebCore::FloatingObjects::removePlacedObject):
* rendering/FloatingObjects.h:
* rendering/GridTrackSizingAlgorithm.cpp:
* rendering/GridTrackSizingAlgorithm.h:
* rendering/LayoutDisallowedScope.cpp:
* rendering/LayoutDisallowedScope.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlockChild):
(WebCore::RenderBlockFlow::removeFloatingObject):
(WebCore::RenderBlockFlow::ensureLineBoxes):
* rendering/RenderBoxModelObject.cpp:
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
* rendering/RenderElement.cpp:
* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::baselinePosition const):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):
* rendering/RenderLayer.cpp:
(WebCore::ClipRectsCache::ClipRectsCache):
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::updateClipRects):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::traverseVisibleNonCompositedDescendantLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const):
(WebCore::RenderLayerCompositor::recursiveRepaintLayer):
(WebCore::RenderLayerCompositor::layerHas3DContent const):
* rendering/RenderLayoutState.cpp:
(WebCore::RenderLayoutState::RenderLayoutState):
(WebCore::RenderLayoutState::computeOffsets):
(WebCore::RenderLayoutState::addLayoutDelta):
* rendering/RenderLayoutState.h:
(WebCore::RenderLayoutState::RenderLayoutState):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::RenderObject):
(WebCore::RenderObject::~RenderObject):
(WebCore::RenderObject::clearNeedsLayout):
* rendering/RenderObject.h:
* rendering/RenderQuote.cpp:
(WebCore::quotesForLanguage):
* rendering/RenderTableCell.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::computeOverflowFromCells):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::checkConsistency const):
* rendering/RenderTextLineBoxes.h:
* rendering/line/BreakingContext.h:
(WebCore::tryHyphenating):
* rendering/style/GridArea.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::~RenderStyle):
* rendering/style/RenderStyle.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::detach):
* rendering/updating/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):
* rendering/updating/RenderTreePosition.h:
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
(WebCore::SVGToOTFFontConverter::Placeholder::populate):
(WebCore::SVGToOTFFontConverter::appendCFFTable):
(WebCore::SVGToOTFFontConverter::firstGlyph const):
(WebCore::SVGToOTFFontConverter::appendKERNTable):
* svg/SVGTransformDistance.cpp:
(WebCore::SVGTransformDistance::SVGTransformDistance):
(WebCore::SVGTransformDistance::scaledDistance const):
(WebCore::SVGTransformDistance::addSVGTransforms):
(WebCore::SVGTransformDistance::addToSVGTransform const):
(WebCore::SVGTransformDistance::distance const):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
* testing/InternalSettings.cpp:
* workers/service/ServiceWorkerJob.h:
* worklets/PaintWorkletGlobalScope.h:
(WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope):
* xml/XPathStep.cpp:
Source/WebKit:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::invalidateAndCancel):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::setCapacity):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toNSURLSessionResponseDisposition):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* Platform/IPC/Connection.cpp:
(IPC::Connection::waitForMessage):
* Platform/IPC/MessageReceiver.h:
(IPC::MessageReceiver::willBeAddedToMessageReceiverMap):
(IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap):
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::readFromMachPort):
* Platform/mac/MachUtilities.cpp:
(setMachExceptionPort):
* Shared/API/APIClient.h:
(API::Client::Client):
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
* Shared/Cocoa/ArgumentCodersCocoa.h:
* Shared/SharedStringHashTableReadOnly.cpp:
* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/GenericCallback.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/PageLoadState.h:
(WebKit::PageLoadState::Transaction::Token::Token):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::~WebPageProxy):
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponse):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
(WebKit::NetscapePluginStream::notifyAndDestroyStream):
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runModal):
* WebProcess/WebProcess.cpp:
(WebKit::checkDocumentsCaptureStateConsistency):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateProcessName):
Source/WebKitLegacy:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Storage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::StorageAreaImpl):
(WebKit::StorageAreaImpl::close):
* Storage/StorageAreaImpl.h:
Source/WebKitLegacy/mac:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* History/WebHistory.mm:
(-[WebHistoryPrivate removeItemForURLString:]):
* WebView/WebFrame.mm:
Source/WebKitLegacy/win:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::CAD3DRenderer::swapChain):
(WKQCA::CAD3DRenderer::initialize):
* WebKitQuartzCoreAdditions/CAD3DRenderer.h:
* WebView.cpp:
(WebView::Release):
* WebView.h:
Source/WTF:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
This patch did the following changes:
1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away
with the need for the double negative !ASSERT_DISABLED test that is commonly
used all over the code, thereby improving code readability.
In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED,
ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and
RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents
as well. We'll do that in another patch. For now, they are left as is to
minimize the size of this patch.
See https://bugs.webkit.org/show_bug.cgi?id=205780.
2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be
guarded by "#if ASSERT_ENABLED" instead.
3. In cases where the change is minimal, we move some code around so that we can
test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED".
* wtf/Assertions.h:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/BitVector.h:
* wtf/BlockObjCExceptions.mm:
(ReportBlockedObjCException):
* wtf/BloomFilter.h:
* wtf/CallbackAggregator.h:
(WTF::CallbackAggregator::CallbackAggregator):
* wtf/CheckedArithmetic.h:
(WTF::observesOverflow<AssertNoOverflow>):
* wtf/CheckedBoolean.h:
(CheckedBoolean::CheckedBoolean):
(CheckedBoolean::operator bool):
* wtf/CompletionHandler.h:
(WTF::CompletionHandler<Out):
* wtf/DateMath.cpp:
(WTF::initializeDates):
* wtf/Gigacage.cpp:
(Gigacage::tryAllocateZeroedVirtualPages):
* wtf/HashTable.h:
(WTF::KeyTraits>::checkKey):
(WTF::KeyTraits>::checkTableConsistencyExceptSize const):
* wtf/LoggerHelper.h:
* wtf/NaturalLoops.h:
(WTF::NaturalLoops::headerOf const):
* wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):
* wtf/Platform.h:
* wtf/PtrTag.h:
* wtf/RefCounted.h:
(WTF::RefCountedBase::disableThreadingChecks):
(WTF::RefCountedBase::enableThreadingChecksGlobally):
(WTF::RefCountedBase::RefCountedBase):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):
* wtf/SingleRootGraph.h:
(WTF::SingleRootGraph::assertIsConsistent const):
* wtf/SizeLimits.cpp:
* wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* wtf/URLParser.cpp:
(WTF::URLParser::URLParser):
(WTF::URLParser::domainToASCII):
* wtf/ValueCheck.h:
* wtf/Vector.h:
(WTF::Malloc>::checkConsistency):
* wtf/WeakHashSet.h:
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::WeakPtrImpl):
(WTF::WeakPtrFactory::WeakPtrFactory):
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringImpl.h:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::reifyString const):
* wtf/text/StringBuilder.h:
* wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* wtf/text/StringHasher.h:
(WTF::StringHasher::addCharacters):
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:
Tools:
Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory
https://bugs.webkit.org/show_bug.cgi?id=205754
Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06
Reviewed by Youenn Fablet.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::websiteDataStore):
(WTR::TestController::platformAdjustContext):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
Canonical link: https://commits.webkit.org/218957@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
|
|
|
#if ASSERT_ENABLED
|
2019-07-14 22:18:03 +00:00
|
|
|
bool m_wasConstructedOnMainThread;
|
|
|
|
#endif
|
2013-01-15 21:35:08 +00:00
|
|
|
};
|
|
|
|
|
2019-08-20 22:18:23 +00:00
|
|
|
// We use lazy initialization of the WeakPtrFactory by default to avoid unnecessary initialization. Eager
|
|
|
|
// initialization is however useful if you plan to call makeWeakPtr() from other threads.
|
|
|
|
enum class WeakPtrFactoryInitialization { Lazy, Eager };
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, WeakPtrFactoryInitialization initializationMode = WeakPtrFactoryInitialization::Lazy, typename Counter = EmptyCounter> class CanMakeWeakPtr {
|
2018-06-08 03:56:04 +00:00
|
|
|
public:
|
2019-08-20 22:18:23 +00:00
|
|
|
using WeakValueType = T;
|
WeakPtr breaks vtables when upcasting to base classes
https://bugs.webkit.org/show_bug.cgi?id=188799
Reviewed by Youenn Fablet.
Source/WebCore:
* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::MediaKeySession):
* Modules/encryptedmedia/MediaKeySession.h: Adopted modern WeakPtr APIs.
Removed redundant WeakPtrFactory.
* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::existingWrapper):
* css/CSSFontFace.h: Moved functions out of line to avoid #include
explosion for .get().
* dom/ContainerNode.h:
* dom/Document.h:
* dom/Element.h: Moved CanMakeWeakPtr to ContainerNode because all
subclasses except for DocumentFragment were already so, and we have
code that uses WeakPtr<ContainerNode>, which, now that WeakPtr is
type-safe, is awkward to do when ContainerNode isn't CanMakeWeakPtr.
* dom/FullscreenManager.cpp:
(WebCore::FullscreenManager::fullscreenRenderer const):
* dom/FullscreenManager.h:
(WebCore::FullscreenManager::fullscreenRenderer const): Deleted.
* html/FormAssociatedElement.cpp:
(WebCore::FormAssociatedElement::form const):
* html/FormAssociatedElement.h:
(WebCore::FormAssociatedElement::form const): Deleted. Moved functions
out of line to avoid #include explosion for .get().
* html/HTMLMediaElement.h: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
* loader/MediaResourceLoader.cpp:
(WebCore::MediaResourceLoader::requestResource): Removed redundant .get().
* page/DOMWindowProperty.cpp:
(WebCore::DOMWindowProperty::window const):
* page/DOMWindowProperty.h:
(WebCore::DOMWindowProperty::window const): Deleted.
* page/FrameViewLayoutContext.cpp:
(WebCore::FrameViewLayoutContext::subtreeLayoutRoot const):
* page/FrameViewLayoutContext.h:
(WebCore::FrameViewLayoutContext::subtreeLayoutRoot const): Deleted.
* page/UndoItem.cpp:
(WebCore::UndoItem::undoManager const):
* page/UndoItem.h:
(WebCore::UndoItem::undoManager const): Deleted. Moved functions out of
line to avoid #include explosion for .get().
* platform/ScrollView.h: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
* platform/Widget.cpp:
(WebCore::Widget::parent const):
* platform/Widget.h:
(WebCore::Widget::parent const): Deleted. Moved functions out of line to avoid #include
explosion for .get().
* platform/encryptedmedia/CDMInstanceSession.h: Made
CDMInstanceSessionClient CanMakeWeakPtr because we use WeakPtr<CDMInstanceSessionClient>.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
CanMakeWeakPtr is inherited now.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
(WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const): Deleted.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createWeakPtr): Deleted.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::CMTimebaseEffectiveRateChangedCallback):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::durationChanged):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled):
(WebCore::SourceBufferPrivateAVFObjC::setCDMSession):
(WebCore::SourceBufferPrivateAVFObjC::flushVideo):
(WebCore::SourceBufferPrivateAVFObjC::enqueueSample):
(WebCore::SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples):
(WebCore::SourceBufferPrivateAVFObjC::setVideoLayer):
(WebCore::SourceBufferPrivateAVFObjC::setDecompressionSession): Modernized WeakPtr API usage.
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::multiColumnFlowSlowCase const):
* rendering/RenderBlockFlow.h:
(WebCore::RenderBlockFlow::multiColumnFlow const):
* rendering/RenderMultiColumnFlow.cpp:
(WebCore::RenderMultiColumnFlow::findColumnSpannerPlaceholder const):
* rendering/RenderMultiColumnFlow.h:
* rendering/RenderTable.cpp:
(WebCore::RenderTable::header const):
(WebCore::RenderTable::footer const):
(WebCore::RenderTable::firstBody const):
(WebCore::RenderTable::topSection const):
* rendering/RenderTable.h:
(WebCore::RenderTable::header const): Deleted.
(WebCore::RenderTable::footer const): Deleted.
(WebCore::RenderTable::firstBody const): Deleted.
(WebCore::RenderTable::topSection const): Deleted. Moved functions out
of line to avoid #include explosion for .get().
Source/WebKit:
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::networkSession):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* Shared/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::suspendedPage const):
* Shared/WebBackForwardListItem.h:
(WebKit::WebBackForwardListItem::suspendedPage const): Deleted. Moved
functions out of line to avoid #include explosion for .get().
* UIProcess/Authentication/cocoa/SecKeyProxyStore.h:
(WebKit::SecKeyProxyStore::get const):
(WebKit::SecKeyProxyStore::weakPtrFactory const): Deleted. Adopted
CanMakeWeakPtr.
* UIProcess/WebAuthentication/AuthenticatorManager.h:
* UIProcess/WebProcessProxy.cpp: It takes an extra using declaration
to disambiguate multiple CanMakeWeakPtr base classes now.
(WebKit::WebProcessProxy::processPool const):
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::processPool const): Deleted. Moved
functions out of line to avoid #include explosion for .get().
Source/WTF:
This patch switches from reinterpret_cast to static_cast when loading
from WeakReference storage.
We know which type to cast *to* because it's specified by the type of
the calling WeakPtr.
We know which type to cast *from* because it's specified by a typedef
in CanMakeWeakPtr.
(Our convention is that we store a pointer to the class that derives
from CanMakeWeakPtr. We cast from that pointer to derived pointers when
we get(). This means that #include of the derived type header is now
required in order to get() the pointer.)
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Definition
is now eagerly required because WeakReference is not a template anymore.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const):
(WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computesEmpty const):
(WTF::WeakHashSet::hasNullReferences const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference<T>>>::isReleasedWeakValue): Deleted.
Updated for new WeakReference get() API.
* wtf/WeakPtr.h: Use a macro for TestAPI support. We can't use template
specialization because WeakReference is not a class template anymore.
(Or maybe we could have kept it working with a dummy template argument?
Felt weird, so I switched.)
(WTF::WeakReference::create):
(WTF::WeakReference::~WeakReference):
(WTF::WeakReference::get const):
(WTF::WeakReference::operator bool const):
(WTF::WeakReference::WeakReference): WeakReference is just a void* now.
It's the caller's responsibility, when creating and getting, to use
a consistent storage type. We ensure a canonical storage type using a
typedef inside CanMakeWeakPtr.
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const): Adopted new WeakReference API.
(WTF::WeakPtrFactory::createWeakPtr const): No need for reinterpret_cast.
(WTF::weak_reference_cast): This isn't required for correctness, but it's
nice to show a complier error at WeakPtr construction sites when you know
that the types won't work. Otherwise, you get compiler errors at
dereference sites, which are slightly more mysterious ways of saying that
you constructed your WeakPtr incorrectly.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::weak_reference_upcast): Deleted.
(WTF::weak_reference_downcast): Deleted.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Adopt the new macro API instead
of template specialization for observing weak references.
(TestWebKitAPI::Int::Int):
(TestWebKitAPI::Int::operator int const):
(TestWebKitAPI::Int::operator== const): Use a class for integer tests
because WeakPtr doesn't naturally support pointing to non-class objects
now.
(TestWebKitAPI::Base::foo):
(TestWebKitAPI::Derived::foo): Inherit from CanMakeWeakPtr to enable
deduction of the weak pointer type.
(TestWebKitAPI::TEST): Updated to use Int.
(TestWebKitAPI::Base::weakPtrFactory const): Deleted.
(WTF::WeakReference<TestWebKitAPI::Base>::WeakReference): Deleted.
(WTF::WeakReference<TestWebKitAPI::Base>::~WeakReference): Deleted.
Canonical link: https://commits.webkit.org/212376@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245868 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-29 21:15:54 +00:00
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
const WeakPtrFactory<T, Counter>& weakPtrFactory() const { return m_weakPtrFactory; }
|
|
|
|
WeakPtrFactory<T, Counter>& weakPtrFactory() { return m_weakPtrFactory; }
|
2018-06-08 03:56:04 +00:00
|
|
|
|
2019-08-20 22:18:23 +00:00
|
|
|
protected:
|
|
|
|
CanMakeWeakPtr()
|
|
|
|
{
|
|
|
|
if (initializationMode == WeakPtrFactoryInitialization::Eager)
|
2021-01-25 20:06:25 +00:00
|
|
|
initializeWeakPtrFactory();
|
|
|
|
}
|
|
|
|
|
|
|
|
void initializeWeakPtrFactory()
|
|
|
|
{
|
|
|
|
m_weakPtrFactory.initializeIfNeeded(static_cast<T&>(*this));
|
2019-08-20 22:18:23 +00:00
|
|
|
}
|
|
|
|
|
2018-06-08 03:56:04 +00:00
|
|
|
private:
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
WeakPtrFactory<T, Counter> m_weakPtrFactory;
|
2018-06-08 03:56:04 +00:00
|
|
|
};
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, typename U, typename Counter> inline WeakPtrImpl<Counter>* weak_ptr_impl_cast(WeakPtrImpl<Counter>* impl)
|
2017-10-03 18:48:57 +00:00
|
|
|
{
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
static_assert(std::is_same_v<typename T::WeakValueType, typename U::WeakValueType>, "Invalid weak pointer cast");
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
return impl;
|
2017-10-03 18:48:57 +00:00
|
|
|
}
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, typename Counter> template<typename U> inline WeakPtr<T, Counter>::WeakPtr(const WeakPtr<U, Counter>& o)
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
: m_impl(weak_ptr_impl_cast<T, U>(o.m_impl.get()))
|
2017-10-03 18:48:57 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, typename Counter> template<typename U> inline WeakPtr<T, Counter>::WeakPtr(WeakPtr<U, Counter>&& o)
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
: m_impl(adoptRef(weak_ptr_impl_cast<T, U>(o.m_impl.leakRef())))
|
2017-10-03 18:48:57 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, typename Counter> template<typename U> inline WeakPtr<T, Counter>& WeakPtr<T, Counter>::operator=(const WeakPtr<U, Counter>& o)
|
2017-10-03 18:48:57 +00:00
|
|
|
{
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
m_impl = weak_ptr_impl_cast<T, U>(o.m_impl.get());
|
2017-10-03 18:48:57 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, typename Counter> template<typename U> inline WeakPtr<T, Counter>& WeakPtr<T, Counter>::operator=(WeakPtr<U, Counter>&& o)
|
2017-10-03 18:48:57 +00:00
|
|
|
{
|
Some WeakPtr cleanup
https://bugs.webkit.org/show_bug.cgi?id=198390
Reviewed by Chris Dumez.
Source/WebCore:
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::storageQuotaManagerGetter): Dereference the weak pointer
directly instead of using a weak pointer to guard a raw pointer. It's
safer and more idiomatic to use weak pointers directly.
* Modules/indexeddb/shared/InProcessIDBServer.h: Use our base clase
weakPtrFactory() definition instead of writing our own. Declare
WeakValueType so we can dereference the weak pointer we create (above).
Source/WTF:
* wtf/WeakHashSet.h:
(WTF::HashTraits<Ref<WeakPtrImpl>>::isReleasedWeakValue):
(WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator):
Updated for rename to WeakPtrImpl.
(WTF::WeakHashSet::WeakHashSetConstIterator::get const): Updated for new
get() interface. Also, switched to iterator operator* to help clarify
the double dereference here.
(WTF::WeakHashSet::add):
(WTF::WeakHashSet::remove):
(WTF::WeakHashSet::contains const):
(WTF::WeakHashSet::computeSize const):
(WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Deleted.
Updated for rename to WeakPtrImpl.
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::create):
(WTF::WeakPtrImpl::~WeakPtrImpl): Renamed WeakReference to WeakPtrImpl.
Now we don't need a comment explaining that this class is the backing
implementation of WeakPtr.
(WTF::WeakPtrImpl::get): Return the pointer type we stored, rather than
the pointer type requested by our client. It's a little too surprising
for a field to store one pointer type and load another.
(WTF::WeakPtrImpl::WeakPtrImpl): Fixed a theoretical type safety bug.
Make sure to store T::WeakValueType* instead of T*, since they might
not be the same pointer value. (In practice, T and T::WeakValueType*
are always the same type in this constructor because WeakPtrFactory
makes them so, but it's best not to depend on implementation details
across classes.)
(WTF::WeakPtr::get const): Updated for new get() interface.
(WTF::WeakPtr::operator bool const):
(WTF::WeakPtr::operator=):
(WTF::WeakPtr::clear):
(WTF::WeakPtr::WeakPtr): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::~WeakPtrFactory): Updated for WeakPtrImpl rename.
(WTF::WeakPtrFactory::createWeakPtr const): ASSERT that the passed-in
pointer is equal to the stored pointer. As a space optimization, we
require our client to remind us what we point to each time a weak
pointer is created -- but nothing guarantees that our client will do
this correctly.
(WTF::WeakPtrFactory::revokeAll): Updated for WeakPtrImpl rename.
(WTF::CanMakeWeakPtr::weakPtrFactory const):
(WTF::CanMakeWeakPtr::weakPtrFactory): Use idiomatic accessor naming.
(WTF::weak_ptr_impl_cast): Fixed a theoretical type safety bug.
Previously, if Base and Derived both inherited CanMakeWeakPtr, and
you casted WeakPtr<Base> to WeakPtr<Derived> (or vice versa), and
casting Base <-> Derived required pointer fixup, the previous
compile-time check would accept the cast, even though the stored pointer
would be wrong.
(WTF::WeakPtr<T>::WeakPtr):
(WTF::=):
(WTF::makeWeakPtr):
(WTF::WeakReference::create): Deleted.
(WTF::WeakReference::~WeakReference): Deleted.
(WTF::WeakReference::get const): Deleted.
(WTF::WeakReference::operator bool const): Deleted.
(WTF::WeakReference::clear): Deleted.
(WTF::WeakReference::WeakReference): Deleted.
(WTF::weak_reference_cast): Deleted. Updated for rename to WeakPtrImpl.
Don't export WeakPtrImpl because it's an implmenetation detail and
it shouldn't be easy to use outside WTF.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Updated for rename.
Canonical link: https://commits.webkit.org/212447@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 17:11:58 +00:00
|
|
|
m_impl = adoptRef(weak_ptr_impl_cast<T, U>(o.m_impl.leakRef()));
|
2017-10-03 18:48:57 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2021-07-29 02:33:05 +00:00
|
|
|
template<typename T, typename = std::enable_if_t<!IsSmartPtr<T>::value>> inline auto makeWeakPtr(T& object, EnableWeakPtrThreadingAssertions enableWeakPtrThreadingAssertions = EnableWeakPtrThreadingAssertions::Yes)
|
2017-09-30 13:44:04 +00:00
|
|
|
{
|
OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224279
Reviewed by Darin Adler.
Source/WebCore:
OfflineAudioContext objects were always leaking due to 2 reference cycles:
1. BaseAudioContext -> m_listener (AudioListener) -> m_positionX (AudioParam) -> m_context (BaseAudioContext)
2. BaseAudioContext -> m_destinationNode (AudioDestinationNode) -> m_context (BaseAudioContext)
For reference cycle 1, I made AudioSummingJunction (base class of AudioParam) hold a weak pointer to the
AudioContext instead of a Ref<>. I don't think there is a good reason for an AudioSummingJunction (AudioParam
or AudioNodeInput) to keep its AudioContext alive. AudioNodes already keep their AudioContext alive.
AudioNodeInputs and AudioParams are associated to AudioNodes.
For reference cycle 2, I made AudioDestinationNode not hold a strong pointer to its context but instead a
weak pointer. Since keeping an AudioDestinationNode alive should keep its AudioContext alive, I made it so
that ref'ing the AudioDestinationNode refs its BaseAudioContext. Also, BaseAudioContext::m_destinationNode
is now a UniqueRef<> instead of a RefPtr<> to avoid a cycle.
Tests: webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html
webaudio/OfflineAudioContext/offlineaudiocontext-leak.html
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::baseLatency):
(WebCore::AudioContext::getOutputTimestamp):
(WebCore::AudioContext::close):
(WebCore::AudioContext::destination):
(WebCore::AudioContext::destination const):
(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::mediaState const):
(WebCore::AudioContext::mayResumePlayback):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::pageMutedStateDidChange):
* Modules/webaudio/AudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::ref):
(WebCore::AudioDestinationNode::deref):
* Modules/webaudio/AudioDestinationNode.h:
Have AudioDestinationNode override AudioNode's ref() / deref() to forward the refcounting
to its BaseAudioContext, instead of using the AudioNode's internal refCount.
* Modules/webaudio/AudioListener.cpp:
(WebCore::AudioListener::updateValuesIfNeeded):
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::setOrientation):
Add some null-checks for AudioParam::context() now that AudioParam holds a WeakPtr to its
context.
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::toWeakOrStrongContext):
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::connect):
(WebCore::AudioNode::sampleRate const):
(WebCore::AudioNode::markNodeForDeletionIfNecessary):
(WebCore::AudioNode::contextForBindings):
(WebCore::AudioNode::context):
(WebCore::AudioNode::context const):
* Modules/webaudio/AudioNode.h:
- Hold the BaseAudioContext as a WeakPtr instead of a Ref<> if the AudioNode is an
AudioDestinationNode. This avoids a reference cycle since the BaseAudioContext owns the
AudioDestinationNode. Even though we are using a WeakPtr, it is safe to assume that
the context is not null because ref'ing an AudioDestinationNode refs its BaseAudioContext.
- Make sure markNodeForDeletionIfNecessary() has no effect for AudioDestinationNode since
BaseAudioContext now owns the AudioDestinationNode when we take care of destroying its
destination node when destroyed.
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::connect):
(WebCore::AudioNodeInput::disconnect):
(WebCore::AudioNodeInput::outputEnabledStateChanged):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::internalSummingBus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):
Add assertions that the context is not null. There were already assertions that we are the graph
owner, which means we are holding the BaseAudioContext's lock, which means that the audio context
is alive.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::value):
(WebCore::AudioParam::setValueForBindings):
(WebCore::AudioParam::smooth):
(WebCore::AudioParam::hasSampleAccurateValues const):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
(WebCore::AudioParam::calculateTimelineValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
Add null-checks for the AudioContext now that the AudioParam is only holding a WeakPtr to its
BaseAudioContext (to avoid a reference cycle).
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::AudioSummingJunction):
(WebCore::AudioSummingJunction::~AudioSummingJunction):
(WebCore::AudioSummingJunction::markRenderingStateAsDirty):
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
(WebCore::AudioSummingJunction::outputEnabledStateChanged):
* Modules/webaudio/AudioSummingJunction.h:
(WebCore::AudioSummingJunction::context):
(WebCore::AudioSummingJunction::context const):
- Hold a WeakPtr to the BaseAudioContext to avoid a reference cycle.
- Deal with the fact that the audio context may be null now that we're holding a WeakPtr
to it (except when holding the graph lock)
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
(WebCore::BaseAudioContext::~BaseAudioContext):
(WebCore::BaseAudioContext::numberOfInstances):
(WebCore::BaseAudioContext::lazyInitialize):
(WebCore::BaseAudioContext::clear):
(WebCore::BaseAudioContext::uninitialize):
(WebCore::BaseAudioContext::stop):
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::decodeAudioData):
(WebCore::BaseAudioContext::markForDeletion):
(WebCore::BaseAudioContext::deleteMarkedNodes):
(WebCore::BaseAudioContext::setPendingActivity):
(WebCore::BaseAudioContext::workletIsReady):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::destination):
(WebCore::BaseAudioContext::destination const):
(WebCore::BaseAudioContext::currentSampleFrame const):
(WebCore::BaseAudioContext::currentTime const):
- Switch m_destinationNode from RefPtr<> to UniqueRef<> since the AudioContext is now
the owner of the destinationNode and since refing the destination node actually refs
its BaseAudioContext.
- Drop some null checks now that m_destinationNode can no longer be null.
- Rename makePendingActivity() to setPendingActivity() to avoid a naming conflict with
ActiveDOMObject::makePendingActivity().
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/OfflineAudioDestinationNode.h:
- Drop create() factory functions and make the constructor public now that the BaseAudioContext owns
its destination node via a UniqueRef<>.
- Make some member functions public as they are virtual and they now called on the subclass instead of the
base class (and these functions are public in the base class).
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
(WebCore::OfflineAudioContext::resumeOfflineRendering):
* Modules/webaudio/OfflineAudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::close):
Drop null checks for the destination node now that it can never be null.
* dom/ShadowRoot.cpp:
* rendering/FloatingObjects.cpp:
* rendering/RootInlineBox.cpp:
Update classes used of size restrictions since the size of a WeakPtr is not longer the same as the size of a
pointer when debug assertions are enabled. As long as they are the same size in release builds, there is no
memory use concern.
* testing/Internals.cpp:
(WebCore::Internals::numberOfBaseAudioContexts const):
* testing/Internals.h:
* testing/Internals.idl:
Add testing function to check how many BaseAudioContexts are alive, so that we can write layout tests and check
for leaks.
Source/WTF:
Add flag that can be passed when constructing a WeakPtr to disable threading assertions.
This is useful for cases where we know it is safe due to locking but we'd like to use a
WeakPtr instead of a raw pointer because it is safer.
* wtf/WeakPtr.h:
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const):
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::=):
(WTF::makeWeakPtr):
LayoutTests:
Add layout test coverage.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak.html: Added.
Canonical link: https://commits.webkit.org/236304@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 18:41:23 +00:00
|
|
|
return object.weakPtrFactory().template createWeakPtr<T>(object, enableWeakPtrThreadingAssertions);
|
2017-09-30 13:44:04 +00:00
|
|
|
}
|
|
|
|
|
2021-07-29 02:33:05 +00:00
|
|
|
template<typename T, typename = std::enable_if_t<!IsSmartPtr<T>::value>> inline auto makeWeakPtr(T* ptr, EnableWeakPtrThreadingAssertions enableWeakPtrThreadingAssertions = EnableWeakPtrThreadingAssertions::Yes) -> decltype(makeWeakPtr(*ptr))
|
2017-10-02 21:31:16 +00:00
|
|
|
{
|
|
|
|
if (!ptr)
|
|
|
|
return { };
|
OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224279
Reviewed by Darin Adler.
Source/WebCore:
OfflineAudioContext objects were always leaking due to 2 reference cycles:
1. BaseAudioContext -> m_listener (AudioListener) -> m_positionX (AudioParam) -> m_context (BaseAudioContext)
2. BaseAudioContext -> m_destinationNode (AudioDestinationNode) -> m_context (BaseAudioContext)
For reference cycle 1, I made AudioSummingJunction (base class of AudioParam) hold a weak pointer to the
AudioContext instead of a Ref<>. I don't think there is a good reason for an AudioSummingJunction (AudioParam
or AudioNodeInput) to keep its AudioContext alive. AudioNodes already keep their AudioContext alive.
AudioNodeInputs and AudioParams are associated to AudioNodes.
For reference cycle 2, I made AudioDestinationNode not hold a strong pointer to its context but instead a
weak pointer. Since keeping an AudioDestinationNode alive should keep its AudioContext alive, I made it so
that ref'ing the AudioDestinationNode refs its BaseAudioContext. Also, BaseAudioContext::m_destinationNode
is now a UniqueRef<> instead of a RefPtr<> to avoid a cycle.
Tests: webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html
webaudio/OfflineAudioContext/offlineaudiocontext-leak.html
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::baseLatency):
(WebCore::AudioContext::getOutputTimestamp):
(WebCore::AudioContext::close):
(WebCore::AudioContext::destination):
(WebCore::AudioContext::destination const):
(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::mediaState const):
(WebCore::AudioContext::mayResumePlayback):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::pageMutedStateDidChange):
* Modules/webaudio/AudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::ref):
(WebCore::AudioDestinationNode::deref):
* Modules/webaudio/AudioDestinationNode.h:
Have AudioDestinationNode override AudioNode's ref() / deref() to forward the refcounting
to its BaseAudioContext, instead of using the AudioNode's internal refCount.
* Modules/webaudio/AudioListener.cpp:
(WebCore::AudioListener::updateValuesIfNeeded):
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::setOrientation):
Add some null-checks for AudioParam::context() now that AudioParam holds a WeakPtr to its
context.
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::toWeakOrStrongContext):
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::connect):
(WebCore::AudioNode::sampleRate const):
(WebCore::AudioNode::markNodeForDeletionIfNecessary):
(WebCore::AudioNode::contextForBindings):
(WebCore::AudioNode::context):
(WebCore::AudioNode::context const):
* Modules/webaudio/AudioNode.h:
- Hold the BaseAudioContext as a WeakPtr instead of a Ref<> if the AudioNode is an
AudioDestinationNode. This avoids a reference cycle since the BaseAudioContext owns the
AudioDestinationNode. Even though we are using a WeakPtr, it is safe to assume that
the context is not null because ref'ing an AudioDestinationNode refs its BaseAudioContext.
- Make sure markNodeForDeletionIfNecessary() has no effect for AudioDestinationNode since
BaseAudioContext now owns the AudioDestinationNode when we take care of destroying its
destination node when destroyed.
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::connect):
(WebCore::AudioNodeInput::disconnect):
(WebCore::AudioNodeInput::outputEnabledStateChanged):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::internalSummingBus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):
Add assertions that the context is not null. There were already assertions that we are the graph
owner, which means we are holding the BaseAudioContext's lock, which means that the audio context
is alive.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::value):
(WebCore::AudioParam::setValueForBindings):
(WebCore::AudioParam::smooth):
(WebCore::AudioParam::hasSampleAccurateValues const):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
(WebCore::AudioParam::calculateTimelineValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
Add null-checks for the AudioContext now that the AudioParam is only holding a WeakPtr to its
BaseAudioContext (to avoid a reference cycle).
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::AudioSummingJunction):
(WebCore::AudioSummingJunction::~AudioSummingJunction):
(WebCore::AudioSummingJunction::markRenderingStateAsDirty):
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
(WebCore::AudioSummingJunction::outputEnabledStateChanged):
* Modules/webaudio/AudioSummingJunction.h:
(WebCore::AudioSummingJunction::context):
(WebCore::AudioSummingJunction::context const):
- Hold a WeakPtr to the BaseAudioContext to avoid a reference cycle.
- Deal with the fact that the audio context may be null now that we're holding a WeakPtr
to it (except when holding the graph lock)
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
(WebCore::BaseAudioContext::~BaseAudioContext):
(WebCore::BaseAudioContext::numberOfInstances):
(WebCore::BaseAudioContext::lazyInitialize):
(WebCore::BaseAudioContext::clear):
(WebCore::BaseAudioContext::uninitialize):
(WebCore::BaseAudioContext::stop):
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::decodeAudioData):
(WebCore::BaseAudioContext::markForDeletion):
(WebCore::BaseAudioContext::deleteMarkedNodes):
(WebCore::BaseAudioContext::setPendingActivity):
(WebCore::BaseAudioContext::workletIsReady):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::destination):
(WebCore::BaseAudioContext::destination const):
(WebCore::BaseAudioContext::currentSampleFrame const):
(WebCore::BaseAudioContext::currentTime const):
- Switch m_destinationNode from RefPtr<> to UniqueRef<> since the AudioContext is now
the owner of the destinationNode and since refing the destination node actually refs
its BaseAudioContext.
- Drop some null checks now that m_destinationNode can no longer be null.
- Rename makePendingActivity() to setPendingActivity() to avoid a naming conflict with
ActiveDOMObject::makePendingActivity().
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/OfflineAudioDestinationNode.h:
- Drop create() factory functions and make the constructor public now that the BaseAudioContext owns
its destination node via a UniqueRef<>.
- Make some member functions public as they are virtual and they now called on the subclass instead of the
base class (and these functions are public in the base class).
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
(WebCore::OfflineAudioContext::resumeOfflineRendering):
* Modules/webaudio/OfflineAudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::close):
Drop null checks for the destination node now that it can never be null.
* dom/ShadowRoot.cpp:
* rendering/FloatingObjects.cpp:
* rendering/RootInlineBox.cpp:
Update classes used of size restrictions since the size of a WeakPtr is not longer the same as the size of a
pointer when debug assertions are enabled. As long as they are the same size in release builds, there is no
memory use concern.
* testing/Internals.cpp:
(WebCore::Internals::numberOfBaseAudioContexts const):
* testing/Internals.h:
* testing/Internals.idl:
Add testing function to check how many BaseAudioContexts are alive, so that we can write layout tests and check
for leaks.
Source/WTF:
Add flag that can be passed when constructing a WeakPtr to disable threading assertions.
This is useful for cases where we know it is safe due to locking but we'd like to use a
WeakPtr instead of a raw pointer because it is safer.
* wtf/WeakPtr.h:
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const):
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::=):
(WTF::makeWeakPtr):
LayoutTests:
Add layout test coverage.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak.html: Added.
Canonical link: https://commits.webkit.org/236304@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 18:41:23 +00:00
|
|
|
return makeWeakPtr(*ptr, enableWeakPtrThreadingAssertions);
|
2017-10-02 21:31:16 +00:00
|
|
|
}
|
|
|
|
|
2021-07-29 02:33:05 +00:00
|
|
|
template<typename T, typename = std::enable_if_t<!IsSmartPtr<T>::value>> inline auto makeWeakPtr(const Ref<T>& object, EnableWeakPtrThreadingAssertions enableWeakPtrThreadingAssertions = EnableWeakPtrThreadingAssertions::Yes)
|
|
|
|
{
|
|
|
|
return makeWeakPtr(object.get(), enableWeakPtrThreadingAssertions);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T, typename = std::enable_if_t<!IsSmartPtr<T>::value>> inline auto makeWeakPtr(const RefPtr<T>& object, EnableWeakPtrThreadingAssertions enableWeakPtrThreadingAssertions = EnableWeakPtrThreadingAssertions::Yes)
|
|
|
|
{
|
|
|
|
return makeWeakPtr(object.get(), enableWeakPtrThreadingAssertions);
|
|
|
|
}
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, typename U, typename Counter> inline bool operator==(const WeakPtr<T, Counter>& a, const WeakPtr<U, Counter>& b)
|
2016-05-20 14:42:45 +00:00
|
|
|
{
|
|
|
|
return a.get() == b.get();
|
|
|
|
}
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, typename U, typename Counter> inline bool operator==(const WeakPtr<T, Counter>& a, U* b)
|
2016-05-20 14:42:45 +00:00
|
|
|
{
|
|
|
|
return a.get() == b;
|
|
|
|
}
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, typename U, typename Counter> inline bool operator==(T* a, const WeakPtr<U, Counter>& b)
|
2016-05-20 14:42:45 +00:00
|
|
|
{
|
|
|
|
return a == b.get();
|
|
|
|
}
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, typename U, typename Counter> inline bool operator!=(const WeakPtr<T, Counter>& a, const WeakPtr<U, Counter>& b)
|
2016-05-20 14:42:45 +00:00
|
|
|
{
|
|
|
|
return a.get() != b.get();
|
|
|
|
}
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, typename U, typename Counter> inline bool operator!=(const WeakPtr<T, Counter>& a, U* b)
|
2016-05-20 14:42:45 +00:00
|
|
|
{
|
|
|
|
return a.get() != b;
|
|
|
|
}
|
|
|
|
|
Add iterator checking to ListHashSet
https://bugs.webkit.org/show_bug.cgi?id=211669
Reviewed by Anders Carlsson.
Source/WebCore:
* page/ios/ContentChangeObserver.h: Added an include of Element.h, needed to call
makeWeakPtr in an inline function. This is due to a change in the way makeWeakPtr
now checks the type of the argument. It's possible we could refine it further to
relax this requirement, but it seems OK to include Element.h here.
Source/WTF:
HashSet and HashMap have iterator checking in debug builds.
Add similar checking to ListHashSet, controlled by the same
macro, CHECK_HASHTABLE_ITERATORS. Use WeakPtr to make the
implementation simple.
* wtf/Forward.h: Update to add a second parameter to WeakPtr.
Also rearranged and tweaked the file a bug.
* wtf/ListHashSet.h: Make ListHashSet and ListHashSetNode derive
from CanMakeWeakPtr. Add m_weakSet and m_weakPosition members to
ListHashSetConstIterator, and assert their values at the appropriate
times so we will get a breakpoint or crash.
* wtf/WeakHashSet.h: Updated to add a Counter argument for testing.
* wtf/WeakPtr.h: Removed the DID_CREATE_WEAK_PTR_IMPL and
WILL_DESTROY_WEAK_PTR_IMPL macros, which didn't really work because
using them violated the C++ one-definition rule. Replaced with
a Counter argument, which defaults to EmptyCounter, which is inlines
that do nothing. This required some updates to the classes and
functions to make them work with a second argument.
Tools:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Removed use of the DID_CREATE_WEAK_PTR_IMPL
and WILL_DESTROY_WEAK_PTR_IMPL, which didn't work consistently because of the
one-definition rule. Instead, this file parameterizes the WeakPtr family of
class templates with a counter class. To avoid having to rewrite test code, used
alias templates to insert these class template into the TestWebKitAPI namespace,
hiding the class templates from the WTF namespace.
Canonical link: https://commits.webkit.org/224909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@261818 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-05-18 17:16:16 +00:00
|
|
|
template<typename T, typename U, typename Counter> inline bool operator!=(T* a, const WeakPtr<U, Counter>& b)
|
2016-05-20 14:42:45 +00:00
|
|
|
{
|
|
|
|
return a != b.get();
|
|
|
|
}
|
|
|
|
|
2013-01-15 21:35:08 +00:00
|
|
|
} // namespace WTF
|
|
|
|
|
2018-06-08 03:56:04 +00:00
|
|
|
using WTF::CanMakeWeakPtr;
|
OfflineAudioContext objects are leaking
https://bugs.webkit.org/show_bug.cgi?id=224279
Reviewed by Darin Adler.
Source/WebCore:
OfflineAudioContext objects were always leaking due to 2 reference cycles:
1. BaseAudioContext -> m_listener (AudioListener) -> m_positionX (AudioParam) -> m_context (BaseAudioContext)
2. BaseAudioContext -> m_destinationNode (AudioDestinationNode) -> m_context (BaseAudioContext)
For reference cycle 1, I made AudioSummingJunction (base class of AudioParam) hold a weak pointer to the
AudioContext instead of a Ref<>. I don't think there is a good reason for an AudioSummingJunction (AudioParam
or AudioNodeInput) to keep its AudioContext alive. AudioNodes already keep their AudioContext alive.
AudioNodeInputs and AudioParams are associated to AudioNodes.
For reference cycle 2, I made AudioDestinationNode not hold a strong pointer to its context but instead a
weak pointer. Since keeping an AudioDestinationNode alive should keep its AudioContext alive, I made it so
that ref'ing the AudioDestinationNode refs its BaseAudioContext. Also, BaseAudioContext::m_destinationNode
is now a UniqueRef<> instead of a RefPtr<> to avoid a cycle.
Tests: webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html
webaudio/OfflineAudioContext/offlineaudiocontext-leak.html
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::baseLatency):
(WebCore::AudioContext::getOutputTimestamp):
(WebCore::AudioContext::close):
(WebCore::AudioContext::destination):
(WebCore::AudioContext::destination const):
(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):
(WebCore::AudioContext::startRendering):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::mediaState const):
(WebCore::AudioContext::mayResumePlayback):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::pageMutedStateDidChange):
* Modules/webaudio/AudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::ref):
(WebCore::AudioDestinationNode::deref):
* Modules/webaudio/AudioDestinationNode.h:
Have AudioDestinationNode override AudioNode's ref() / deref() to forward the refcounting
to its BaseAudioContext, instead of using the AudioNode's internal refCount.
* Modules/webaudio/AudioListener.cpp:
(WebCore::AudioListener::updateValuesIfNeeded):
(WebCore::AudioListener::setPosition):
(WebCore::AudioListener::setOrientation):
Add some null-checks for AudioParam::context() now that AudioParam holds a WeakPtr to its
context.
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::toWeakOrStrongContext):
(WebCore::AudioNode::AudioNode):
(WebCore::AudioNode::connect):
(WebCore::AudioNode::sampleRate const):
(WebCore::AudioNode::markNodeForDeletionIfNecessary):
(WebCore::AudioNode::contextForBindings):
(WebCore::AudioNode::context):
(WebCore::AudioNode::context const):
* Modules/webaudio/AudioNode.h:
- Hold the BaseAudioContext as a WeakPtr instead of a Ref<> if the AudioNode is an
AudioDestinationNode. This avoids a reference cycle since the BaseAudioContext owns the
AudioDestinationNode. Even though we are using a WeakPtr, it is safe to assume that
the context is not null because ref'ing an AudioDestinationNode refs its BaseAudioContext.
- Make sure markNodeForDeletionIfNecessary() has no effect for AudioDestinationNode since
BaseAudioContext now owns the AudioDestinationNode when we take care of destroying its
destination node when destroyed.
* Modules/webaudio/AudioNodeInput.cpp:
(WebCore::AudioNodeInput::connect):
(WebCore::AudioNodeInput::disconnect):
(WebCore::AudioNodeInput::outputEnabledStateChanged):
(WebCore::AudioNodeInput::updateInternalBus):
(WebCore::AudioNodeInput::bus):
(WebCore::AudioNodeInput::internalSummingBus):
(WebCore::AudioNodeInput::sumAllConnections):
(WebCore::AudioNodeInput::pull):
Add assertions that the context is not null. There were already assertions that we are the graph
owner, which means we are holding the BaseAudioContext's lock, which means that the audio context
is alive.
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::value):
(WebCore::AudioParam::setValueForBindings):
(WebCore::AudioParam::smooth):
(WebCore::AudioParam::hasSampleAccurateValues const):
(WebCore::AudioParam::calculateSampleAccurateValues):
(WebCore::AudioParam::calculateFinalValues):
(WebCore::AudioParam::calculateTimelineValues):
(WebCore::AudioParam::connect):
(WebCore::AudioParam::disconnect):
Add null-checks for the AudioContext now that the AudioParam is only holding a WeakPtr to its
BaseAudioContext (to avoid a reference cycle).
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::AudioSummingJunction):
(WebCore::AudioSummingJunction::~AudioSummingJunction):
(WebCore::AudioSummingJunction::markRenderingStateAsDirty):
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
(WebCore::AudioSummingJunction::outputEnabledStateChanged):
* Modules/webaudio/AudioSummingJunction.h:
(WebCore::AudioSummingJunction::context):
(WebCore::AudioSummingJunction::context const):
- Hold a WeakPtr to the BaseAudioContext to avoid a reference cycle.
- Deal with the fact that the audio context may be null now that we're holding a WeakPtr
to it (except when holding the graph lock)
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::BaseAudioContext):
(WebCore::BaseAudioContext::~BaseAudioContext):
(WebCore::BaseAudioContext::numberOfInstances):
(WebCore::BaseAudioContext::lazyInitialize):
(WebCore::BaseAudioContext::clear):
(WebCore::BaseAudioContext::uninitialize):
(WebCore::BaseAudioContext::stop):
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::decodeAudioData):
(WebCore::BaseAudioContext::markForDeletion):
(WebCore::BaseAudioContext::deleteMarkedNodes):
(WebCore::BaseAudioContext::setPendingActivity):
(WebCore::BaseAudioContext::workletIsReady):
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::destination):
(WebCore::BaseAudioContext::destination const):
(WebCore::BaseAudioContext::currentSampleFrame const):
(WebCore::BaseAudioContext::currentTime const):
- Switch m_destinationNode from RefPtr<> to UniqueRef<> since the AudioContext is now
the owner of the destinationNode and since refing the destination node actually refs
its BaseAudioContext.
- Drop some null checks now that m_destinationNode can no longer be null.
- Rename makePendingActivity() to setPendingActivity() to avoid a naming conflict with
ActiveDOMObject::makePendingActivity().
* Modules/webaudio/DefaultAudioDestinationNode.h:
* Modules/webaudio/OfflineAudioDestinationNode.h:
- Drop create() factory functions and make the constructor public now that the BaseAudioContext owns
its destination node via a UniqueRef<>.
- Make some member functions public as they are virtual and they now called on the subclass instead of the
base class (and these functions are public in the base class).
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::startOfflineRendering):
(WebCore::OfflineAudioContext::resumeOfflineRendering):
* Modules/webaudio/OfflineAudioContext.h:
- Drop some null checks now that m_destinationNode can no longer be null.
- Capture an ActiveDOMObject::PendingActivity when doing async work that ends up resolving a Promise, so that
we keep both the object and its wrapper alive for the duration of the async work.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::close):
Drop null checks for the destination node now that it can never be null.
* dom/ShadowRoot.cpp:
* rendering/FloatingObjects.cpp:
* rendering/RootInlineBox.cpp:
Update classes used of size restrictions since the size of a WeakPtr is not longer the same as the size of a
pointer when debug assertions are enabled. As long as they are the same size in release builds, there is no
memory use concern.
* testing/Internals.cpp:
(WebCore::Internals::numberOfBaseAudioContexts const):
* testing/Internals.h:
* testing/Internals.idl:
Add testing function to check how many BaseAudioContexts are alive, so that we can write layout tests and check
for leaks.
Source/WTF:
Add flag that can be passed when constructing a WeakPtr to disable threading assertions.
This is useful for cases where we know it is safe due to locking but we'd like to use a
WeakPtr instead of a raw pointer because it is safer.
* wtf/WeakPtr.h:
(WTF::WeakPtr::get const):
(WTF::WeakPtr::operator-> const):
(WTF::WeakPtr::operator* const):
(WTF::WeakPtr::WeakPtr):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::=):
(WTF::makeWeakPtr):
LayoutTests:
Add layout test coverage.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-after-rendering.html: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak-expected.txt: Added.
* webaudio/OfflineAudioContext/offlineaudiocontext-leak.html: Added.
Canonical link: https://commits.webkit.org/236304@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275668 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 18:41:23 +00:00
|
|
|
using WTF::EnableWeakPtrThreadingAssertions;
|
2013-01-15 21:35:08 +00:00
|
|
|
using WTF::WeakPtr;
|
|
|
|
using WTF::WeakPtrFactory;
|
2019-08-20 22:18:23 +00:00
|
|
|
using WTF::WeakPtrFactoryInitialization;
|
2017-09-30 13:44:04 +00:00
|
|
|
using WTF::makeWeakPtr;
|