| 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 HeapAllocator_h | 5 #ifndef HeapAllocator_h |
| 6 #define HeapAllocator_h | 6 #define HeapAllocator_h |
| 7 | 7 |
| 8 #include "platform/heap/Heap.h" | 8 #include "platform/heap/Heap.h" |
| 9 #include "platform/heap/TraceTraits.h" | 9 #include "platform/heap/TraceTraits.h" |
| 10 #include "wtf/Assertions.h" | 10 #include "wtf/Assertions.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 public: | 272 public: |
| 273 static void finalize(void* pointer); | 273 static void finalize(void* pointer); |
| 274 void finalizeGarbageCollectedObject() { finalize(this); } | 274 void finalizeGarbageCollectedObject() { finalize(this); } |
| 275 }; | 275 }; |
| 276 | 276 |
| 277 template<typename T, typename Traits> | 277 template<typename T, typename Traits> |
| 278 void HeapVectorBacking<T, Traits>::finalize(void* pointer) | 278 void HeapVectorBacking<T, Traits>::finalize(void* pointer) |
| 279 { | 279 { |
| 280 static_assert(Traits::needsDestruction, "Only vector buffers with items requ
iring destruction should be finalized"); | 280 static_assert(Traits::needsDestruction, "Only vector buffers with items requ
iring destruction should be finalized"); |
| 281 // See the comment in HeapVectorBacking::trace. | 281 // See the comment in HeapVectorBacking::trace. |
| 282 static_assert(Traits::canInitializeWithMemset || WTF::IsPolymorphic<T>::valu
e, "HeapVectorBacking doesn't support objects that cannot be initialized with me
mset or don't have a vtable"); | 282 static_assert(Traits::canClearUnusedSlotsWithMemset || WTF::IsPolymorphic<T>
::value, "HeapVectorBacking doesn't support objects that cannot be cleared as un
used with memset or don't have a vtable"); |
| 283 | 283 |
| 284 ASSERT(!WTF::IsTriviallyDestructible<T>::value); | 284 ASSERT(!WTF::IsTriviallyDestructible<T>::value); |
| 285 HeapObjectHeader* header = HeapObjectHeader::fromPayload(pointer); | 285 HeapObjectHeader* header = HeapObjectHeader::fromPayload(pointer); |
| 286 header->checkHeader(); | 286 header->checkHeader(); |
| 287 // Use the payload size as recorded by the heap to determine how many | 287 // Use the payload size as recorded by the heap to determine how many |
| 288 // elements to finalize. | 288 // elements to finalize. |
| 289 size_t length = header->payloadSize() / sizeof(T); | 289 size_t length = header->payloadSize() / sizeof(T); |
| 290 T* buffer = reinterpret_cast<T*>(pointer); | 290 T* buffer = reinterpret_cast<T*>(pointer); |
| 291 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER | 291 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER |
| 292 // As commented above, HeapVectorBacking calls finalizers for unused slots | 292 // As commented above, HeapVectorBacking calls finalizers for unused slots |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 template<typename T, size_t i, typename U> | 457 template<typename T, size_t i, typename U> |
| 458 inline void swap(HeapListHashSet<T, i, U>& a, HeapListHashSet<T, i, U>& b) { a.s
wap(b); } | 458 inline void swap(HeapListHashSet<T, i, U>& a, HeapListHashSet<T, i, U>& b) { a.s
wap(b); } |
| 459 template<typename T, typename U, typename V> | 459 template<typename T, typename U, typename V> |
| 460 inline void swap(HeapLinkedHashSet<T, U, V>& a, HeapLinkedHashSet<T, U, V>& b) {
a.swap(b); } | 460 inline void swap(HeapLinkedHashSet<T, U, V>& a, HeapLinkedHashSet<T, U, V>& b) {
a.swap(b); } |
| 461 template<typename T, typename U, typename V> | 461 template<typename T, typename U, typename V> |
| 462 inline void swap(HeapHashCountedSet<T, U, V>& a, HeapHashCountedSet<T, U, V>& b)
{ a.swap(b); } | 462 inline void swap(HeapHashCountedSet<T, U, V>& a, HeapHashCountedSet<T, U, V>& b)
{ a.swap(b); } |
| 463 | 463 |
| 464 } // namespace blink | 464 } // namespace blink |
| 465 | 465 |
| 466 #endif | 466 #endif |
| OLD | NEW |