| 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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 | 791 |
| 792 void trace(Visitor* visitor) | 792 void trace(Visitor* visitor) |
| 793 { | 793 { |
| 794 #if ENABLE_OILPAN | 794 #if ENABLE_OILPAN |
| 795 visitor->trace(m_backPointer); | 795 visitor->trace(m_backPointer); |
| 796 #endif | 796 #endif |
| 797 } | 797 } |
| 798 | 798 |
| 799 static int s_aliveCount; | 799 static int s_aliveCount; |
| 800 private: | 800 private: |
| 801 PointsBack() : m_backPointer(0) | 801 PointsBack() : m_backPointer(nullptr) |
| 802 { | 802 { |
| 803 ++s_aliveCount; | 803 ++s_aliveCount; |
| 804 } | 804 } |
| 805 | 805 |
| 806 RawPtrWillBeWeakMember<SuperClass> m_backPointer; | 806 RawPtrWillBeWeakMember<SuperClass> m_backPointer; |
| 807 }; | 807 }; |
| 808 | 808 |
| 809 int PointsBack::s_aliveCount = 0; | 809 int PointsBack::s_aliveCount = 0; |
| 810 | 810 |
| 811 class SuperClass : public RefCountedWillBeGarbageCollectedFinalized<SuperClass>
{ | 811 class SuperClass : public RefCountedWillBeGarbageCollectedFinalized<SuperClass>
{ |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 weakSet->add(IntWrapper::create(0)); | 1811 weakSet->add(IntWrapper::create(0)); |
| 1812 weakSet->add(two); | 1812 weakSet->add(two); |
| 1813 weakSet->add(keepNumbersAlive[0]); | 1813 weakSet->add(keepNumbersAlive[0]); |
| 1814 weakSet->add(keepNumbersAlive[1]); | 1814 weakSet->add(keepNumbersAlive[1]); |
| 1815 EXPECT_EQ(1u, weakStrong->size()); | 1815 EXPECT_EQ(1u, weakStrong->size()); |
| 1816 EXPECT_EQ(1u, strongWeak->size()); | 1816 EXPECT_EQ(1u, strongWeak->size()); |
| 1817 EXPECT_EQ(2u, weakWeak->size()); | 1817 EXPECT_EQ(2u, weakWeak->size()); |
| 1818 EXPECT_EQ(4u, weakSet->size()); | 1818 EXPECT_EQ(4u, weakSet->size()); |
| 1819 } | 1819 } |
| 1820 | 1820 |
| 1821 keepNumbersAlive[0] = 0; | 1821 keepNumbersAlive[0] = nullptr; |
| 1822 | 1822 |
| 1823 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 1823 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
| 1824 | 1824 |
| 1825 EXPECT_EQ(0u, weakStrong->size()); | 1825 EXPECT_EQ(0u, weakStrong->size()); |
| 1826 EXPECT_EQ(0u, strongWeak->size()); | 1826 EXPECT_EQ(0u, strongWeak->size()); |
| 1827 EXPECT_EQ(0u, weakWeak->size()); | 1827 EXPECT_EQ(0u, weakWeak->size()); |
| 1828 EXPECT_EQ(2u, weakSet->size()); | 1828 EXPECT_EQ(2u, weakSet->size()); |
| 1829 } | 1829 } |
| 1830 | 1830 |
| 1831 TEST(HeapTest, HeapWeakCollectionTypes) | 1831 TEST(HeapTest, HeapWeakCollectionTypes) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1895 for (int i = 0; i < 128; i += 2) { | 1895 for (int i = 0; i < 128; i += 2) { |
| 1896 IntWrapper* wrapped = keepNumbersAlive[i]; | 1896 IntWrapper* wrapped = keepNumbersAlive[i]; |
| 1897 IntWrapper* wrapped2 = keepNumbersAlive[i + 1]; | 1897 IntWrapper* wrapped2 = keepNumbersAlive[i + 1]; |
| 1898 EXPECT_EQ(wrapped2, weakStrong->get(wrapped)); | 1898 EXPECT_EQ(wrapped2, weakStrong->get(wrapped)); |
| 1899 EXPECT_EQ(wrapped, strongWeak->get(wrapped2)); | 1899 EXPECT_EQ(wrapped, strongWeak->get(wrapped2)); |
| 1900 EXPECT_EQ(wrapped2, weakWeak->get(wrapped)); | 1900 EXPECT_EQ(wrapped2, weakWeak->get(wrapped)); |
| 1901 EXPECT_TRUE(weakSet->contains(wrapped)); | 1901 EXPECT_TRUE(weakSet->contains(wrapped)); |
| 1902 } | 1902 } |
| 1903 | 1903 |
| 1904 for (int i = 0; i < 128; i += 3) | 1904 for (int i = 0; i < 128; i += 3) |
| 1905 keepNumbersAlive[i] = 0; | 1905 keepNumbersAlive[i] = nullptr; |
| 1906 | 1906 |
| 1907 if (collectionNumber != weakStrongIndex) | 1907 if (collectionNumber != weakStrongIndex) |
| 1908 weakStrong->clear(); | 1908 weakStrong->clear(); |
| 1909 if (collectionNumber != strongWeakIndex) | 1909 if (collectionNumber != strongWeakIndex) |
| 1910 strongWeak->clear(); | 1910 strongWeak->clear(); |
| 1911 if (collectionNumber != weakWeakIndex) | 1911 if (collectionNumber != weakWeakIndex) |
| 1912 weakWeak->clear(); | 1912 weakWeak->clear(); |
| 1913 if (collectionNumber != weakSetIndex) | 1913 if (collectionNumber != weakSetIndex) |
| 1914 weakSet->clear(); | 1914 weakSet->clear(); |
| 1915 | 1915 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1986 WeakStrong::iterator it1 = weakStrong->begin(); | 1986 WeakStrong::iterator it1 = weakStrong->begin(); |
| 1987 StrongWeak::iterator it2 = strongWeak->begin(); | 1987 StrongWeak::iterator it2 = strongWeak->begin(); |
| 1988 WeakWeak::iterator it3 = weakWeak->begin(); | 1988 WeakWeak::iterator it3 = weakWeak->begin(); |
| 1989 WeakSet::iterator it4 = weakSet->begin(); | 1989 WeakSet::iterator it4 = weakSet->begin(); |
| 1990 MapIteratorCheck(it1, weakStrong->end(), (collectionNumber == we
akStrongIndex ? count : 0) + added); | 1990 MapIteratorCheck(it1, weakStrong->end(), (collectionNumber == we
akStrongIndex ? count : 0) + added); |
| 1991 MapIteratorCheck(it2, strongWeak->end(), (collectionNumber == st
rongWeakIndex ? count : 0) + added); | 1991 MapIteratorCheck(it2, strongWeak->end(), (collectionNumber == st
rongWeakIndex ? count : 0) + added); |
| 1992 MapIteratorCheck(it3, weakWeak->end(), (collectionNumber == weak
WeakIndex ? count : 0) + added); | 1992 MapIteratorCheck(it3, weakWeak->end(), (collectionNumber == weak
WeakIndex ? count : 0) + added); |
| 1993 SetIteratorCheck(it4, weakSet->end(), (collectionNumber == weakS
etIndex ? count : 0) + added); | 1993 SetIteratorCheck(it4, weakSet->end(), (collectionNumber == weakS
etIndex ? count : 0) + added); |
| 1994 } | 1994 } |
| 1995 for (unsigned i = 0; i < 128 + added; i++) | 1995 for (unsigned i = 0; i < 128 + added; i++) |
| 1996 keepNumbersAlive[i] = 0; | 1996 keepNumbersAlive[i] = nullptr; |
| 1997 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 1997 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
| 1998 EXPECT_EQ(added, weakStrong->size()); | 1998 EXPECT_EQ(added, weakStrong->size()); |
| 1999 EXPECT_EQ(added, strongWeak->size()); | 1999 EXPECT_EQ(added, strongWeak->size()); |
| 2000 EXPECT_EQ(added, weakWeak->size()); | 2000 EXPECT_EQ(added, weakWeak->size()); |
| 2001 EXPECT_EQ(added, weakSet->size()); | 2001 EXPECT_EQ(added, weakSet->size()); |
| 2002 } | 2002 } |
| 2003 } | 2003 } |
| 2004 } | 2004 } |
| 2005 | 2005 |
| 2006 TEST(HeapTest, RefCountedGarbageCollected) | 2006 TEST(HeapTest, RefCountedGarbageCollected) |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2200 } | 2200 } |
| 2201 | 2201 |
| 2202 TEST(HeapTest, VisitOffHeapCollections) | 2202 TEST(HeapTest, VisitOffHeapCollections) |
| 2203 { | 2203 { |
| 2204 HeapStats initialHeapStats; | 2204 HeapStats initialHeapStats; |
| 2205 clearOutOldGarbage(&initialHeapStats); | 2205 clearOutOldGarbage(&initialHeapStats); |
| 2206 IntWrapper::s_destructorCalls = 0; | 2206 IntWrapper::s_destructorCalls = 0; |
| 2207 Persistent<OffHeapContainer> container = OffHeapContainer::create(); | 2207 Persistent<OffHeapContainer> container = OffHeapContainer::create(); |
| 2208 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 2208 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
| 2209 EXPECT_EQ(0, IntWrapper::s_destructorCalls); | 2209 EXPECT_EQ(0, IntWrapper::s_destructorCalls); |
| 2210 container = 0; | 2210 container = nullptr; |
| 2211 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 2211 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
| 2212 EXPECT_EQ(7, IntWrapper::s_destructorCalls); | 2212 EXPECT_EQ(7, IntWrapper::s_destructorCalls); |
| 2213 } | 2213 } |
| 2214 | 2214 |
| 2215 TEST(HeapTest, PersistentHeapCollectionTypes) | 2215 TEST(HeapTest, PersistentHeapCollectionTypes) |
| 2216 { | 2216 { |
| 2217 HeapStats initialHeapSize; | 2217 HeapStats initialHeapSize; |
| 2218 IntWrapper::s_destructorCalls = 0; | 2218 IntWrapper::s_destructorCalls = 0; |
| 2219 | 2219 |
| 2220 typedef HeapVector<Member<IntWrapper> > Vec; | 2220 typedef HeapVector<Member<IntWrapper> > Vec; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2304 DEFINE_GC_INFO(RefCountedAndGarbageCollected2); | 2304 DEFINE_GC_INFO(RefCountedAndGarbageCollected2); |
| 2305 DEFINE_GC_INFO(SimpleFinalizedObject); | 2305 DEFINE_GC_INFO(SimpleFinalizedObject); |
| 2306 DEFINE_GC_INFO(SimpleObject); | 2306 DEFINE_GC_INFO(SimpleObject); |
| 2307 DEFINE_GC_INFO(SuperClass); | 2307 DEFINE_GC_INFO(SuperClass); |
| 2308 DEFINE_GC_INFO(SubData); | 2308 DEFINE_GC_INFO(SubData); |
| 2309 DEFINE_GC_INFO(TestTypedHeapClass); | 2309 DEFINE_GC_INFO(TestTypedHeapClass); |
| 2310 DEFINE_GC_INFO(TraceCounter); | 2310 DEFINE_GC_INFO(TraceCounter); |
| 2311 DEFINE_GC_INFO(TransitionRefCounted); | 2311 DEFINE_GC_INFO(TransitionRefCounted); |
| 2312 | 2312 |
| 2313 } // namespace | 2313 } // namespace |
| OLD | NEW |