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

Unified Diff: third_party/WebKit/Source/platform/heap/HeapTest.cpp

Issue 1912093002: Require that heap collections are used over traceable elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « third_party/WebKit/Source/platform/heap/HeapAllocator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/HeapTest.cpp
diff --git a/third_party/WebKit/Source/platform/heap/HeapTest.cpp b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
index 0fd79a2c0c7e25a4809c7797dcf1e79298b06e08..0f274bb815f96143b4bab44bee966e13a3e8f401 100644
--- a/third_party/WebKit/Source/platform/heap/HeapTest.cpp
+++ b/third_party/WebKit/Source/platform/heap/HeapTest.cpp
@@ -232,6 +232,11 @@ template<> struct HashTraits<blink::PairWithWeakHandling> : blink::WeakHandlingH
static bool isDeletedValue(const blink::PairWithWeakHandling& value) { return value.isHashTableDeletedValue(); }
};
+template<>
+struct NeedsTracing<blink::PairWithWeakHandling> {
+ static const bool value = NeedsTracing<blink::StrongWeakPair>::value;
+};
+
} // namespace WTF
namespace blink {
@@ -4059,20 +4064,9 @@ TEST(HeapTest, EmbeddedInVector)
preciselyCollectGarbage();
EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls);
- // Since VectorObjectNoTrace has no trace method it will
- // not be traced and hence be collected when doing GC.
- // We trace items in a collection braced on the item's
- // having a trace method. This is determined via the
- // NeedsTracing trait in wtf/TypeTraits.h.
- PersistentHeapVector<VectorObjectNoTrace> vectorNoTrace;
- VectorObjectNoTrace n1, n2;
- vectorNoTrace.append(n1);
- vectorNoTrace.append(n2);
- preciselyCollectGarbage();
- EXPECT_EQ(2, SimpleFinalizedObject::s_destructorCalls);
}
preciselyCollectGarbage();
- EXPECT_EQ(8, SimpleFinalizedObject::s_destructorCalls);
+ EXPECT_EQ(6, SimpleFinalizedObject::s_destructorCalls);
}
TEST(HeapTest, EmbeddedInDeque)
@@ -4097,21 +4091,9 @@ TEST(HeapTest, EmbeddedInDeque)
preciselyCollectGarbage();
EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls);
-
- // Since VectorObjectNoTrace has no trace method it will
- // not be traced and hence be collected when doing GC.
- // We trace items in a collection braced on the item's
- // having a trace method. This is determined via the
- // NeedsTracing trait in wtf/TypeTraits.h.
- PersistentHeapDeque<VectorObjectNoTrace> dequeNoTrace;
- VectorObjectNoTrace n1, n2;
- dequeNoTrace.append(n1);
- dequeNoTrace.append(n2);
- preciselyCollectGarbage();
- EXPECT_EQ(2, SimpleFinalizedObject::s_destructorCalls);
}
preciselyCollectGarbage();
- EXPECT_EQ(8, SimpleFinalizedObject::s_destructorCalls);
+ EXPECT_EQ(6, SimpleFinalizedObject::s_destructorCalls);
}
class InlinedVectorObject {
@@ -4528,26 +4510,12 @@ void destructorsCalledOnClear(bool addLots)
TEST(HeapTest, DestructorsCalled)
{
- HeapHashMap<SimpleClassWithDestructor*, OwnPtr<SimpleClassWithDestructor>> map;
+ HeapHashMap<Member<IntWrapper>, OwnPtr<SimpleClassWithDestructor>> map;
SimpleClassWithDestructor* hasDestructor = new SimpleClassWithDestructor();
- map.add(hasDestructor, adoptPtr(hasDestructor));
+ map.add(IntWrapper::create(1), adoptPtr(hasDestructor));
SimpleClassWithDestructor::s_wasDestructed = false;
map.clear();
EXPECT_TRUE(SimpleClassWithDestructor::s_wasDestructed);
-
- destructorsCalledOnClear<HeapHashSet<RefPtr<RefCountedWithDestructor>>>(false);
- destructorsCalledOnClear<HeapListHashSet<RefPtr<RefCountedWithDestructor>>>(false);
- destructorsCalledOnClear<HeapLinkedHashSet<RefPtr<RefCountedWithDestructor>>>(false);
- destructorsCalledOnClear<HeapHashSet<RefPtr<RefCountedWithDestructor>>>(true);
- destructorsCalledOnClear<HeapListHashSet<RefPtr<RefCountedWithDestructor>>>(true);
- destructorsCalledOnClear<HeapLinkedHashSet<RefPtr<RefCountedWithDestructor>>>(true);
-
- destructorsCalledOnGC<HeapHashSet<RefPtr<RefCountedWithDestructor>>>(false);
- destructorsCalledOnGC<HeapListHashSet<RefPtr<RefCountedWithDestructor>>>(false);
- destructorsCalledOnGC<HeapLinkedHashSet<RefPtr<RefCountedWithDestructor>>>(false);
- destructorsCalledOnGC<HeapHashSet<RefPtr<RefCountedWithDestructor>>>(true);
- destructorsCalledOnGC<HeapListHashSet<RefPtr<RefCountedWithDestructor>>>(true);
- destructorsCalledOnGC<HeapLinkedHashSet<RefPtr<RefCountedWithDestructor>>>(true);
}
class MixinA : public GarbageCollectedMixin {
@@ -6102,6 +6070,8 @@ public:
{
}
+ DEFINE_INLINE_TRACE() { }
+
int value() const { return m_value->value(); }
private:
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapAllocator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698