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