Chromium Code Reviews| Index: third_party/WebKit/Source/platform/heap/Persistent.h |
| diff --git a/third_party/WebKit/Source/platform/heap/Persistent.h b/third_party/WebKit/Source/platform/heap/Persistent.h |
| index 8aa3708af2df13521feaaa734413965cde3ac299..7fca638311f43904d5f900151488508b0c71d525 100644 |
| --- a/third_party/WebKit/Source/platform/heap/Persistent.h |
| +++ b/third_party/WebKit/Source/platform/heap/Persistent.h |
| @@ -77,12 +77,20 @@ public: |
| checkPointer(); |
| } |
| + PersistentBase(WTF::HashTableDeletedValueType) : m_raw(reinterpret_cast<T*>(-1)) |
| + { |
| + initialize(); |
| + checkPointer(); |
| + } |
| + |
| ~PersistentBase() |
| { |
| uninitialize(); |
| m_raw = nullptr; |
| } |
| + bool isHashTableDeletedValue() const { return m_raw == reinterpret_cast<T*>(-1); } |
| + |
| template<typename VisitorDispatcher> |
| void trace(VisitorDispatcher visitor) |
| { |
| @@ -184,7 +192,7 @@ private: |
| void initialize() |
| { |
| ASSERT(!m_persistentNode); |
| - if (!m_raw) |
| + if (!m_raw || isHashTableDeletedValue()) |
| return; |
| TraceCallback traceCallback = TraceMethodDelegate<PersistentBase<T, weaknessConfiguration, crossThreadnessConfiguration>, &PersistentBase<T, weaknessConfiguration, crossThreadnessConfiguration>::trace>::trampoline; |
| @@ -221,7 +229,7 @@ private: |
| void checkPointer() |
| { |
| #if ENABLE(ASSERT) && defined(ADDRESS_SANITIZER) |
| - if (!m_raw) |
| + if (!m_raw || isHashTableDeletedValue()) |
| return; |
| // ThreadHeap::isHeapObjectAlive(m_raw) checks that m_raw is a traceable |
| @@ -372,6 +380,7 @@ public: |
| CrossThreadPersistent(const CrossThreadPersistent<U>& other) : Parent(other) { } |
| template<typename U> |
| CrossThreadPersistent(const Member<U>& other) : Parent(other) { } |
| + CrossThreadPersistent(WTF::HashTableDeletedValueType x) : Parent(x) { } |
|
sof
2016/05/26 09:41:44
Isn't this ctor needed for Persistent<> also?
|
| T* atomicGet() { return Parent::atomicGet(); } |
| @@ -682,6 +691,17 @@ template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, |
| namespace WTF { |
| +template <typename T> |
| +struct CrossThreadPersistentHash : MemberHash<T> { |
|
sof
2016/05/26 09:41:44
Add for Persistent<> also.
|
| + STATIC_ONLY(CrossThreadPersistentHash); |
| +}; |
| + |
| +template <typename T> |
| +struct DefaultHash<blink::CrossThreadPersistent<T>> { |
| + STATIC_ONLY(DefaultHash); |
| + using Hash = CrossThreadPersistentHash<T>; |
| +}; |
| + |
| template<typename T> |
| struct ParamStorageTraits<blink::WeakPersistentThisPointer<T>> { |
| STATIC_ONLY(ParamStorageTraits); |