| OLD | NEW |
| 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 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 1870 |
| 1871 class SimpleFinalizedEagerObjectBase : public GarbageCollectedFinalized<SimpleFi
nalizedEagerObjectBase> { | 1871 class SimpleFinalizedEagerObjectBase : public GarbageCollectedFinalized<SimpleFi
nalizedEagerObjectBase> { |
| 1872 public: | 1872 public: |
| 1873 virtual ~SimpleFinalizedEagerObjectBase() { } | 1873 virtual ~SimpleFinalizedEagerObjectBase() { } |
| 1874 DEFINE_INLINE_TRACE() { } | 1874 DEFINE_INLINE_TRACE() { } |
| 1875 |
| 1876 EAGERLY_SWEEP(); |
| 1875 protected: | 1877 protected: |
| 1876 SimpleFinalizedEagerObjectBase() { } | 1878 SimpleFinalizedEagerObjectBase() { } |
| 1877 }; | 1879 }; |
| 1878 | 1880 |
| 1879 class SimpleFinalizedEagerObject : public SimpleFinalizedEagerObjectBase { | 1881 class SimpleFinalizedEagerObject : public SimpleFinalizedEagerObjectBase { |
| 1880 public: | 1882 public: |
| 1881 static SimpleFinalizedEagerObject* create() | 1883 static SimpleFinalizedEagerObject* create() |
| 1882 { | 1884 { |
| 1883 return new SimpleFinalizedEagerObject(); | 1885 return new SimpleFinalizedEagerObject(); |
| 1884 } | 1886 } |
| 1885 | 1887 |
| 1886 virtual ~SimpleFinalizedEagerObject() | 1888 virtual ~SimpleFinalizedEagerObject() |
| 1887 { | 1889 { |
| 1888 ++s_destructorCalls; | 1890 ++s_destructorCalls; |
| 1889 } | 1891 } |
| 1890 | 1892 |
| 1891 static int s_destructorCalls; | 1893 static int s_destructorCalls; |
| 1892 private: | 1894 private: |
| 1893 SimpleFinalizedEagerObject() { } | 1895 SimpleFinalizedEagerObject() { } |
| 1894 }; | 1896 }; |
| 1895 | 1897 |
| 1898 template<typename T> |
| 1899 class ParameterizedButEmpty { |
| 1900 public: |
| 1901 EAGERLY_SWEEP(); |
| 1902 }; |
| 1903 |
| 1904 class SimpleFinalizedObjectInstanceOfTemplate final : public GarbageCollectedFin
alized<SimpleFinalizedObjectInstanceOfTemplate>, public ParameterizedButEmpty<Si
mpleFinalizedObjectInstanceOfTemplate> { |
| 1905 public: |
| 1906 static SimpleFinalizedObjectInstanceOfTemplate* create() |
| 1907 { |
| 1908 return new SimpleFinalizedObjectInstanceOfTemplate(); |
| 1909 } |
| 1910 ~SimpleFinalizedObjectInstanceOfTemplate() |
| 1911 { |
| 1912 ++s_destructorCalls; |
| 1913 } |
| 1914 |
| 1915 DEFINE_INLINE_TRACE() { } |
| 1916 |
| 1917 static int s_destructorCalls; |
| 1918 private: |
| 1919 SimpleFinalizedObjectInstanceOfTemplate() { } |
| 1920 }; |
| 1921 |
| 1896 int SimpleFinalizedEagerObject::s_destructorCalls = 0; | 1922 int SimpleFinalizedEagerObject::s_destructorCalls = 0; |
| 1897 | 1923 int SimpleFinalizedObjectInstanceOfTemplate::s_destructorCalls = 0; |
| 1898 EAGERLY_SWEEP(SimpleFinalizedEagerObjectBase); | |
| 1899 | 1924 |
| 1900 TEST(HeapTest, EagerlySweepingPages) | 1925 TEST(HeapTest, EagerlySweepingPages) |
| 1901 { | 1926 { |
| 1902 clearOutOldGarbage(); | 1927 clearOutOldGarbage(); |
| 1903 | 1928 |
| 1904 SimpleFinalizedObject::s_destructorCalls = 0; | 1929 SimpleFinalizedObject::s_destructorCalls = 0; |
| 1905 SimpleFinalizedEagerObject::s_destructorCalls = 0; | 1930 SimpleFinalizedEagerObject::s_destructorCalls = 0; |
| 1931 SimpleFinalizedObjectInstanceOfTemplate::s_destructorCalls = 0; |
| 1906 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls); | 1932 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls); |
| 1907 EXPECT_EQ(0, SimpleFinalizedEagerObject::s_destructorCalls); | 1933 EXPECT_EQ(0, SimpleFinalizedEagerObject::s_destructorCalls); |
| 1908 for (int i = 0; i < 1000; i++) | 1934 for (int i = 0; i < 1000; i++) |
| 1909 SimpleFinalizedObject::create(); | 1935 SimpleFinalizedObject::create(); |
| 1910 for (int i = 0; i < 100; i++) | 1936 for (int i = 0; i < 100; i++) |
| 1911 SimpleFinalizedEagerObject::create(); | 1937 SimpleFinalizedEagerObject::create(); |
| 1938 for (int i = 0; i < 100; i++) |
| 1939 SimpleFinalizedObjectInstanceOfTemplate::create(); |
| 1912 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
outSweep, Heap::ForcedGC); | 1940 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadState::GCWith
outSweep, Heap::ForcedGC); |
| 1913 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls); | 1941 EXPECT_EQ(0, SimpleFinalizedObject::s_destructorCalls); |
| 1914 EXPECT_EQ(100, SimpleFinalizedEagerObject::s_destructorCalls); | 1942 EXPECT_EQ(100, SimpleFinalizedEagerObject::s_destructorCalls); |
| 1943 EXPECT_EQ(100, SimpleFinalizedObjectInstanceOfTemplate::s_destructorCalls); |
| 1915 } | 1944 } |
| 1916 #endif | 1945 #endif |
| 1917 | 1946 |
| 1918 TEST(HeapTest, Finalization) | 1947 TEST(HeapTest, Finalization) |
| 1919 { | 1948 { |
| 1920 { | 1949 { |
| 1921 HeapTestSubClass* t1 = HeapTestSubClass::create(); | 1950 HeapTestSubClass* t1 = HeapTestSubClass::create(); |
| 1922 HeapTestSubClass* t2 = HeapTestSubClass::create(); | 1951 HeapTestSubClass* t2 = HeapTestSubClass::create(); |
| 1923 HeapTestSuperClass* t3 = HeapTestSuperClass::create(); | 1952 HeapTestSuperClass* t3 = HeapTestSuperClass::create(); |
| 1924 // FIXME(oilpan): Ignore unused variables. | 1953 // FIXME(oilpan): Ignore unused variables. |
| (...skipping 4157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6082 { | 6111 { |
| 6083 Persistent<ClassWithMember> object = ClassWithMember::create(); | 6112 Persistent<ClassWithMember> object = ClassWithMember::create(); |
| 6084 EXPECT_EQ(0, object->traceCount()); | 6113 EXPECT_EQ(0, object->traceCount()); |
| 6085 TestMixinAllocatingObject* mixin = TestMixinAllocatingObject::create(object.
get()); | 6114 TestMixinAllocatingObject* mixin = TestMixinAllocatingObject::create(object.
get()); |
| 6086 EXPECT_TRUE(mixin); | 6115 EXPECT_TRUE(mixin); |
| 6087 EXPECT_GT(object->traceCount(), 0); | 6116 EXPECT_GT(object->traceCount(), 0); |
| 6088 EXPECT_GT(mixin->traceCount(), 0); | 6117 EXPECT_GT(mixin->traceCount(), 0); |
| 6089 } | 6118 } |
| 6090 | 6119 |
| 6091 } // namespace blink | 6120 } // namespace blink |
| OLD | NEW |