| 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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 DCHECK(IsTraceableInCollectionTrait<Traits>::value); | 484 DCHECK(IsTraceableInCollectionTrait<Traits>::value); |
| 485 | 485 |
| 486 T* array = reinterpret_cast<T*>(self); | 486 T* array = reinterpret_cast<T*>(self); |
| 487 blink::HeapObjectHeader* header = | 487 blink::HeapObjectHeader* header = |
| 488 blink::HeapObjectHeader::fromPayload(self); | 488 blink::HeapObjectHeader::fromPayload(self); |
| 489 ASSERT(header->checkHeader()); | 489 ASSERT(header->checkHeader()); |
| 490 // Use the payload size as recorded by the heap to determine how many | 490 // Use the payload size as recorded by the heap to determine how many |
| 491 // elements to trace. | 491 // elements to trace. |
| 492 size_t length = header->payloadSize() / sizeof(T); | 492 size_t length = header->payloadSize() / sizeof(T); |
| 493 if (std::is_polymorphic<T>::value) { | 493 if (std::is_polymorphic<T>::value) { |
| 494 for (size_t i = 0; i < length; ++i) { | 494 char* pointer = reinterpret_cast<char*>(array); |
| 495 if (blink::vTableInitialized(&array[i])) | 495 for (unsigned i = 0; i < length; ++i) { |
| 496 char* element = pointer + i * sizeof(T); |
| 497 if (blink::vTableInitialized(element)) |
| 496 blink::TraceIfEnabled< | 498 blink::TraceIfEnabled< |
| 497 T, IsTraceableInCollectionTrait<Traits>::value>::trace(visitor, | 499 T, IsTraceableInCollectionTrait<Traits>::value>::trace(visitor, |
| 498 array[i]); | 500 array[i]); |
| 499 } | 501 } |
| 500 } else { | 502 } else { |
| 501 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER | 503 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER |
| 502 // As commented above, HeapVectorBacking can trace unused slots | 504 // As commented above, HeapVectorBacking can trace unused slots |
| 503 // (which are already zeroed out). | 505 // (which are already zeroed out). |
| 504 ANNOTATE_CHANGE_SIZE(array, length, 0, length); | 506 ANNOTATE_CHANGE_SIZE(array, length, 0, length); |
| 505 #endif | 507 #endif |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 // since iterating over the hash table backing will find the whole | 758 // since iterating over the hash table backing will find the whole |
| 757 // chain. | 759 // chain. |
| 758 visitor->markNoTracing(node); | 760 visitor->markNoTracing(node); |
| 759 return false; | 761 return false; |
| 760 } | 762 } |
| 761 }; | 763 }; |
| 762 | 764 |
| 763 } // namespace WTF | 765 } // namespace WTF |
| 764 | 766 |
| 765 #endif | 767 #endif |
| OLD | NEW |