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