OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 Member_h | 5 #ifndef Member_h |
6 #define Member_h | 6 #define Member_h |
7 | 7 |
8 #include "wtf/Allocator.h" | 8 #include "wtf/Allocator.h" |
9 #include "wtf/HashFunctions.h" | 9 #include "wtf/HashFunctions.h" |
10 #include "wtf/HashTraits.h" | 10 #include "wtf/HashTraits.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // collection iterator. | 172 // collection iterator. |
173 DCHECK(m_creationThreadState || !m_raw); | 173 DCHECK(m_creationThreadState || !m_raw); |
174 } | 174 } |
175 #endif | 175 #endif |
176 } | 176 } |
177 | 177 |
178 T* m_raw; | 178 T* m_raw; |
179 #if DCHECK_IS_ON() | 179 #if DCHECK_IS_ON() |
180 const ThreadState* m_creationThreadState; | 180 const ThreadState* m_creationThreadState; |
181 #endif | 181 #endif |
182 | |
183 template <bool x, | |
184 WTF::WeakHandlingFlag y, | |
185 WTF::ShouldWeakPointersBeMarkedStrongly z, | |
186 typename U, | |
187 typename V> | |
188 friend struct CollectionBackingTraceTrait; | |
189 friend class Visitor; | |
190 }; | 182 }; |
191 | 183 |
192 // Members are used in classes to contain strong pointers to other oilpan heap | 184 // Members are used in classes to contain strong pointers to other oilpan heap |
193 // allocated objects. | 185 // allocated objects. |
194 // All Member fields of a class must be traced in the class' trace method. | 186 // All Member fields of a class must be traced in the class' trace method. |
195 // During the mark phase of the GC all live objects are marked as live and | 187 // During the mark phase of the GC all live objects are marked as live and |
196 // all Member fields of a live object will be traced marked as live as well. | 188 // all Member fields of a live object will be traced marked as live as well. |
197 template <typename T> | 189 template <typename T> |
198 class Member : public MemberBase<T, TracenessMemberConfiguration::Traced> { | 190 class Member : public MemberBase<T, TracenessMemberConfiguration::Traced> { |
199 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 191 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 template <typename U> | 225 template <typename U> |
234 Member& operator=(U* other) { | 226 Member& operator=(U* other) { |
235 Parent::operator=(other); | 227 Parent::operator=(other); |
236 return *this; | 228 return *this; |
237 } | 229 } |
238 | 230 |
239 Member& operator=(std::nullptr_t) { | 231 Member& operator=(std::nullptr_t) { |
240 Parent::operator=(nullptr); | 232 Parent::operator=(nullptr); |
241 return *this; | 233 return *this; |
242 } | 234 } |
243 | |
244 protected: | |
245 template <bool x, | |
246 WTF::WeakHandlingFlag y, | |
247 WTF::ShouldWeakPointersBeMarkedStrongly z, | |
248 typename U, | |
249 typename V> | |
250 friend struct CollectionBackingTraceTrait; | |
251 friend class Visitor; | |
252 }; | 235 }; |
253 | 236 |
254 // A checked version of Member<>, verifying that only same-thread references | 237 // A checked version of Member<>, verifying that only same-thread references |
255 // are kept in the smart pointer. Intended to be used to diagnose unclean | 238 // are kept in the smart pointer. Intended to be used to diagnose unclean |
256 // thread reference usage in release builds. It simply exposes the debug-only | 239 // thread reference usage in release builds. It simply exposes the debug-only |
257 // MemberBase<> checking we already have in place for select usage to diagnose | 240 // MemberBase<> checking we already have in place for select usage to diagnose |
258 // per-thread issues. Only intended used temporarily while diagnosing suspected | 241 // per-thread issues. Only intended used temporarily while diagnosing suspected |
259 // problems with cross-thread references. | 242 // problems with cross-thread references. |
260 template <typename T> | 243 template <typename T> |
261 class SameThreadCheckedMember : public Member<T> { | 244 class SameThreadCheckedMember : public Member<T> { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 Parent::operator=(other); | 309 Parent::operator=(other); |
327 checkPointer(); | 310 checkPointer(); |
328 return *this; | 311 return *this; |
329 } | 312 } |
330 | 313 |
331 SameThreadCheckedMember& operator=(std::nullptr_t) { | 314 SameThreadCheckedMember& operator=(std::nullptr_t) { |
332 Parent::operator=(nullptr); | 315 Parent::operator=(nullptr); |
333 return *this; | 316 return *this; |
334 } | 317 } |
335 | 318 |
336 protected: | |
337 template <bool x, | |
338 WTF::WeakHandlingFlag y, | |
339 WTF::ShouldWeakPointersBeMarkedStrongly z, | |
340 typename U, | |
341 typename V> | |
342 friend struct CollectionBackingTraceTrait; | |
343 friend class Visitor; | |
344 | |
345 private: | 319 private: |
346 void checkPointer() { | 320 void checkPointer() { |
347 if (!this->m_raw) | 321 if (!this->m_raw) |
348 return; | 322 return; |
349 // HashTable can store a special value (which is not aligned to the | 323 // HashTable can store a special value (which is not aligned to the |
350 // allocation granularity) to Member<> to represent a deleted entry. | 324 // allocation granularity) to Member<> to represent a deleted entry. |
351 // Thus we treat a pointer that is not aligned to the granularity | 325 // Thus we treat a pointer that is not aligned to the granularity |
352 // as a valid pointer. | 326 // as a valid pointer. |
353 if (reinterpret_cast<intptr_t>(this->m_raw) % allocationGranularity) | 327 if (reinterpret_cast<intptr_t>(this->m_raw) % allocationGranularity) |
354 return; | 328 return; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 | 540 |
567 template <typename T> | 541 template <typename T> |
568 struct IsTraceable<blink::TraceWrapperMember<T>> { | 542 struct IsTraceable<blink::TraceWrapperMember<T>> { |
569 STATIC_ONLY(IsTraceable); | 543 STATIC_ONLY(IsTraceable); |
570 static const bool value = true; | 544 static const bool value = true; |
571 }; | 545 }; |
572 | 546 |
573 } // namespace WTF | 547 } // namespace WTF |
574 | 548 |
575 #endif // Member_h | 549 #endif // Member_h |
OLD | NEW |