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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 165 } |
166 | 166 |
167 protected: | 167 protected: |
168 NO_SANITIZE_ADDRESS | 168 NO_SANITIZE_ADDRESS |
169 T* atomicGet() { | 169 T* atomicGet() { |
170 return reinterpret_cast<T*>( | 170 return reinterpret_cast<T*>( |
171 acquireLoad(reinterpret_cast<void* volatile*>(&m_raw))); | 171 acquireLoad(reinterpret_cast<void* volatile*>(&m_raw))); |
172 } | 172 } |
173 | 173 |
174 private: | 174 private: |
175 NO_LAZY_SWEEP_SANITIZE_ADDRESS | |
176 void assign(T* ptr) { | 175 void assign(T* ptr) { |
177 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) | 176 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) |
178 releaseStore(reinterpret_cast<void* volatile*>(&m_raw), ptr); | 177 releaseStore(reinterpret_cast<void* volatile*>(&m_raw), ptr); |
179 else | 178 else |
180 m_raw = ptr; | 179 m_raw = ptr; |
181 checkPointer(); | 180 checkPointer(); |
182 if (m_raw) { | 181 if (m_raw) { |
183 if (!m_persistentNode) | 182 if (!m_persistentNode) |
184 initialize(); | 183 initialize(); |
185 return; | 184 return; |
(...skipping 10 matching lines...) Expand all Loading... |
196 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) | 195 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) |
197 visitor->registerWeakCellWithCallback(reinterpret_cast<void**>(this), | 196 visitor->registerWeakCellWithCallback(reinterpret_cast<void**>(this), |
198 handleWeakPersistent); | 197 handleWeakPersistent); |
199 else | 198 else |
200 visitor->registerWeakMembers(this, m_raw, handleWeakPersistent); | 199 visitor->registerWeakMembers(this, m_raw, handleWeakPersistent); |
201 } else { | 200 } else { |
202 visitor->mark(m_raw); | 201 visitor->mark(m_raw); |
203 } | 202 } |
204 } | 203 } |
205 | 204 |
206 NO_LAZY_SWEEP_SANITIZE_ADDRESS | |
207 void initialize() { | 205 void initialize() { |
208 ASSERT(!m_persistentNode); | 206 ASSERT(!m_persistentNode); |
209 if (!m_raw || isHashTableDeletedValue()) | 207 if (!m_raw || isHashTableDeletedValue()) |
210 return; | 208 return; |
211 | 209 |
212 TraceCallback traceCallback = | 210 TraceCallback traceCallback = |
213 TraceMethodDelegate<PersistentBase, | 211 TraceMethodDelegate<PersistentBase, |
214 &PersistentBase::tracePersistent>::trampoline; | 212 &PersistentBase::tracePersistent>::trampoline; |
215 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) { | 213 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) { |
216 ProcessHeap::crossThreadPersistentRegion().allocatePersistentNode( | 214 ProcessHeap::crossThreadPersistentRegion().allocatePersistentNode( |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 | 580 |
583 // Used when the registered PersistentNode of this object is | 581 // Used when the registered PersistentNode of this object is |
584 // released during ThreadState shutdown, clearing the association. | 582 // released during ThreadState shutdown, clearing the association. |
585 static void clearPersistentNode(void* self) { | 583 static void clearPersistentNode(void* self) { |
586 PersistentHeapCollectionBase<Collection>* collection = | 584 PersistentHeapCollectionBase<Collection>* collection = |
587 (reinterpret_cast<PersistentHeapCollectionBase<Collection>*>(self)); | 585 (reinterpret_cast<PersistentHeapCollectionBase<Collection>*>(self)); |
588 collection->uninitialize(); | 586 collection->uninitialize(); |
589 collection->clear(); | 587 collection->clear(); |
590 } | 588 } |
591 | 589 |
592 NO_LAZY_SWEEP_SANITIZE_ADDRESS | |
593 void initialize() { | 590 void initialize() { |
594 // FIXME: Derive affinity based on the collection. | 591 // FIXME: Derive affinity based on the collection. |
595 ThreadState* state = ThreadState::current(); | 592 ThreadState* state = ThreadState::current(); |
596 ASSERT(state->checkThread()); | 593 ASSERT(state->checkThread()); |
597 m_persistentNode = state->getPersistentRegion()->allocatePersistentNode( | 594 m_persistentNode = state->getPersistentRegion()->allocatePersistentNode( |
598 this, | 595 this, |
599 TraceMethodDelegate<PersistentHeapCollectionBase<Collection>, | 596 TraceMethodDelegate<PersistentHeapCollectionBase<Collection>, |
600 &PersistentHeapCollectionBase< | 597 &PersistentHeapCollectionBase< |
601 Collection>::tracePersistent>::trampoline); | 598 Collection>::tracePersistent>::trampoline); |
602 #if ENABLE(ASSERT) | 599 #if ENABLE(ASSERT) |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 static blink::CrossThreadPersistent<T> Unwrap( | 799 static blink::CrossThreadPersistent<T> Unwrap( |
803 const blink::CrossThreadWeakPersistent<T>& wrapped) { | 800 const blink::CrossThreadWeakPersistent<T>& wrapped) { |
804 blink::CrossThreadPersistentRegion::LockScope persistentLock( | 801 blink::CrossThreadPersistentRegion::LockScope persistentLock( |
805 blink::ProcessHeap::crossThreadPersistentRegion()); | 802 blink::ProcessHeap::crossThreadPersistentRegion()); |
806 return blink::CrossThreadPersistent<T>(wrapped.get()); | 803 return blink::CrossThreadPersistent<T>(wrapped.get()); |
807 } | 804 } |
808 }; | 805 }; |
809 } | 806 } |
810 | 807 |
811 #endif // Persistent_h | 808 #endif // Persistent_h |
OLD | NEW |