| 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |