OLD | NEW |
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 // to the start of the object in the Blink garbage-collected heap. In | 181 // to the start of the object in the Blink garbage-collected heap. In |
182 // that case the pointer has to be adjusted before marking. | 182 // that case the pointer has to be adjusted before marking. |
183 template <typename T> | 183 template <typename T> |
184 class TraceTrait { | 184 class TraceTrait { |
185 STATIC_ONLY(TraceTrait); | 185 STATIC_ONLY(TraceTrait); |
186 | 186 |
187 public: | 187 public: |
188 static void trace(Visitor*, void* self); | 188 static void trace(Visitor*, void* self); |
189 static void trace(InlinedGlobalMarkingVisitor, void* self); | 189 static void trace(InlinedGlobalMarkingVisitor, void* self); |
190 | 190 |
191 static void markAndTraceWrapper(const WrapperVisitor*, const void*); | |
192 static void markWrapperNoTracing(const WrapperVisitor*, const void*); | 191 static void markWrapperNoTracing(const WrapperVisitor*, const void*); |
193 static void traceMarkedWrapper(const WrapperVisitor*, const void*); | 192 static void traceMarkedWrapper(const WrapperVisitor*, const void*); |
194 static HeapObjectHeader* heapObjectHeader(const void*); | 193 static HeapObjectHeader* heapObjectHeader(const void*); |
195 | 194 |
196 template <typename VisitorDispatcher> | 195 template <typename VisitorDispatcher> |
197 static void mark(VisitorDispatcher visitor, const T* t) { | 196 static void mark(VisitorDispatcher visitor, const T* t) { |
198 AdjustAndMarkTrait<T>::mark(visitor, t); | 197 AdjustAndMarkTrait<T>::mark(visitor, t); |
199 } | 198 } |
200 | 199 |
201 private: | 200 private: |
(...skipping 25 matching lines...) Expand all Loading... |
227 } | 226 } |
228 } | 227 } |
229 | 228 |
230 template <typename T> | 229 template <typename T> |
231 void TraceTrait<T>::trace(InlinedGlobalMarkingVisitor visitor, void* self) { | 230 void TraceTrait<T>::trace(InlinedGlobalMarkingVisitor visitor, void* self) { |
232 static_assert(WTF::IsTraceable<T>::value, "T should not be traced"); | 231 static_assert(WTF::IsTraceable<T>::value, "T should not be traced"); |
233 static_cast<T*>(self)->trace(visitor); | 232 static_cast<T*>(self)->trace(visitor); |
234 } | 233 } |
235 | 234 |
236 template <typename T> | 235 template <typename T> |
237 void TraceTrait<T>::markAndTraceWrapper(const WrapperVisitor* visitor, | |
238 const void* t) { | |
239 const T* traceable = ToWrapperTracingType(t); | |
240 if (visitor->markWrapperHeader(heapObjectHeader(traceable))) { | |
241 visitor->markWrappersInAllWorlds(traceable); | |
242 visitor->dispatchTraceWrappers(traceable); | |
243 } | |
244 } | |
245 | |
246 template <typename T> | |
247 void TraceTrait<T>::markWrapperNoTracing(const WrapperVisitor* visitor, | 236 void TraceTrait<T>::markWrapperNoTracing(const WrapperVisitor* visitor, |
248 const void* t) { | 237 const void* t) { |
249 const T* traceable = ToWrapperTracingType(t); | 238 const T* traceable = ToWrapperTracingType(t); |
250 DCHECK(!heapObjectHeader(traceable)->isWrapperHeaderMarked()); | 239 DCHECK(!heapObjectHeader(traceable)->isWrapperHeaderMarked()); |
251 visitor->markWrapperHeader(heapObjectHeader(traceable)); | 240 visitor->markWrapperHeader(heapObjectHeader(traceable)); |
252 } | 241 } |
253 | 242 |
254 template <typename T> | 243 template <typename T> |
255 void TraceTrait<T>::traceMarkedWrapper(const WrapperVisitor* visitor, | 244 void TraceTrait<T>::traceMarkedWrapper(const WrapperVisitor* visitor, |
256 const void* t) { | 245 const void* t) { |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 // since iterating over the hash table backing will find the whole | 791 // since iterating over the hash table backing will find the whole |
803 // chain. | 792 // chain. |
804 visitor->markNoTracing(node); | 793 visitor->markNoTracing(node); |
805 return false; | 794 return false; |
806 } | 795 } |
807 }; | 796 }; |
808 | 797 |
809 } // namespace WTF | 798 } // namespace WTF |
810 | 799 |
811 #endif | 800 #endif |
OLD | NEW |