| 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/Assertions.h" | 10 #include "wtf/Assertions.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 bool isUnused() const | 75 bool isUnused() const |
| 76 { | 76 { |
| 77 return !m_trace; | 77 return !m_trace; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void* self() const | 80 void* self() const |
| 81 { | 81 { |
| 82 return m_self; | 82 return m_self; |
| 83 } | 83 } |
| 84 | 84 |
| 85 TraceCallback traceCallback() const | |
| 86 { | |
| 87 return m_trace; | |
| 88 } | |
| 89 | |
| 90 private: | 85 private: |
| 91 // If this PersistentNode is in use: | 86 // If this PersistentNode is in use: |
| 92 // - m_self points to the corresponding Persistent handle. | 87 // - m_self points to the corresponding Persistent handle. |
| 93 // - m_trace points to the trace method. | 88 // - m_trace points to the trace method. |
| 94 // If this PersistentNode is freed: | 89 // If this PersistentNode is freed: |
| 95 // - m_self points to the next freed PersistentNode. | 90 // - m_self points to the next freed PersistentNode. |
| 96 // - m_trace is nullptr. | 91 // - m_trace is nullptr. |
| 97 void* m_self; | 92 void* m_self; |
| 98 TraceCallback m_trace; | 93 TraceCallback m_trace; |
| 99 }; | 94 }; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 ASSERT(m_persistentCount > 0); | 137 ASSERT(m_persistentCount > 0); |
| 143 persistentNode->setFreeListNext(m_freeListHead); | 138 persistentNode->setFreeListNext(m_freeListHead); |
| 144 m_freeListHead = persistentNode; | 139 m_freeListHead = persistentNode; |
| 145 #if ENABLE(ASSERT) | 140 #if ENABLE(ASSERT) |
| 146 --m_persistentCount; | 141 --m_persistentCount; |
| 147 #endif | 142 #endif |
| 148 } | 143 } |
| 149 void tracePersistentNodes(Visitor*); | 144 void tracePersistentNodes(Visitor*); |
| 150 int numberOfPersistents(); | 145 int numberOfPersistents(); |
| 151 | 146 |
| 152 #if ENABLE(ASSERT) | |
| 153 void dumpLivePersistents(); | |
| 154 #endif | |
| 155 | |
| 156 private: | 147 private: |
| 157 friend CrossThreadPersistentRegion; | 148 friend CrossThreadPersistentRegion; |
| 158 | 149 |
| 159 void ensurePersistentNodeSlots(void*, TraceCallback); | 150 void ensurePersistentNodeSlots(void*, TraceCallback); |
| 160 | 151 |
| 161 PersistentNode* m_freeListHead; | 152 PersistentNode* m_freeListHead; |
| 162 PersistentNodeSlots* m_slots; | 153 PersistentNodeSlots* m_slots; |
| 163 #if ENABLE(ASSERT) | 154 #if ENABLE(ASSERT) |
| 164 int m_persistentCount; | 155 int m_persistentCount; |
| 165 #endif | 156 #endif |
| (...skipping 27 matching lines...) Expand all Loading... |
| 193 // We don't make CrossThreadPersistentRegion inherit from PersistentRegion | 184 // We don't make CrossThreadPersistentRegion inherit from PersistentRegion |
| 194 // because we don't want to virtualize performance-sensitive methods | 185 // because we don't want to virtualize performance-sensitive methods |
| 195 // such as PersistentRegion::allocate/freePersistentNode. | 186 // such as PersistentRegion::allocate/freePersistentNode. |
| 196 OwnPtr<PersistentRegion> m_persistentRegion; | 187 OwnPtr<PersistentRegion> m_persistentRegion; |
| 197 Mutex m_mutex; | 188 Mutex m_mutex; |
| 198 }; | 189 }; |
| 199 | 190 |
| 200 } // namespace blink | 191 } // namespace blink |
| 201 | 192 |
| 202 #endif | 193 #endif |
| OLD | NEW |