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

Unified Diff: Source/platform/heap/Heap.h

Issue 1086413003: Oilpan: HeapVectorBacking should call destructors for its elements (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add test comment Created 5 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 side-by-side diff with in-line comments
Download patch
Index: Source/platform/heap/Heap.h
diff --git a/Source/platform/heap/Heap.h b/Source/platform/heap/Heap.h
index 5bd5addd0d4027a38ae0463c9cf356c07053c2a5..00fa08fbec5e15e840882f641e4fa21a87d3562b 100644
--- a/Source/platform/heap/Heap.h
+++ b/Source/platform/heap/Heap.h
@@ -1501,7 +1501,11 @@ inline void Heap::increaseExternallyAllocatedBytes(size_t delta)
}
template<bool needsTracing, WTF::WeakHandlingFlag weakHandlingFlag, WTF::ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Traits> struct CollectionBackingTraceTrait;
-template<typename T, typename Traits = WTF::VectorTraits<T>> class HeapVectorBacking;
+template<typename T, typename Traits = WTF::VectorTraits<T>> class HeapVectorBacking {
+public:
+ static void finalize(void* pointer);
+ void finalizeGarbageCollectedObject() { finalize(this); }
+};
template<typename Table> class HeapHashTableBacking {
public:
static void finalize(void* pointer);
@@ -2211,6 +2215,20 @@ struct TraceTrait<HeapHashTableBacking<Table>> {
}
};
+template<typename T, typename Traits>
+void HeapVectorBacking<T, Traits>::finalize(void* pointer)
+{
+ ASSERT(!WTF::IsTriviallyDestructible<T>::value);
+ HeapObjectHeader* header = HeapObjectHeader::fromPayload(pointer);
+ // Use the payload size as recorded by the heap to determine how many
+ // elements to finalize.
+ size_t length = header->payloadSize() / sizeof(T);
+ T* array = reinterpret_cast<T*>(pointer);
+ for (unsigned i = 0; i < length; ++i) {
+ array[i].~T();
+ }
+}
+
template<typename Table>
void HeapHashTableBacking<Table>::finalize(void* pointer)
{

Powered by Google App Engine
This is Rietveld 408576698