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