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 28 matching lines...) Expand all Loading... |
39 #include "wtf/Assertions.h" | 39 #include "wtf/Assertions.h" |
40 #include "wtf/HashCountedSet.h" | 40 #include "wtf/HashCountedSet.h" |
41 #include "wtf/LinkedHashSet.h" | 41 #include "wtf/LinkedHashSet.h" |
42 #include "wtf/ListHashSet.h" | 42 #include "wtf/ListHashSet.h" |
43 #include "wtf/OwnPtr.h" | 43 #include "wtf/OwnPtr.h" |
44 #include "wtf/PassRefPtr.h" | 44 #include "wtf/PassRefPtr.h" |
45 #include "wtf/ThreadSafeRefCounted.h" | 45 #include "wtf/ThreadSafeRefCounted.h" |
46 | 46 |
47 #include <stdint.h> | 47 #include <stdint.h> |
48 | 48 |
49 namespace WebCore { | 49 namespace blink { |
50 | 50 |
51 const size_t blinkPageSizeLog2 = 17; | 51 const size_t blinkPageSizeLog2 = 17; |
52 const size_t blinkPageSize = 1 << blinkPageSizeLog2; | 52 const size_t blinkPageSize = 1 << blinkPageSizeLog2; |
53 const size_t blinkPageOffsetMask = blinkPageSize - 1; | 53 const size_t blinkPageOffsetMask = blinkPageSize - 1; |
54 const size_t blinkPageBaseMask = ~blinkPageOffsetMask; | 54 const size_t blinkPageBaseMask = ~blinkPageOffsetMask; |
55 | 55 |
56 // We allocate pages at random addresses but in groups of | 56 // We allocate pages at random addresses but in groups of |
57 // blinkPagesPerRegion at a given random address. We group pages to | 57 // blinkPagesPerRegion at a given random address. We group pages to |
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. |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 return HeapTrait<T>::HeapType::roundedAllocationSize(count * sizeof(T)); | 1462 return HeapTrait<T>::HeapType::roundedAllocationSize(count * sizeof(T)); |
1463 } | 1463 } |
1464 static const size_t kMaxUnquantizedAllocation = maxHeapObjectSize; | 1464 static const size_t kMaxUnquantizedAllocation = maxHeapObjectSize; |
1465 }; | 1465 }; |
1466 | 1466 |
1467 // This is a static-only class used as a trait on collections to make them heap
allocated. | 1467 // This is a static-only class used as a trait on collections to make them heap
allocated. |
1468 // However see also HeapListHashSetAllocator. | 1468 // However see also HeapListHashSetAllocator. |
1469 class HeapAllocator { | 1469 class HeapAllocator { |
1470 public: | 1470 public: |
1471 typedef HeapAllocatorQuantizer Quantizer; | 1471 typedef HeapAllocatorQuantizer Quantizer; |
1472 typedef WebCore::Visitor Visitor; | 1472 typedef blink::Visitor Visitor; |
1473 static const bool isGarbageCollected = true; | 1473 static const bool isGarbageCollected = true; |
1474 | 1474 |
1475 template <typename Return, typename Metadata> | 1475 template <typename Return, typename Metadata> |
1476 static Return backingMalloc(size_t size) | 1476 static Return backingMalloc(size_t size) |
1477 { | 1477 { |
1478 return malloc<Return, Metadata>(size); | 1478 return malloc<Return, Metadata>(size); |
1479 } | 1479 } |
1480 template <typename Return, typename Metadata> | 1480 template <typename Return, typename Metadata> |
1481 static Return zeroedBackingMalloc(size_t size) | 1481 static Return zeroedBackingMalloc(size_t size) |
1482 { | 1482 { |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2039 Table::ValueTraits::needsDestruction, | 2039 Table::ValueTraits::needsDestruction, |
2040 WTF::IsPolymorphic<TargetType>::value, | 2040 WTF::IsPolymorphic<TargetType>::value, |
2041 #if ENABLE(GC_TRACING) | 2041 #if ENABLE(GC_TRACING) |
2042 TypenameStringTrait<TargetType>::get() | 2042 TypenameStringTrait<TargetType>::get() |
2043 #endif | 2043 #endif |
2044 }; | 2044 }; |
2045 return &info; | 2045 return &info; |
2046 } | 2046 } |
2047 }; | 2047 }; |
2048 | 2048 |
2049 } // namespace WebCore | 2049 } // namespace blink |
2050 | 2050 |
2051 namespace WTF { | 2051 namespace WTF { |
2052 | 2052 |
2053 // Catch-all for types that have a way to trace that don't have special | 2053 // Catch-all for types that have a way to trace that don't have special |
2054 // handling for weakness in collections. This means that if this type | 2054 // handling for weakness in collections. This means that if this type |
2055 // contains WeakMember fields, they will simply be zeroed, but the entry | 2055 // contains WeakMember fields, they will simply be zeroed, but the entry |
2056 // will not be removed from the collection. This always happens for | 2056 // will not be removed from the collection. This always happens for |
2057 // things in vectors, which don't currently support special handling of | 2057 // things in vectors, which don't currently support special handling of |
2058 // weak elements. | 2058 // weak elements. |
2059 template<ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Trai
ts> | 2059 template<ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Trai
ts> |
2060 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, T, Traits>
{ | 2060 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, T, Traits>
{ |
2061 static bool trace(WebCore::Visitor* visitor, T& t) | 2061 static bool trace(blink::Visitor* visitor, T& t) |
2062 { | 2062 { |
2063 WebCore::TraceTrait<T>::trace(visitor, &t); | 2063 blink::TraceTrait<T>::trace(visitor, &t); |
2064 return false; | 2064 return false; |
2065 } | 2065 } |
2066 }; | 2066 }; |
2067 | 2067 |
2068 // Catch-all for things that have HashTrait support for tracing with weakness. | 2068 // Catch-all for things that have HashTrait support for tracing with weakness. |
2069 template<ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Trai
ts> | 2069 template<ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Trai
ts> |
2070 struct TraceInCollectionTrait<WeakHandlingInCollections, strongify, T, Traits> { | 2070 struct TraceInCollectionTrait<WeakHandlingInCollections, strongify, T, Traits> { |
2071 static bool trace(WebCore::Visitor* visitor, T& t) | 2071 static bool trace(blink::Visitor* visitor, T& t) |
2072 { | 2072 { |
2073 return Traits::traceInCollection(visitor, t, strongify); | 2073 return Traits::traceInCollection(visitor, t, strongify); |
2074 } | 2074 } |
2075 }; | 2075 }; |
2076 | 2076 |
2077 // Vector backing that needs marking. We don't support weak members in vectors. | 2077 // Vector backing that needs marking. We don't support weak members in vectors. |
2078 template<ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Trai
ts> | 2078 template<ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Trai
ts> |
2079 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, WebCore::H
eapVectorBacking<T, Traits>, void> { | 2079 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, blink::Hea
pVectorBacking<T, Traits>, void> { |
2080 static bool trace(WebCore::Visitor* visitor, void* self) | 2080 static bool trace(blink::Visitor* visitor, void* self) |
2081 { | 2081 { |
2082 // The allocator can oversize the allocation a little, according to | 2082 // The allocator can oversize the allocation a little, according to |
2083 // the allocation granularity. The extra size is included in the | 2083 // the allocation granularity. The extra size is included in the |
2084 // payloadSize call below, since there is nowhere to store the | 2084 // payloadSize call below, since there is nowhere to store the |
2085 // originally allocated memory. This assert ensures that visiting the | 2085 // originally allocated memory. This assert ensures that visiting the |
2086 // last bit of memory can't cause trouble. | 2086 // last bit of memory can't cause trouble. |
2087 COMPILE_ASSERT(!ShouldBeTraced<Traits>::value || sizeof(T) > WebCore::al
locationGranularity || Traits::canInitializeWithMemset, HeapOverallocationCanCau
seSpuriousVisits); | 2087 COMPILE_ASSERT(!ShouldBeTraced<Traits>::value || sizeof(T) > blink::allo
cationGranularity || Traits::canInitializeWithMemset, HeapOverallocationCanCause
SpuriousVisits); |
2088 | 2088 |
2089 T* array = reinterpret_cast<T*>(self); | 2089 T* array = reinterpret_cast<T*>(self); |
2090 WebCore::FinalizedHeapObjectHeader* header = WebCore::FinalizedHeapObjec
tHeader::fromPayload(self); | 2090 blink::FinalizedHeapObjectHeader* header = blink::FinalizedHeapObjectHea
der::fromPayload(self); |
2091 // Use the payload size as recorded by the heap to determine how many | 2091 // Use the payload size as recorded by the heap to determine how many |
2092 // elements to mark. | 2092 // elements to mark. |
2093 size_t length = header->payloadSize() / sizeof(T); | 2093 size_t length = header->payloadSize() / sizeof(T); |
2094 for (size_t i = 0; i < length; i++) | 2094 for (size_t i = 0; i < length; i++) |
2095 WebCore::CollectionBackingTraceTrait<ShouldBeTraced<Traits>::value,
Traits::weakHandlingFlag, WeakPointersActStrong, T, Traits>::trace(visitor, arra
y[i]); | 2095 blink::CollectionBackingTraceTrait<ShouldBeTraced<Traits>::value, Tr
aits::weakHandlingFlag, WeakPointersActStrong, T, Traits>::trace(visitor, array[
i]); |
2096 return false; | 2096 return false; |
2097 } | 2097 } |
2098 }; | 2098 }; |
2099 | 2099 |
2100 // Almost all hash table backings are visited with this specialization. | 2100 // Almost all hash table backings are visited with this specialization. |
2101 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Table> | 2101 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Table> |
2102 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, WebCore::H
eapHashTableBacking<Table>, void> { | 2102 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, blink::Hea
pHashTableBacking<Table>, void> { |
2103 typedef typename Table::ValueType Value; | 2103 typedef typename Table::ValueType Value; |
2104 typedef typename Table::ValueTraits Traits; | 2104 typedef typename Table::ValueTraits Traits; |
2105 static bool trace(WebCore::Visitor* visitor, void* self) | 2105 static bool trace(blink::Visitor* visitor, void* self) |
2106 { | 2106 { |
2107 Value* array = reinterpret_cast<Value*>(self); | 2107 Value* array = reinterpret_cast<Value*>(self); |
2108 WebCore::FinalizedHeapObjectHeader* header = WebCore::FinalizedHeapObjec
tHeader::fromPayload(self); | 2108 blink::FinalizedHeapObjectHeader* header = blink::FinalizedHeapObjectHea
der::fromPayload(self); |
2109 size_t length = header->payloadSize() / sizeof(Value); | 2109 size_t length = header->payloadSize() / sizeof(Value); |
2110 for (size_t i = 0; i < length; i++) { | 2110 for (size_t i = 0; i < length; i++) { |
2111 if (!HashTableHelper<Value, typename Table::ExtractorType, typename
Table::KeyTraitsType>::isEmptyOrDeletedBucket(array[i])) | 2111 if (!HashTableHelper<Value, typename Table::ExtractorType, typename
Table::KeyTraitsType>::isEmptyOrDeletedBucket(array[i])) |
2112 WebCore::CollectionBackingTraceTrait<ShouldBeTraced<Traits>::val
ue, Traits::weakHandlingFlag, strongify, Value, Traits>::trace(visitor, array[i]
); | 2112 blink::CollectionBackingTraceTrait<ShouldBeTraced<Traits>::value
, Traits::weakHandlingFlag, strongify, Value, Traits>::trace(visitor, array[i]); |
2113 } | 2113 } |
2114 return false; | 2114 return false; |
2115 } | 2115 } |
2116 }; | 2116 }; |
2117 | 2117 |
2118 // This specialization of TraceInCollectionTrait is for the backing of | 2118 // This specialization of TraceInCollectionTrait is for the backing of |
2119 // HeapListHashSet. This is for the case that we find a reference to the | 2119 // HeapListHashSet. This is for the case that we find a reference to the |
2120 // backing from the stack. That probably means we have a GC while we are in a | 2120 // backing from the stack. That probably means we have a GC while we are in a |
2121 // ListHashSet method since normal API use does not put pointers to the backing | 2121 // ListHashSet method since normal API use does not put pointers to the backing |
2122 // on the stack. | 2122 // on the stack. |
2123 template<ShouldWeakPointersBeMarkedStrongly strongify, typename NodeContents, si
ze_t inlineCapacity, typename T, typename U, typename V, typename W, typename X,
typename Y> | 2123 template<ShouldWeakPointersBeMarkedStrongly strongify, typename NodeContents, si
ze_t inlineCapacity, typename T, typename U, typename V, typename W, typename X,
typename Y> |
2124 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, WebCore::H
eapHashTableBacking<HashTable<ListHashSetNode<NodeContents, WebCore::HeapListHas
hSetAllocator<T, inlineCapacity> >*, U, V, W, X, Y, WebCore::HeapAllocator> >, v
oid> { | 2124 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, blink::Hea
pHashTableBacking<HashTable<ListHashSetNode<NodeContents, blink::HeapListHashSet
Allocator<T, inlineCapacity> >*, U, V, W, X, Y, blink::HeapAllocator> >, void> { |
2125 typedef ListHashSetNode<NodeContents, WebCore::HeapListHashSetAllocator<T, i
nlineCapacity> > Node; | 2125 typedef ListHashSetNode<NodeContents, blink::HeapListHashSetAllocator<T, inl
ineCapacity> > Node; |
2126 typedef HashTable<Node*, U, V, W, X, Y, WebCore::HeapAllocator> Table; | 2126 typedef HashTable<Node*, U, V, W, X, Y, blink::HeapAllocator> Table; |
2127 static bool trace(WebCore::Visitor* visitor, void* self) | 2127 static bool trace(blink::Visitor* visitor, void* self) |
2128 { | 2128 { |
2129 Node** array = reinterpret_cast<Node**>(self); | 2129 Node** array = reinterpret_cast<Node**>(self); |
2130 WebCore::FinalizedHeapObjectHeader* header = WebCore::FinalizedHeapObjec
tHeader::fromPayload(self); | 2130 blink::FinalizedHeapObjectHeader* header = blink::FinalizedHeapObjectHea
der::fromPayload(self); |
2131 size_t length = header->payloadSize() / sizeof(Node*); | 2131 size_t length = header->payloadSize() / sizeof(Node*); |
2132 for (size_t i = 0; i < length; i++) { | 2132 for (size_t i = 0; i < length; i++) { |
2133 if (!HashTableHelper<Node*, typename Table::ExtractorType, typename
Table::KeyTraitsType>::isEmptyOrDeletedBucket(array[i])) { | 2133 if (!HashTableHelper<Node*, typename Table::ExtractorType, typename
Table::KeyTraitsType>::isEmptyOrDeletedBucket(array[i])) { |
2134 traceListHashSetValue(visitor, array[i]->m_value); | 2134 traceListHashSetValue(visitor, array[i]->m_value); |
2135 // Just mark the node without tracing because we already traced | 2135 // Just mark the node without tracing because we already traced |
2136 // the contents, and there is no need to trace the next and | 2136 // the contents, and there is no need to trace the next and |
2137 // prev fields since iterating over the hash table backing will | 2137 // prev fields since iterating over the hash table backing will |
2138 // find the whole chain. | 2138 // find the whole chain. |
2139 visitor->markNoTracing(array[i]); | 2139 visitor->markNoTracing(array[i]); |
2140 } | 2140 } |
2141 } | 2141 } |
2142 return false; | 2142 return false; |
2143 } | 2143 } |
2144 }; | 2144 }; |
2145 | 2145 |
2146 // Key value pairs, as used in HashMap. To disambiguate template choice we have | 2146 // Key value pairs, as used in HashMap. To disambiguate template choice we have |
2147 // to have two versions, first the one with no special weak handling, then the | 2147 // to have two versions, first the one with no special weak handling, then the |
2148 // one with weak handling. | 2148 // one with weak handling. |
2149 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Key, typename Va
lue, typename Traits> | 2149 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Key, typename Va
lue, typename Traits> |
2150 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, KeyValuePa
ir<Key, Value>, Traits> { | 2150 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, KeyValuePa
ir<Key, Value>, Traits> { |
2151 static bool trace(WebCore::Visitor* visitor, KeyValuePair<Key, Value>& self) | 2151 static bool trace(blink::Visitor* visitor, KeyValuePair<Key, Value>& self) |
2152 { | 2152 { |
2153 ASSERT(ShouldBeTraced<Traits>::value); | 2153 ASSERT(ShouldBeTraced<Traits>::value); |
2154 WebCore::CollectionBackingTraceTrait<ShouldBeTraced<typename Traits::Key
Traits>::value, NoWeakHandlingInCollections, strongify, Key, typename Traits::Ke
yTraits>::trace(visitor, self.key); | 2154 blink::CollectionBackingTraceTrait<ShouldBeTraced<typename Traits::KeyTr
aits>::value, NoWeakHandlingInCollections, strongify, Key, typename Traits::KeyT
raits>::trace(visitor, self.key); |
2155 WebCore::CollectionBackingTraceTrait<ShouldBeTraced<typename Traits::Val
ueTraits>::value, NoWeakHandlingInCollections, strongify, Value, typename Traits
::ValueTraits>::trace(visitor, self.value); | 2155 blink::CollectionBackingTraceTrait<ShouldBeTraced<typename Traits::Value
Traits>::value, NoWeakHandlingInCollections, strongify, Value, typename Traits::
ValueTraits>::trace(visitor, self.value); |
2156 return false; | 2156 return false; |
2157 } | 2157 } |
2158 }; | 2158 }; |
2159 | 2159 |
2160 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Key, typename Va
lue, typename Traits> | 2160 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Key, typename Va
lue, typename Traits> |
2161 struct TraceInCollectionTrait<WeakHandlingInCollections, strongify, KeyValuePair
<Key, Value>, Traits> { | 2161 struct TraceInCollectionTrait<WeakHandlingInCollections, strongify, KeyValuePair
<Key, Value>, Traits> { |
2162 static bool trace(WebCore::Visitor* visitor, KeyValuePair<Key, Value>& self) | 2162 static bool trace(blink::Visitor* visitor, KeyValuePair<Key, Value>& self) |
2163 { | 2163 { |
2164 // This is the core of the ephemeron-like functionality. If there is | 2164 // This is the core of the ephemeron-like functionality. If there is |
2165 // weakness on the key side then we first check whether there are | 2165 // weakness on the key side then we first check whether there are |
2166 // dead weak pointers on that side, and if there are we don't mark the | 2166 // dead weak pointers on that side, and if there are we don't mark the |
2167 // value side (yet). Conversely if there is weakness on the value side | 2167 // value side (yet). Conversely if there is weakness on the value side |
2168 // we check that first and don't mark the key side yet if we find dead | 2168 // we check that first and don't mark the key side yet if we find dead |
2169 // weak pointers. | 2169 // weak pointers. |
2170 // Corner case: If there is weakness on both the key and value side, | 2170 // Corner case: If there is weakness on both the key and value side, |
2171 // and there are also strong pointers on the both sides then we could | 2171 // and there are also strong pointers on the both sides then we could |
2172 // unexpectedly leak. The scenario is that the weak pointer on the key | 2172 // unexpectedly leak. The scenario is that the weak pointer on the key |
2173 // side is alive, which causes the strong pointer on the key side to be | 2173 // side is alive, which causes the strong pointer on the key side to be |
2174 // marked. If that then results in the object pointed to by the weak | 2174 // marked. If that then results in the object pointed to by the weak |
2175 // pointer on the value side being marked live, then the whole | 2175 // pointer on the value side being marked live, then the whole |
2176 // key-value entry is leaked. To avoid unexpected leaking, we disallow | 2176 // key-value entry is leaked. To avoid unexpected leaking, we disallow |
2177 // this case, but if you run into this assert, please reach out to Blink | 2177 // this case, but if you run into this assert, please reach out to Blink |
2178 // reviewers, and we may relax it. | 2178 // reviewers, and we may relax it. |
2179 const bool keyIsWeak = Traits::KeyTraits::weakHandlingFlag == WeakHandli
ngInCollections; | 2179 const bool keyIsWeak = Traits::KeyTraits::weakHandlingFlag == WeakHandli
ngInCollections; |
2180 const bool valueIsWeak = Traits::ValueTraits::weakHandlingFlag == WeakHa
ndlingInCollections; | 2180 const bool valueIsWeak = Traits::ValueTraits::weakHandlingFlag == WeakHa
ndlingInCollections; |
2181 const bool keyHasStrongRefs = ShouldBeTraced<typename Traits::KeyTraits>
::value; | 2181 const bool keyHasStrongRefs = ShouldBeTraced<typename Traits::KeyTraits>
::value; |
2182 const bool valueHasStrongRefs = ShouldBeTraced<typename Traits::ValueTra
its>::value; | 2182 const bool valueHasStrongRefs = ShouldBeTraced<typename Traits::ValueTra
its>::value; |
2183 COMPILE_ASSERT(!keyIsWeak || !valueIsWeak || !keyHasStrongRefs || !value
HasStrongRefs, ThisConfigurationWasDisallowedToAvoidUnexpectedLeaks); | 2183 COMPILE_ASSERT(!keyIsWeak || !valueIsWeak || !keyHasStrongRefs || !value
HasStrongRefs, ThisConfigurationWasDisallowedToAvoidUnexpectedLeaks); |
2184 if ((valueIsWeak && !keyIsWeak) || (valueIsWeak && keyIsWeak && !valueHa
sStrongRefs)) { | 2184 if ((valueIsWeak && !keyIsWeak) || (valueIsWeak && keyIsWeak && !valueHa
sStrongRefs)) { |
2185 // Check value first. | 2185 // Check value first. |
2186 bool deadWeakObjectsFoundOnValueSide = WebCore::CollectionBackingTra
ceTrait<ShouldBeTraced<typename Traits::ValueTraits>::value, Traits::ValueTraits
::weakHandlingFlag, strongify, Value, typename Traits::ValueTraits>::trace(visit
or, self.value); | 2186 bool deadWeakObjectsFoundOnValueSide = blink::CollectionBackingTrace
Trait<ShouldBeTraced<typename Traits::ValueTraits>::value, Traits::ValueTraits::
weakHandlingFlag, strongify, Value, typename Traits::ValueTraits>::trace(visitor
, self.value); |
2187 if (deadWeakObjectsFoundOnValueSide) | 2187 if (deadWeakObjectsFoundOnValueSide) |
2188 return true; | 2188 return true; |
2189 return WebCore::CollectionBackingTraceTrait<ShouldBeTraced<typename
Traits::KeyTraits>::value, Traits::KeyTraits::weakHandlingFlag, strongify, Key,
typename Traits::KeyTraits>::trace(visitor, self.key); | 2189 return blink::CollectionBackingTraceTrait<ShouldBeTraced<typename Tr
aits::KeyTraits>::value, Traits::KeyTraits::weakHandlingFlag, strongify, Key, ty
pename Traits::KeyTraits>::trace(visitor, self.key); |
2190 } | 2190 } |
2191 // Check key first. | 2191 // Check key first. |
2192 bool deadWeakObjectsFoundOnKeySide = WebCore::CollectionBackingTraceTrai
t<ShouldBeTraced<typename Traits::KeyTraits>::value, Traits::KeyTraits::weakHand
lingFlag, strongify, Key, typename Traits::KeyTraits>::trace(visitor, self.key); | 2192 bool deadWeakObjectsFoundOnKeySide = blink::CollectionBackingTraceTrait<
ShouldBeTraced<typename Traits::KeyTraits>::value, Traits::KeyTraits::weakHandli
ngFlag, strongify, Key, typename Traits::KeyTraits>::trace(visitor, self.key); |
2193 if (deadWeakObjectsFoundOnKeySide) | 2193 if (deadWeakObjectsFoundOnKeySide) |
2194 return true; | 2194 return true; |
2195 return WebCore::CollectionBackingTraceTrait<ShouldBeTraced<typename Trai
ts::ValueTraits>::value, Traits::ValueTraits::weakHandlingFlag, strongify, Value
, typename Traits::ValueTraits>::trace(visitor, self.value); | 2195 return blink::CollectionBackingTraceTrait<ShouldBeTraced<typename Traits
::ValueTraits>::value, Traits::ValueTraits::weakHandlingFlag, strongify, Value,
typename Traits::ValueTraits>::trace(visitor, self.value); |
2196 } | 2196 } |
2197 }; | 2197 }; |
2198 | 2198 |
2199 // Nodes used by LinkedHashSet. Again we need two versions to disambiguate the | 2199 // Nodes used by LinkedHashSet. Again we need two versions to disambiguate the |
2200 // template. | 2200 // template. |
2201 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Value, typename
Traits> | 2201 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Value, typename
Traits> |
2202 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, LinkedHash
SetNode<Value>, Traits> { | 2202 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, LinkedHash
SetNode<Value>, Traits> { |
2203 static bool trace(WebCore::Visitor* visitor, LinkedHashSetNode<Value>& self) | 2203 static bool trace(blink::Visitor* visitor, LinkedHashSetNode<Value>& self) |
2204 { | 2204 { |
2205 ASSERT(ShouldBeTraced<Traits>::value); | 2205 ASSERT(ShouldBeTraced<Traits>::value); |
2206 WebCore::TraceTrait<Value>::trace(visitor, &self.m_value); | 2206 blink::TraceTrait<Value>::trace(visitor, &self.m_value); |
2207 return false; | 2207 return false; |
2208 } | 2208 } |
2209 }; | 2209 }; |
2210 | 2210 |
2211 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Value, typename
Traits> | 2211 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Value, typename
Traits> |
2212 struct TraceInCollectionTrait<WeakHandlingInCollections, strongify, LinkedHashSe
tNode<Value>, Traits> { | 2212 struct TraceInCollectionTrait<WeakHandlingInCollections, strongify, LinkedHashSe
tNode<Value>, Traits> { |
2213 static bool trace(WebCore::Visitor* visitor, LinkedHashSetNode<Value>& self) | 2213 static bool trace(blink::Visitor* visitor, LinkedHashSetNode<Value>& self) |
2214 { | 2214 { |
2215 return TraceInCollectionTrait<WeakHandlingInCollections, strongify, Valu
e, typename Traits::ValueTraits>::trace(visitor, self.m_value); | 2215 return TraceInCollectionTrait<WeakHandlingInCollections, strongify, Valu
e, typename Traits::ValueTraits>::trace(visitor, self.m_value); |
2216 } | 2216 } |
2217 }; | 2217 }; |
2218 | 2218 |
2219 // ListHashSetNode pointers (a ListHashSet is implemented as a hash table of the
se pointers). | 2219 // ListHashSetNode pointers (a ListHashSet is implemented as a hash table of the
se pointers). |
2220 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Value, size_t in
lineCapacity, typename Traits> | 2220 template<ShouldWeakPointersBeMarkedStrongly strongify, typename Value, size_t in
lineCapacity, typename Traits> |
2221 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, ListHashSe
tNode<Value, WebCore::HeapListHashSetAllocator<Value, inlineCapacity> >*, Traits
> { | 2221 struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, ListHashSe
tNode<Value, blink::HeapListHashSetAllocator<Value, inlineCapacity> >*, Traits>
{ |
2222 typedef ListHashSetNode<Value, WebCore::HeapListHashSetAllocator<Value, inli
neCapacity> > Node; | 2222 typedef ListHashSetNode<Value, blink::HeapListHashSetAllocator<Value, inline
Capacity> > Node; |
2223 static bool trace(WebCore::Visitor* visitor, Node* node) | 2223 static bool trace(blink::Visitor* visitor, Node* node) |
2224 { | 2224 { |
2225 traceListHashSetValue(visitor, node->m_value); | 2225 traceListHashSetValue(visitor, node->m_value); |
2226 // Just mark the node without tracing because we already traced the | 2226 // Just mark the node without tracing because we already traced the |
2227 // contents, and there is no need to trace the next and prev fields | 2227 // contents, and there is no need to trace the next and prev fields |
2228 // since iterating over the hash table backing will find the whole | 2228 // since iterating over the hash table backing will find the whole |
2229 // chain. | 2229 // chain. |
2230 visitor->markNoTracing(node); | 2230 visitor->markNoTracing(node); |
2231 return false; | 2231 return false; |
2232 } | 2232 } |
2233 }; | 2233 }; |
2234 | 2234 |
2235 } // namespace WTF | 2235 } // namespace WTF |
2236 | 2236 |
2237 namespace WebCore { | 2237 namespace blink { |
2238 | 2238 |
2239 // CollectionBackingTraceTrait. Do nothing for things in collections that don't | 2239 // CollectionBackingTraceTrait. Do nothing for things in collections that don't |
2240 // need tracing, or call TraceInCollectionTrait for those that do. | 2240 // need tracing, or call TraceInCollectionTrait for those that do. |
2241 | 2241 |
2242 // Specialization for things that don't need marking and have no weak pointers.
We | 2242 // Specialization for things that don't need marking and have no weak pointers.
We |
2243 // do nothing, even if WTF::WeakPointersActStrong. | 2243 // do nothing, even if WTF::WeakPointersActStrong. |
2244 template<WTF::ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename
Traits> | 2244 template<WTF::ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename
Traits> |
2245 struct CollectionBackingTraceTrait<false, WTF::NoWeakHandlingInCollections, stro
ngify, T, Traits> { | 2245 struct CollectionBackingTraceTrait<false, WTF::NoWeakHandlingInCollections, stro
ngify, T, Traits> { |
2246 static bool trace(Visitor*, T&) { return false; } | 2246 static bool trace(Visitor*, T&) { return false; } |
2247 }; | 2247 }; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2375 }; | 2375 }; |
2376 | 2376 |
2377 template<typename T> | 2377 template<typename T> |
2378 struct IfWeakMember<WeakMember<T> > { | 2378 struct IfWeakMember<WeakMember<T> > { |
2379 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit
or->isAlive(t.get()); } | 2379 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit
or->isAlive(t.get()); } |
2380 }; | 2380 }; |
2381 | 2381 |
2382 } | 2382 } |
2383 | 2383 |
2384 #endif // Heap_h | 2384 #endif // Heap_h |
OLD | NEW |