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

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

Issue 1138663002: Oilpan: support eager finalization/sweeping. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase + introduce OILPAN_EAGERLY_SWEEP() 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
Index: Source/platform/heap/HeapTest.cpp
diff --git a/Source/platform/heap/HeapTest.cpp b/Source/platform/heap/HeapTest.cpp
index 9f7024173d5b9186e68b130471c593ebf210bea0..2f287fb40cb9da526b025dfc59dead91da80b588 100644
--- a/Source/platform/heap/HeapTest.cpp
+++ b/Source/platform/heap/HeapTest.cpp
@@ -1867,6 +1867,52 @@ TEST(HeapTest, LazySweepingLargeObjectPages)
Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWithSweep, Heap::ForcedGC);
EXPECT_EQ(22, LargeHeapObject::s_destructorCalls);
}
+
+class SimpleFinalizedEagerObjectBase : public GarbageCollectedFinalized<SimpleFinalizedEagerObjectBase> {
+public:
+ virtual ~SimpleFinalizedEagerObjectBase() { }
+ DEFINE_INLINE_TRACE() { }
+protected:
+ SimpleFinalizedEagerObjectBase() { }
+};
+
+class SimpleFinalizedEagerObject : public SimpleFinalizedEagerObjectBase {
+public:
+ static SimpleFinalizedEagerObject* create()
+ {
+ return new SimpleFinalizedEagerObject();
+ }
+
+ virtual ~SimpleFinalizedEagerObject()
+ {
+ ++s_destructorCalls;
+ }
+
+ static int s_destructorCalls;
+private:
+ SimpleFinalizedEagerObject() { }
+};
+
+int SimpleFinalizedEagerObject::s_destructorCalls = 0;
+
+OILPAN_EAGERLY_SWEEP(SimpleFinalizedEagerObjectBase);
+
+TEST(HeapTest, EagerlySweepingPages)
+{
+ clearOutOldGarbage();
+
+ SimpleFinalizedObject::s_destructorCalls = 0;
+ SimpleFinalizedEagerObject::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();
+ Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWithoutSweep, Heap::ForcedGC);
+ EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls);
+ EXPECT_EQ(100, SimpleFinalizedEagerObject::s_destructorCalls);
+}
#endif
TEST(HeapTest, Finalization)

Powered by Google App Engine
This is Rietveld 408576698