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

Unified Diff: Source/heap/HeapTest.cpp

Issue 222653003: Oilpan: Fix isAlive dispatching for GarbageCollectedMixins. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add comment to virtual method Created 6 years, 9 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 | « no previous file | Source/heap/Visitor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/heap/HeapTest.cpp
diff --git a/Source/heap/HeapTest.cpp b/Source/heap/HeapTest.cpp
index 5b9d450b0cd2ca77736bf2debacb03f96b544d09..f1bbe104fdfd41094719fef93bc9a15c7321083e 100644
--- a/Source/heap/HeapTest.cpp
+++ b/Source/heap/HeapTest.cpp
@@ -175,6 +175,13 @@ public:
static SimpleObject* create() { return new SimpleObject(); }
void trace(Visitor*) { }
char getPayload(int i) { return payload[i]; }
+ // This virtual method is unused but it is here to make sure
+ // that this object has a vtable. This object is used
+ // as the super class for objects that also have garbage
+ // collected mixins and having a virtual here makes sure
+ // that adjustment is needed both for marking and for isAlive
+ // checks.
+ virtual void virtualMethod() { }
protected:
SimpleObject() { }
char payload[64];
@@ -1137,10 +1144,9 @@ class Mixin : public GarbageCollectedMixin {
public:
virtual void trace(Visitor* visitor) { }
- char getPayload(int i) { return m_padding[i]; }
+ virtual char getPayload(int i) { return m_padding[i]; }
protected:
- // This is to force ptr diff for SimpleObject, Mixin, and UseMixin.
int m_padding[8];
};
@@ -2983,20 +2989,25 @@ TEST(HeapTest, CollectionNesting)
EXPECT_EQ(1, IntWrapper::s_destructorCalls);
}
-TEST(heap, GarbageCollectedMixin)
+TEST(HeapTest, GarbageCollectedMixin)
{
HeapStats initialHeapStats;
clearOutOldGarbage(&initialHeapStats);
Persistent<UseMixin> usemixin = UseMixin::create();
- ASSERT_EQ(0, UseMixin::s_traceCount);
+ EXPECT_EQ(0, UseMixin::s_traceCount);
Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
- ASSERT_EQ(1, UseMixin::s_traceCount);
+ EXPECT_EQ(1, UseMixin::s_traceCount);
Persistent<Mixin> mixin = usemixin;
usemixin = nullptr;
Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
- ASSERT_EQ(2, UseMixin::s_traceCount);
+ EXPECT_EQ(2, UseMixin::s_traceCount);
+
+ PersistentHeapHashSet<WeakMember<Mixin> > weakMap;
+ weakMap.add(UseMixin::create());
+ Heap::collectGarbage(ThreadState::NoHeapPointersOnStack);
+ EXPECT_EQ(0u, weakMap.size());
}
TEST(HeapTest, CollectionNesting2)
« no previous file with comments | « no previous file | Source/heap/Visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698