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

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: Refactored Created 4 years, 11 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/Assertions.h" 10 #include "wtf/Assertions.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 void freePersistentNode(PersistentNode* persistentNode) 137 void freePersistentNode(PersistentNode* persistentNode)
138 { 138 {
139 ASSERT(m_persistentCount > 0); 139 ASSERT(m_persistentCount > 0);
140 persistentNode->setFreeListNext(m_freeListHead); 140 persistentNode->setFreeListNext(m_freeListHead);
141 m_freeListHead = persistentNode; 141 m_freeListHead = persistentNode;
142 #if ENABLE(ASSERT) 142 #if ENABLE(ASSERT)
143 --m_persistentCount; 143 --m_persistentCount;
144 #endif 144 #endif
145 } 145 }
146 void tracePersistentNodes(Visitor*); 146 void tracePersistentNodes(Visitor*, bool (*shouldTrace)(Visitor*, Persistent Node*) = nullptr);
haraken 2016/01/28 15:52:50 Use typedef for the function signature.
keishi 2016/02/29 06:02:33 Done.
147 int numberOfPersistents(); 147 int numberOfPersistents();
148 148
149 private: 149 private:
150 friend CrossThreadPersistentRegion; 150 friend CrossThreadPersistentRegion;
151 151
152 void ensurePersistentNodeSlots(void*, TraceCallback); 152 void ensurePersistentNodeSlots(void*, TraceCallback);
153 153
154 PersistentNode* m_freeListHead; 154 PersistentNode* m_freeListHead;
155 PersistentNodeSlots* m_slots; 155 PersistentNodeSlots* m_slots;
156 #if ENABLE(ASSERT) 156 #if ENABLE(ASSERT)
(...skipping 13 matching lines...) Expand all
170 170
171 void freePersistentNode(PersistentNode* persistentNode) 171 void freePersistentNode(PersistentNode* persistentNode)
172 { 172 {
173 MutexLocker lock(m_mutex); 173 MutexLocker lock(m_mutex);
174 m_persistentRegion->freePersistentNode(persistentNode); 174 m_persistentRegion->freePersistentNode(persistentNode);
175 } 175 }
176 176
177 void tracePersistentNodes(Visitor* visitor) 177 void tracePersistentNodes(Visitor* visitor)
178 { 178 {
179 MutexLocker lock(m_mutex); 179 MutexLocker lock(m_mutex);
180 m_persistentRegion->tracePersistentNodes(visitor); 180 m_persistentRegion->tracePersistentNodes(visitor, CrossThreadPersistentR egion::shouldTracePersistentNode);
181 } 181 }
182 182
183 void prepareForThreadStateTermination(ThreadState*); 183 void prepareForThreadStateTermination(ThreadState*);
184 184
185 static bool shouldTracePersistentNode(Visitor*, PersistentNode*);
186
185 private: 187 private:
186 // We don't make CrossThreadPersistentRegion inherit from PersistentRegion 188 // We don't make CrossThreadPersistentRegion inherit from PersistentRegion
187 // because we don't want to virtualize performance-sensitive methods 189 // because we don't want to virtualize performance-sensitive methods
188 // such as PersistentRegion::allocate/freePersistentNode. 190 // such as PersistentRegion::allocate/freePersistentNode.
189 OwnPtr<PersistentRegion> m_persistentRegion; 191 OwnPtr<PersistentRegion> m_persistentRegion;
190 Mutex m_mutex; 192 Mutex m_mutex;
191 }; 193 };
192 194
193 } // namespace blink 195 } // namespace blink
194 196
195 #endif 197 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698