| 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/Persistent.h" | 9 #include "platform/heap/Persistent.h" |
| 10 #include "platform/heap/TraceTraits.h" | 10 #include "platform/heap/TraceTraits.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 // Use the payload size as recorded by the heap to determine how many | 299 // Use the payload size as recorded by the heap to determine how many |
| 300 // elements to finalize. | 300 // elements to finalize. |
| 301 size_t length = header->payloadSize() / sizeof(T); | 301 size_t length = header->payloadSize() / sizeof(T); |
| 302 T* buffer = reinterpret_cast<T*>(pointer); | 302 T* buffer = reinterpret_cast<T*>(pointer); |
| 303 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER | 303 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER |
| 304 // As commented above, HeapVectorBacking calls finalizers for unused slots | 304 // As commented above, HeapVectorBacking calls finalizers for unused slots |
| 305 // (which are already zeroed out). | 305 // (which are already zeroed out). |
| 306 ANNOTATE_CHANGE_SIZE(buffer, length, 0, length); | 306 ANNOTATE_CHANGE_SIZE(buffer, length, 0, length); |
| 307 #endif | 307 #endif |
| 308 if (std::is_polymorphic<T>::value) { | 308 if (std::is_polymorphic<T>::value) { |
| 309 char* pointer = reinterpret_cast<char*>(buffer); |
| 309 for (unsigned i = 0; i < length; ++i) { | 310 for (unsigned i = 0; i < length; ++i) { |
| 310 if (blink::vTableInitialized(&buffer[i])) | 311 char* element = pointer + i * sizeof(T); |
| 311 buffer[i].~T(); | 312 if (blink::vTableInitialized(element)) |
| 313 reinterpret_cast<T*>(element)->~T(); |
| 312 } | 314 } |
| 313 } else { | 315 } else { |
| 314 for (unsigned i = 0; i < length; ++i) { | 316 for (unsigned i = 0; i < length; ++i) { |
| 315 buffer[i].~T(); | 317 buffer[i].~T(); |
| 316 } | 318 } |
| 317 } | 319 } |
| 318 } | 320 } |
| 319 | 321 |
| 320 template <typename Table> | 322 template <typename Table> |
| 321 void HeapHashTableBacking<Table>::finalize(void* pointer) { | 323 void HeapHashTableBacking<Table>::finalize(void* pointer) { |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 const blink::HeapHashCountedSet<Value, HashFunctions, Traits>& set, | 771 const blink::HeapHashCountedSet<Value, HashFunctions, Traits>& set, |
| 770 VectorType& vector) { | 772 VectorType& vector) { |
| 771 copyToVector(static_cast<const HashCountedSet<Value, HashFunctions, Traits, | 773 copyToVector(static_cast<const HashCountedSet<Value, HashFunctions, Traits, |
| 772 blink::HeapAllocator>&>(set), | 774 blink::HeapAllocator>&>(set), |
| 773 vector); | 775 vector); |
| 774 } | 776 } |
| 775 | 777 |
| 776 } // namespace WTF | 778 } // namespace WTF |
| 777 | 779 |
| 778 #endif | 780 #endif |
| OLD | NEW |