Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: third_party/WebKit/Source/platform/heap/PersistentNode.h

Issue 1477023003: Refactor the Heap into ThreadHeap to prepare for per thread heaps Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698