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

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

Issue 2698673003: Call HeapObjectHeader::checkHeader solely for its side-effect. (Closed)
Patch Set: Use DCHECK on a bool instead of DCHECK_EQ. Created 3 years, 8 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 | « third_party/WebKit/Source/platform/heap/Member.h ('k') | 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/StackFrameDepth.h" 10 #include "platform/heap/StackFrameDepth.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 DCHECK(HeapObjectHeader::fromPayload(t)->checkHeader()); 210 HeapObjectHeader::fromPayload(t)->checkHeader();
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
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 ASSERT(header->checkHeader()); 512 header->checkHeader();
513 // Use the payload size as recorded by the heap to determine how many 513 // Use the payload size as recorded by the heap to determine how many
514 // elements to trace. 514 // elements to trace.
515 size_t length = header->payloadSize() / sizeof(T); 515 size_t length = header->payloadSize() / sizeof(T);
516 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER 516 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER
517 // As commented above, HeapVectorBacking can trace unused slots 517 // As commented above, HeapVectorBacking can trace unused slots
518 // (which are already zeroed out). 518 // (which are already zeroed out).
519 ANNOTATE_CHANGE_SIZE(array, length, 0, length); 519 ANNOTATE_CHANGE_SIZE(array, length, 0, length);
520 #endif 520 #endif
521 if (std::is_polymorphic<T>::value) { 521 if (std::is_polymorphic<T>::value) {
522 char* pointer = reinterpret_cast<char*>(array); 522 char* pointer = reinterpret_cast<char*>(array);
(...skipping 27 matching lines...) Expand all
550 template <typename VisitorDispatcher> 550 template <typename VisitorDispatcher>
551 static bool trace(VisitorDispatcher visitor, void* self) { 551 static bool trace(VisitorDispatcher visitor, void* self) {
552 static_assert(strongify == WTF::WeakPointersActStrong, 552 static_assert(strongify == WTF::WeakPointersActStrong,
553 "An on-stack HeapHashTable needs to be visited strongly."); 553 "An on-stack HeapHashTable needs to be visited strongly.");
554 554
555 DCHECK(IsTraceableInCollectionTrait<Traits>::value || 555 DCHECK(IsTraceableInCollectionTrait<Traits>::value ||
556 Traits::weakHandlingFlag == WeakHandlingInCollections); 556 Traits::weakHandlingFlag == WeakHandlingInCollections);
557 Value* array = reinterpret_cast<Value*>(self); 557 Value* array = reinterpret_cast<Value*>(self);
558 blink::HeapObjectHeader* header = 558 blink::HeapObjectHeader* header =
559 blink::HeapObjectHeader::fromPayload(self); 559 blink::HeapObjectHeader::fromPayload(self);
560 ASSERT(header->checkHeader()); 560 header->checkHeader();
561 // Use the payload size as recorded by the heap to determine how many 561 // Use the payload size as recorded by the heap to determine how many
562 // elements to trace. 562 // elements to trace.
563 size_t length = header->payloadSize() / sizeof(Value); 563 size_t length = header->payloadSize() / sizeof(Value);
564 for (size_t i = 0; i < length; ++i) { 564 for (size_t i = 0; i < length; ++i) {
565 if (!HashTableHelper< 565 if (!HashTableHelper<
566 Value, typename Table::ExtractorType, 566 Value, typename Table::ExtractorType,
567 typename Table::KeyTraitsType>::isEmptyOrDeletedBucket(array[i])) 567 typename Table::KeyTraitsType>::isEmptyOrDeletedBucket(array[i]))
568 blink::TraceCollectionIfEnabled< 568 blink::TraceCollectionIfEnabled<
569 IsTraceableInCollectionTrait<Traits>::value, 569 IsTraceableInCollectionTrait<Traits>::value,
570 Traits::weakHandlingFlag, strongify, Value, 570 Traits::weakHandlingFlag, strongify, Value,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 using Node = 604 using Node =
605 ListHashSetNode<NodeContents, 605 ListHashSetNode<NodeContents,
606 blink::HeapListHashSetAllocator<T, inlineCapacity>>; 606 blink::HeapListHashSetAllocator<T, inlineCapacity>>;
607 using Table = HashTable<Node*, U, V, W, X, Y, blink::HeapAllocator>; 607 using Table = HashTable<Node*, U, V, W, X, Y, blink::HeapAllocator>;
608 608
609 template <typename VisitorDispatcher> 609 template <typename VisitorDispatcher>
610 static bool trace(VisitorDispatcher visitor, void* self) { 610 static bool trace(VisitorDispatcher visitor, void* self) {
611 Node** array = reinterpret_cast<Node**>(self); 611 Node** array = reinterpret_cast<Node**>(self);
612 blink::HeapObjectHeader* header = 612 blink::HeapObjectHeader* header =
613 blink::HeapObjectHeader::fromPayload(self); 613 blink::HeapObjectHeader::fromPayload(self);
614 ASSERT(header->checkHeader()); 614 header->checkHeader();
615 size_t length = header->payloadSize() / sizeof(Node*); 615 size_t length = header->payloadSize() / sizeof(Node*);
616 for (size_t i = 0; i < length; ++i) { 616 for (size_t i = 0; i < length; ++i) {
617 if (!HashTableHelper<Node*, typename Table::ExtractorType, 617 if (!HashTableHelper<Node*, typename Table::ExtractorType,
618 typename Table::KeyTraitsType>:: 618 typename Table::KeyTraitsType>::
619 isEmptyOrDeletedBucket(array[i])) { 619 isEmptyOrDeletedBucket(array[i])) {
620 traceListHashSetValue(visitor, array[i]->m_value); 620 traceListHashSetValue(visitor, array[i]->m_value);
621 // Just mark the node without tracing because we already traced 621 // Just mark the node without tracing because we already traced
622 // the contents, and there is no need to trace the next and 622 // the contents, and there is no need to trace the next and
623 // prev fields since iterating over the hash table backing will 623 // prev fields since iterating over the hash table backing will
624 // find the whole chain. 624 // find the whole chain.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 // since iterating over the hash table backing will find the whole 781 // since iterating over the hash table backing will find the whole
782 // chain. 782 // chain.
783 visitor->markNoTracing(node); 783 visitor->markNoTracing(node);
784 return false; 784 return false;
785 } 785 }
786 }; 786 };
787 787
788 } // namespace WTF 788 } // namespace WTF
789 789
790 #endif 790 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Member.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698