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

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

Issue 2652923002: Devirtualize Visitor and remove inline visitor specialization. (Closed)
Patch Set: rebased Created 3 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 TraceTraits_h 5 #ifndef TraceTraits_h
6 #define TraceTraits_h 6 #define TraceTraits_h
7 7
8 #include "platform/heap/GCInfo.h" 8 #include "platform/heap/GCInfo.h"
9 #include "platform/heap/Heap.h" 9 #include "platform/heap/Heap.h"
10 #include "platform/heap/InlinedGlobalMarkingVisitor.h"
11 #include "platform/heap/StackFrameDepth.h" 10 #include "platform/heap/StackFrameDepth.h"
12 #include "platform/heap/Visitor.h" 11 #include "platform/heap/Visitor.h"
13 #include "platform/heap/WrapperVisitor.h" 12 #include "platform/heap/WrapperVisitor.h"
14 #include "wtf/Allocator.h" 13 #include "wtf/Allocator.h"
15 #include "wtf/Assertions.h" 14 #include "wtf/Assertions.h"
16 #include "wtf/HashCountedSet.h" 15 #include "wtf/HashCountedSet.h"
17 #include "wtf/HashMap.h" 16 #include "wtf/HashMap.h"
18 #include "wtf/HashSet.h" 17 #include "wtf/HashSet.h"
19 #include "wtf/HashTable.h" 18 #include "wtf/HashTable.h"
20 #include "wtf/LinkedHashSet.h" 19 #include "wtf/LinkedHashSet.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // implementation. A common case where a TraceTrait specialization is 194 // implementation. A common case where a TraceTrait specialization is
196 // needed is when multiple inheritance leads to pointers that are not 195 // needed is when multiple inheritance leads to pointers that are not
197 // to the start of the object in the Blink garbage-collected heap. In 196 // to the start of the object in the Blink garbage-collected heap. In
198 // that case the pointer has to be adjusted before marking. 197 // that case the pointer has to be adjusted before marking.
199 template <typename T> 198 template <typename T>
200 class TraceTrait { 199 class TraceTrait {
201 STATIC_ONLY(TraceTrait); 200 STATIC_ONLY(TraceTrait);
202 201
203 public: 202 public:
204 static void trace(Visitor*, void* self); 203 static void trace(Visitor*, void* self);
205 static void trace(InlinedGlobalMarkingVisitor, void* self);
206 204
207 static void markWrapperNoTracing(const WrapperVisitor*, const void*); 205 static void markWrapperNoTracing(const WrapperVisitor*, const void*);
208 static void traceMarkedWrapper(const WrapperVisitor*, const void*); 206 static void traceMarkedWrapper(const WrapperVisitor*, const void*);
209 static HeapObjectHeader* heapObjectHeader(const void*); 207 static HeapObjectHeader* heapObjectHeader(const void*);
210 208
211 template <typename VisitorDispatcher> 209 template <typename VisitorDispatcher>
212 static void mark(VisitorDispatcher visitor, const T* t) { 210 static void mark(VisitorDispatcher visitor, const T* t) {
213 AdjustAndMarkTrait<T>::mark(visitor, t); 211 AdjustAndMarkTrait<T>::mark(visitor, t);
214 } 212 }
215 213
(...skipping 10 matching lines...) Expand all
226 return reinterpret_cast<const T*>(t); 224 return reinterpret_cast<const T*>(t);
227 } 225 }
228 }; 226 };
229 227
230 template <typename T> 228 template <typename T>
231 class TraceTrait<const T> : public TraceTrait<T> {}; 229 class TraceTrait<const T> : public TraceTrait<T> {};
232 230
233 template <typename T> 231 template <typename T>
234 void TraceTrait<T>::trace(Visitor* visitor, void* self) { 232 void TraceTrait<T>::trace(Visitor* visitor, void* self) {
235 static_assert(WTF::IsTraceable<T>::value, "T should not be traced"); 233 static_assert(WTF::IsTraceable<T>::value, "T should not be traced");
236 if (visitor->isGlobalMarking()) {
237 // Switch to inlined global marking dispatch.
238 static_cast<T*>(self)->trace(InlinedGlobalMarkingVisitor(
239 visitor->state(), visitor->getMarkingMode()));
240 } else {
241 static_cast<T*>(self)->trace(visitor);
242 }
243 }
244
245 template <typename T>
246 void TraceTrait<T>::trace(InlinedGlobalMarkingVisitor visitor, void* self) {
247 static_assert(WTF::IsTraceable<T>::value, "T should not be traced");
248 static_cast<T*>(self)->trace(visitor); 234 static_cast<T*>(self)->trace(visitor);
249 } 235 }
250 236
251 template <typename T> 237 template <typename T>
252 void TraceTrait<T>::markWrapperNoTracing(const WrapperVisitor* visitor, 238 void TraceTrait<T>::markWrapperNoTracing(const WrapperVisitor* visitor,
253 const void* t) { 239 const void* t) {
254 const T* traceable = ToWrapperTracingType(t); 240 const T* traceable = ToWrapperTracingType(t);
255 DCHECK(!heapObjectHeader(traceable)->isWrapperHeaderMarked()); 241 DCHECK(!heapObjectHeader(traceable)->isWrapperHeaderMarked());
256 visitor->markWrapperHeader(heapObjectHeader(traceable)); 242 visitor->markWrapperHeader(heapObjectHeader(traceable));
257 } 243 }
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 // since iterating over the hash table backing will find the whole 793 // since iterating over the hash table backing will find the whole
808 // chain. 794 // chain.
809 visitor->markNoTracing(node); 795 visitor->markNoTracing(node);
810 return false; 796 return false;
811 } 797 }
812 }; 798 };
813 799
814 } // namespace WTF 800 } // namespace WTF
815 801
816 #endif 802 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/RunAllTests.cpp ('k') | third_party/WebKit/Source/platform/heap/Visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698