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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // not spread out too much over the address space which would blow | 58 // not spread out too much over the address space which would blow |
59 // away the page tables and lead to bad performance. | 59 // away the page tables and lead to bad performance. |
60 const size_t blinkPagesPerRegion = 10; | 60 const size_t blinkPagesPerRegion = 10; |
61 | 61 |
62 // Double precision floats are more efficient when 8 byte aligned, so we 8 byte | 62 // Double precision floats are more efficient when 8 byte aligned, so we 8 byte |
63 // align all allocations even on 32 bit. | 63 // align all allocations even on 32 bit. |
64 const size_t allocationGranularity = 8; | 64 const size_t allocationGranularity = 8; |
65 const size_t allocationMask = allocationGranularity - 1; | 65 const size_t allocationMask = allocationGranularity - 1; |
66 const size_t objectStartBitMapSize = (blinkPageSize + ((8 * allocationGranularit
y) - 1)) / (8 * allocationGranularity); | 66 const size_t objectStartBitMapSize = (blinkPageSize + ((8 * allocationGranularit
y) - 1)) / (8 * allocationGranularity); |
67 const size_t reservedForObjectBitMap = ((objectStartBitMapSize + allocationMask)
& ~allocationMask); | 67 const size_t reservedForObjectBitMap = ((objectStartBitMapSize + allocationMask)
& ~allocationMask); |
68 const size_t maxHeapObjectSize = 1 << 27; | 68 const size_t maxHeapObjectSizeLog2 = 27; |
| 69 const size_t maxHeapObjectSize = 1 << maxHeapObjectSizeLog2; |
69 | 70 |
70 const size_t markBitMask = 1; | 71 const size_t markBitMask = 1; |
71 const size_t freeListMask = 2; | 72 const size_t freeListMask = 2; |
72 // The dead bit is used for objects that have gone through a GC marking, but did | 73 // The dead bit is used for objects that have gone through a GC marking, but did |
73 // not get swept before a new GC started. In that case we set the dead bit on | 74 // not get swept before a new GC started. In that case we set the dead bit on |
74 // objects that were not marked in the previous GC to ensure we are not tracing | 75 // objects that were not marked in the previous GC to ensure we are not tracing |
75 // them via a conservatively found pointer. Tracing dead objects could lead to | 76 // them via a conservatively found pointer. Tracing dead objects could lead to |
76 // tracing of already finalized objects in another thread's heap which is a | 77 // tracing of already finalized objects in another thread's heap which is a |
77 // use-after-free situation. | 78 // use-after-free situation. |
78 const size_t deadBitMask = 4; | 79 const size_t deadBitMask = 4; |
| 80 #if ENABLE(GC_PROFILE_HEAP) |
| 81 const size_t heapObjectGenerations = 8; |
| 82 const size_t maxHeapObjectAge = heapObjectGenerations - 1; |
| 83 const size_t heapObjectAgeMask = ~(maxHeapObjectSize - 1); |
| 84 const size_t sizeMask = ~heapObjectAgeMask & ~static_cast<size_t>(7); |
| 85 #else |
79 const size_t sizeMask = ~static_cast<size_t>(7); | 86 const size_t sizeMask = ~static_cast<size_t>(7); |
| 87 #endif |
80 const uint8_t freelistZapValue = 42; | 88 const uint8_t freelistZapValue = 42; |
81 const uint8_t finalizedZapValue = 24; | 89 const uint8_t finalizedZapValue = 24; |
82 // The orphaned zap value must be zero in the lowest bits to allow for using | 90 // The orphaned zap value must be zero in the lowest bits to allow for using |
83 // the mark bit when tracing. | 91 // the mark bit when tracing. |
84 const uint8_t orphanedZapValue = 240; | 92 const uint8_t orphanedZapValue = 240; |
85 | 93 |
86 enum CallbackInvocationMode { | 94 enum CallbackInvocationMode { |
87 GlobalMarking, | 95 GlobalMarking, |
88 ThreadLocalMarking, | 96 ThreadLocalMarking, |
89 WeaknessProcessing, | 97 WeaknessProcessing, |
90 }; | 98 }; |
91 | 99 |
92 class HeapStats; | 100 class HeapStats; |
93 class PageMemory; | 101 class PageMemory; |
94 template<ThreadAffinity affinity> class ThreadLocalPersistents; | 102 template<ThreadAffinity affinity> class ThreadLocalPersistents; |
95 template<typename T, typename RootsAccessor = ThreadLocalPersistents<ThreadingTr
ait<T>::Affinity > > class Persistent; | 103 template<typename T, typename RootsAccessor = ThreadLocalPersistents<ThreadingTr
ait<T>::Affinity > > class Persistent; |
96 template<typename T> class CrossThreadPersistent; | 104 template<typename T> class CrossThreadPersistent; |
97 | 105 |
| 106 #if ENABLE(GC_PROFILE_HEAP) |
| 107 class TracedValue; |
| 108 #endif |
| 109 |
98 PLATFORM_EXPORT size_t osPageSize(); | 110 PLATFORM_EXPORT size_t osPageSize(); |
99 | 111 |
100 // Blink heap pages are set up with a guard page before and after the | 112 // Blink heap pages are set up with a guard page before and after the |
101 // payload. | 113 // payload. |
102 inline size_t blinkPagePayloadSize() | 114 inline size_t blinkPagePayloadSize() |
103 { | 115 { |
104 return blinkPageSize - 2 * osPageSize(); | 116 return blinkPageSize - 2 * osPageSize(); |
105 } | 117 } |
106 | 118 |
107 // Blink heap pages are aligned to the Blink heap page size. | 119 // Blink heap pages are aligned to the Blink heap page size. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 class LargeHeapObject : public BaseHeapPage { | 178 class LargeHeapObject : public BaseHeapPage { |
167 public: | 179 public: |
168 LargeHeapObject(PageMemory* storage, const GCInfo* gcInfo, ThreadState* stat
e) : BaseHeapPage(storage, gcInfo, state) | 180 LargeHeapObject(PageMemory* storage, const GCInfo* gcInfo, ThreadState* stat
e) : BaseHeapPage(storage, gcInfo, state) |
169 { | 181 { |
170 COMPILE_ASSERT(!(sizeof(LargeHeapObject<Header>) & allocationMask), larg
e_heap_object_header_misaligned); | 182 COMPILE_ASSERT(!(sizeof(LargeHeapObject<Header>) & allocationMask), larg
e_heap_object_header_misaligned); |
171 } | 183 } |
172 | 184 |
173 virtual void checkAndMarkPointer(Visitor*, Address) OVERRIDE; | 185 virtual void checkAndMarkPointer(Visitor*, Address) OVERRIDE; |
174 virtual bool isLargeObject() OVERRIDE { return true; } | 186 virtual bool isLargeObject() OVERRIDE { return true; } |
175 | 187 |
176 #if ENABLE(GC_TRACING) | 188 #if ENABLE(GC_PROFILE_MARKING) |
177 virtual const GCInfo* findGCInfo(Address address) | 189 virtual const GCInfo* findGCInfo(Address address) |
178 { | 190 { |
179 if (!objectContains(address)) | 191 if (!objectContains(address)) |
180 return 0; | 192 return 0; |
181 return gcInfo(); | 193 return gcInfo(); |
182 } | 194 } |
183 #endif | 195 #endif |
184 | 196 |
| 197 #if ENABLE(GC_PROFILE_HEAP) |
| 198 void snapshot(TracedValue*, ThreadState::SnapshotInfo*); |
| 199 #endif |
| 200 |
185 void link(LargeHeapObject<Header>** previousNext) | 201 void link(LargeHeapObject<Header>** previousNext) |
186 { | 202 { |
187 m_next = *previousNext; | 203 m_next = *previousNext; |
188 *previousNext = this; | 204 *previousNext = this; |
189 } | 205 } |
190 | 206 |
191 void unlink(LargeHeapObject<Header>** previousNext) | 207 void unlink(LargeHeapObject<Header>** previousNext) |
192 { | 208 { |
193 *previousNext = m_next; | 209 *previousNext = m_next; |
194 } | 210 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 : m_size(encodedSize) { } | 273 : m_size(encodedSize) { } |
258 | 274 |
259 static size_t freeListEncodedSize(size_t size) { return size | freeListMask;
} | 275 static size_t freeListEncodedSize(size_t size) { return size | freeListMask;
} |
260 | 276 |
261 NO_SANITIZE_ADDRESS | 277 NO_SANITIZE_ADDRESS |
262 bool isFree() { return m_size & freeListMask; } | 278 bool isFree() { return m_size & freeListMask; } |
263 | 279 |
264 NO_SANITIZE_ADDRESS | 280 NO_SANITIZE_ADDRESS |
265 size_t size() const { return m_size & sizeMask; } | 281 size_t size() const { return m_size & sizeMask; } |
266 | 282 |
| 283 #if ENABLE(GC_PROFILE_HEAP) |
| 284 NO_SANITIZE_ADDRESS |
| 285 size_t encodedSize() const { return m_size; } |
| 286 |
| 287 NO_SANITIZE_ADDRESS |
| 288 size_t age() const { return m_size >> maxHeapObjectSizeLog2; } |
| 289 |
| 290 NO_SANITIZE_ADDRESS |
| 291 void incAge() |
| 292 { |
| 293 size_t current = age(); |
| 294 if (current < maxHeapObjectAge) |
| 295 m_size = ((current + 1) << maxHeapObjectSizeLog2) | (m_size & ~heapO
bjectAgeMask); |
| 296 } |
| 297 #endif |
| 298 |
267 protected: | 299 protected: |
268 size_t m_size; | 300 size_t m_size; |
269 }; | 301 }; |
270 | 302 |
271 // Our heap object layout is layered with the HeapObjectHeader closest | 303 // Our heap object layout is layered with the HeapObjectHeader closest |
272 // to the payload, this can be wrapped in a FinalizedObjectHeader if the | 304 // to the payload, this can be wrapped in a FinalizedObjectHeader if the |
273 // object is on the GeneralHeap and not on a specific TypedHeap. | 305 // object is on the GeneralHeap and not on a specific TypedHeap. |
274 // Finally if the object is a large object (> blinkPageSize/2) then it is | 306 // Finally if the object is a large object (> blinkPageSize/2) then it is |
275 // wrapped with a LargeObjectHeader. | 307 // wrapped with a LargeObjectHeader. |
276 // | 308 // |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 } | 499 } |
468 | 500 |
469 Address end() { return payload() + payloadSize(); } | 501 Address end() { return payload() + payloadSize(); } |
470 | 502 |
471 void getStats(HeapStats&); | 503 void getStats(HeapStats&); |
472 void clearLiveAndMarkDead(); | 504 void clearLiveAndMarkDead(); |
473 void sweep(); | 505 void sweep(); |
474 void clearObjectStartBitMap(); | 506 void clearObjectStartBitMap(); |
475 void finalize(Header*); | 507 void finalize(Header*); |
476 virtual void checkAndMarkPointer(Visitor*, Address) OVERRIDE; | 508 virtual void checkAndMarkPointer(Visitor*, Address) OVERRIDE; |
477 #if ENABLE(GC_TRACING) | 509 #if ENABLE(GC_PROFILE_MARKING) |
478 const GCInfo* findGCInfo(Address) OVERRIDE; | 510 const GCInfo* findGCInfo(Address) OVERRIDE; |
479 #endif | 511 #endif |
| 512 #if ENABLE(GC_PROFILE_HEAP) |
| 513 virtual void snapshot(TracedValue*, ThreadState::SnapshotInfo*); |
| 514 #endif |
480 ThreadHeap<Header>* heap() { return m_heap; } | 515 ThreadHeap<Header>* heap() { return m_heap; } |
481 #if defined(ADDRESS_SANITIZER) | 516 #if defined(ADDRESS_SANITIZER) |
482 void poisonUnmarkedObjects(); | 517 void poisonUnmarkedObjects(); |
483 #endif | 518 #endif |
484 NO_SANITIZE_ADDRESS | 519 NO_SANITIZE_ADDRESS |
485 virtual void markOrphaned() | 520 virtual void markOrphaned() |
486 { | 521 { |
487 // Zap the payload with a recognizable value to detect any incorrect | 522 // Zap the payload with a recognizable value to detect any incorrect |
488 // cross thread pointer usage. | 523 // cross thread pointer usage. |
489 #if defined(ADDRESS_SANITIZER) | 524 #if defined(ADDRESS_SANITIZER) |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 class BaseHeap { | 834 class BaseHeap { |
800 public: | 835 public: |
801 virtual ~BaseHeap() { } | 836 virtual ~BaseHeap() { } |
802 virtual void cleanupPages() = 0; | 837 virtual void cleanupPages() = 0; |
803 | 838 |
804 // Find the page in this thread heap containing the given | 839 // Find the page in this thread heap containing the given |
805 // address. Returns 0 if the address is not contained in any | 840 // address. Returns 0 if the address is not contained in any |
806 // page in this thread heap. | 841 // page in this thread heap. |
807 virtual BaseHeapPage* heapPageFromAddress(Address) = 0; | 842 virtual BaseHeapPage* heapPageFromAddress(Address) = 0; |
808 | 843 |
809 #if ENABLE(GC_TRACING) | 844 #if ENABLE(GC_PROFILE_MARKING) |
810 virtual const GCInfo* findGCInfoOfLargeHeapObject(Address) = 0; | 845 virtual const GCInfo* findGCInfoOfLargeHeapObject(Address) = 0; |
811 #endif | 846 #endif |
812 | 847 |
| 848 #if ENABLE(GC_PROFILE_HEAP) |
| 849 virtual void snapshot(TracedValue*, ThreadState::SnapshotInfo*) = 0; |
| 850 #endif |
| 851 |
813 // Sweep this part of the Blink heap. This finalizes dead objects | 852 // Sweep this part of the Blink heap. This finalizes dead objects |
814 // and builds freelists for all the unused memory. | 853 // and builds freelists for all the unused memory. |
815 virtual void sweep() = 0; | 854 virtual void sweep() = 0; |
816 | 855 |
817 virtual void clearFreeLists() = 0; | 856 virtual void clearFreeLists() = 0; |
818 virtual void clearLiveAndMarkDead() = 0; | 857 virtual void clearLiveAndMarkDead() = 0; |
819 #if ENABLE(ASSERT) | 858 #if ENABLE(ASSERT) |
820 virtual void getScannedStats(HeapStats&) = 0; | 859 virtual void getScannedStats(HeapStats&) = 0; |
821 #endif | 860 #endif |
822 | 861 |
(...skipping 19 matching lines...) Expand all Loading... |
842 // objects during conservative stack scanning and to sweep the set of | 881 // objects during conservative stack scanning and to sweep the set of |
843 // pages after a GC. | 882 // pages after a GC. |
844 template<typename Header> | 883 template<typename Header> |
845 class ThreadHeap : public BaseHeap { | 884 class ThreadHeap : public BaseHeap { |
846 public: | 885 public: |
847 ThreadHeap(ThreadState*, int); | 886 ThreadHeap(ThreadState*, int); |
848 virtual ~ThreadHeap(); | 887 virtual ~ThreadHeap(); |
849 virtual void cleanupPages(); | 888 virtual void cleanupPages(); |
850 | 889 |
851 virtual BaseHeapPage* heapPageFromAddress(Address); | 890 virtual BaseHeapPage* heapPageFromAddress(Address); |
852 #if ENABLE(GC_TRACING) | 891 #if ENABLE(GC_PROFILE_MARKING) |
853 virtual const GCInfo* findGCInfoOfLargeHeapObject(Address); | 892 virtual const GCInfo* findGCInfoOfLargeHeapObject(Address); |
854 #endif | 893 #endif |
| 894 #if ENABLE(GC_PROFILE_HEAP) |
| 895 virtual void snapshot(TracedValue*, ThreadState::SnapshotInfo*); |
| 896 #endif |
855 virtual void sweep(); | 897 virtual void sweep(); |
856 virtual void clearFreeLists(); | 898 virtual void clearFreeLists(); |
857 virtual void clearLiveAndMarkDead(); | 899 virtual void clearLiveAndMarkDead(); |
858 #if ENABLE(ASSERT) | 900 #if ENABLE(ASSERT) |
859 virtual void getScannedStats(HeapStats&); | 901 virtual void getScannedStats(HeapStats&); |
860 #endif | 902 #endif |
861 | 903 |
862 virtual void makeConsistentForGC(); | 904 virtual void makeConsistentForGC(); |
863 virtual bool isConsistentForGC(); | 905 virtual bool isConsistentForGC(); |
864 | 906 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 template<CallbackInvocationMode Mode> static void processMarkingStack(); | 1014 template<CallbackInvocationMode Mode> static void processMarkingStack(); |
973 static void globalWeakProcessingAndCleanup(); | 1015 static void globalWeakProcessingAndCleanup(); |
974 static void setForcePreciseGCForTesting(); | 1016 static void setForcePreciseGCForTesting(); |
975 | 1017 |
976 static void prepareForGC(); | 1018 static void prepareForGC(); |
977 | 1019 |
978 // Conservatively checks whether an address is a pointer in any of the threa
d | 1020 // Conservatively checks whether an address is a pointer in any of the threa
d |
979 // heaps. If so marks the object pointed to as live. | 1021 // heaps. If so marks the object pointed to as live. |
980 static Address checkAndMarkPointer(Visitor*, Address); | 1022 static Address checkAndMarkPointer(Visitor*, Address); |
981 | 1023 |
982 #if ENABLE(GC_TRACING) | 1024 #if ENABLE(GC_PROFILE_MARKING) |
983 // Dump the path to specified object on the next GC. This method is to be in
voked from GDB. | 1025 // Dump the path to specified object on the next GC. This method is to be in
voked from GDB. |
984 static void dumpPathToObjectOnNextGC(void* p); | 1026 static void dumpPathToObjectOnNextGC(void* p); |
985 | 1027 |
986 // Forcibly find GCInfo of the object at Address. | 1028 // Forcibly find GCInfo of the object at Address. |
987 // This is slow and should only be used for debug purposes. | 1029 // This is slow and should only be used for debug purposes. |
988 // It involves finding the heap page and scanning the heap page for an objec
t header. | 1030 // It involves finding the heap page and scanning the heap page for an objec
t header. |
989 static const GCInfo* findGCInfo(Address); | 1031 static const GCInfo* findGCInfo(Address); |
990 | 1032 |
991 static String createBacktraceString(); | 1033 static String createBacktraceString(); |
992 #endif | 1034 #endif |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 template<typename Key, typename Value, typename T, typename U, typename V> | 1868 template<typename Key, typename Value, typename T, typename U, typename V> |
1827 struct GCInfoTrait<HashMap<Key, Value, T, U, V, HeapAllocator> > { | 1869 struct GCInfoTrait<HashMap<Key, Value, T, U, V, HeapAllocator> > { |
1828 static const GCInfo* get() | 1870 static const GCInfo* get() |
1829 { | 1871 { |
1830 typedef HashMap<Key, Value, T, U, V, HeapAllocator> TargetType; | 1872 typedef HashMap<Key, Value, T, U, V, HeapAllocator> TargetType; |
1831 static const GCInfo info = { | 1873 static const GCInfo info = { |
1832 TraceTrait<TargetType>::trace, | 1874 TraceTrait<TargetType>::trace, |
1833 0, | 1875 0, |
1834 false, // HashMap needs no finalizer. | 1876 false, // HashMap needs no finalizer. |
1835 WTF::IsPolymorphic<TargetType>::value, | 1877 WTF::IsPolymorphic<TargetType>::value, |
1836 #if ENABLE(GC_TRACING) | 1878 #if ENABLE(GC_PROFILING) |
1837 TypenameStringTrait<TargetType>::get() | 1879 TypenameStringTrait<TargetType>::get() |
1838 #endif | 1880 #endif |
1839 }; | 1881 }; |
1840 return &info; | 1882 return &info; |
1841 } | 1883 } |
1842 }; | 1884 }; |
1843 | 1885 |
1844 template<typename T, typename U, typename V> | 1886 template<typename T, typename U, typename V> |
1845 struct GCInfoTrait<HashSet<T, U, V, HeapAllocator> > { | 1887 struct GCInfoTrait<HashSet<T, U, V, HeapAllocator> > { |
1846 static const GCInfo* get() | 1888 static const GCInfo* get() |
1847 { | 1889 { |
1848 typedef HashSet<T, U, V, HeapAllocator> TargetType; | 1890 typedef HashSet<T, U, V, HeapAllocator> TargetType; |
1849 static const GCInfo info = { | 1891 static const GCInfo info = { |
1850 TraceTrait<TargetType>::trace, | 1892 TraceTrait<TargetType>::trace, |
1851 0, | 1893 0, |
1852 false, // HashSet needs no finalizer. | 1894 false, // HashSet needs no finalizer. |
1853 WTF::IsPolymorphic<TargetType>::value, | 1895 WTF::IsPolymorphic<TargetType>::value, |
1854 #if ENABLE(GC_TRACING) | 1896 #if ENABLE(GC_PROFILING) |
1855 TypenameStringTrait<TargetType>::get() | 1897 TypenameStringTrait<TargetType>::get() |
1856 #endif | 1898 #endif |
1857 }; | 1899 }; |
1858 return &info; | 1900 return &info; |
1859 } | 1901 } |
1860 }; | 1902 }; |
1861 | 1903 |
1862 template<typename T, typename U, typename V> | 1904 template<typename T, typename U, typename V> |
1863 struct GCInfoTrait<LinkedHashSet<T, U, V, HeapAllocator> > { | 1905 struct GCInfoTrait<LinkedHashSet<T, U, V, HeapAllocator> > { |
1864 static const GCInfo* get() | 1906 static const GCInfo* get() |
1865 { | 1907 { |
1866 typedef LinkedHashSet<T, U, V, HeapAllocator> TargetType; | 1908 typedef LinkedHashSet<T, U, V, HeapAllocator> TargetType; |
1867 static const GCInfo info = { | 1909 static const GCInfo info = { |
1868 TraceTrait<TargetType>::trace, | 1910 TraceTrait<TargetType>::trace, |
1869 LinkedHashSet<T, U, V, HeapAllocator>::finalize, | 1911 LinkedHashSet<T, U, V, HeapAllocator>::finalize, |
1870 true, // Needs finalization. The anchor needs to unlink itself from
the chain. | 1912 true, // Needs finalization. The anchor needs to unlink itself from
the chain. |
1871 WTF::IsPolymorphic<TargetType>::value, | 1913 WTF::IsPolymorphic<TargetType>::value, |
1872 #if ENABLE(GC_TRACING) | 1914 #if ENABLE(GC_PROFILING) |
1873 TypenameStringTrait<TargetType>::get() | 1915 TypenameStringTrait<TargetType>::get() |
1874 #endif | 1916 #endif |
1875 }; | 1917 }; |
1876 return &info; | 1918 return &info; |
1877 } | 1919 } |
1878 }; | 1920 }; |
1879 | 1921 |
1880 template<typename ValueArg, size_t inlineCapacity, typename U> | 1922 template<typename ValueArg, size_t inlineCapacity, typename U> |
1881 struct GCInfoTrait<ListHashSet<ValueArg, inlineCapacity, U, HeapListHashSetAlloc
ator<ValueArg, inlineCapacity> > > { | 1923 struct GCInfoTrait<ListHashSet<ValueArg, inlineCapacity, U, HeapListHashSetAlloc
ator<ValueArg, inlineCapacity> > > { |
1882 static const GCInfo* get() | 1924 static const GCInfo* get() |
1883 { | 1925 { |
1884 typedef WTF::ListHashSet<ValueArg, inlineCapacity, U, HeapListHashSetAll
ocator<ValueArg, inlineCapacity> > TargetType; | 1926 typedef WTF::ListHashSet<ValueArg, inlineCapacity, U, HeapListHashSetAll
ocator<ValueArg, inlineCapacity> > TargetType; |
1885 static const GCInfo info = { | 1927 static const GCInfo info = { |
1886 TraceTrait<TargetType>::trace, | 1928 TraceTrait<TargetType>::trace, |
1887 0, | 1929 0, |
1888 false, // ListHashSet needs no finalization though its backing might
. | 1930 false, // ListHashSet needs no finalization though its backing might
. |
1889 false, // no vtable. | 1931 false, // no vtable. |
1890 #if ENABLE(GC_TRACING) | 1932 #if ENABLE(GC_PROFILING) |
1891 TypenameStringTrait<TargetType>::get() | 1933 TypenameStringTrait<TargetType>::get() |
1892 #endif | 1934 #endif |
1893 }; | 1935 }; |
1894 return &info; | 1936 return &info; |
1895 } | 1937 } |
1896 }; | 1938 }; |
1897 | 1939 |
1898 template<typename T, typename Allocator> | 1940 template<typename T, typename Allocator> |
1899 struct GCInfoTrait<WTF::ListHashSetNode<T, Allocator> > { | 1941 struct GCInfoTrait<WTF::ListHashSetNode<T, Allocator> > { |
1900 static const GCInfo* get() | 1942 static const GCInfo* get() |
1901 { | 1943 { |
1902 typedef WTF::ListHashSetNode<T, Allocator> TargetType; | 1944 typedef WTF::ListHashSetNode<T, Allocator> TargetType; |
1903 static const GCInfo info = { | 1945 static const GCInfo info = { |
1904 TraceTrait<TargetType>::trace, | 1946 TraceTrait<TargetType>::trace, |
1905 TargetType::finalize, | 1947 TargetType::finalize, |
1906 WTF::HashTraits<T>::needsDestruction, // The node needs destruction
if its data does. | 1948 WTF::HashTraits<T>::needsDestruction, // The node needs destruction
if its data does. |
1907 false, // no vtable. | 1949 false, // no vtable. |
1908 #if ENABLE(GC_TRACING) | 1950 #if ENABLE(GC_PROFILING) |
1909 TypenameStringTrait<TargetType>::get() | 1951 TypenameStringTrait<TargetType>::get() |
1910 #endif | 1952 #endif |
1911 }; | 1953 }; |
1912 return &info; | 1954 return &info; |
1913 } | 1955 } |
1914 }; | 1956 }; |
1915 | 1957 |
1916 template<typename T> | 1958 template<typename T> |
1917 struct GCInfoTrait<Vector<T, 0, HeapAllocator> > { | 1959 struct GCInfoTrait<Vector<T, 0, HeapAllocator> > { |
1918 static const GCInfo* get() | 1960 static const GCInfo* get() |
1919 { | 1961 { |
1920 #if ENABLE(GC_TRACING) | 1962 #if ENABLE(GC_PROFILING) |
1921 typedef Vector<T, 0, HeapAllocator> TargetType; | 1963 typedef Vector<T, 0, HeapAllocator> TargetType; |
1922 #endif | 1964 #endif |
1923 static const GCInfo info = { | 1965 static const GCInfo info = { |
1924 TraceTrait<Vector<T, 0, HeapAllocator> >::trace, | 1966 TraceTrait<Vector<T, 0, HeapAllocator> >::trace, |
1925 0, | 1967 0, |
1926 false, // Vector needs no finalizer if it has no inline capacity. | 1968 false, // Vector needs no finalizer if it has no inline capacity. |
1927 WTF::IsPolymorphic<Vector<T, 0, HeapAllocator> >::value, | 1969 WTF::IsPolymorphic<Vector<T, 0, HeapAllocator> >::value, |
1928 #if ENABLE(GC_TRACING) | 1970 #if ENABLE(GC_PROFILING) |
1929 TypenameStringTrait<TargetType>::get() | 1971 TypenameStringTrait<TargetType>::get() |
1930 #endif | 1972 #endif |
1931 }; | 1973 }; |
1932 return &info; | 1974 return &info; |
1933 } | 1975 } |
1934 }; | 1976 }; |
1935 | 1977 |
1936 template<typename T, size_t inlineCapacity> | 1978 template<typename T, size_t inlineCapacity> |
1937 struct FinalizerTrait<Vector<T, inlineCapacity, HeapAllocator> > : public Finali
zerTraitImpl<Vector<T, inlineCapacity, HeapAllocator>, true> { }; | 1979 struct FinalizerTrait<Vector<T, inlineCapacity, HeapAllocator> > : public Finali
zerTraitImpl<Vector<T, inlineCapacity, HeapAllocator>, true> { }; |
1938 | 1980 |
1939 template<typename T, size_t inlineCapacity> | 1981 template<typename T, size_t inlineCapacity> |
1940 struct GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator> > { | 1982 struct GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator> > { |
1941 static const GCInfo* get() | 1983 static const GCInfo* get() |
1942 { | 1984 { |
1943 typedef Vector<T, inlineCapacity, HeapAllocator> TargetType; | 1985 typedef Vector<T, inlineCapacity, HeapAllocator> TargetType; |
1944 static const GCInfo info = { | 1986 static const GCInfo info = { |
1945 TraceTrait<TargetType>::trace, | 1987 TraceTrait<TargetType>::trace, |
1946 FinalizerTrait<TargetType>::finalize, | 1988 FinalizerTrait<TargetType>::finalize, |
1947 // Finalizer is needed to destruct things stored in the inline capac
ity. | 1989 // Finalizer is needed to destruct things stored in the inline capac
ity. |
1948 inlineCapacity && VectorTraits<T>::needsDestruction, | 1990 inlineCapacity && VectorTraits<T>::needsDestruction, |
1949 WTF::IsPolymorphic<TargetType>::value, | 1991 WTF::IsPolymorphic<TargetType>::value, |
1950 #if ENABLE(GC_TRACING) | 1992 #if ENABLE(GC_PROFILING) |
1951 TypenameStringTrait<TargetType>::get() | 1993 TypenameStringTrait<TargetType>::get() |
1952 #endif | 1994 #endif |
1953 }; | 1995 }; |
1954 return &info; | 1996 return &info; |
1955 } | 1997 } |
1956 }; | 1998 }; |
1957 | 1999 |
1958 template<typename T> | 2000 template<typename T> |
1959 struct GCInfoTrait<Deque<T, 0, HeapAllocator> > { | 2001 struct GCInfoTrait<Deque<T, 0, HeapAllocator> > { |
1960 static const GCInfo* get() | 2002 static const GCInfo* get() |
1961 { | 2003 { |
1962 typedef Deque<T, 0, HeapAllocator> TargetType; | 2004 typedef Deque<T, 0, HeapAllocator> TargetType; |
1963 static const GCInfo info = { | 2005 static const GCInfo info = { |
1964 TraceTrait<TargetType>::trace, | 2006 TraceTrait<TargetType>::trace, |
1965 0, | 2007 0, |
1966 false, // Deque needs no finalizer if it has no inline capacity. | 2008 false, // Deque needs no finalizer if it has no inline capacity. |
1967 WTF::IsPolymorphic<TargetType>::value, | 2009 WTF::IsPolymorphic<TargetType>::value, |
1968 #if ENABLE(GC_TRACING) | 2010 #if ENABLE(GC_PROFILING) |
1969 TypenameStringTrait<TargetType>::get() | 2011 TypenameStringTrait<TargetType>::get() |
1970 #endif | 2012 #endif |
1971 }; | 2013 }; |
1972 return &info; | 2014 return &info; |
1973 } | 2015 } |
1974 static const GCInfo info; | 2016 static const GCInfo info; |
1975 }; | 2017 }; |
1976 | 2018 |
1977 template<typename T, typename U, typename V> | 2019 template<typename T, typename U, typename V> |
1978 struct GCInfoTrait<HashCountedSet<T, U, V, HeapAllocator> > { | 2020 struct GCInfoTrait<HashCountedSet<T, U, V, HeapAllocator> > { |
1979 static const GCInfo* get() | 2021 static const GCInfo* get() |
1980 { | 2022 { |
1981 typedef HashCountedSet<T, U, V, HeapAllocator> TargetType; | 2023 typedef HashCountedSet<T, U, V, HeapAllocator> TargetType; |
1982 static const GCInfo info = { | 2024 static const GCInfo info = { |
1983 TraceTrait<TargetType>::trace, | 2025 TraceTrait<TargetType>::trace, |
1984 0, | 2026 0, |
1985 false, // HashCountedSet is just a HashTable, and needs no finalizer
. | 2027 false, // HashCountedSet is just a HashTable, and needs no finalizer
. |
1986 WTF::IsPolymorphic<TargetType>::value, | 2028 WTF::IsPolymorphic<TargetType>::value, |
1987 #if ENABLE(GC_TRACING) | 2029 #if ENABLE(GC_PROFILING) |
1988 TypenameStringTrait<TargetType>::get() | 2030 TypenameStringTrait<TargetType>::get() |
1989 #endif | 2031 #endif |
1990 }; | 2032 }; |
1991 return &info; | 2033 return &info; |
1992 } | 2034 } |
1993 static const GCInfo info; | 2035 static const GCInfo info; |
1994 }; | 2036 }; |
1995 | 2037 |
1996 template<typename T, size_t inlineCapacity> | 2038 template<typename T, size_t inlineCapacity> |
1997 struct FinalizerTrait<Deque<T, inlineCapacity, HeapAllocator> > : public Finaliz
erTraitImpl<Deque<T, inlineCapacity, HeapAllocator>, true> { }; | 2039 struct FinalizerTrait<Deque<T, inlineCapacity, HeapAllocator> > : public Finaliz
erTraitImpl<Deque<T, inlineCapacity, HeapAllocator>, true> { }; |
1998 | 2040 |
1999 template<typename T, size_t inlineCapacity> | 2041 template<typename T, size_t inlineCapacity> |
2000 struct GCInfoTrait<Deque<T, inlineCapacity, HeapAllocator> > { | 2042 struct GCInfoTrait<Deque<T, inlineCapacity, HeapAllocator> > { |
2001 static const GCInfo* get() | 2043 static const GCInfo* get() |
2002 { | 2044 { |
2003 typedef Deque<T, inlineCapacity, HeapAllocator> TargetType; | 2045 typedef Deque<T, inlineCapacity, HeapAllocator> TargetType; |
2004 static const GCInfo info = { | 2046 static const GCInfo info = { |
2005 TraceTrait<TargetType>::trace, | 2047 TraceTrait<TargetType>::trace, |
2006 FinalizerTrait<TargetType>::finalize, | 2048 FinalizerTrait<TargetType>::finalize, |
2007 // Finalizer is needed to destruct things stored in the inline capac
ity. | 2049 // Finalizer is needed to destruct things stored in the inline capac
ity. |
2008 inlineCapacity && VectorTraits<T>::needsDestruction, | 2050 inlineCapacity && VectorTraits<T>::needsDestruction, |
2009 WTF::IsPolymorphic<TargetType>::value, | 2051 WTF::IsPolymorphic<TargetType>::value, |
2010 #if ENABLE(GC_TRACING) | 2052 #if ENABLE(GC_PROFILING) |
2011 TypenameStringTrait<TargetType>::get() | 2053 TypenameStringTrait<TargetType>::get() |
2012 #endif | 2054 #endif |
2013 }; | 2055 }; |
2014 return &info; | 2056 return &info; |
2015 } | 2057 } |
2016 static const GCInfo info; | 2058 static const GCInfo info; |
2017 }; | 2059 }; |
2018 | 2060 |
2019 template<typename T, typename Traits> | 2061 template<typename T, typename Traits> |
2020 struct GCInfoTrait<HeapVectorBacking<T, Traits> > { | 2062 struct GCInfoTrait<HeapVectorBacking<T, Traits> > { |
2021 static const GCInfo* get() | 2063 static const GCInfo* get() |
2022 { | 2064 { |
2023 typedef HeapVectorBacking<T, Traits> TargetType; | 2065 typedef HeapVectorBacking<T, Traits> TargetType; |
2024 static const GCInfo info = { | 2066 static const GCInfo info = { |
2025 TraceTrait<TargetType>::trace, | 2067 TraceTrait<TargetType>::trace, |
2026 FinalizerTrait<TargetType>::finalize, | 2068 FinalizerTrait<TargetType>::finalize, |
2027 Traits::needsDestruction, | 2069 Traits::needsDestruction, |
2028 false, // We don't support embedded objects in HeapVectors with vtab
les. | 2070 false, // We don't support embedded objects in HeapVectors with vtab
les. |
2029 #if ENABLE(GC_TRACING) | 2071 #if ENABLE(GC_PROFILING) |
2030 TypenameStringTrait<TargetType>::get() | 2072 TypenameStringTrait<TargetType>::get() |
2031 #endif | 2073 #endif |
2032 }; | 2074 }; |
2033 return &info; | 2075 return &info; |
2034 } | 2076 } |
2035 }; | 2077 }; |
2036 | 2078 |
2037 template<typename Table> | 2079 template<typename Table> |
2038 struct GCInfoTrait<HeapHashTableBacking<Table> > { | 2080 struct GCInfoTrait<HeapHashTableBacking<Table> > { |
2039 static const GCInfo* get() | 2081 static const GCInfo* get() |
2040 { | 2082 { |
2041 typedef HeapHashTableBacking<Table> TargetType; | 2083 typedef HeapHashTableBacking<Table> TargetType; |
2042 static const GCInfo info = { | 2084 static const GCInfo info = { |
2043 TraceTrait<TargetType>::trace, | 2085 TraceTrait<TargetType>::trace, |
2044 HeapHashTableBacking<Table>::finalize, | 2086 HeapHashTableBacking<Table>::finalize, |
2045 Table::ValueTraits::needsDestruction, | 2087 Table::ValueTraits::needsDestruction, |
2046 WTF::IsPolymorphic<TargetType>::value, | 2088 WTF::IsPolymorphic<TargetType>::value, |
2047 #if ENABLE(GC_TRACING) | 2089 #if ENABLE(GC_PROFILING) |
2048 TypenameStringTrait<TargetType>::get() | 2090 TypenameStringTrait<TargetType>::get() |
2049 #endif | 2091 #endif |
2050 }; | 2092 }; |
2051 return &info; | 2093 return &info; |
2052 } | 2094 } |
2053 }; | 2095 }; |
2054 | 2096 |
2055 } // namespace blink | 2097 } // namespace blink |
2056 | 2098 |
2057 namespace WTF { | 2099 namespace WTF { |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2381 }; | 2423 }; |
2382 | 2424 |
2383 template<typename T> | 2425 template<typename T> |
2384 struct IfWeakMember<WeakMember<T> > { | 2426 struct IfWeakMember<WeakMember<T> > { |
2385 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit
or->isAlive(t.get()); } | 2427 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit
or->isAlive(t.get()); } |
2386 }; | 2428 }; |
2387 | 2429 |
2388 } | 2430 } |
2389 | 2431 |
2390 #endif // Heap_h | 2432 #endif // Heap_h |
OLD | NEW |