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

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

Issue 2585433003: [wrapper-tracing] Reduce marking overhead: Tri-color marking without 3 colors (Closed)
Patch Set: Fix test case Created 3 years, 12 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" 10 #include "platform/heap/InlinedGlobalMarkingVisitor.h"
(...skipping 29 matching lines...) Expand all
40 class WeakPersistent; 40 class WeakPersistent;
41 41
42 template <typename T, bool = NeedsAdjustAndMark<T>::value> 42 template <typename T, bool = NeedsAdjustAndMark<T>::value>
43 class AdjustAndMarkTrait; 43 class AdjustAndMarkTrait;
44 44
45 template <typename T> 45 template <typename T>
46 class AdjustAndMarkTrait<T, false> { 46 class AdjustAndMarkTrait<T, false> {
47 STATIC_ONLY(AdjustAndMarkTrait); 47 STATIC_ONLY(AdjustAndMarkTrait);
48 48
49 public: 49 public:
50 static void markWrapper(const WrapperVisitor* visitor, const T* t) { 50 static void markAndTraceWrapper(const WrapperVisitor* visitor, const T* t) {
51 if (visitor->markWrapperHeader(heapObjectHeader(t))) { 51 if (visitor->markWrapperHeader(heapObjectHeader(t))) {
52 visitor->markWrappersInAllWorlds(t); 52 visitor->markWrappersInAllWorlds(t);
53 visitor->dispatchTraceWrappers(t); 53 visitor->dispatchTraceWrappers(t);
54 } 54 }
55 } 55 }
56 static void markWrapperNoTracing(const WrapperVisitor* visitor, const T* t) {
57 DCHECK(!heapObjectHeader(t)->isWrapperHeaderMarked());
58 visitor->markWrapperHeader(heapObjectHeader(t));
59 }
60 static void traceMarkedWrapper(const WrapperVisitor* visitor, const T* t) {
61 DCHECK(heapObjectHeader(t)->isWrapperHeaderMarked());
62 // The term *mark* is misleading here as we effectively trace through the
63 // API boundary, i.e., tell V8 that an object is alive. Actual marking
64 // will be done in V8.
65 visitor->markWrappersInAllWorlds(t);
66 visitor->dispatchTraceWrappers(t);
67 }
56 static HeapObjectHeader* heapObjectHeader(const T* t) { 68 static HeapObjectHeader* heapObjectHeader(const T* t) {
57 return HeapObjectHeader::fromPayload(t); 69 return HeapObjectHeader::fromPayload(t);
58 } 70 }
59 71
60 template <typename VisitorDispatcher> 72 template <typename VisitorDispatcher>
61 static void mark(VisitorDispatcher visitor, const T* t) { 73 static void mark(VisitorDispatcher visitor, const T* t) {
62 #if ENABLE(ASSERT) 74 #if ENABLE(ASSERT)
63 assertObjectHasGCInfo(const_cast<T*>(t), GCInfoTrait<T>::index()); 75 assertObjectHasGCInfo(const_cast<T*>(t), GCInfoTrait<T>::index());
64 #endif 76 #endif
65 // Default mark method of the trait just calls the two-argument mark 77 // Default mark method of the trait just calls the two-argument mark
(...skipping 26 matching lines...) Expand all
92 } 104 }
93 visitor->mark(const_cast<T*>(t), &TraceTrait<T>::trace); 105 visitor->mark(const_cast<T*>(t), &TraceTrait<T>::trace);
94 } 106 }
95 }; 107 };
96 108
97 template <typename T> 109 template <typename T>
98 class AdjustAndMarkTrait<T, true> { 110 class AdjustAndMarkTrait<T, true> {
99 STATIC_ONLY(AdjustAndMarkTrait); 111 STATIC_ONLY(AdjustAndMarkTrait);
100 112
101 public: 113 public:
102 static void markWrapper(const WrapperVisitor* visitor, const T* t) { 114 static void markAndTraceWrapper(const WrapperVisitor* visitor, const T* t) {
103 t->adjustAndMarkWrapper(visitor); 115 t->adjustAndMarkAndTraceWrapper(visitor);
116 }
117 static void markWrapperNoTracing(const WrapperVisitor* visitor, const T* t) {
118 t->adjustAndMarkWrapperNoTracing(visitor);
119 }
120 static void traceMarkedWrapper(const WrapperVisitor* visitor, const T* t) {
121 t->adjustAndTraceMarkedWrapper(visitor);
104 } 122 }
105 static HeapObjectHeader* heapObjectHeader(const T* t) { 123 static HeapObjectHeader* heapObjectHeader(const T* t) {
106 return t->adjustAndGetHeapObjectHeader(); 124 return t->adjustAndGetHeapObjectHeader();
107 } 125 }
108 126
109 template <typename VisitorDispatcher> 127 template <typename VisitorDispatcher>
110 static void mark(VisitorDispatcher visitor, const T* self) { 128 static void mark(VisitorDispatcher visitor, const T* self) {
111 if (!self) 129 if (!self)
112 return; 130 return;
113 131
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // to the start of the object in the Blink garbage-collected heap. In 216 // to the start of the object in the Blink garbage-collected heap. In
199 // that case the pointer has to be adjusted before marking. 217 // that case the pointer has to be adjusted before marking.
200 template <typename T> 218 template <typename T>
201 class TraceTrait { 219 class TraceTrait {
202 STATIC_ONLY(TraceTrait); 220 STATIC_ONLY(TraceTrait);
203 221
204 public: 222 public:
205 static void trace(Visitor*, void* self); 223 static void trace(Visitor*, void* self);
206 static void trace(InlinedGlobalMarkingVisitor, void* self); 224 static void trace(InlinedGlobalMarkingVisitor, void* self);
207 225
208 static void markWrapper(const WrapperVisitor* visitor, const void* t) { 226 static void markAndTraceWrapper(const WrapperVisitor* visitor,
227 const void* t) {
209 static_assert(CanTraceWrappers<T>::value, 228 static_assert(CanTraceWrappers<T>::value,
210 "T should be able to trace wrappers. See " 229 "T should be able to trace wrappers. See "
211 "dispatchTraceWrappers in WrapperVisitor.h"); 230 "dispatchTraceWrappers in WrapperVisitor.h");
212 AdjustAndMarkTrait<T>::markWrapper(visitor, reinterpret_cast<const T*>(t)); 231 AdjustAndMarkTrait<T>::markAndTraceWrapper(visitor,
232 reinterpret_cast<const T*>(t));
233 }
234 static void markWrapperNoTracing(const WrapperVisitor* visitor,
235 const void* t) {
236 static_assert(CanTraceWrappers<T>::value,
237 "T should be able to trace wrappers. See "
238 "dispatchTraceWrappers in WrapperVisitor.h");
239 AdjustAndMarkTrait<T>::markWrapperNoTracing(visitor,
240 reinterpret_cast<const T*>(t));
241 }
242 static void traceMarkedWrapper(const WrapperVisitor* visitor, const void* t) {
243 static_assert(CanTraceWrappers<T>::value,
244 "T should be able to trace wrappers. See "
245 "dispatchTraceWrappers in WrapperVisitor.h");
246 AdjustAndMarkTrait<T>::traceMarkedWrapper(visitor,
247 reinterpret_cast<const T*>(t));
213 } 248 }
214 static HeapObjectHeader* heapObjectHeader(const void* t) { 249 static HeapObjectHeader* heapObjectHeader(const void* t) {
215 static_assert(CanTraceWrappers<T>::value, 250 static_assert(CanTraceWrappers<T>::value,
216 "T should be able to trace wrappers. See " 251 "T should be able to trace wrappers. See "
217 "dispatchTraceWrappers in WrapperVisitor.h"); 252 "dispatchTraceWrappers in WrapperVisitor.h");
218 return AdjustAndMarkTrait<T>::heapObjectHeader( 253 return AdjustAndMarkTrait<T>::heapObjectHeader(
219 reinterpret_cast<const T*>(t)); 254 reinterpret_cast<const T*>(t));
220 } 255 }
221 256
222 template <typename VisitorDispatcher> 257 template <typename VisitorDispatcher>
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 // since iterating over the hash table backing will find the whole 807 // since iterating over the hash table backing will find the whole
773 // chain. 808 // chain.
774 visitor->markNoTracing(node); 809 visitor->markNoTracing(node);
775 return false; 810 return false;
776 } 811 }
777 }; 812 };
778 813
779 } // namespace WTF 814 } // namespace WTF
780 815
781 #endif 816 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/GarbageCollected.h ('k') | third_party/WebKit/Source/platform/heap/WrapperVisitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698