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

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

Issue 1919663002: Unify and generalize thread static persistent finalization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 8 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 #endif 132 #endif
133 if (UNLIKELY(!m_freeListHead)) 133 if (UNLIKELY(!m_freeListHead))
134 ensurePersistentNodeSlots(self, trace); 134 ensurePersistentNodeSlots(self, trace);
135 ASSERT(m_freeListHead); 135 ASSERT(m_freeListHead);
136 PersistentNode* node = m_freeListHead; 136 PersistentNode* node = m_freeListHead;
137 m_freeListHead = m_freeListHead->freeListNext(); 137 m_freeListHead = m_freeListHead->freeListNext();
138 node->initialize(self, trace); 138 node->initialize(self, trace);
139 ASSERT(!node->isUnused()); 139 ASSERT(!node->isUnused());
140 return node; 140 return node;
141 } 141 }
142
142 void freePersistentNode(PersistentNode* persistentNode) 143 void freePersistentNode(PersistentNode* persistentNode)
143 { 144 {
144 ASSERT(m_persistentCount > 0); 145 ASSERT(m_persistentCount > 0);
145 persistentNode->setFreeListNext(m_freeListHead); 146 persistentNode->setFreeListNext(m_freeListHead);
146 m_freeListHead = persistentNode; 147 m_freeListHead = persistentNode;
147 #if ENABLE(ASSERT) 148 #if ENABLE(ASSERT)
148 --m_persistentCount; 149 --m_persistentCount;
149 #endif 150 #endif
150 } 151 }
151 152
152 static bool shouldTracePersistentNode(Visitor*, PersistentNode*) { return tr ue; } 153 static bool shouldTracePersistentNode(Visitor*, PersistentNode*) { return tr ue; }
153 154
154 using ShouldTraceCallback = bool (*)(Visitor*, PersistentNode*); 155 using ShouldTraceCallback = bool (*)(Visitor*, PersistentNode*);
155 void tracePersistentNodes(Visitor*, ShouldTraceCallback = PersistentRegion:: shouldTracePersistentNode); 156 void tracePersistentNodes(Visitor*, ShouldTraceCallback = PersistentRegion:: shouldTracePersistentNode);
157
158 void releasePersistentNode(PersistentNode*, ThreadState::PersistentClearCall back);
156 int numberOfPersistents(); 159 int numberOfPersistents();
157 160
158 private: 161 private:
159 friend CrossThreadPersistentRegion; 162 friend CrossThreadPersistentRegion;
160 163
161 void ensurePersistentNodeSlots(void*, TraceCallback); 164 void ensurePersistentNodeSlots(void*, TraceCallback);
162 165
163 PersistentNode* m_freeListHead; 166 PersistentNode* m_freeListHead;
164 PersistentNodeSlots* m_slots; 167 PersistentNodeSlots* m_slots;
165 #if ENABLE(ASSERT) 168 #if ENABLE(ASSERT)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // We don't make CrossThreadPersistentRegion inherit from PersistentRegion 201 // We don't make CrossThreadPersistentRegion inherit from PersistentRegion
199 // because we don't want to virtualize performance-sensitive methods 202 // because we don't want to virtualize performance-sensitive methods
200 // such as PersistentRegion::allocate/freePersistentNode. 203 // such as PersistentRegion::allocate/freePersistentNode.
201 OwnPtr<PersistentRegion> m_persistentRegion; 204 OwnPtr<PersistentRegion> m_persistentRegion;
202 Mutex m_mutex; 205 Mutex m_mutex;
203 }; 206 };
204 207
205 } // namespace blink 208 } // namespace blink
206 209
207 #endif 210 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapTest.cpp ('k') | third_party/WebKit/Source/platform/heap/PersistentNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698