OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef Persistent_h | 5 #ifndef Persistent_h |
6 #define Persistent_h | 6 #define Persistent_h |
7 | 7 |
8 #include "platform/heap/Heap.h" | 8 #include "platform/heap/Heap.h" |
9 #include "platform/heap/Member.h" | 9 #include "platform/heap/Member.h" |
10 #include "platform/heap/PersistentNode.h" | 10 #include "platform/heap/PersistentNode.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // collection which initialized the Persistent with memset and the | 255 // collection which initialized the Persistent with memset and the |
256 // constructor wasn't called. | 256 // constructor wasn't called. |
257 if (m_creationThreadState) { | 257 if (m_creationThreadState) { |
258 // Member should point to objects that belong in the same ThreadHeap. | 258 // Member should point to objects that belong in the same ThreadHeap. |
259 DCHECK_EQ(&ThreadState::fromObject(m_raw)->heap(), | 259 DCHECK_EQ(&ThreadState::fromObject(m_raw)->heap(), |
260 &m_creationThreadState->heap()); | 260 &m_creationThreadState->heap()); |
261 // Member should point to objects that belong in the same ThreadHeap. | 261 // Member should point to objects that belong in the same ThreadHeap. |
262 DCHECK_EQ(¤t->heap(), &m_creationThreadState->heap()); | 262 DCHECK_EQ(¤t->heap(), &m_creationThreadState->heap()); |
263 } | 263 } |
264 } | 264 } |
265 | |
266 #if defined(ADDRESS_SANITIZER) | |
267 // ThreadHeap::isHeapObjectAlive(m_raw) checks that m_raw is a traceable | |
268 // object. In other words, it checks that the pointer is either of: | |
269 // | |
270 // (a) a pointer to the head of an on-heap object. | |
271 // (b) a pointer to the head of an on-heap mixin object. | |
272 // | |
273 // Otherwise, ThreadHeap::isHeapObjectAlive will crash when it calls | |
274 // header->checkHeader(). | |
275 ThreadHeap::isHeapObjectAlive(m_raw); | |
276 #endif | |
277 #endif | 265 #endif |
278 } | 266 } |
279 | 267 |
280 void saveCreationThreadHeap() { | 268 void saveCreationThreadHeap() { |
281 #if DCHECK_IS_ON() | 269 #if DCHECK_IS_ON() |
282 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) { | 270 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) { |
283 m_creationThreadState = nullptr; | 271 m_creationThreadState = nullptr; |
284 } else { | 272 } else { |
285 m_creationThreadState = ThreadState::current(); | 273 m_creationThreadState = ThreadState::current(); |
286 DCHECK(m_creationThreadState); | 274 DCHECK(m_creationThreadState); |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 static blink::CrossThreadPersistent<T> Unwrap( | 793 static blink::CrossThreadPersistent<T> Unwrap( |
806 const blink::CrossThreadWeakPersistent<T>& wrapped) { | 794 const blink::CrossThreadWeakPersistent<T>& wrapped) { |
807 blink::CrossThreadPersistentRegion::LockScope persistentLock( | 795 blink::CrossThreadPersistentRegion::LockScope persistentLock( |
808 blink::ProcessHeap::crossThreadPersistentRegion()); | 796 blink::ProcessHeap::crossThreadPersistentRegion()); |
809 return blink::CrossThreadPersistent<T>(wrapped.get()); | 797 return blink::CrossThreadPersistent<T>(wrapped.get()); |
810 } | 798 } |
811 }; | 799 }; |
812 } | 800 } |
813 | 801 |
814 #endif // Persistent_h | 802 #endif // Persistent_h |
OLD | NEW |