WebKit Bugzilla
Attachment 373759 Details for
Bug 199517
: Add threading assertion to WTF::WeakPtr
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP Patch
199517_wip.patch (text/plain), 4.05 KB, created by
Chris Dumez
on 2019-07-09 13:58:10 PDT
(
hide
)
Description:
WIP Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2019-07-09 13:58:10 PDT
Size:
4.05 KB
patch
obsolete
>diff --git a/Source/WTF/wtf/WeakPtr.h b/Source/WTF/wtf/WeakPtr.h >index 7f108a713a4..f848ceace20 100644 >--- a/Source/WTF/wtf/WeakPtr.h >+++ b/Source/WTF/wtf/WeakPtr.h >@@ -26,6 +26,7 @@ > > #pragma once > >+#include <wtf/MainThread.h> > #include <wtf/Noncopyable.h> > #include <wtf/Ref.h> > #include <wtf/ThreadSafeRefCounted.h> >@@ -49,9 +50,9 @@ class WeakPtrImpl : public ThreadSafeRefCounted<WeakPtrImpl> { > WTF_MAKE_NONCOPYABLE(WeakPtrImpl); > WTF_MAKE_FAST_ALLOCATED; > public: >- template<typename T> static Ref<WeakPtrImpl> create(T* ptr) >+ template<typename T> static Ref<WeakPtrImpl> create(T* ptr, bool wasConstructedOnMainThread) > { >- return adoptRef(*new WeakPtrImpl(ptr)); >+ return adoptRef(*new WeakPtrImpl(ptr, wasConstructedOnMainThread)); > } > > ~WeakPtrImpl() >@@ -61,20 +62,26 @@ public: > > template<typename T> typename T::WeakValueType* get() > { >+ RELEASE_ASSERT(Thread::mayBeGCThread() || m_wasConstructedOnMainThread == isMainThread()); // FIXME: Make it a debug ASSERT(). > return static_cast<typename T::WeakValueType*>(m_ptr); > } > >- explicit operator bool() const { return m_ptr; } >+ explicit operator bool() const >+ { >+ return m_ptr; >+ } > void clear() { m_ptr = nullptr; } > > private: >- template<typename T> explicit WeakPtrImpl(T* ptr) >+ template<typename T> explicit WeakPtrImpl(T* ptr, bool wasConstructedOnMainThread) > : m_ptr(static_cast<typename T::WeakValueType*>(ptr)) >+ , m_wasConstructedOnMainThread(wasConstructedOnMainThread) > { > DID_CREATE_WEAK_PTR_IMPL(ptr); > } > > void* m_ptr; >+ bool m_wasConstructedOnMainThread; > }; > > template<typename T> >@@ -114,7 +121,11 @@ class WeakPtrFactory { > WTF_MAKE_NONCOPYABLE(WeakPtrFactory<T>); > WTF_MAKE_FAST_ALLOCATED; > public: >- WeakPtrFactory() = default; >+ WeakPtrFactory() >+ : m_wasConstructedOnMainThread(isMainThread()) >+ { >+ } >+ > ~WeakPtrFactory() > { > if (!m_impl) >@@ -124,8 +135,9 @@ public: > > WeakPtr<T> createWeakPtr(T& object) const > { >+ RELEASE_ASSERT(m_wasConstructedOnMainThread == isMainThread()); // FIXME: Make it a debug ASSERT(). > if (!m_impl) >- m_impl = WeakPtrImpl::create(&object); >+ m_impl = WeakPtrImpl::create(&object, m_wasConstructedOnMainThread); > > ASSERT(&object == m_impl->get<T>()); > return WeakPtr<T>(makeRef(*m_impl)); >@@ -133,8 +145,9 @@ public: > > WeakPtr<const T> createWeakPtr(const T& object) const > { >+ RELEASE_ASSERT(m_wasConstructedOnMainThread == isMainThread()); // FIXME: Make it a debug ASSERT(). > if (!m_impl) >- m_impl = WeakPtrImpl::create(const_cast<T*>(&object)); >+ m_impl = WeakPtrImpl::create(const_cast<T*>(&object), m_wasConstructedOnMainThread); > > ASSERT(&object == m_impl->get<T>()); > return WeakPtr<T>(makeRef(*m_impl)); >@@ -153,6 +166,7 @@ private: > template<typename> friend class WeakHashSet; > > mutable RefPtr<WeakPtrImpl> m_impl; >+ bool m_wasConstructedOnMainThread; > }; > > template<typename T> class CanMakeWeakPtr { >diff --git a/Source/WebCore/platform/ScrollableArea.cpp b/Source/WebCore/platform/ScrollableArea.cpp >index c8882ee2305..7ca4f194f07 100644 >--- a/Source/WebCore/platform/ScrollableArea.cpp >+++ b/Source/WebCore/platform/ScrollableArea.cpp >@@ -47,6 +47,7 @@ namespace WebCore { > > struct SameSizeAsScrollableArea { > virtual ~SameSizeAsScrollableArea(); >+ bool debug; > #if ENABLE(CSS_SCROLL_SNAP) > void* pointers[3]; > unsigned currentIndices[2]; >diff --git a/Source/WebCore/rendering/RenderObject.cpp b/Source/WebCore/rendering/RenderObject.cpp >index 78c0958db31..09d3e634768 100644 >--- a/Source/WebCore/rendering/RenderObject.cpp >+++ b/Source/WebCore/rendering/RenderObject.cpp >@@ -102,6 +102,7 @@ RenderObject::SetLayoutNeededForbiddenScope::~SetLayoutNeededForbiddenScope() > > struct SameSizeAsRenderObject { > virtual ~SameSizeAsRenderObject() = default; // Allocate vtable pointer. >+ bool debug; > void* pointers[5]; > #ifndef NDEBUG > unsigned m_debugBitfields : 2;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199517
:
373494
|
373495
|
373501
|
373502
|
373503
|
373505
|
373508
|
373626
|
373633
|
373634
|
373636
|
373638
|
373656
|
373684
|
373685
|
373686
|
373687
|
373747
|
373757
|
373759
|
373773
|
373783
|
373786
|
373794
|
373804
|
373809
|
373845
|
374012
|
374015
|
374017
|
374022