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 420d487cb2c0af301e3f82d17f3616d228fb6d22..c1724a322387b569d95c552ba9374e0c36b4d5de 100644 |
| --- a/third_party/WebKit/Source/platform/heap/Persistent.h |
| +++ b/third_party/WebKit/Source/platform/heap/Persistent.h |
| @@ -39,28 +39,33 @@ class PersistentBase { |
| public: |
| PersistentBase() : m_raw(nullptr) |
| { |
| + saveCreationThreadHeap(); |
| initialize(); |
| } |
| PersistentBase(std::nullptr_t) : m_raw(nullptr) |
| { |
| + saveCreationThreadHeap(); |
| initialize(); |
| } |
| PersistentBase(T* raw) : m_raw(raw) |
| { |
| + saveCreationThreadHeap(); |
| initialize(); |
| checkPointer(); |
| } |
| PersistentBase(T& raw) : m_raw(&raw) |
| { |
| + saveCreationThreadHeap(); |
| initialize(); |
| checkPointer(); |
| } |
| PersistentBase(const PersistentBase& other) : m_raw(other) |
| { |
| + saveCreationThreadHeap(); |
| initialize(); |
| checkPointer(); |
| } |
| @@ -68,6 +73,7 @@ public: |
| template<typename U> |
| PersistentBase(const PersistentBase<U, weaknessConfiguration, crossThreadnessConfiguration>& other) : m_raw(other) |
| { |
| + saveCreationThreadHeap(); |
| initialize(); |
| checkPointer(); |
| } |
| @@ -75,12 +81,14 @@ public: |
| template<typename U> |
| PersistentBase(const Member<U>& other) : m_raw(other) |
| { |
| + saveCreationThreadHeap(); |
| initialize(); |
| checkPointer(); |
| } |
| PersistentBase(WTF::HashTableDeletedValueType) : m_raw(reinterpret_cast<T*>(-1)) |
| { |
| + saveCreationThreadHeap(); |
| initialize(); |
| checkPointer(); |
| } |
| @@ -234,10 +242,19 @@ private: |
| void checkPointer() |
| { |
| -#if ENABLE(ASSERT) && defined(ADDRESS_SANITIZER) |
| +#if DCHECK_IS_ON() |
| if (!m_raw || isHashTableDeletedValue()) |
| return; |
| + if (crossThreadnessConfiguration != CrossThreadPersistentConfiguration && m_creationThreadHeap) { |
|
haraken
2016/08/16 13:35:48
I'm wondering if it's valid that m_creationThread
|
| + ThreadState* current = ThreadState::current(); |
| + if (current && current->perThreadHeapEnabled()) { |
|
haraken
2016/08/16 13:35:48
What we really want to check is m_creationThreadHe
keishi
2016/08/17 09:48:57
Mistake. Done.
|
| + DCHECK_EQ(&ThreadState::fromObject(m_raw)->heap(), m_creationThreadHeap); |
| + DCHECK_EQ(¤t->heap(), m_creationThreadHeap); |
| + } |
| + } |
| + |
| +#if defined(ADDRESS_SANITIZER) |
| // ThreadHeap::isHeapObjectAlive(m_raw) checks that m_raw is a traceable |
| // object. In other words, it checks that the pointer is either of: |
| // |
| @@ -248,6 +265,17 @@ private: |
| // header->checkHeader(). |
| ThreadHeap::isHeapObjectAlive(m_raw); |
| #endif |
| +#endif |
| + } |
| + |
| + void saveCreationThreadHeap() |
| + { |
| +#if DCHECK_IS_ON() |
| + if (ThreadState::current()) |
|
haraken
2016/08/16 13:35:48
Is it possible that ThreadState::current() is null
keishi
2016/08/17 09:48:57
We were creating Persistent(null) before ThreadSta
|
| + m_creationThreadHeap = &ThreadState::current()->heap(); |
| + else |
| + m_creationThreadHeap = nullptr; |
| +#endif |
| } |
| static void handleWeakPersistent(Visitor* self, void* persistentPointer) |
| @@ -265,6 +293,9 @@ private: |
| #if ENABLE(ASSERT) |
| ThreadState* m_state = nullptr; |
| #endif |
| +#if DCHECK_IS_ON() |
| + const ThreadHeap* m_creationThreadHeap; |
| +#endif |
| }; |
| // Persistent is a way to create a strong pointer from an off-heap object |