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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 // IsTraceableInCollectionTrait<Traits>::value but should runtime-assert it. | 527 // IsTraceableInCollectionTrait<Traits>::value but should runtime-assert it. |
528 DCHECK(IsTraceableInCollectionTrait<Traits>::value); | 528 DCHECK(IsTraceableInCollectionTrait<Traits>::value); |
529 | 529 |
530 T* array = reinterpret_cast<T*>(self); | 530 T* array = reinterpret_cast<T*>(self); |
531 blink::HeapObjectHeader* header = | 531 blink::HeapObjectHeader* header = |
532 blink::HeapObjectHeader::fromPayload(self); | 532 blink::HeapObjectHeader::fromPayload(self); |
533 ASSERT(header->checkHeader()); | 533 ASSERT(header->checkHeader()); |
534 // Use the payload size as recorded by the heap to determine how many | 534 // Use the payload size as recorded by the heap to determine how many |
535 // elements to trace. | 535 // elements to trace. |
536 size_t length = header->payloadSize() / sizeof(T); | 536 size_t length = header->payloadSize() / sizeof(T); |
| 537 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER |
| 538 // As commented above, HeapVectorBacking can trace unused slots |
| 539 // (which are already zeroed out). |
| 540 ANNOTATE_CHANGE_SIZE(array, length, 0, length); |
| 541 #endif |
537 if (std::is_polymorphic<T>::value) { | 542 if (std::is_polymorphic<T>::value) { |
538 char* pointer = reinterpret_cast<char*>(array); | 543 char* pointer = reinterpret_cast<char*>(array); |
539 for (unsigned i = 0; i < length; ++i) { | 544 for (unsigned i = 0; i < length; ++i) { |
540 char* element = pointer + i * sizeof(T); | 545 char* element = pointer + i * sizeof(T); |
541 if (blink::vTableInitialized(element)) | 546 if (blink::vTableInitialized(element)) |
542 blink::TraceIfEnabled< | 547 blink::TraceIfEnabled< |
543 T, IsTraceableInCollectionTrait<Traits>::value>::trace(visitor, | 548 T, IsTraceableInCollectionTrait<Traits>::value>::trace(visitor, |
544 array[i]); | 549 array[i]); |
545 } | 550 } |
546 } else { | 551 } else { |
547 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER | |
548 // As commented above, HeapVectorBacking can trace unused slots | |
549 // (which are already zeroed out). | |
550 ANNOTATE_CHANGE_SIZE(array, length, 0, length); | |
551 #endif | |
552 for (size_t i = 0; i < length; ++i) | 552 for (size_t i = 0; i < length; ++i) |
553 blink::TraceIfEnabled< | 553 blink::TraceIfEnabled< |
554 T, IsTraceableInCollectionTrait<Traits>::value>::trace(visitor, | 554 T, IsTraceableInCollectionTrait<Traits>::value>::trace(visitor, |
555 array[i]); | 555 array[i]); |
556 } | 556 } |
557 return false; | 557 return false; |
558 } | 558 } |
559 }; | 559 }; |
560 | 560 |
561 // This trace method is used only for on-stack HeapHashTables found in | 561 // This trace method is used only for on-stack HeapHashTables found in |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 // since iterating over the hash table backing will find the whole | 802 // since iterating over the hash table backing will find the whole |
803 // chain. | 803 // chain. |
804 visitor->markNoTracing(node); | 804 visitor->markNoTracing(node); |
805 return false; | 805 return false; |
806 } | 806 } |
807 }; | 807 }; |
808 | 808 |
809 } // namespace WTF | 809 } // namespace WTF |
810 | 810 |
811 #endif | 811 #endif |
OLD | NEW |