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