| 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" |
| 11 #include "platform/heap/Visitor.h" | 11 #include "platform/heap/Visitor.h" |
| 12 #include "wtf/Allocator.h" |
| 12 #include "wtf/Assertions.h" | 13 #include "wtf/Assertions.h" |
| 13 #include "wtf/Deque.h" | 14 #include "wtf/Deque.h" |
| 14 #include "wtf/HashCountedSet.h" | 15 #include "wtf/HashCountedSet.h" |
| 15 #include "wtf/HashMap.h" | 16 #include "wtf/HashMap.h" |
| 16 #include "wtf/HashSet.h" | 17 #include "wtf/HashSet.h" |
| 17 #include "wtf/HashTable.h" | 18 #include "wtf/HashTable.h" |
| 18 #include "wtf/LinkedHashSet.h" | 19 #include "wtf/LinkedHashSet.h" |
| 19 #include "wtf/ListHashSet.h" | 20 #include "wtf/ListHashSet.h" |
| 20 #include "wtf/TypeTraits.h" | 21 #include "wtf/TypeTraits.h" |
| 21 #include "wtf/Vector.h" | 22 #include "wtf/Vector.h" |
| 22 | 23 |
| 23 namespace blink { | 24 namespace blink { |
| 24 | 25 |
| 25 template<typename T> class CrossThreadPersistent; | 26 template<typename T> class CrossThreadPersistent; |
| 26 template<typename T> class CrossThreadWeakPersistent; | 27 template<typename T> class CrossThreadWeakPersistent; |
| 27 template<typename T> class Member; | 28 template<typename T> class Member; |
| 28 template<typename T> class TraceTrait; | 29 template<typename T> class TraceTrait; |
| 29 template<typename T> class WeakMember; | 30 template<typename T> class WeakMember; |
| 30 template<typename T> class WeakPersistent; | 31 template<typename T> class WeakPersistent; |
| 31 | 32 |
| 32 template<typename T, bool = NeedsAdjustAndMark<T>::value> class AdjustAndMarkTra
it; | 33 template<typename T, bool = NeedsAdjustAndMark<T>::value> class AdjustAndMarkTra
it; |
| 33 | 34 |
| 34 template<typename T> | 35 template<typename T> |
| 35 class AdjustAndMarkTrait<T, false> { | 36 class AdjustAndMarkTrait<T, false> { |
| 37 STATIC_ONLY(AdjustAndMarkTrait); |
| 36 public: | 38 public: |
| 37 template<typename VisitorDispatcher> | 39 template<typename VisitorDispatcher> |
| 38 static void mark(VisitorDispatcher visitor, const T* t) | 40 static void mark(VisitorDispatcher visitor, const T* t) |
| 39 { | 41 { |
| 40 #if ENABLE(ASSERT) | 42 #if ENABLE(ASSERT) |
| 41 assertObjectHasGCInfo(const_cast<T*>(t), GCInfoTrait<T>::index()); | 43 assertObjectHasGCInfo(const_cast<T*>(t), GCInfoTrait<T>::index()); |
| 42 #endif | 44 #endif |
| 43 // Default mark method of the trait just calls the two-argument mark | 45 // Default mark method of the trait just calls the two-argument mark |
| 44 // method on the visitor. The second argument is the static trace method | 46 // method on the visitor. The second argument is the static trace method |
| 45 // of the trait, which by default calls the instance method | 47 // of the trait, which by default calls the instance method |
| (...skipping 21 matching lines...) Expand all Loading... |
| 67 } | 69 } |
| 68 return; | 70 return; |
| 69 } | 71 } |
| 70 } | 72 } |
| 71 visitor->mark(const_cast<T*>(t), &TraceTrait<T>::trace); | 73 visitor->mark(const_cast<T*>(t), &TraceTrait<T>::trace); |
| 72 } | 74 } |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 template<typename T> | 77 template<typename T> |
| 76 class AdjustAndMarkTrait<T, true> { | 78 class AdjustAndMarkTrait<T, true> { |
| 79 STATIC_ONLY(AdjustAndMarkTrait); |
| 77 public: | 80 public: |
| 78 template<typename VisitorDispatcher> | 81 template<typename VisitorDispatcher> |
| 79 static void mark(VisitorDispatcher visitor, const T* self) | 82 static void mark(VisitorDispatcher visitor, const T* self) |
| 80 { | 83 { |
| 81 if (!self) | 84 if (!self) |
| 82 return; | 85 return; |
| 83 | 86 |
| 84 // If you hit this ASSERT, it means that there is a dangling pointer | 87 // If you hit this ASSERT, it means that there is a dangling pointer |
| 85 // from a live thread heap to a dead thread heap. We must eliminate | 88 // from a live thread heap to a dead thread heap. We must eliminate |
| 86 // the dangling pointer. | 89 // the dangling pointer. |
| 87 // Release builds don't have the ASSERT, but it is OK because | 90 // Release builds don't have the ASSERT, but it is OK because |
| 88 // release builds will crash at the following self->adjustAndMark | 91 // release builds will crash at the following self->adjustAndMark |
| 89 // because all the entries of the orphaned heaps are zeroed out and | 92 // because all the entries of the orphaned heaps are zeroed out and |
| 90 // thus the item does not have a valid vtable. | 93 // thus the item does not have a valid vtable. |
| 91 ASSERT(!pageFromObject(self)->orphaned()); | 94 ASSERT(!pageFromObject(self)->orphaned()); |
| 92 self->adjustAndMark(visitor); | 95 self->adjustAndMark(visitor); |
| 93 } | 96 } |
| 94 }; | 97 }; |
| 95 | 98 |
| 96 template<typename T, bool needsTracing> | 99 template<typename T, bool needsTracing> |
| 97 struct TraceIfEnabled; | 100 struct TraceIfEnabled; |
| 98 | 101 |
| 99 template<typename T> | 102 template<typename T> |
| 100 struct TraceIfEnabled<T, false> { | 103 struct TraceIfEnabled<T, false> { |
| 104 STATIC_ONLY(TraceIfEnabled); |
| 101 template<typename VisitorDispatcher> | 105 template<typename VisitorDispatcher> |
| 102 static void trace(VisitorDispatcher, T&) | 106 static void trace(VisitorDispatcher, T&) |
| 103 { | 107 { |
| 104 static_assert(!WTF::NeedsTracing<T>::value, "T should not be traced"); | 108 static_assert(!WTF::NeedsTracing<T>::value, "T should not be traced"); |
| 105 } | 109 } |
| 106 }; | 110 }; |
| 107 | 111 |
| 108 template<typename T> | 112 template<typename T> |
| 109 struct TraceIfEnabled<T, true> { | 113 struct TraceIfEnabled<T, true> { |
| 114 STATIC_ONLY(TraceIfEnabled); |
| 110 template<typename VisitorDispatcher> | 115 template<typename VisitorDispatcher> |
| 111 static void trace(VisitorDispatcher visitor, T& t) | 116 static void trace(VisitorDispatcher visitor, T& t) |
| 112 { | 117 { |
| 113 static_assert(WTF::NeedsTracing<T>::value || WTF::IsWeak<T>::value, "T s
hould be traced"); | 118 static_assert(WTF::NeedsTracing<T>::value || WTF::IsWeak<T>::value, "T s
hould be traced"); |
| 114 visitor->trace(t); | 119 visitor->trace(t); |
| 115 } | 120 } |
| 116 }; | 121 }; |
| 117 | 122 |
| 118 template<bool needsTracing, WTF::WeakHandlingFlag weakHandlingFlag, WTF::ShouldW
eakPointersBeMarkedStrongly strongify, typename T, typename Traits> struct Trace
CollectionIfEnabled; | 123 template<bool needsTracing, WTF::WeakHandlingFlag weakHandlingFlag, WTF::ShouldW
eakPointersBeMarkedStrongly strongify, typename T, typename Traits> struct Trace
CollectionIfEnabled; |
| 119 | 124 |
| 120 template<WTF::ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename
Traits> | 125 template<WTF::ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename
Traits> |
| 121 struct TraceCollectionIfEnabled<false, WTF::NoWeakHandlingInCollections, strongi
fy, T, Traits> { | 126 struct TraceCollectionIfEnabled<false, WTF::NoWeakHandlingInCollections, strongi
fy, T, Traits> { |
| 127 STATIC_ONLY(TraceCollectionIfEnabled); |
| 122 template<typename VisitorDispatcher> | 128 template<typename VisitorDispatcher> |
| 123 static bool trace(VisitorDispatcher, T&) | 129 static bool trace(VisitorDispatcher, T&) |
| 124 { | 130 { |
| 125 static_assert(!WTF::NeedsTracingTrait<Traits>::value, "Traits should not
be traced"); | 131 static_assert(!WTF::NeedsTracingTrait<Traits>::value, "Traits should not
be traced"); |
| 126 return false; | 132 return false; |
| 127 } | 133 } |
| 128 }; | 134 }; |
| 129 | 135 |
| 130 template<bool needsTracing, WTF::WeakHandlingFlag weakHandlingFlag, WTF::ShouldW
eakPointersBeMarkedStrongly strongify, typename T, typename Traits> | 136 template<bool needsTracing, WTF::WeakHandlingFlag weakHandlingFlag, WTF::ShouldW
eakPointersBeMarkedStrongly strongify, typename T, typename Traits> |
| 131 struct TraceCollectionIfEnabled { | 137 struct TraceCollectionIfEnabled { |
| 138 STATIC_ONLY(TraceCollectionIfEnabled); |
| 132 template<typename VisitorDispatcher> | 139 template<typename VisitorDispatcher> |
| 133 static bool trace(VisitorDispatcher visitor, T& t) | 140 static bool trace(VisitorDispatcher visitor, T& t) |
| 134 { | 141 { |
| 135 static_assert(WTF::NeedsTracingTrait<Traits>::value || weakHandlingFlag
== WTF::WeakHandlingInCollections, "Traits should be traced"); | 142 static_assert(WTF::NeedsTracingTrait<Traits>::value || weakHandlingFlag
== WTF::WeakHandlingInCollections, "Traits should be traced"); |
| 136 return WTF::TraceInCollectionTrait<weakHandlingFlag, strongify, T, Trait
s>::trace(visitor, t); | 143 return WTF::TraceInCollectionTrait<weakHandlingFlag, strongify, T, Trait
s>::trace(visitor, t); |
| 137 } | 144 } |
| 138 }; | 145 }; |
| 139 | 146 |
| 140 // The TraceTrait is used to specify how to mark an object pointer and | 147 // The TraceTrait is used to specify how to mark an object pointer and |
| 141 // how to trace all of the pointers in the object. | 148 // how to trace all of the pointers in the object. |
| 142 // | 149 // |
| 143 // By default, the 'trace' method implemented on an object itself is | 150 // By default, the 'trace' method implemented on an object itself is |
| 144 // used to trace the pointers to other heap objects inside the object. | 151 // used to trace the pointers to other heap objects inside the object. |
| 145 // | 152 // |
| 146 // However, the TraceTrait can be specialized to use a different | 153 // However, the TraceTrait can be specialized to use a different |
| 147 // implementation. A common case where a TraceTrait specialization is | 154 // implementation. A common case where a TraceTrait specialization is |
| 148 // needed is when multiple inheritance leads to pointers that are not | 155 // needed is when multiple inheritance leads to pointers that are not |
| 149 // to the start of the object in the Blink garbage-collected heap. In | 156 // to the start of the object in the Blink garbage-collected heap. In |
| 150 // that case the pointer has to be adjusted before marking. | 157 // that case the pointer has to be adjusted before marking. |
| 151 template<typename T> | 158 template<typename T> |
| 152 class TraceTrait { | 159 class TraceTrait { |
| 160 STATIC_ONLY(TraceTrait); |
| 153 public: | 161 public: |
| 154 static void trace(Visitor*, void* self); | 162 static void trace(Visitor*, void* self); |
| 155 static void trace(InlinedGlobalMarkingVisitor, void* self); | 163 static void trace(InlinedGlobalMarkingVisitor, void* self); |
| 156 | 164 |
| 157 template<typename VisitorDispatcher> | 165 template<typename VisitorDispatcher> |
| 158 static void mark(VisitorDispatcher visitor, const T* t) | 166 static void mark(VisitorDispatcher visitor, const T* t) |
| 159 { | 167 { |
| 160 AdjustAndMarkTrait<T>::mark(visitor, t); | 168 AdjustAndMarkTrait<T>::mark(visitor, t); |
| 161 } | 169 } |
| 162 }; | 170 }; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 177 | 185 |
| 178 template<typename T> | 186 template<typename T> |
| 179 void TraceTrait<T>::trace(InlinedGlobalMarkingVisitor visitor, void* self) | 187 void TraceTrait<T>::trace(InlinedGlobalMarkingVisitor visitor, void* self) |
| 180 { | 188 { |
| 181 static_assert(WTF::NeedsTracing<T>::value || WTF::IsWeak<T>::value, "T shoul
d be traced"); | 189 static_assert(WTF::NeedsTracing<T>::value || WTF::IsWeak<T>::value, "T shoul
d be traced"); |
| 182 static_cast<T*>(self)->trace(visitor); | 190 static_cast<T*>(self)->trace(visitor); |
| 183 } | 191 } |
| 184 | 192 |
| 185 template<typename T, typename Traits> | 193 template<typename T, typename Traits> |
| 186 struct TraceTrait<HeapVectorBacking<T, Traits>> { | 194 struct TraceTrait<HeapVectorBacking<T, Traits>> { |
| 195 STATIC_ONLY(TraceTrait); |
| 187 using Backing = HeapVectorBacking<T, Traits>; | 196 using Backing = HeapVectorBacking<T, Traits>; |
| 188 | 197 |
| 189 template<typename VisitorDispatcher> | 198 template<typename VisitorDispatcher> |
| 190 static void trace(VisitorDispatcher visitor, void* self) | 199 static void trace(VisitorDispatcher visitor, void* self) |
| 191 { | 200 { |
| 192 static_assert(!WTF::IsWeak<T>::value, "weakness in HeapVectors and Deque
s are not supported"); | 201 static_assert(!WTF::IsWeak<T>::value, "weakness in HeapVectors and Deque
s are not supported"); |
| 193 if (WTF::NeedsTracingTrait<Traits>::value) | 202 if (WTF::NeedsTracingTrait<Traits>::value) |
| 194 WTF::TraceInCollectionTrait<WTF::NoWeakHandlingInCollections, WTF::W
eakPointersActWeak, HeapVectorBacking<T, Traits>, void>::trace(visitor, self); | 203 WTF::TraceInCollectionTrait<WTF::NoWeakHandlingInCollections, WTF::W
eakPointersActWeak, HeapVectorBacking<T, Traits>, void>::trace(visitor, self); |
| 195 } | 204 } |
| 196 | 205 |
| 197 template<typename VisitorDispatcher> | 206 template<typename VisitorDispatcher> |
| 198 static void mark(VisitorDispatcher visitor, const Backing* backing) | 207 static void mark(VisitorDispatcher visitor, const Backing* backing) |
| 199 { | 208 { |
| 200 AdjustAndMarkTrait<Backing>::mark(visitor, backing); | 209 AdjustAndMarkTrait<Backing>::mark(visitor, backing); |
| 201 } | 210 } |
| 202 }; | 211 }; |
| 203 | 212 |
| 204 // The trace trait for the heap hashtable backing is used when we find a | 213 // The trace trait for the heap hashtable backing is used when we find a |
| 205 // direct pointer to the backing from the conservative stack scanner. This | 214 // direct pointer to the backing from the conservative stack scanner. This |
| 206 // normally indicates that there is an ongoing iteration over the table, and so | 215 // normally indicates that there is an ongoing iteration over the table, and so |
| 207 // we disable weak processing of table entries. When the backing is found | 216 // we disable weak processing of table entries. When the backing is found |
| 208 // through the owning hash table we mark differently, in order to do weak | 217 // through the owning hash table we mark differently, in order to do weak |
| 209 // processing. | 218 // processing. |
| 210 template<typename Table> | 219 template<typename Table> |
| 211 struct TraceTrait<HeapHashTableBacking<Table>> { | 220 struct TraceTrait<HeapHashTableBacking<Table>> { |
| 221 STATIC_ONLY(TraceTrait); |
| 212 using Backing = HeapHashTableBacking<Table>; | 222 using Backing = HeapHashTableBacking<Table>; |
| 213 using Traits = typename Table::ValueTraits; | 223 using Traits = typename Table::ValueTraits; |
| 214 | 224 |
| 215 template<typename VisitorDispatcher> | 225 template<typename VisitorDispatcher> |
| 216 static void trace(VisitorDispatcher visitor, void* self) | 226 static void trace(VisitorDispatcher visitor, void* self) |
| 217 { | 227 { |
| 218 if (WTF::NeedsTracingTrait<Traits>::value || Traits::weakHandlingFlag ==
WTF::WeakHandlingInCollections) | 228 if (WTF::NeedsTracingTrait<Traits>::value || Traits::weakHandlingFlag ==
WTF::WeakHandlingInCollections) |
| 219 WTF::TraceInCollectionTrait<WTF::NoWeakHandlingInCollections, WTF::W
eakPointersActStrong, Backing, void>::trace(visitor, self); | 229 WTF::TraceInCollectionTrait<WTF::NoWeakHandlingInCollections, WTF::W
eakPointersActStrong, Backing, void>::trace(visitor, self); |
| 220 } | 230 } |
| 221 | 231 |
| 222 template<typename VisitorDispatcher> | 232 template<typename VisitorDispatcher> |
| 223 static void mark(VisitorDispatcher visitor, const Backing* backing) | 233 static void mark(VisitorDispatcher visitor, const Backing* backing) |
| 224 { | 234 { |
| 225 AdjustAndMarkTrait<Backing>::mark(visitor, backing); | 235 AdjustAndMarkTrait<Backing>::mark(visitor, backing); |
| 226 } | 236 } |
| 227 }; | 237 }; |
| 228 | 238 |
| 229 // This trace trait for std::pair will null weak members if their referent is | 239 // This trace trait for std::pair will null weak members if their referent is |
| 230 // collected. If you have a collection that contain weakness it does not remove | 240 // collected. If you have a collection that contain weakness it does not remove |
| 231 // entries from the collection that contain nulled weak members. | 241 // entries from the collection that contain nulled weak members. |
| 232 template<typename T, typename U> | 242 template<typename T, typename U> |
| 233 class TraceTrait<std::pair<T, U>> { | 243 class TraceTrait<std::pair<T, U>> { |
| 244 STATIC_ONLY(TraceTrait); |
| 234 public: | 245 public: |
| 235 static const bool firstNeedsTracing = WTF::NeedsTracing<T>::value || WTF::Is
Weak<T>::value; | 246 static const bool firstNeedsTracing = WTF::NeedsTracing<T>::value || WTF::Is
Weak<T>::value; |
| 236 static const bool secondNeedsTracing = WTF::NeedsTracing<U>::value || WTF::I
sWeak<U>::value; | 247 static const bool secondNeedsTracing = WTF::NeedsTracing<U>::value || WTF::I
sWeak<U>::value; |
| 237 template<typename VisitorDispatcher> | 248 template<typename VisitorDispatcher> |
| 238 static void trace(VisitorDispatcher visitor, std::pair<T, U>* pair) | 249 static void trace(VisitorDispatcher visitor, std::pair<T, U>* pair) |
| 239 { | 250 { |
| 240 TraceIfEnabled<T, firstNeedsTracing>::trace(visitor, pair->first); | 251 TraceIfEnabled<T, firstNeedsTracing>::trace(visitor, pair->first); |
| 241 TraceIfEnabled<U, secondNeedsTracing>::trace(visitor, pair->second); | 252 TraceIfEnabled<U, secondNeedsTracing>::trace(visitor, pair->second); |
| 242 } | 253 } |
| 243 }; | 254 }; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 259 // should invoke |trace()| on not-yet-marked objects deriving from class T | 270 // should invoke |trace()| on not-yet-marked objects deriving from class T |
| 260 // right away, and not queue their trace callbacks on its marker stack, | 271 // right away, and not queue their trace callbacks on its marker stack, |
| 261 // which it will do if |value| is |false|. | 272 // which it will do if |value| is |false|. |
| 262 // | 273 // |
| 263 // The trait can be declared to enable/disable eager tracing for a class T | 274 // The trait can be declared to enable/disable eager tracing for a class T |
| 264 // and any of its subclasses, or just to the class T, but none of its | 275 // and any of its subclasses, or just to the class T, but none of its |
| 265 // subclasses. | 276 // subclasses. |
| 266 // | 277 // |
| 267 template<typename T> | 278 template<typename T> |
| 268 class TraceEagerlyTrait { | 279 class TraceEagerlyTrait { |
| 280 STATIC_ONLY(TraceEagerlyTrait); |
| 269 public: | 281 public: |
| 270 static const bool value = true; | 282 static const bool value = true; |
| 271 }; | 283 }; |
| 272 | 284 |
| 273 // Disable eager tracing for TYPE, but not any of its subclasses. | 285 // Disable eager tracing for TYPE, but not any of its subclasses. |
| 274 #define WILL_NOT_BE_EAGERLY_TRACED_CLASS(TYPE) \ | 286 #define WILL_NOT_BE_EAGERLY_TRACED_CLASS(TYPE) \ |
| 275 template<> \ | 287 template<> \ |
| 276 class TraceEagerlyTrait<TYPE> { \ | 288 class TraceEagerlyTrait<TYPE> { \ |
| 289 STATIC_ONLY(TraceEagerlyTrait); \ |
| 277 public: \ | 290 public: \ |
| 278 static const bool value = false; \ | 291 static const bool value = false; \ |
| 279 } | 292 } |
| 280 | 293 |
| 281 template<typename T> | 294 template<typename T> |
| 282 class TraceEagerlyTrait<Member<T>> { | 295 class TraceEagerlyTrait<Member<T>> { |
| 296 STATIC_ONLY(TraceEagerlyTrait); |
| 283 public: | 297 public: |
| 284 static const bool value = TraceEagerlyTrait<T>::value; | 298 static const bool value = TraceEagerlyTrait<T>::value; |
| 285 }; | 299 }; |
| 286 | 300 |
| 287 template<typename T> | 301 template<typename T> |
| 288 class TraceEagerlyTrait<WeakMember<T>> { | 302 class TraceEagerlyTrait<WeakMember<T>> { |
| 303 STATIC_ONLY(TraceEagerlyTrait); |
| 289 public: | 304 public: |
| 290 static const bool value = TraceEagerlyTrait<T>::value; | 305 static const bool value = TraceEagerlyTrait<T>::value; |
| 291 }; | 306 }; |
| 292 | 307 |
| 293 template<typename T> | 308 template<typename T> |
| 294 class TraceEagerlyTrait<Persistent<T>> { | 309 class TraceEagerlyTrait<Persistent<T>> { |
| 310 STATIC_ONLY(TraceEagerlyTrait); |
| 295 public: | 311 public: |
| 296 static const bool value = TraceEagerlyTrait<T>::value; | 312 static const bool value = TraceEagerlyTrait<T>::value; |
| 297 }; | 313 }; |
| 298 | 314 |
| 299 template<typename T> | 315 template<typename T> |
| 300 class TraceEagerlyTrait<WeakPersistent<T>> { | 316 class TraceEagerlyTrait<WeakPersistent<T>> { |
| 317 STATIC_ONLY(TraceEagerlyTrait); |
| 301 public: | 318 public: |
| 302 static const bool value = TraceEagerlyTrait<T>::value; | 319 static const bool value = TraceEagerlyTrait<T>::value; |
| 303 }; | 320 }; |
| 304 | 321 |
| 305 template<typename T> | 322 template<typename T> |
| 306 class TraceEagerlyTrait<CrossThreadPersistent<T>> { | 323 class TraceEagerlyTrait<CrossThreadPersistent<T>> { |
| 324 STATIC_ONLY(TraceEagerlyTrait); |
| 307 public: | 325 public: |
| 308 static const bool value = TraceEagerlyTrait<T>::value; | 326 static const bool value = TraceEagerlyTrait<T>::value; |
| 309 }; | 327 }; |
| 310 | 328 |
| 311 template<typename T> | 329 template<typename T> |
| 312 class TraceEagerlyTrait<CrossThreadWeakPersistent<T>> { | 330 class TraceEagerlyTrait<CrossThreadWeakPersistent<T>> { |
| 331 STATIC_ONLY(TraceEagerlyTrait); |
| 313 public: | 332 public: |
| 314 static const bool value = TraceEagerlyTrait<T>::value; | 333 static const bool value = TraceEagerlyTrait<T>::value; |
| 315 }; | 334 }; |
| 316 | 335 |
| 317 template<typename ValueArg, size_t inlineCapacity> class HeapListHashSetAllocato
r; | 336 template<typename ValueArg, size_t inlineCapacity> class HeapListHashSetAllocato
r; |
| 318 template<typename T, size_t inlineCapacity> | 337 template<typename T, size_t inlineCapacity> |
| 319 class TraceEagerlyTrait<WTF::ListHashSetNode<T, HeapListHashSetAllocator<T, inli
neCapacity>>> { | 338 class TraceEagerlyTrait<WTF::ListHashSetNode<T, HeapListHashSetAllocator<T, inli
neCapacity>>> { |
| 339 STATIC_ONLY(TraceEagerlyTrait); |
| 320 public: | 340 public: |
| 321 static const bool value = false; | 341 static const bool value = false; |
| 322 }; | 342 }; |
| 323 | 343 |
| 324 template <typename T> struct RemoveHeapPointerWrapperTypes { | 344 template <typename T> struct RemoveHeapPointerWrapperTypes { |
| 345 STATIC_ONLY(RemoveHeapPointerWrapperTypes); |
| 325 using Type = typename WTF::RemoveTemplate<typename WTF::RemoveTemplate<typen
ame WTF::RemoveTemplate<T, Member>::Type, WeakMember>::Type, RawPtr>::Type; | 346 using Type = typename WTF::RemoveTemplate<typename WTF::RemoveTemplate<typen
ame WTF::RemoveTemplate<T, Member>::Type, WeakMember>::Type, RawPtr>::Type; |
| 326 }; | 347 }; |
| 327 | 348 |
| 328 // FIXME: Oilpan: TraceIfNeeded should be implemented ala: | 349 // FIXME: Oilpan: TraceIfNeeded should be implemented ala: |
| 329 // NeedsTracing<T>::value || IsWeakMember<T>::value. It should not need to test | 350 // NeedsTracing<T>::value || IsWeakMember<T>::value. It should not need to test |
| 330 // raw pointer types. To remove these tests, we may need support for | 351 // raw pointer types. To remove these tests, we may need support for |
| 331 // instantiating a template with a RawPtrOrMember'ish template. | 352 // instantiating a template with a RawPtrOrMember'ish template. |
| 332 template<typename T> | 353 template<typename T> |
| 333 struct TraceIfNeeded : public TraceIfEnabled<T, WTF::NeedsTracing<T>::value || I
sGarbageCollectedType<typename RemoveHeapPointerWrapperTypes<typename std::remov
e_pointer<T>::type>::Type>::value> { }; | 354 struct TraceIfNeeded : public TraceIfEnabled<T, WTF::NeedsTracing<T>::value || I
sGarbageCollectedType<typename RemoveHeapPointerWrapperTypes<typename std::remov
e_pointer<T>::type>::Type>::value> { |
| 355 STATIC_ONLY(TraceIfNeeded); |
| 356 }; |
| 334 | 357 |
| 335 } // namespace blink | 358 } // namespace blink |
| 336 | 359 |
| 337 namespace WTF { | 360 namespace WTF { |
| 338 | 361 |
| 339 // Catch-all for types that have a way to trace that don't have special | 362 // Catch-all for types that have a way to trace that don't have special |
| 340 // handling for weakness in collections. This means that if this type | 363 // handling for weakness in collections. This means that if this type |
| 341 // contains WeakMember fields, they will simply be zeroed, but the entry | 364 // contains WeakMember fields, they will simply be zeroed, but the entry |
| 342 // will not be removed from the collection. This always happens for | 365 // will not be removed from the collection. This always happens for |
| 343 // things in vectors, which don't currently support special handling of | 366 // things in vectors, which don't currently support special handling of |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 // since iterating over the hash table backing will find the whole | 590 // since iterating over the hash table backing will find the whole |
| 568 // chain. | 591 // chain. |
| 569 visitor->markNoTracing(node); | 592 visitor->markNoTracing(node); |
| 570 return false; | 593 return false; |
| 571 } | 594 } |
| 572 }; | 595 }; |
| 573 | 596 |
| 574 } // namespace WTF | 597 } // namespace WTF |
| 575 | 598 |
| 576 #endif | 599 #endif |
| OLD | NEW |