Chromium Code Reviews| 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 29 matching lines...) Expand all Loading... | |
| 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 fullyMarkAndTraceWrapper(const WrapperVisitor* visitor, |
| 51 const T* t) { | |
|
Hannes Payer (out of office)
2016/12/20 15:30:33
DCHECK(!heapObjectHeader(t)->isWrapperHeaderMarked
Michael Lippautz
2016/12/20 15:57:23
This one cannot be done, as it is used when we can
| |
| 51 if (visitor->markWrapperHeader(heapObjectHeader(t))) { | 52 if (visitor->markWrapperHeader(heapObjectHeader(t))) { |
| 52 visitor->markWrappersInAllWorlds(t); | 53 visitor->markWrappersInAllWorlds(t); |
| 53 visitor->dispatchTraceWrappers(t); | 54 visitor->dispatchTraceWrappers(t); |
| 54 } | 55 } |
| 55 } | 56 } |
| 57 static void markWrapperHeaderOnly(const WrapperVisitor* visitor, const T* t) { | |
|
Hannes Payer (out of office)
2016/12/20 15:30:33
DCHECK(!heapObjectHeader(t)->isWrapperHeaderMarked
Michael Lippautz
2016/12/20 15:57:23
Done.
| |
| 58 visitor->markWrapperHeader(heapObjectHeader(t)); | |
| 59 } | |
| 60 static void finishMarkAndTraceMarkedWrapper(const WrapperVisitor* visitor, | |
| 61 const T* t) { | |
| 62 CHECK(heapObjectHeader(t)->isWrapperHeaderMarked()); | |
|
Hannes Payer (out of office)
2016/12/20 15:30:34
s/CHECK/DCHECK/
Michael Lippautz
2016/12/20 15:57:23
Most of the assertions will be CHECKs until this i
| |
| 63 visitor->markWrappersInAllWorlds(t); | |
| 64 visitor->dispatchTraceWrappers(t); | |
| 65 } | |
| 56 static HeapObjectHeader* heapObjectHeader(const T* t) { | 66 static HeapObjectHeader* heapObjectHeader(const T* t) { |
| 57 return HeapObjectHeader::fromPayload(t); | 67 return HeapObjectHeader::fromPayload(t); |
| 58 } | 68 } |
| 59 | 69 |
| 60 template <typename VisitorDispatcher> | 70 template <typename VisitorDispatcher> |
| 61 static void mark(VisitorDispatcher visitor, const T* t) { | 71 static void mark(VisitorDispatcher visitor, const T* t) { |
| 62 #if ENABLE(ASSERT) | 72 #if ENABLE(ASSERT) |
| 63 assertObjectHasGCInfo(const_cast<T*>(t), GCInfoTrait<T>::index()); | 73 assertObjectHasGCInfo(const_cast<T*>(t), GCInfoTrait<T>::index()); |
| 64 #endif | 74 #endif |
| 65 // Default mark method of the trait just calls the two-argument mark | 75 // Default mark method of the trait just calls the two-argument mark |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 92 } | 102 } |
| 93 visitor->mark(const_cast<T*>(t), &TraceTrait<T>::trace); | 103 visitor->mark(const_cast<T*>(t), &TraceTrait<T>::trace); |
| 94 } | 104 } |
| 95 }; | 105 }; |
| 96 | 106 |
| 97 template <typename T> | 107 template <typename T> |
| 98 class AdjustAndMarkTrait<T, true> { | 108 class AdjustAndMarkTrait<T, true> { |
| 99 STATIC_ONLY(AdjustAndMarkTrait); | 109 STATIC_ONLY(AdjustAndMarkTrait); |
| 100 | 110 |
| 101 public: | 111 public: |
| 102 static void markWrapper(const WrapperVisitor* visitor, const T* t) { | 112 static void fullyMarkAndTraceWrapper(const WrapperVisitor* visitor, |
| 103 t->adjustAndMarkWrapper(visitor); | 113 const T* t) { |
| 114 t->adjustAndFullyMarkAndTraceWrapper(visitor); | |
| 115 } | |
| 116 static void markWrapperHeaderOnly(const WrapperVisitor* visitor, const T* t) { | |
| 117 t->adjustAndMarkWrapperHeaderOnly(visitor); | |
| 118 } | |
| 119 static void finishMarkAndTraceMarkedWrapper(const WrapperVisitor* visitor, | |
| 120 const T* t) { | |
| 121 t->adjustAndFinishMarkAndTraceMarkedWrapper(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 Loading... | |
| 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 fullyMarkAndTraceWrapper(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 return AdjustAndMarkTrait<T>::fullyMarkAndTraceWrapper( |
| 232 visitor, reinterpret_cast<const T*>(t)); | |
| 233 } | |
| 234 static void markWrapperHeaderOnly(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 return AdjustAndMarkTrait<T>::markWrapperHeaderOnly( | |
| 240 visitor, reinterpret_cast<const T*>(t)); | |
| 241 } | |
| 242 static void finishMarkAndTraceMarkedWrapper(const WrapperVisitor* visitor, | |
| 243 const void* t) { | |
| 244 static_assert(CanTraceWrappers<T>::value, | |
| 245 "T should be able to trace wrappers. See " | |
| 246 "dispatchTraceWrappers in WrapperVisitor.h"); | |
| 247 AdjustAndMarkTrait<T>::finishMarkAndTraceMarkedWrapper( | |
| 248 visitor, reinterpret_cast<const T*>(t)); | |
| 213 } | 249 } |
| 214 static HeapObjectHeader* heapObjectHeader(const void* t) { | 250 static HeapObjectHeader* heapObjectHeader(const void* t) { |
| 215 static_assert(CanTraceWrappers<T>::value, | 251 static_assert(CanTraceWrappers<T>::value, |
| 216 "T should be able to trace wrappers. See " | 252 "T should be able to trace wrappers. See " |
| 217 "dispatchTraceWrappers in WrapperVisitor.h"); | 253 "dispatchTraceWrappers in WrapperVisitor.h"); |
| 218 return AdjustAndMarkTrait<T>::heapObjectHeader( | 254 return AdjustAndMarkTrait<T>::heapObjectHeader( |
| 219 reinterpret_cast<const T*>(t)); | 255 reinterpret_cast<const T*>(t)); |
| 220 } | 256 } |
| 221 | 257 |
| 222 template <typename VisitorDispatcher> | 258 template <typename VisitorDispatcher> |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 // since iterating over the hash table backing will find the whole | 808 // since iterating over the hash table backing will find the whole |
| 773 // chain. | 809 // chain. |
| 774 visitor->markNoTracing(node); | 810 visitor->markNoTracing(node); |
| 775 return false; | 811 return false; |
| 776 } | 812 } |
| 777 }; | 813 }; |
| 778 | 814 |
| 779 } // namespace WTF | 815 } // namespace WTF |
| 780 | 816 |
| 781 #endif | 817 #endif |
| OLD | NEW |