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

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

Issue 1146353002: Oilpan: insist on eager sweeping for some objects. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add some limited-lifetime comments Created 5 years, 7 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/Heap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/HeapTest.cpp
diff --git a/Source/platform/heap/HeapTest.cpp b/Source/platform/heap/HeapTest.cpp
index fecd86f9523074d57edc1870b9c4c7430694a12c..12a382c2f82f77c8161d990340fe9e1946ccf214 100644
--- a/Source/platform/heap/HeapTest.cpp
+++ b/Source/platform/heap/HeapTest.cpp
@@ -1872,6 +1872,8 @@ class SimpleFinalizedEagerObjectBase : public GarbageCollectedFinalized<SimpleFi
public:
virtual ~SimpleFinalizedEagerObjectBase() { }
DEFINE_INLINE_TRACE() { }
+
+ EAGERLY_SWEEP();
protected:
SimpleFinalizedEagerObjectBase() { }
};
@@ -1893,9 +1895,32 @@ private:
SimpleFinalizedEagerObject() { }
};
-int SimpleFinalizedEagerObject::s_destructorCalls = 0;
+template<typename T>
+class ParameterizedButEmpty {
+public:
+ EAGERLY_SWEEP();
+};
+
+class SimpleFinalizedObjectInstanceOfTemplate final : public GarbageCollectedFinalized<SimpleFinalizedObjectInstanceOfTemplate>, public ParameterizedButEmpty<SimpleFinalizedObjectInstanceOfTemplate> {
+public:
+ static SimpleFinalizedObjectInstanceOfTemplate* create()
+ {
+ return new SimpleFinalizedObjectInstanceOfTemplate();
+ }
+ ~SimpleFinalizedObjectInstanceOfTemplate()
+ {
+ ++s_destructorCalls;
+ }
+
+ DEFINE_INLINE_TRACE() { }
+
+ static int s_destructorCalls;
+private:
+ SimpleFinalizedObjectInstanceOfTemplate() { }
+};
-EAGERLY_SWEEP(SimpleFinalizedEagerObjectBase);
+int SimpleFinalizedEagerObject::s_destructorCalls = 0;
+int SimpleFinalizedObjectInstanceOfTemplate::s_destructorCalls = 0;
TEST(HeapTest, EagerlySweepingPages)
{
@@ -1903,15 +1928,19 @@ TEST(HeapTest, EagerlySweepingPages)
SimpleFinalizedObject::s_destructorCalls = 0;
SimpleFinalizedEagerObject::s_destructorCalls = 0;
+ SimpleFinalizedObjectInstanceOfTemplate::s_destructorCalls = 0;
EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls);
EXPECT_EQ(0, SimpleFinalizedEagerObject::s_destructorCalls);
for (int i = 0; i < 1000; i++)
SimpleFinalizedObject::create();
for (int i = 0; i < 100; i++)
SimpleFinalizedEagerObject::create();
+ for (int i = 0; i < 100; i++)
+ SimpleFinalizedObjectInstanceOfTemplate::create();
Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWithoutSweep, Heap::ForcedGC);
EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls);
EXPECT_EQ(100, SimpleFinalizedEagerObject::s_destructorCalls);
+ EXPECT_EQ(100, SimpleFinalizedObjectInstanceOfTemplate::s_destructorCalls);
}
#endif
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698