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

Side by Side Diff: Source/platform/heap/HeapTest.cpp

Issue 1138663002: Oilpan: support eager finalization/sweeping. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review iteration + rebase 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 EXPECT_EQ(i + 1, LargeHeapObject::s_destructorCalls); 1860 EXPECT_EQ(i + 1, LargeHeapObject::s_destructorCalls);
1861 } 1861 }
1862 LargeHeapObject::create(); 1862 LargeHeapObject::create();
1863 LargeHeapObject::create(); 1863 LargeHeapObject::create();
1864 EXPECT_EQ(10, LargeHeapObject::s_destructorCalls); 1864 EXPECT_EQ(10, LargeHeapObject::s_destructorCalls);
1865 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith outSweep, Heap::ForcedGC); 1865 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith outSweep, Heap::ForcedGC);
1866 EXPECT_EQ(10, LargeHeapObject::s_destructorCalls); 1866 EXPECT_EQ(10, LargeHeapObject::s_destructorCalls);
1867 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith Sweep, Heap::ForcedGC); 1867 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith Sweep, Heap::ForcedGC);
1868 EXPECT_EQ(22, LargeHeapObject::s_destructorCalls); 1868 EXPECT_EQ(22, LargeHeapObject::s_destructorCalls);
1869 } 1869 }
1870
1871 class SimpleFinalizedEagerObjectBase : public GarbageCollectedFinalized<SimpleFi nalizedEagerObjectBase> {
1872 public:
1873 virtual ~SimpleFinalizedEagerObjectBase() { }
1874 DEFINE_INLINE_TRACE() { }
1875 protected:
1876 SimpleFinalizedEagerObjectBase() { }
1877 };
1878
1879 class SimpleFinalizedEagerObject : public SimpleFinalizedEagerObjectBase {
1880 public:
1881 static SimpleFinalizedEagerObject* create()
1882 {
1883 return new SimpleFinalizedEagerObject();
1884 }
1885
1886 virtual ~SimpleFinalizedEagerObject()
1887 {
1888 ++s_destructorCalls;
1889 }
1890
1891 static int s_destructorCalls;
1892 private:
1893 SimpleFinalizedEagerObject() { }
1894 };
1895
1896 int SimpleFinalizedEagerObject::s_destructorCalls = 0;
1897
1898 EAGERLY_SWEEP(SimpleFinalizedEagerObjectBase);
1899
1900 TEST(HeapTest, EagerlySweepingPages)
1901 {
1902 clearOutOldGarbage();
1903
1904 SimpleFinalizedObject::s_destructorCalls = 0;
1905 SimpleFinalizedEagerObject::s_destructorCalls = 0;
1906 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls);
1907 EXPECT_EQ(0, SimpleFinalizedEagerObject::s_destructorCalls);
1908 for (int i = 0; i < 1000; i++)
1909 SimpleFinalizedObject::create();
1910 for (int i = 0; i < 100; i++)
1911 SimpleFinalizedEagerObject::create();
1912 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith outSweep, Heap::ForcedGC);
1913 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls);
1914 EXPECT_EQ(100, SimpleFinalizedEagerObject::s_destructorCalls);
1915 }
1870 #endif 1916 #endif
1871 1917
1872 TEST(HeapTest, Finalization) 1918 TEST(HeapTest, Finalization)
1873 { 1919 {
1874 { 1920 {
1875 HeapTestSubClass* t1 = HeapTestSubClass::create(); 1921 HeapTestSubClass* t1 = HeapTestSubClass::create();
1876 HeapTestSubClass* t2 = HeapTestSubClass::create(); 1922 HeapTestSubClass* t2 = HeapTestSubClass::create();
1877 HeapTestSuperClass* t3 = HeapTestSuperClass::create(); 1923 HeapTestSuperClass* t3 = HeapTestSuperClass::create();
1878 // FIXME(oilpan): Ignore unused variables. 1924 // FIXME(oilpan): Ignore unused variables.
1879 (void)t1; 1925 (void)t1;
(...skipping 4152 matching lines...) Expand 10 before | Expand all | Expand 10 after
6032 { 6078 {
6033 Persistent<ClassWithMember> object = ClassWithMember::create(); 6079 Persistent<ClassWithMember> object = ClassWithMember::create();
6034 EXPECT_EQ(0, object->traceCount()); 6080 EXPECT_EQ(0, object->traceCount());
6035 TestMixinAllocatingObject* mixin = TestMixinAllocatingObject::create(object. get()); 6081 TestMixinAllocatingObject* mixin = TestMixinAllocatingObject::create(object. get());
6036 EXPECT_TRUE(mixin); 6082 EXPECT_TRUE(mixin);
6037 EXPECT_GT(object->traceCount(), 0); 6083 EXPECT_GT(object->traceCount(), 0);
6038 EXPECT_GT(mixin->traceCount(), 0); 6084 EXPECT_GT(mixin->traceCount(), 0);
6039 } 6085 }
6040 6086
6041 } // namespace blink 6087 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698