| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 return; | 129 return; |
| 130 | 130 |
| 131 if (tracenessConfiguration != TracenessMemberConfiguration::Untraced) { | 131 if (tracenessConfiguration != TracenessMemberConfiguration::Untraced) { |
| 132 ThreadState* current = ThreadState::current(); | 132 ThreadState* current = ThreadState::current(); |
| 133 DCHECK(current); | 133 DCHECK(current); |
| 134 // m_creationThreadState may be null when this is used in a heap | 134 // m_creationThreadState may be null when this is used in a heap |
| 135 // collection which initialized the Member with memset and the | 135 // collection which initialized the Member with memset and the |
| 136 // constructor wasn't called. | 136 // constructor wasn't called. |
| 137 if (m_creationThreadState) { | 137 if (m_creationThreadState) { |
| 138 // Member should point to objects that belong in the same ThreadHeap. | 138 // Member should point to objects that belong in the same ThreadHeap. |
| 139 DCHECK_EQ(&ThreadState::fromObject(m_raw)->heap(), | 139 DCHECK(m_creationThreadState->isOnThreadHeap(m_raw)); |
| 140 &m_creationThreadState->heap()); | |
| 141 // Member should point to objects that belong in the same ThreadHeap. | 140 // Member should point to objects that belong in the same ThreadHeap. |
| 142 DCHECK_EQ(¤t->heap(), &m_creationThreadState->heap()); | 141 DCHECK_EQ(¤t->heap(), &m_creationThreadState->heap()); |
| 143 } else { | 142 } else { |
| 144 DCHECK_EQ(&ThreadState::fromObject(m_raw)->heap(), ¤t->heap()); | 143 DCHECK(current->isOnThreadHeap(m_raw)); |
| 145 } | 144 } |
| 146 } | 145 } |
| 147 | 146 |
| 148 #if defined(ADDRESS_SANITIZER) | 147 #if defined(ADDRESS_SANITIZER) |
| 149 // TODO(haraken): What we really want to check here is that the pointer | 148 // TODO(haraken): What we really want to check here is that the pointer |
| 150 // is a traceable object. In other words, the pointer is either of: | 149 // is a traceable object. In other words, the pointer is either of: |
| 151 // | 150 // |
| 152 // (a) a pointer to the head of an on-heap object. | 151 // (a) a pointer to the head of an on-heap object. |
| 153 // (b) a pointer to the head of an on-heap mixin object. | 152 // (b) a pointer to the head of an on-heap mixin object. |
| 154 // | 153 // |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 if (reinterpret_cast<intptr_t>(this->m_raw) % allocationGranularity) | 353 if (reinterpret_cast<intptr_t>(this->m_raw) % allocationGranularity) |
| 355 return; | 354 return; |
| 356 | 355 |
| 357 ThreadState* current = ThreadState::current(); | 356 ThreadState* current = ThreadState::current(); |
| 358 DCHECK(current); | 357 DCHECK(current); |
| 359 // m_creationThreadState may be null when this is used in a heap | 358 // m_creationThreadState may be null when this is used in a heap |
| 360 // collection which initialized the Member with memset and the | 359 // collection which initialized the Member with memset and the |
| 361 // constructor wasn't called. | 360 // constructor wasn't called. |
| 362 if (m_creationThreadState) { | 361 if (m_creationThreadState) { |
| 363 // Member should point to objects that belong in the same ThreadHeap. | 362 // Member should point to objects that belong in the same ThreadHeap. |
| 364 CHECK_EQ(&ThreadState::fromObject(this->m_raw)->heap(), | 363 CHECK(m_creationThreadState->isOnThreadHeap(this->m_raw)); |
| 365 &m_creationThreadState->heap()); | |
| 366 // Member should point to objects that belong in the same ThreadHeap. | 364 // Member should point to objects that belong in the same ThreadHeap. |
| 367 CHECK_EQ(¤t->heap(), &m_creationThreadState->heap()); | 365 CHECK_EQ(¤t->heap(), &m_creationThreadState->heap()); |
| 368 } else { | 366 } else { |
| 369 CHECK_EQ(&ThreadState::fromObject(this->m_raw)->heap(), ¤t->heap()); | 367 CHECK(current->isOnThreadHeap(this->m_raw)); |
| 370 } | 368 } |
| 371 } | 369 } |
| 372 | 370 |
| 373 void saveCreationThreadState() { | 371 void saveCreationThreadState() { |
| 374 m_creationThreadState = ThreadState::current(); | 372 m_creationThreadState = ThreadState::current(); |
| 375 // All Members should be created in an attached thread, but an empty | 373 // All Members should be created in an attached thread, but an empty |
| 376 // value Member may be created on an unattached thread by a heap | 374 // value Member may be created on an unattached thread by a heap |
| 377 // collection iterator. | 375 // collection iterator. |
| 378 CHECK(this->m_creationThreadState || !this->m_raw); | 376 CHECK(this->m_creationThreadState || !this->m_raw); |
| 379 } | 377 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 | 567 |
| 570 template <typename T> | 568 template <typename T> |
| 571 struct IsTraceable<blink::TraceWrapperMember<T>> { | 569 struct IsTraceable<blink::TraceWrapperMember<T>> { |
| 572 STATIC_ONLY(IsTraceable); | 570 STATIC_ONLY(IsTraceable); |
| 573 static const bool value = true; | 571 static const bool value = true; |
| 574 }; | 572 }; |
| 575 | 573 |
| 576 } // namespace WTF | 574 } // namespace WTF |
| 577 | 575 |
| 578 #endif // Member_h | 576 #endif // Member_h |
| OLD | NEW |