| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 142 } |
| 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 void tracePersistentNodes(Visitor*); | 152 using ShouldTraceCallback = bool (*)(Visitor*, PersistentNode*); |
| 153 void tracePersistentNodes(Visitor*, ShouldTraceCallback = nullptr); |
| 153 int numberOfPersistents(); | 154 int numberOfPersistents(); |
| 154 | 155 |
| 155 private: | 156 private: |
| 156 friend CrossThreadPersistentRegion; | 157 friend CrossThreadPersistentRegion; |
| 157 | 158 |
| 158 void ensurePersistentNodeSlots(void*, TraceCallback); | 159 void ensurePersistentNodeSlots(void*, TraceCallback); |
| 159 | 160 |
| 160 PersistentNode* m_freeListHead; | 161 PersistentNode* m_freeListHead; |
| 161 PersistentNodeSlots* m_slots; | 162 PersistentNodeSlots* m_slots; |
| 162 #if ENABLE(ASSERT) | 163 #if ENABLE(ASSERT) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 177 | 178 |
| 178 void freePersistentNode(PersistentNode* persistentNode) | 179 void freePersistentNode(PersistentNode* persistentNode) |
| 179 { | 180 { |
| 180 MutexLocker lock(m_mutex); | 181 MutexLocker lock(m_mutex); |
| 181 m_persistentRegion->freePersistentNode(persistentNode); | 182 m_persistentRegion->freePersistentNode(persistentNode); |
| 182 } | 183 } |
| 183 | 184 |
| 184 void tracePersistentNodes(Visitor* visitor) | 185 void tracePersistentNodes(Visitor* visitor) |
| 185 { | 186 { |
| 186 MutexLocker lock(m_mutex); | 187 MutexLocker lock(m_mutex); |
| 187 m_persistentRegion->tracePersistentNodes(visitor); | 188 m_persistentRegion->tracePersistentNodes(visitor, CrossThreadPersistentR
egion::shouldTracePersistentNode); |
| 188 } | 189 } |
| 189 | 190 |
| 190 void prepareForThreadStateTermination(ThreadState*); | 191 void prepareForThreadStateTermination(ThreadState*); |
| 191 | 192 |
| 193 static bool shouldTracePersistentNode(Visitor*, PersistentNode*); |
| 194 |
| 192 private: | 195 private: |
| 193 // We don't make CrossThreadPersistentRegion inherit from PersistentRegion | 196 // We don't make CrossThreadPersistentRegion inherit from PersistentRegion |
| 194 // because we don't want to virtualize performance-sensitive methods | 197 // because we don't want to virtualize performance-sensitive methods |
| 195 // such as PersistentRegion::allocate/freePersistentNode. | 198 // such as PersistentRegion::allocate/freePersistentNode. |
| 196 OwnPtr<PersistentRegion> m_persistentRegion; | 199 OwnPtr<PersistentRegion> m_persistentRegion; |
| 197 Mutex m_mutex; | 200 Mutex m_mutex; |
| 198 }; | 201 }; |
| 199 | 202 |
| 200 } // namespace blink | 203 } // namespace blink |
| 201 | 204 |
| 202 #endif | 205 #endif |
| OLD | NEW |