Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: third_party/WebKit/Source/platform/heap/TraceTraits.h

Issue 2602363002: Always adjust container size when tracing HeapVectorBacking contents. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698