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

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

Issue 1180383002: Introduce (Heap)Vector trait covering zero'ed memory for unused slots. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sof-hittestcache
Patch Set: rebased Created 5 years, 6 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 | « Source/platform/heap/HeapAllocator.h ('k') | Source/wtf/VectorTraits.h » ('j') | 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 // traces only slots that are not zeroed out. This is because if 354 // traces only slots that are not zeroed out. This is because if
355 // the object has a vtable, the zeroed slot means that it is 355 // the object has a vtable, the zeroed slot means that it is
356 // an unused slot (Remember that the unused slots are guaranteed 356 // an unused slot (Remember that the unused slots are guaranteed
357 // to be zeroed out by VectorUnusedSlotClearer). 357 // to be zeroed out by VectorUnusedSlotClearer).
358 // 358 //
359 // - An object that can be initialized with memset. In this case, 359 // - An object that can be initialized with memset. In this case,
360 // HeapVectorBacking traces all slots including unused slots. 360 // HeapVectorBacking traces all slots including unused slots.
361 // This is fine because the fact that the object can be initialized 361 // This is fine because the fact that the object can be initialized
362 // with memset indicates that it is safe to treat the zerod slot 362 // with memset indicates that it is safe to treat the zerod slot
363 // as a valid object. 363 // as a valid object.
364 static_assert(!ShouldBeTraced<Traits>::value || Traits::canInitializeWit hMemset || WTF::IsPolymorphic<T>::value, "HeapVectorBacking doesn't support obje cts that cannot be initialized with memset."); 364 static_assert(!ShouldBeTraced<Traits>::value || Traits::canClearUnusedSl otsWithMemset || WTF::IsPolymorphic<T>::value, "HeapVectorBacking doesn't suppor t objects that cannot be cleared as unused with memset.");
365 365
366 // This trace method is instantiated for vectors where 366 // This trace method is instantiated for vectors where
367 // ShouldBeTraced<Traits>::value is false, but the trace method 367 // ShouldBeTraced<Traits>::value is false, but the trace method
368 // should not be called. Thus we cannot static-assert 368 // should not be called. Thus we cannot static-assert
369 // ShouldBeTraced<Traits>::value but should runtime-assert it. 369 // ShouldBeTraced<Traits>::value but should runtime-assert it.
370 ASSERT(ShouldBeTraced<Traits>::value); 370 ASSERT(ShouldBeTraced<Traits>::value);
371 371
372 T* array = reinterpret_cast<T*>(self); 372 T* array = reinterpret_cast<T*>(self);
373 blink::HeapObjectHeader* header = blink::HeapObjectHeader::fromPayload(s elf); 373 blink::HeapObjectHeader* header = blink::HeapObjectHeader::fromPayload(s elf);
374 header->checkHeader(); 374 header->checkHeader();
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 // since iterating over the hash table backing will find the whole 541 // since iterating over the hash table backing will find the whole
542 // chain. 542 // chain.
543 visitor->markNoTracing(node); 543 visitor->markNoTracing(node);
544 return false; 544 return false;
545 } 545 }
546 }; 546 };
547 547
548 } // namespace WTF 548 } // namespace WTF
549 549
550 #endif 550 #endif
OLDNEW
« no previous file with comments | « Source/platform/heap/HeapAllocator.h ('k') | Source/wtf/VectorTraits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698