| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 PersistentNode_h | 5 #ifndef PersistentNode_h |
| 6 #define PersistentNode_h | 6 #define PersistentNode_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/heap/ThreadState.h" | 9 #include "platform/heap/ThreadState.h" |
| 10 #include "wtf/Allocator.h" | 10 #include "wtf/Allocator.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 void freePersistentNode(PersistentNode* persistentNode) | 143 void freePersistentNode(PersistentNode* persistentNode) |
| 144 { | 144 { |
| 145 ASSERT(m_persistentCount > 0); | 145 ASSERT(m_persistentCount > 0); |
| 146 persistentNode->setFreeListNext(m_freeListHead); | 146 persistentNode->setFreeListNext(m_freeListHead); |
| 147 m_freeListHead = persistentNode; | 147 m_freeListHead = persistentNode; |
| 148 #if ENABLE(ASSERT) | 148 #if ENABLE(ASSERT) |
| 149 --m_persistentCount; | 149 --m_persistentCount; |
| 150 #endif | 150 #endif |
| 151 } | 151 } |
| 152 | 152 |
| 153 static bool shouldTracePersistentNode(Visitor*, PersistentNode*) { return tr
ue; } | |
| 154 | |
| 155 using ShouldTraceCallback = bool (*)(Visitor*, PersistentNode*); | |
| 156 void tracePersistentNodes(Visitor*, ShouldTraceCallback = PersistentRegion::
shouldTracePersistentNode); | |
| 157 | |
| 158 void releasePersistentNode(PersistentNode*, ThreadState::PersistentClearCall
back); | 153 void releasePersistentNode(PersistentNode*, ThreadState::PersistentClearCall
back); |
| 154 void tracePersistentNodes(Visitor*); |
| 159 int numberOfPersistents(); | 155 int numberOfPersistents(); |
| 160 | 156 |
| 161 private: | 157 private: |
| 162 friend CrossThreadPersistentRegion; | 158 friend CrossThreadPersistentRegion; |
| 163 | 159 |
| 164 void ensurePersistentNodeSlots(void*, TraceCallback); | 160 void ensurePersistentNodeSlots(void*, TraceCallback); |
| 165 | 161 |
| 166 PersistentNode* m_freeListHead; | 162 PersistentNode* m_freeListHead; |
| 167 PersistentNodeSlots* m_slots; | 163 PersistentNodeSlots* m_slots; |
| 168 #if ENABLE(ASSERT) | 164 #if ENABLE(ASSERT) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 183 | 179 |
| 184 void freePersistentNode(PersistentNode* persistentNode) | 180 void freePersistentNode(PersistentNode* persistentNode) |
| 185 { | 181 { |
| 186 MutexLocker lock(m_mutex); | 182 MutexLocker lock(m_mutex); |
| 187 m_persistentRegion->freePersistentNode(persistentNode); | 183 m_persistentRegion->freePersistentNode(persistentNode); |
| 188 } | 184 } |
| 189 | 185 |
| 190 void tracePersistentNodes(Visitor* visitor) | 186 void tracePersistentNodes(Visitor* visitor) |
| 191 { | 187 { |
| 192 MutexLocker lock(m_mutex); | 188 MutexLocker lock(m_mutex); |
| 193 m_persistentRegion->tracePersistentNodes(visitor, CrossThreadPersistentR
egion::shouldTracePersistentNode); | 189 m_persistentRegion->tracePersistentNodes(visitor); |
| 194 } | 190 } |
| 195 | 191 |
| 196 void prepareForThreadStateTermination(ThreadState*); | 192 void prepareForThreadStateTermination(ThreadState*); |
| 197 | 193 |
| 198 static bool shouldTracePersistentNode(Visitor*, PersistentNode*); | |
| 199 | |
| 200 private: | 194 private: |
| 201 // We don't make CrossThreadPersistentRegion inherit from PersistentRegion | 195 // We don't make CrossThreadPersistentRegion inherit from PersistentRegion |
| 202 // because we don't want to virtualize performance-sensitive methods | 196 // because we don't want to virtualize performance-sensitive methods |
| 203 // such as PersistentRegion::allocate/freePersistentNode. | 197 // such as PersistentRegion::allocate/freePersistentNode. |
| 204 OwnPtr<PersistentRegion> m_persistentRegion; | 198 OwnPtr<PersistentRegion> m_persistentRegion; |
| 205 Mutex m_mutex; | 199 Mutex m_mutex; |
| 206 }; | 200 }; |
| 207 | 201 |
| 208 } // namespace blink | 202 } // namespace blink |
| 209 | 203 |
| 210 #endif | 204 #endif |
| OLD | NEW |