| Index: sky/engine/platform/heap/Heap.h
|
| diff --git a/sky/engine/platform/heap/Heap.h b/sky/engine/platform/heap/Heap.h
|
| index 9ee1865ab8955a65dca88d1d02e6bfbdd77d0f3f..8acbc707079e38ba8792b6f38a5e8541b71cd467 100644
|
| --- a/sky/engine/platform/heap/Heap.h
|
| +++ b/sky/engine/platform/heap/Heap.h
|
| @@ -1152,99 +1152,6 @@ private:
|
| bool m_active;
|
| };
|
|
|
| -// Base class for objects that are in the Blink garbage-collected heap
|
| -// and are still reference counted.
|
| -//
|
| -// This class should be used sparingly and only to gradually move
|
| -// objects from being reference counted to being managed by the blink
|
| -// garbage collector.
|
| -//
|
| -// While the current reference counting keeps one of these objects
|
| -// alive it will have a Persistent handle to itself allocated so we
|
| -// will not reclaim the memory. When the reference count reaches 0 the
|
| -// persistent handle will be deleted. When the garbage collector
|
| -// determines that there are no other references to the object it will
|
| -// be reclaimed and the destructor of the reclaimed object will be
|
| -// called at that time.
|
| -template<typename T>
|
| -class RefCountedGarbageCollected : public GarbageCollectedFinalized<T> {
|
| - WTF_MAKE_NONCOPYABLE(RefCountedGarbageCollected);
|
| -
|
| -public:
|
| - RefCountedGarbageCollected()
|
| - : m_refCount(1)
|
| - {
|
| - makeKeepAlive();
|
| - }
|
| -
|
| - // Implement method to increase reference count for use with
|
| - // RefPtrs.
|
| - //
|
| - // In contrast to the normal WTF::RefCounted, the reference count
|
| - // can reach 0 and increase again. This happens in the following
|
| - // scenario:
|
| - //
|
| - // (1) The reference count becomes 0, but members, persistents, or
|
| - // on-stack pointers keep references to the object.
|
| - //
|
| - // (2) The pointer is assigned to a RefPtr again and the reference
|
| - // count becomes 1.
|
| - //
|
| - // In this case, we have to resurrect m_keepAlive.
|
| - void ref()
|
| - {
|
| - if (UNLIKELY(!m_refCount)) {
|
| - ASSERT(ThreadStateFor<ThreadingTrait<T>::Affinity>::state()->contains(reinterpret_cast<Address>(this)));
|
| - makeKeepAlive();
|
| - }
|
| - ++m_refCount;
|
| - }
|
| -
|
| - // Implement method to decrease reference count for use with
|
| - // RefPtrs.
|
| - //
|
| - // In contrast to the normal WTF::RefCounted implementation, the
|
| - // object itself is not deleted when the reference count reaches
|
| - // 0. Instead, the keep-alive persistent handle is deallocated so
|
| - // that the object can be reclaimed when the garbage collector
|
| - // determines that there are no other references to the object.
|
| - void deref()
|
| - {
|
| - ASSERT(m_refCount > 0);
|
| - if (!--m_refCount) {
|
| - delete m_keepAlive;
|
| - m_keepAlive = 0;
|
| - }
|
| - }
|
| -
|
| - bool hasOneRef()
|
| - {
|
| - return m_refCount == 1;
|
| - }
|
| -
|
| -protected:
|
| - ~RefCountedGarbageCollected() { }
|
| -
|
| -private:
|
| - void makeKeepAlive()
|
| - {
|
| - ASSERT(!m_keepAlive);
|
| - m_keepAlive = new Persistent<T>(static_cast<T*>(this));
|
| - }
|
| -
|
| - int m_refCount;
|
| - Persistent<T>* m_keepAlive;
|
| -};
|
| -
|
| -template<typename T>
|
| -T* adoptRefCountedGarbageCollected(T* ptr)
|
| -{
|
| - ASSERT(ptr->hasOneRef());
|
| - ptr->deref();
|
| - WTF::adopted(ptr);
|
| - return ptr;
|
| -}
|
| -
|
| // Classes that contain heap references but aren't themselves heap
|
| // allocated, have some extra macros available which allows their use
|
| // to be restricted to cases where the garbage collector is able
|
| @@ -1527,25 +1434,6 @@ public:
|
| typedef T* Type;
|
| };
|
|
|
| - // The WTF classes use Allocator::VectorBackingHelper in order to find a
|
| - // class to template their backing allocation operation on. For off-heap
|
| - // allocations the VectorBackingHelper is a dummy class, since the class is
|
| - // not used during allocation of backing. For on-heap allocations this
|
| - // typedef ensures that the allocation is done with the correct templated
|
| - // instantiation of the allocation function. This ensures the correct GC
|
| - // map is written when backing allocations take place.
|
| - template<typename T, typename Traits>
|
| - struct VectorBackingHelper {
|
| - typedef HeapVectorBacking<T, Traits> Type;
|
| - };
|
| -
|
| - // Like the VectorBackingHelper, but this type is used for HashSet and
|
| - // HashMap, both of which are implemented using HashTable.
|
| - template<typename Table>
|
| - struct HashTableBackingHelper {
|
| - typedef HeapHashTableBacking<Table> Type;
|
| - };
|
| -
|
| template<typename T>
|
| struct OtherType {
|
| typedef T* Type;
|
| @@ -1624,554 +1512,6 @@ public:
|
| }
|
| };
|
|
|
| -// FIXME: These should just be template aliases:
|
| -//
|
| -// template<typename T, size_t inlineCapacity = 0>
|
| -// using HeapVector = Vector<T, inlineCapacity, HeapAllocator>;
|
| -//
|
| -// as soon as all the compilers we care about support that.
|
| -// MSVC supports it only in MSVC 2013.
|
| -template<
|
| - typename KeyArg,
|
| - typename MappedArg,
|
| - typename HashArg = typename DefaultHash<KeyArg>::Hash,
|
| - typename KeyTraitsArg = HashTraits<KeyArg>,
|
| - typename MappedTraitsArg = HashTraits<MappedArg> >
|
| -class HeapHashMap : public HashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg, HeapAllocator> { };
|
| -
|
| -template<
|
| - typename ValueArg,
|
| - typename HashArg = typename DefaultHash<ValueArg>::Hash,
|
| - typename TraitsArg = HashTraits<ValueArg> >
|
| -class HeapHashSet : public HashSet<ValueArg, HashArg, TraitsArg, HeapAllocator> { };
|
| -
|
| -template<
|
| - typename ValueArg,
|
| - typename HashArg = typename DefaultHash<ValueArg>::Hash,
|
| - typename TraitsArg = HashTraits<ValueArg> >
|
| -class HeapLinkedHashSet : public LinkedHashSet<ValueArg, HashArg, TraitsArg, HeapAllocator> { };
|
| -
|
| -template<
|
| - typename ValueArg,
|
| - size_t inlineCapacity = 0, // The inlineCapacity is just a dummy to match ListHashSet (off-heap).
|
| - typename HashArg = typename DefaultHash<ValueArg>::Hash>
|
| -class HeapListHashSet : public ListHashSet<ValueArg, inlineCapacity, HashArg, HeapListHashSetAllocator<ValueArg, inlineCapacity> > { };
|
| -
|
| -template<
|
| - typename Value,
|
| - typename HashFunctions = typename DefaultHash<Value>::Hash,
|
| - typename Traits = HashTraits<Value> >
|
| -class HeapHashCountedSet : public HashCountedSet<Value, HashFunctions, Traits, HeapAllocator> { };
|
| -
|
| -template<typename T, size_t inlineCapacity = 0>
|
| -class HeapVector : public Vector<T, inlineCapacity, HeapAllocator> {
|
| -public:
|
| - HeapVector() { }
|
| -
|
| - explicit HeapVector(size_t size) : Vector<T, inlineCapacity, HeapAllocator>(size)
|
| - {
|
| - }
|
| -
|
| - HeapVector(size_t size, const T& val) : Vector<T, inlineCapacity, HeapAllocator>(size, val)
|
| - {
|
| - }
|
| -
|
| - template<size_t otherCapacity>
|
| - HeapVector(const HeapVector<T, otherCapacity>& other)
|
| - : Vector<T, inlineCapacity, HeapAllocator>(other)
|
| - {
|
| - }
|
| -
|
| - template<typename U>
|
| - void append(const U& other)
|
| - {
|
| - Vector<T, inlineCapacity, HeapAllocator>::append(other);
|
| - }
|
| -
|
| - template<typename U, size_t otherCapacity>
|
| - void appendVector(const HeapVector<U, otherCapacity>& other)
|
| - {
|
| - const Vector<U, otherCapacity, HeapAllocator>& otherVector = other;
|
| - Vector<T, inlineCapacity, HeapAllocator>::appendVector(otherVector);
|
| - }
|
| -};
|
| -
|
| -template<typename T, size_t inlineCapacity = 0>
|
| -class HeapDeque : public Deque<T, inlineCapacity, HeapAllocator> {
|
| -public:
|
| - HeapDeque() { }
|
| -
|
| - explicit HeapDeque(size_t size) : Deque<T, inlineCapacity, HeapAllocator>(size)
|
| - {
|
| - }
|
| -
|
| - HeapDeque(size_t size, const T& val) : Deque<T, inlineCapacity, HeapAllocator>(size, val)
|
| - {
|
| - }
|
| -
|
| - // FIXME: Doesn't work if there is an inline buffer, due to crbug.com/360572
|
| - HeapDeque<T, 0>& operator=(const HeapDeque& other)
|
| - {
|
| - HeapDeque<T> copy(other);
|
| - swap(copy);
|
| - return *this;
|
| - }
|
| -
|
| - // FIXME: Doesn't work if there is an inline buffer, due to crbug.com/360572
|
| - inline void swap(HeapDeque& other)
|
| - {
|
| - Deque<T, inlineCapacity, HeapAllocator>::swap(other);
|
| - }
|
| -
|
| - template<size_t otherCapacity>
|
| - HeapDeque(const HeapDeque<T, otherCapacity>& other)
|
| - : Deque<T, inlineCapacity, HeapAllocator>(other)
|
| - {
|
| - }
|
| -
|
| - template<typename U>
|
| - void append(const U& other)
|
| - {
|
| - Deque<T, inlineCapacity, HeapAllocator>::append(other);
|
| - }
|
| -};
|
| -
|
| -template<typename T, size_t i>
|
| -inline void swap(HeapVector<T, i>& a, HeapVector<T, i>& b) { a.swap(b); }
|
| -template<typename T, size_t i>
|
| -inline void swap(HeapDeque<T, i>& a, HeapDeque<T, i>& b) { a.swap(b); }
|
| -template<typename T, typename U, typename V>
|
| -inline void swap(HeapHashSet<T, U, V>& a, HeapHashSet<T, U, V>& b) { a.swap(b); }
|
| -template<typename T, typename U, typename V, typename W, typename X>
|
| -inline void swap(HeapHashMap<T, U, V, W, X>& a, HeapHashMap<T, U, V, W, X>& b) { a.swap(b); }
|
| -template<typename T, size_t i, typename U>
|
| -inline void swap(HeapListHashSet<T, i, U>& a, HeapListHashSet<T, i, U>& b) { a.swap(b); }
|
| -template<typename T, typename U, typename V>
|
| -inline void swap(HeapLinkedHashSet<T, U, V>& a, HeapLinkedHashSet<T, U, V>& b) { a.swap(b); }
|
| -template<typename T, typename U, typename V>
|
| -inline void swap(HeapHashCountedSet<T, U, V>& a, HeapHashCountedSet<T, U, V>& b) { a.swap(b); }
|
| -
|
| -template<typename T>
|
| -struct ThreadingTrait<Member<T> > {
|
| - static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
|
| -};
|
| -
|
| -template<typename T>
|
| -struct ThreadingTrait<WeakMember<T> > {
|
| - static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
|
| -};
|
| -
|
| -template<typename Key, typename Value, typename T, typename U, typename V>
|
| -struct ThreadingTrait<HashMap<Key, Value, T, U, V, HeapAllocator> > {
|
| - static const ThreadAffinity Affinity =
|
| - (ThreadingTrait<Key>::Affinity == MainThreadOnly)
|
| - && (ThreadingTrait<Value>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread;
|
| -};
|
| -
|
| -template<typename First, typename Second>
|
| -struct ThreadingTrait<WTF::KeyValuePair<First, Second> > {
|
| - static const ThreadAffinity Affinity =
|
| - (ThreadingTrait<First>::Affinity == MainThreadOnly)
|
| - && (ThreadingTrait<Second>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread;
|
| -};
|
| -
|
| -template<typename T, typename U, typename V>
|
| -struct ThreadingTrait<HashSet<T, U, V, HeapAllocator> > {
|
| - static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
|
| -};
|
| -
|
| -
|
| -template<typename T, size_t inlineCapacity>
|
| -struct ThreadingTrait<Vector<T, inlineCapacity, HeapAllocator> > {
|
| - static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
|
| -};
|
| -
|
| -template<typename T, typename Traits>
|
| -struct ThreadingTrait<HeapVectorBacking<T, Traits> > {
|
| - static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
|
| -};
|
| -
|
| -template<typename T, size_t inlineCapacity>
|
| -struct ThreadingTrait<Deque<T, inlineCapacity, HeapAllocator> > {
|
| - static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
|
| -};
|
| -
|
| -template<typename T, typename U, typename V>
|
| -struct ThreadingTrait<HashCountedSet<T, U, V, HeapAllocator> > {
|
| - static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
|
| -};
|
| -
|
| -template<typename Table>
|
| -struct ThreadingTrait<HeapHashTableBacking<Table> > {
|
| - typedef typename Table::KeyType Key;
|
| - typedef typename Table::ValueType Value;
|
| - static const ThreadAffinity Affinity =
|
| - (ThreadingTrait<Key>::Affinity == MainThreadOnly)
|
| - && (ThreadingTrait<Value>::Affinity == MainThreadOnly) ? MainThreadOnly : AnyThread;
|
| -};
|
| -
|
| -template<typename T, typename U, typename V, typename W, typename X>
|
| -struct ThreadingTrait<HeapHashMap<T, U, V, W, X> > : public ThreadingTrait<HashMap<T, U, V, W, X, HeapAllocator> > { };
|
| -
|
| -template<typename T, typename U, typename V>
|
| -struct ThreadingTrait<HeapHashSet<T, U, V> > : public ThreadingTrait<HashSet<T, U, V, HeapAllocator> > { };
|
| -
|
| -template<typename T, size_t inlineCapacity>
|
| -struct ThreadingTrait<HeapVector<T, inlineCapacity> > : public ThreadingTrait<Vector<T, inlineCapacity, HeapAllocator> > { };
|
| -
|
| -template<typename T, size_t inlineCapacity>
|
| -struct ThreadingTrait<HeapDeque<T, inlineCapacity> > : public ThreadingTrait<Deque<T, inlineCapacity, HeapAllocator> > { };
|
| -
|
| -template<typename T, typename U, typename V>
|
| -struct ThreadingTrait<HeapHashCountedSet<T, U, V> > : public ThreadingTrait<HashCountedSet<T, U, V, HeapAllocator> > { };
|
| -
|
| -// The standard implementation of GCInfoTrait<T>::get() just returns a static
|
| -// from the class T, but we can't do that for HashMap, HashSet, Vector, etc.
|
| -// because they are in WTF and know nothing of GCInfos. Instead we have a
|
| -// specialization of GCInfoTrait for these four classes here.
|
| -
|
| -template<typename Key, typename Value, typename T, typename U, typename V>
|
| -struct GCInfoTrait<HashMap<Key, Value, T, U, V, HeapAllocator> > {
|
| - static const GCInfo* get()
|
| - {
|
| - typedef HashMap<Key, Value, T, U, V, HeapAllocator> TargetType;
|
| - static const GCInfo info = {
|
| - TraceTrait<TargetType>::trace,
|
| - 0,
|
| - false, // HashMap needs no finalizer.
|
| - WTF::IsPolymorphic<TargetType>::value,
|
| -#if ENABLE(GC_PROFILING)
|
| - TypenameStringTrait<TargetType>::get()
|
| -#endif
|
| - };
|
| - return &info;
|
| - }
|
| -};
|
| -
|
| -template<typename T, typename U, typename V>
|
| -struct GCInfoTrait<HashSet<T, U, V, HeapAllocator> > {
|
| - static const GCInfo* get()
|
| - {
|
| - typedef HashSet<T, U, V, HeapAllocator> TargetType;
|
| - static const GCInfo info = {
|
| - TraceTrait<TargetType>::trace,
|
| - 0,
|
| - false, // HashSet needs no finalizer.
|
| - WTF::IsPolymorphic<TargetType>::value,
|
| -#if ENABLE(GC_PROFILING)
|
| - TypenameStringTrait<TargetType>::get()
|
| -#endif
|
| - };
|
| - return &info;
|
| - }
|
| -};
|
| -
|
| -template<typename T, typename U, typename V>
|
| -struct GCInfoTrait<LinkedHashSet<T, U, V, HeapAllocator> > {
|
| - static const GCInfo* get()
|
| - {
|
| - typedef LinkedHashSet<T, U, V, HeapAllocator> TargetType;
|
| - static const GCInfo info = {
|
| - TraceTrait<TargetType>::trace,
|
| - LinkedHashSet<T, U, V, HeapAllocator>::finalize,
|
| - true, // Needs finalization. The anchor needs to unlink itself from the chain.
|
| - WTF::IsPolymorphic<TargetType>::value,
|
| -#if ENABLE(GC_PROFILING)
|
| - TypenameStringTrait<TargetType>::get()
|
| -#endif
|
| - };
|
| - return &info;
|
| - }
|
| -};
|
| -
|
| -template<typename ValueArg, size_t inlineCapacity, typename U>
|
| -struct GCInfoTrait<ListHashSet<ValueArg, inlineCapacity, U, HeapListHashSetAllocator<ValueArg, inlineCapacity> > > {
|
| - static const GCInfo* get()
|
| - {
|
| - typedef WTF::ListHashSet<ValueArg, inlineCapacity, U, HeapListHashSetAllocator<ValueArg, inlineCapacity> > TargetType;
|
| - static const GCInfo info = {
|
| - TraceTrait<TargetType>::trace,
|
| - 0,
|
| - false, // ListHashSet needs no finalization though its backing might.
|
| - false, // no vtable.
|
| -#if ENABLE(GC_PROFILING)
|
| - TypenameStringTrait<TargetType>::get()
|
| -#endif
|
| - };
|
| - return &info;
|
| - }
|
| -};
|
| -
|
| -template<typename T, typename Allocator>
|
| -struct GCInfoTrait<WTF::ListHashSetNode<T, Allocator> > {
|
| - static const GCInfo* get()
|
| - {
|
| - typedef WTF::ListHashSetNode<T, Allocator> TargetType;
|
| - static const GCInfo info = {
|
| - TraceTrait<TargetType>::trace,
|
| - TargetType::finalize,
|
| - WTF::HashTraits<T>::needsDestruction, // The node needs destruction if its data does.
|
| - false, // no vtable.
|
| -#if ENABLE(GC_PROFILING)
|
| - TypenameStringTrait<TargetType>::get()
|
| -#endif
|
| - };
|
| - return &info;
|
| - }
|
| -};
|
| -
|
| -template<typename T>
|
| -struct GCInfoTrait<Vector<T, 0, HeapAllocator> > {
|
| - static const GCInfo* get()
|
| - {
|
| -#if ENABLE(GC_PROFILING)
|
| - typedef Vector<T, 0, HeapAllocator> TargetType;
|
| -#endif
|
| - static const GCInfo info = {
|
| - TraceTrait<Vector<T, 0, HeapAllocator> >::trace,
|
| - 0,
|
| - false, // Vector needs no finalizer if it has no inline capacity.
|
| - WTF::IsPolymorphic<Vector<T, 0, HeapAllocator> >::value,
|
| -#if ENABLE(GC_PROFILING)
|
| - TypenameStringTrait<TargetType>::get()
|
| -#endif
|
| - };
|
| - return &info;
|
| - }
|
| -};
|
| -
|
| -template<typename T, size_t inlineCapacity>
|
| -struct FinalizerTrait<Vector<T, inlineCapacity, HeapAllocator> > : public FinalizerTraitImpl<Vector<T, inlineCapacity, HeapAllocator>, true> { };
|
| -
|
| -template<typename T, size_t inlineCapacity>
|
| -struct GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator> > {
|
| - static const GCInfo* get()
|
| - {
|
| - typedef Vector<T, inlineCapacity, HeapAllocator> TargetType;
|
| - static const GCInfo info = {
|
| - TraceTrait<TargetType>::trace,
|
| - FinalizerTrait<TargetType>::finalize,
|
| - // Finalizer is needed to destruct things stored in the inline capacity.
|
| - inlineCapacity && VectorTraits<T>::needsDestruction,
|
| - WTF::IsPolymorphic<TargetType>::value,
|
| -#if ENABLE(GC_PROFILING)
|
| - TypenameStringTrait<TargetType>::get()
|
| -#endif
|
| - };
|
| - return &info;
|
| - }
|
| -};
|
| -
|
| -template<typename T>
|
| -struct GCInfoTrait<Deque<T, 0, HeapAllocator> > {
|
| - static const GCInfo* get()
|
| - {
|
| - typedef Deque<T, 0, HeapAllocator> TargetType;
|
| - static const GCInfo info = {
|
| - TraceTrait<TargetType>::trace,
|
| - 0,
|
| - false, // Deque needs no finalizer if it has no inline capacity.
|
| - WTF::IsPolymorphic<TargetType>::value,
|
| -#if ENABLE(GC_PROFILING)
|
| - TypenameStringTrait<TargetType>::get()
|
| -#endif
|
| - };
|
| - return &info;
|
| - }
|
| - static const GCInfo info;
|
| -};
|
| -
|
| -template<typename T, typename U, typename V>
|
| -struct GCInfoTrait<HashCountedSet<T, U, V, HeapAllocator> > {
|
| - static const GCInfo* get()
|
| - {
|
| - typedef HashCountedSet<T, U, V, HeapAllocator> TargetType;
|
| - static const GCInfo info = {
|
| - TraceTrait<TargetType>::trace,
|
| - 0,
|
| - false, // HashCountedSet is just a HashTable, and needs no finalizer.
|
| - WTF::IsPolymorphic<TargetType>::value,
|
| -#if ENABLE(GC_PROFILING)
|
| - TypenameStringTrait<TargetType>::get()
|
| -#endif
|
| - };
|
| - return &info;
|
| - }
|
| - static const GCInfo info;
|
| -};
|
| -
|
| -template<typename T, size_t inlineCapacity>
|
| -struct FinalizerTrait<Deque<T, inlineCapacity, HeapAllocator> > : public FinalizerTraitImpl<Deque<T, inlineCapacity, HeapAllocator>, true> { };
|
| -
|
| -template<typename T, size_t inlineCapacity>
|
| -struct GCInfoTrait<Deque<T, inlineCapacity, HeapAllocator> > {
|
| - static const GCInfo* get()
|
| - {
|
| - typedef Deque<T, inlineCapacity, HeapAllocator> TargetType;
|
| - static const GCInfo info = {
|
| - TraceTrait<TargetType>::trace,
|
| - FinalizerTrait<TargetType>::finalize,
|
| - // Finalizer is needed to destruct things stored in the inline capacity.
|
| - inlineCapacity && VectorTraits<T>::needsDestruction,
|
| - WTF::IsPolymorphic<TargetType>::value,
|
| -#if ENABLE(GC_PROFILING)
|
| - TypenameStringTrait<TargetType>::get()
|
| -#endif
|
| - };
|
| - return &info;
|
| - }
|
| - static const GCInfo info;
|
| -};
|
| -
|
| -template<typename T, typename Traits>
|
| -struct GCInfoTrait<HeapVectorBacking<T, Traits> > {
|
| - static const GCInfo* get()
|
| - {
|
| - typedef HeapVectorBacking<T, Traits> TargetType;
|
| - static const GCInfo info = {
|
| - TraceTrait<TargetType>::trace,
|
| - FinalizerTrait<TargetType>::finalize,
|
| - Traits::needsDestruction,
|
| - false, // We don't support embedded objects in HeapVectors with vtables.
|
| -#if ENABLE(GC_PROFILING)
|
| - TypenameStringTrait<TargetType>::get()
|
| -#endif
|
| - };
|
| - return &info;
|
| - }
|
| -};
|
| -
|
| -template<typename Table>
|
| -struct GCInfoTrait<HeapHashTableBacking<Table> > {
|
| - static const GCInfo* get()
|
| - {
|
| - typedef HeapHashTableBacking<Table> TargetType;
|
| - static const GCInfo info = {
|
| - TraceTrait<TargetType>::trace,
|
| - HeapHashTableBacking<Table>::finalize,
|
| - Table::ValueTraits::needsDestruction,
|
| - WTF::IsPolymorphic<TargetType>::value,
|
| -#if ENABLE(GC_PROFILING)
|
| - TypenameStringTrait<TargetType>::get()
|
| -#endif
|
| - };
|
| - return &info;
|
| - }
|
| -};
|
| -
|
| -} // namespace blink
|
| -
|
| -namespace WTF {
|
| -
|
| -// Catch-all for types that have a way to trace that don't have special
|
| -// handling for weakness in collections. This means that if this type
|
| -// contains WeakMember fields, they will simply be zeroed, but the entry
|
| -// will not be removed from the collection. This always happens for
|
| -// things in vectors, which don't currently support special handling of
|
| -// weak elements.
|
| -template<ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Traits>
|
| -struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, T, Traits> {
|
| - static bool trace(blink::Visitor* visitor, T& t)
|
| - {
|
| - return false;
|
| - }
|
| -};
|
| -
|
| -// Catch-all for things that have HashTrait support for tracing with weakness.
|
| -template<ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Traits>
|
| -struct TraceInCollectionTrait<WeakHandlingInCollections, strongify, T, Traits> {
|
| - static bool trace(blink::Visitor* visitor, T& t)
|
| - {
|
| - return false;
|
| - }
|
| -};
|
| -
|
| -// Vector backing that needs marking. We don't support weak members in vectors.
|
| -template<ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Traits>
|
| -struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, blink::HeapVectorBacking<T, Traits>, void> {
|
| - static bool trace(blink::Visitor* visitor, void* self)
|
| - {
|
| - return false;
|
| - }
|
| -};
|
| -
|
| -// Almost all hash table backings are visited with this specialization.
|
| -template<ShouldWeakPointersBeMarkedStrongly strongify, typename Table>
|
| -struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, blink::HeapHashTableBacking<Table>, void> {
|
| - typedef typename Table::ValueType Value;
|
| - typedef typename Table::ValueTraits Traits;
|
| - static bool trace(blink::Visitor* visitor, void* self)
|
| - {
|
| - return false;
|
| - }
|
| -};
|
| -
|
| -// This specialization of TraceInCollectionTrait is for the backing of
|
| -// HeapListHashSet. This is for the case that we find a reference to the
|
| -// backing from the stack. That probably means we have a GC while we are in a
|
| -// ListHashSet method since normal API use does not put pointers to the backing
|
| -// on the stack.
|
| -template<ShouldWeakPointersBeMarkedStrongly strongify, typename NodeContents, size_t inlineCapacity, typename T, typename U, typename V, typename W, typename X, typename Y>
|
| -struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, blink::HeapHashTableBacking<HashTable<ListHashSetNode<NodeContents, blink::HeapListHashSetAllocator<T, inlineCapacity> >*, U, V, W, X, Y, blink::HeapAllocator> >, void> {
|
| - typedef ListHashSetNode<NodeContents, blink::HeapListHashSetAllocator<T, inlineCapacity> > Node;
|
| - typedef HashTable<Node*, U, V, W, X, Y, blink::HeapAllocator> Table;
|
| - static bool trace(blink::Visitor* visitor, void* self)
|
| - {
|
| - return false;
|
| - }
|
| -};
|
| -
|
| -// Key value pairs, as used in HashMap. To disambiguate template choice we have
|
| -// to have two versions, first the one with no special weak handling, then the
|
| -// one with weak handling.
|
| -template<ShouldWeakPointersBeMarkedStrongly strongify, typename Key, typename Value, typename Traits>
|
| -struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, KeyValuePair<Key, Value>, Traits> {
|
| - static bool trace(blink::Visitor* visitor, KeyValuePair<Key, Value>& self)
|
| - {
|
| - return false;
|
| - }
|
| -};
|
| -
|
| -template<ShouldWeakPointersBeMarkedStrongly strongify, typename Key, typename Value, typename Traits>
|
| -struct TraceInCollectionTrait<WeakHandlingInCollections, strongify, KeyValuePair<Key, Value>, Traits> {
|
| - static bool trace(blink::Visitor* visitor, KeyValuePair<Key, Value>& self)
|
| - {
|
| - return false;
|
| - }
|
| -};
|
| -
|
| -// Nodes used by LinkedHashSet. Again we need two versions to disambiguate the
|
| -// template.
|
| -template<ShouldWeakPointersBeMarkedStrongly strongify, typename Value, typename Allocator, typename Traits>
|
| -struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, LinkedHashSetNode<Value, Allocator>, Traits> {
|
| - static bool trace(blink::Visitor* visitor, LinkedHashSetNode<Value, Allocator>& self)
|
| - {
|
| - return false;
|
| - }
|
| -};
|
| -
|
| -template<ShouldWeakPointersBeMarkedStrongly strongify, typename Value, typename Allocator, typename Traits>
|
| -struct TraceInCollectionTrait<WeakHandlingInCollections, strongify, LinkedHashSetNode<Value, Allocator>, Traits> {
|
| - static bool trace(blink::Visitor* visitor, LinkedHashSetNode<Value, Allocator>& self)
|
| - {
|
| - return false;
|
| - }
|
| -};
|
| -
|
| -// ListHashSetNode pointers (a ListHashSet is implemented as a hash table of these pointers).
|
| -template<ShouldWeakPointersBeMarkedStrongly strongify, typename Value, size_t inlineCapacity, typename Traits>
|
| -struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, ListHashSetNode<Value, blink::HeapListHashSetAllocator<Value, inlineCapacity> >*, Traits> {
|
| - typedef ListHashSetNode<Value, blink::HeapListHashSetAllocator<Value, inlineCapacity> > Node;
|
| - static bool trace(blink::Visitor* visitor, Node* node)
|
| - {
|
| - return false;
|
| - }
|
| -};
|
| -
|
| -} // namespace WTF
|
| -
|
| -namespace blink {
|
| -
|
| // CollectionBackingTraceTrait. Do nothing for things in collections that don't
|
| // need tracing, or call TraceInCollectionTrait for those that do.
|
|
|
| @@ -2229,44 +1569,6 @@ struct TraceTrait<HeapVectorBacking<T, Traits> > {
|
| }
|
| };
|
|
|
| -// The trace trait for the heap hashtable backing is used when we find a
|
| -// direct pointer to the backing from the conservative stack scanner. This
|
| -// normally indicates that there is an ongoing iteration over the table, and so
|
| -// we disable weak processing of table entries. When the backing is found
|
| -// through the owning hash table we mark differently, in order to do weak
|
| -// processing.
|
| -template<typename Table>
|
| -struct TraceTrait<HeapHashTableBacking<Table> > {
|
| - typedef HeapHashTableBacking<Table> Backing;
|
| - typedef typename Table::ValueTraits Traits;
|
| - static void trace(Visitor* visitor, void* self)
|
| - {
|
| - }
|
| - static void mark(Visitor* visitor, const Backing* backing)
|
| - {
|
| - }
|
| -};
|
| -
|
| -template<typename Table>
|
| -void HeapHashTableBacking<Table>::finalize(void* pointer)
|
| -{
|
| -}
|
| -
|
| -template<typename T, typename U, typename V, typename W, typename X>
|
| -struct GCInfoTrait<HeapHashMap<T, U, V, W, X> > : public GCInfoTrait<HashMap<T, U, V, W, X, HeapAllocator> > { };
|
| -template<typename T, typename U, typename V>
|
| -struct GCInfoTrait<HeapHashSet<T, U, V> > : public GCInfoTrait<HashSet<T, U, V, HeapAllocator> > { };
|
| -template<typename T, typename U, typename V>
|
| -struct GCInfoTrait<HeapLinkedHashSet<T, U, V> > : public GCInfoTrait<LinkedHashSet<T, U, V, HeapAllocator> > { };
|
| -template<typename T, size_t inlineCapacity, typename U>
|
| -struct GCInfoTrait<HeapListHashSet<T, inlineCapacity, U> > : public GCInfoTrait<ListHashSet<T, inlineCapacity, U, HeapListHashSetAllocator<T, inlineCapacity> > > { };
|
| -template<typename T, size_t inlineCapacity>
|
| -struct GCInfoTrait<HeapVector<T, inlineCapacity> > : public GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator> > { };
|
| -template<typename T, size_t inlineCapacity>
|
| -struct GCInfoTrait<HeapDeque<T, inlineCapacity> > : public GCInfoTrait<Deque<T, inlineCapacity, HeapAllocator> > { };
|
| -template<typename T, typename U, typename V>
|
| -struct GCInfoTrait<HeapHashCountedSet<T, U, V> > : public GCInfoTrait<HashCountedSet<T, U, V, HeapAllocator> > { };
|
| -
|
| template<typename T>
|
| struct IfWeakMember;
|
|
|
|
|