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

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: rebased past r194046 (upto r194085.) 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
« no previous file with comments | « Source/platform/heap/GCInfo.h ('k') | Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Heap.h
diff --git a/Source/platform/heap/Heap.h b/Source/platform/heap/Heap.h
index a23055acd18fd47b50494232e5cfe3e7555f074c..629efc43eba2132accc62c286262c5c21599c549 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)
{
« no previous file with comments | « Source/platform/heap/GCInfo.h ('k') | Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698