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/StackFrameDepth.h" | 10 #include "platform/heap/StackFrameDepth.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 template <typename VisitorDispatcher> | 200 template <typename VisitorDispatcher> |
201 static void mark(VisitorDispatcher visitor, const T* t) { | 201 static void mark(VisitorDispatcher visitor, const T* t) { |
202 AdjustAndMarkTrait<T>::mark(visitor, t); | 202 AdjustAndMarkTrait<T>::mark(visitor, t); |
203 } | 203 } |
204 | 204 |
205 private: | 205 private: |
206 static const T* ToWrapperTracingType(const void* t) { | 206 static const T* ToWrapperTracingType(const void* t) { |
207 static_assert(!NeedsAdjustAndMark<T>::value, | 207 static_assert(!NeedsAdjustAndMark<T>::value, |
208 "wrapper tracing is not supported within mixins"); | 208 "wrapper tracing is not supported within mixins"); |
209 #if DCHECK_IS_ON() | 209 #if DCHECK_IS_ON() |
210 HeapObjectHeader::fromPayload(t)->checkHeader(); | 210 HeapObjectHeader::checkFromPayload(t); |
211 #endif | 211 #endif |
212 return reinterpret_cast<const T*>(t); | 212 return reinterpret_cast<const T*>(t); |
213 } | 213 } |
214 }; | 214 }; |
215 | 215 |
216 template <typename T> | 216 template <typename T> |
217 class TraceTrait<const T> : public TraceTrait<T> {}; | 217 class TraceTrait<const T> : public TraceTrait<T> {}; |
218 | 218 |
219 template <typename T> | 219 template <typename T> |
220 void TraceTrait<T>::trace(Visitor* visitor, void* self) { | 220 void TraceTrait<T>::trace(Visitor* visitor, void* self) { |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 502 |
503 // This trace method is instantiated for vectors where | 503 // This trace method is instantiated for vectors where |
504 // IsTraceableInCollectionTrait<Traits>::value is false, but the trace | 504 // IsTraceableInCollectionTrait<Traits>::value is false, but the trace |
505 // method should not be called. Thus we cannot static-assert | 505 // method should not be called. Thus we cannot static-assert |
506 // IsTraceableInCollectionTrait<Traits>::value but should runtime-assert it. | 506 // IsTraceableInCollectionTrait<Traits>::value but should runtime-assert it. |
507 DCHECK(IsTraceableInCollectionTrait<Traits>::value); | 507 DCHECK(IsTraceableInCollectionTrait<Traits>::value); |
508 | 508 |
509 T* array = reinterpret_cast<T*>(self); | 509 T* array = reinterpret_cast<T*>(self); |
510 blink::HeapObjectHeader* header = | 510 blink::HeapObjectHeader* header = |
511 blink::HeapObjectHeader::fromPayload(self); | 511 blink::HeapObjectHeader::fromPayload(self); |
512 header->checkHeader(); | |
513 // Use the payload size as recorded by the heap to determine how many | 512 // Use the payload size as recorded by the heap to determine how many |
514 // elements to trace. | 513 // elements to trace. |
515 size_t length = header->payloadSize() / sizeof(T); | 514 size_t length = header->payloadSize() / sizeof(T); |
516 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER | 515 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER |
517 // As commented above, HeapVectorBacking can trace unused slots | 516 // As commented above, HeapVectorBacking can trace unused slots |
518 // (which are already zeroed out). | 517 // (which are already zeroed out). |
519 ANNOTATE_CHANGE_SIZE(array, length, 0, length); | 518 ANNOTATE_CHANGE_SIZE(array, length, 0, length); |
520 #endif | 519 #endif |
521 if (std::is_polymorphic<T>::value) { | 520 if (std::is_polymorphic<T>::value) { |
522 char* pointer = reinterpret_cast<char*>(array); | 521 char* pointer = reinterpret_cast<char*>(array); |
(...skipping 27 matching lines...) Expand all Loading... |
550 template <typename VisitorDispatcher> | 549 template <typename VisitorDispatcher> |
551 static bool trace(VisitorDispatcher visitor, void* self) { | 550 static bool trace(VisitorDispatcher visitor, void* self) { |
552 static_assert(strongify == WTF::WeakPointersActStrong, | 551 static_assert(strongify == WTF::WeakPointersActStrong, |
553 "An on-stack HeapHashTable needs to be visited strongly."); | 552 "An on-stack HeapHashTable needs to be visited strongly."); |
554 | 553 |
555 DCHECK(IsTraceableInCollectionTrait<Traits>::value || | 554 DCHECK(IsTraceableInCollectionTrait<Traits>::value || |
556 Traits::weakHandlingFlag == WeakHandlingInCollections); | 555 Traits::weakHandlingFlag == WeakHandlingInCollections); |
557 Value* array = reinterpret_cast<Value*>(self); | 556 Value* array = reinterpret_cast<Value*>(self); |
558 blink::HeapObjectHeader* header = | 557 blink::HeapObjectHeader* header = |
559 blink::HeapObjectHeader::fromPayload(self); | 558 blink::HeapObjectHeader::fromPayload(self); |
560 header->checkHeader(); | |
561 // Use the payload size as recorded by the heap to determine how many | 559 // Use the payload size as recorded by the heap to determine how many |
562 // elements to trace. | 560 // elements to trace. |
563 size_t length = header->payloadSize() / sizeof(Value); | 561 size_t length = header->payloadSize() / sizeof(Value); |
564 for (size_t i = 0; i < length; ++i) { | 562 for (size_t i = 0; i < length; ++i) { |
565 if (!HashTableHelper< | 563 if (!HashTableHelper< |
566 Value, typename Table::ExtractorType, | 564 Value, typename Table::ExtractorType, |
567 typename Table::KeyTraitsType>::isEmptyOrDeletedBucket(array[i])) | 565 typename Table::KeyTraitsType>::isEmptyOrDeletedBucket(array[i])) |
568 blink::TraceCollectionIfEnabled< | 566 blink::TraceCollectionIfEnabled< |
569 IsTraceableInCollectionTrait<Traits>::value, | 567 IsTraceableInCollectionTrait<Traits>::value, |
570 Traits::weakHandlingFlag, strongify, Value, | 568 Traits::weakHandlingFlag, strongify, Value, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 using Node = | 602 using Node = |
605 ListHashSetNode<NodeContents, | 603 ListHashSetNode<NodeContents, |
606 blink::HeapListHashSetAllocator<T, inlineCapacity>>; | 604 blink::HeapListHashSetAllocator<T, inlineCapacity>>; |
607 using Table = HashTable<Node*, U, V, W, X, Y, blink::HeapAllocator>; | 605 using Table = HashTable<Node*, U, V, W, X, Y, blink::HeapAllocator>; |
608 | 606 |
609 template <typename VisitorDispatcher> | 607 template <typename VisitorDispatcher> |
610 static bool trace(VisitorDispatcher visitor, void* self) { | 608 static bool trace(VisitorDispatcher visitor, void* self) { |
611 Node** array = reinterpret_cast<Node**>(self); | 609 Node** array = reinterpret_cast<Node**>(self); |
612 blink::HeapObjectHeader* header = | 610 blink::HeapObjectHeader* header = |
613 blink::HeapObjectHeader::fromPayload(self); | 611 blink::HeapObjectHeader::fromPayload(self); |
614 header->checkHeader(); | |
615 size_t length = header->payloadSize() / sizeof(Node*); | 612 size_t length = header->payloadSize() / sizeof(Node*); |
616 for (size_t i = 0; i < length; ++i) { | 613 for (size_t i = 0; i < length; ++i) { |
617 if (!HashTableHelper<Node*, typename Table::ExtractorType, | 614 if (!HashTableHelper<Node*, typename Table::ExtractorType, |
618 typename Table::KeyTraitsType>:: | 615 typename Table::KeyTraitsType>:: |
619 isEmptyOrDeletedBucket(array[i])) { | 616 isEmptyOrDeletedBucket(array[i])) { |
620 traceListHashSetValue(visitor, array[i]->m_value); | 617 traceListHashSetValue(visitor, array[i]->m_value); |
621 // Just mark the node without tracing because we already traced | 618 // Just mark the node without tracing because we already traced |
622 // the contents, and there is no need to trace the next and | 619 // the contents, and there is no need to trace the next and |
623 // prev fields since iterating over the hash table backing will | 620 // prev fields since iterating over the hash table backing will |
624 // find the whole chain. | 621 // find the whole chain. |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 // since iterating over the hash table backing will find the whole | 778 // since iterating over the hash table backing will find the whole |
782 // chain. | 779 // chain. |
783 visitor->markNoTracing(node); | 780 visitor->markNoTracing(node); |
784 return false; | 781 return false; |
785 } | 782 } |
786 }; | 783 }; |
787 | 784 |
788 } // namespace WTF | 785 } // namespace WTF |
789 | 786 |
790 #endif | 787 #endif |
OLD | NEW |