| Index: Source/heap/Heap.h
|
| diff --git a/Source/heap/Heap.h b/Source/heap/Heap.h
|
| index 19ba86b1bed229144ff0f0405516dd2cb31e4e5a..1ccbb680f540e739c1e0a2340a7745a274b49e92 100644
|
| --- a/Source/heap/Heap.h
|
| +++ b/Source/heap/Heap.h
|
| @@ -225,7 +225,7 @@ public:
|
| inline bool hasDebugMark() const;
|
|
|
| // Zap magic number with a new magic number that means there was once an
|
| - // object allocated here, but it was freed because nobody visited it during
|
| + // object allocated here, but it was freed because nobody marked it during
|
| // GC.
|
| void zapMagic();
|
|
|
| @@ -348,7 +348,7 @@ public:
|
|
|
| Address address() { return reinterpret_cast<Address>(this); }
|
| const GCInfo* gcInfo() { return m_gcInfo; }
|
| - virtual bool checkAndVisitPointer(Visitor*, Address) = 0;
|
| + virtual bool checkAndMarkPointer(Visitor*, Address) = 0;
|
|
|
| PageMemory* storage() const { return m_storage; }
|
|
|
| @@ -408,9 +408,9 @@ public:
|
| bool isMarked();
|
| void unmark();
|
| void getStats(HeapStats&);
|
| - void visit(Visitor*);
|
| + void mark(Visitor*);
|
| void finalize();
|
| - virtual bool checkAndVisitPointer(Visitor*, Address);
|
| + virtual bool checkAndMarkPointer(Visitor*, Address);
|
|
|
| private:
|
| friend class Heap;
|
| @@ -513,7 +513,7 @@ public:
|
| void sweep();
|
| void clearObjectStartBitMap();
|
| void finalize(Header*);
|
| - virtual bool checkAndVisitPointer(Visitor*, Address);
|
| + virtual bool checkAndMarkPointer(Visitor*, Address);
|
| ThreadHeap<Header>* heap() { return m_heap; }
|
| #if USE_ASAN
|
| void poisonUnmarkedObjects();
|
| @@ -594,20 +594,6 @@ private:
|
| friend class ThreadState;
|
| };
|
|
|
| -enum TraceRequirement {
|
| - // TraceChecker does not perform checks, because there are weak pointers
|
| - // present that cannot be distinguished from pointers that were incorrectly
|
| - // not visited. Later, however, we can check that the weak pointers were
|
| - // cleared by the weak pointer callback.
|
| - NoRequirement,
|
| - // The trace method must visit all member pointers.
|
| - AllPointersMustBeVisited,
|
| - // All member pointers must be marked live if they were not already. This
|
| - // also means that all weak pointers must be cleared if they are not
|
| - // pointing to objects that are marked live.
|
| - AllPointersMustBeMarked
|
| -};
|
| -
|
| typedef void (*TraceTrampoline)(VisitorCallback, Visitor*, void*);
|
|
|
| class Heap {
|
| @@ -648,7 +634,7 @@ public:
|
| static void prepareForGC();
|
|
|
| static void visitRoots(Visitor*);
|
| - static Address checkAndVisitPointer(Visitor*, Address);
|
| + static Address checkAndMarkPointer(Visitor*, Address);
|
|
|
| static void getStats(HeapStats*);
|
|
|
| @@ -687,7 +673,7 @@ public:
|
| // Large objects and adding pages are handled by the ThreadHeap
|
| virtual BaseHeapPage* heapPageFromAddress(Address) = 0;
|
| virtual BaseHeapPage* largeHeapObjectFromAddress(Address) = 0;
|
| - virtual bool checkAndVisitLargeHeapObjects(Visitor*, Address) = 0;
|
| + virtual bool checkAndMarkLargeHeapObjects(Visitor*, Address) = 0;
|
| virtual void sweep() = 0;
|
| virtual void finalizeAll(const void* except = 0) = 0;
|
| virtual bool inFinalizeAll() = 0;
|
| @@ -715,7 +701,7 @@ public:
|
|
|
| virtual BaseHeapPage* heapPageFromAddress(Address);
|
| virtual BaseHeapPage* largeHeapObjectFromAddress(Address);
|
| - virtual bool checkAndVisitLargeHeapObjects(Visitor*, Address);
|
| + virtual bool checkAndMarkLargeHeapObjects(Visitor*, Address);
|
| virtual void sweep();
|
| virtual void finalizeAll(const void* except = 0);
|
| virtual bool inFinalizeAll() { return m_inFinalizeAll; }
|
| @@ -1073,7 +1059,7 @@ public:
|
|
|
| static void init(CallbackStack** first);
|
| static void shutdown(CallbackStack** first);
|
| - bool popAndTrace(CallbackStack** first, Visitor*, TraceRequirement, TraceTrampoline);
|
| + bool popAndTrace(CallbackStack** first, Visitor*, TraceTrampoline);
|
|
|
| Item* allocateEntry(CallbackStack** first)
|
| {
|
| @@ -1155,130 +1141,130 @@ void FinalizerTrait<HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTrait
|
| }
|
| }
|
|
|
| -template<bool visitWeakPointersStrongly, typename T, typename Traits>
|
| +template<bool markWeakPointersStrongly, typename T, typename Traits>
|
| struct BaseVisitVectorBackingTrait {
|
| - static void visit(WebCore::Visitor* visitor, void* self)
|
| + static void mark(WebCore::Visitor* visitor, void* self)
|
| {
|
| // The alllocator can oversize the allocation a little, according to
|
| // the allocation granularity. The extra size is included in the
|
| // payloadSize call below, since there is nowhere to store the
|
| // originally allocated memory. This assert ensures that visiting the
|
| // last bit of memory can't cause trouble.
|
| - COMPILE_ASSERT(!Traits::needsVisiting || sizeof(T) > allocationGranularity || Traits::canInitializeWithMemset, HeapOverallocationCanCauseSpuriousVisits);
|
| + COMPILE_ASSERT(!Traits::needsTracing || sizeof(T) > allocationGranularity || Traits::canInitializeWithMemset, HeapOverallocationCanCauseSpuriousVisits);
|
|
|
| T* array = reinterpret_cast<T*>(self);
|
| WebCore::FinalizedHeapObjectHeader* header = WebCore::FinalizedHeapObjectHeader::fromPayload(self);
|
| // Use the payload size as recorded by the heap to determine how many
|
| - // elements to visit.
|
| + // elements to mark.
|
| int length = header->payloadSize() / sizeof(T);
|
| for (int i = 0; i < length; i++)
|
| - VisitCollectionBackingTrait<Traits::needsVisiting, Traits::isWeak, visitWeakPointersStrongly, T, Traits>::visit(visitor, array[i]);
|
| + CollectionBackingTraceTrait<Traits::needsTracing, Traits::isWeak, markWeakPointersStrongly, T, Traits>::mark(visitor, array[i]);
|
| }
|
| };
|
|
|
| -template<bool visitWeakPointersStrongly, typename Key, typename Value, typename Extractor, typename Traits, typename KeyTraits>
|
| +template<bool markWeakPointersStrongly, typename Key, typename Value, typename Extractor, typename Traits, typename KeyTraits>
|
| struct BaseVisitHashTableBackingTrait {
|
| - static void visit(WebCore::Visitor* visitor, void* self)
|
| + static void mark(WebCore::Visitor* visitor, void* self)
|
| {
|
| Value* array = reinterpret_cast<Value*>(self);
|
| WebCore::FinalizedHeapObjectHeader* header = WebCore::FinalizedHeapObjectHeader::fromPayload(self);
|
| int length = header->payloadSize() / sizeof(Value);
|
| for (int i = 0; i < length; i++) {
|
| if (!WTF::HashTableHelper<Value, Extractor, KeyTraits>::isEmptyOrDeletedBucket(array[i]))
|
| - VisitCollectionBackingTrait<Traits::needsVisiting, Traits::isWeak, visitWeakPointersStrongly, Value, Traits>::visit(visitor, array[i]);
|
| + CollectionBackingTraceTrait<Traits::needsTracing, Traits::isWeak, markWeakPointersStrongly, Value, Traits>::mark(visitor, array[i]);
|
| }
|
| }
|
| };
|
|
|
| -template<bool visitWeakPointersStrongly, typename Key, typename Value, typename Traits>
|
| +template<bool markWeakPointersStrongly, typename Key, typename Value, typename Traits>
|
| struct BaseVisitKeyValuePairTrait {
|
| - static void visit(WebCore::Visitor* visitor, WTF::KeyValuePair<Key, Value>& self)
|
| + static void mark(WebCore::Visitor* visitor, WTF::KeyValuePair<Key, Value>& self)
|
| {
|
| - ASSERT(Traits::needsVisiting || (Traits::isWeak && visitWeakPointersStrongly));
|
| - VisitCollectionBackingTrait<Traits::KeyTraits::needsVisiting, Traits::KeyTraits::isWeak, visitWeakPointersStrongly, Key, typename Traits::KeyTraits>::visit(visitor, self.key);
|
| - VisitCollectionBackingTrait<Traits::ValueTraits::needsVisiting, Traits::ValueTraits::isWeak, visitWeakPointersStrongly, Value, typename Traits::ValueTraits>::visit(visitor, self.value);
|
| + ASSERT(Traits::needsTracing || (Traits::isWeak && markWeakPointersStrongly));
|
| + CollectionBackingTraceTrait<Traits::KeyTraits::needsTracing, Traits::KeyTraits::isWeak, markWeakPointersStrongly, Key, typename Traits::KeyTraits>::mark(visitor, self.key);
|
| + CollectionBackingTraceTrait<Traits::ValueTraits::needsTracing, Traits::ValueTraits::isWeak, markWeakPointersStrongly, Value, typename Traits::ValueTraits>::mark(visitor, self.value);
|
| }
|
| };
|
|
|
| -// FFX - Things that don't need visiting and have no weak pointers.
|
| -template<bool visitWeakPointersStrongly, typename T, typename U>
|
| -struct VisitCollectionBackingTrait<false, false, visitWeakPointersStrongly, T, U> {
|
| - static void visit(Visitor*, const T&) { }
|
| - static void visit(Visitor*, const void*) { }
|
| +// FFX - Things that don't need marking and have no weak pointers.
|
| +template<bool markWeakPointersStrongly, typename T, typename U>
|
| +struct CollectionBackingTraceTrait<false, false, markWeakPointersStrongly, T, U> {
|
| + static void mark(Visitor*, const T&) { }
|
| + static void mark(Visitor*, const void*) { }
|
| };
|
|
|
| -// FTF - Things that don't need visiting. They have weak pointers, but we are
|
| -// not visiting weak pointers in this object in this GC.
|
| +// FTF - Things that don't need marking. They have weak pointers, but we are
|
| +// not marking weak pointers in this object in this GC.
|
| template<typename T, typename U>
|
| -struct VisitCollectionBackingTrait<false, true, false, T, U> {
|
| - static void visit(Visitor*, const T&) { }
|
| - static void visit(Visitor*, const void*) { }
|
| +struct CollectionBackingTraceTrait<false, true, false, T, U> {
|
| + static void mark(Visitor*, const T&) { }
|
| + static void mark(Visitor*, const void*) { }
|
| };
|
|
|
| // For each type that we understand we have the FTT case and the TXX case. The
|
| -// FTT case is where we would not normally need to visit it, but it has weak
|
| -// pointers, and we are visiting them as strong. The TXX case is the regular
|
| -// case for things that need visiting.
|
| +// FTT case is where we would not normally need to mark it, but it has weak
|
| +// pointers, and we are marking them as strong. The TXX case is the regular
|
| +// case for things that need marking.
|
|
|
| // FTT (vector)
|
| template<typename T, typename Traits>
|
| -struct VisitCollectionBackingTrait<false, true, true, HeapVectorBacking<T, Traits>, void> : public BaseVisitVectorBackingTrait<true, T, Traits> {
|
| +struct CollectionBackingTraceTrait<false, true, true, HeapVectorBacking<T, Traits>, void> : public BaseVisitVectorBackingTrait<true, T, Traits> {
|
| };
|
|
|
| // TXX (vector)
|
| -template<bool isWeak, bool visitWeakPointersStrongly, typename T, typename Traits>
|
| -struct VisitCollectionBackingTrait<true, isWeak, visitWeakPointersStrongly, HeapVectorBacking<T, Traits>, void> : public BaseVisitVectorBackingTrait<visitWeakPointersStrongly, T, Traits> {
|
| +template<bool isWeak, bool markWeakPointersStrongly, typename T, typename Traits>
|
| +struct CollectionBackingTraceTrait<true, isWeak, markWeakPointersStrongly, HeapVectorBacking<T, Traits>, void> : public BaseVisitVectorBackingTrait<markWeakPointersStrongly, T, Traits> {
|
| };
|
|
|
| // FTT (hash table)
|
| template<typename Key, typename Value, typename Extractor, typename Traits, typename KeyTraits>
|
| -struct VisitCollectionBackingTrait<false, true, true, HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits>, void> : public BaseVisitHashTableBackingTrait<true, Key, Value, Extractor, Traits, KeyTraits> {
|
| +struct CollectionBackingTraceTrait<false, true, true, HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits>, void> : public BaseVisitHashTableBackingTrait<true, Key, Value, Extractor, Traits, KeyTraits> {
|
| };
|
|
|
| // TXX (hash table)
|
| -template<bool isWeak, bool visitWeakPointersStrongly, typename Key, typename Value, typename Extractor, typename Traits, typename KeyTraits>
|
| -struct VisitCollectionBackingTrait<true, isWeak, visitWeakPointersStrongly, HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits>, void> : public BaseVisitHashTableBackingTrait<visitWeakPointersStrongly, Key, Value, Extractor, Traits, KeyTraits> {
|
| +template<bool isWeak, bool markWeakPointersStrongly, typename Key, typename Value, typename Extractor, typename Traits, typename KeyTraits>
|
| +struct CollectionBackingTraceTrait<true, isWeak, markWeakPointersStrongly, HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits>, void> : public BaseVisitHashTableBackingTrait<markWeakPointersStrongly, Key, Value, Extractor, Traits, KeyTraits> {
|
| };
|
|
|
| // FTT (key value pair)
|
| template<typename Key, typename Value, typename Traits>
|
| -struct VisitCollectionBackingTrait<false, true, true, WTF::KeyValuePair<Key, Value>, Traits> : public BaseVisitKeyValuePairTrait<true, Key, Value, Traits> {
|
| +struct CollectionBackingTraceTrait<false, true, true, WTF::KeyValuePair<Key, Value>, Traits> : public BaseVisitKeyValuePairTrait<true, Key, Value, Traits> {
|
| };
|
|
|
| // TXX (key value pair)
|
| -template<bool isWeak, bool visitWeakPointersStrongly, typename Key, typename Value, typename Traits>
|
| -struct VisitCollectionBackingTrait<true, isWeak, visitWeakPointersStrongly, WTF::KeyValuePair<Key, Value>, Traits> : public BaseVisitKeyValuePairTrait<visitWeakPointersStrongly, Key, Value, Traits> {
|
| +template<bool isWeak, bool markWeakPointersStrongly, typename Key, typename Value, typename Traits>
|
| +struct CollectionBackingTraceTrait<true, isWeak, markWeakPointersStrongly, WTF::KeyValuePair<Key, Value>, Traits> : public BaseVisitKeyValuePairTrait<markWeakPointersStrongly, Key, Value, Traits> {
|
| };
|
|
|
| // TFX (member)
|
| -template<bool visitWeakPointersStrongly, typename T, typename Traits>
|
| -struct VisitCollectionBackingTrait<true, false, visitWeakPointersStrongly, Member<T>, Traits> {
|
| - static void visit(WebCore::Visitor* visitor, Member<T> self)
|
| +template<bool markWeakPointersStrongly, typename T, typename Traits>
|
| +struct CollectionBackingTraceTrait<true, false, markWeakPointersStrongly, Member<T>, Traits> {
|
| + static void mark(WebCore::Visitor* visitor, Member<T> self)
|
| {
|
| - visitor->visit(self.raw());
|
| + visitor->mark(self.raw());
|
| }
|
| };
|
|
|
| // FTT (weak member)
|
| template<typename T, typename Traits>
|
| -struct VisitCollectionBackingTrait<false, true, true, WeakMember<T>, Traits> {
|
| - static void visit(WebCore::Visitor* visitor, WeakMember<T> self)
|
| +struct CollectionBackingTraceTrait<false, true, true, WeakMember<T>, Traits> {
|
| + static void mark(WebCore::Visitor* visitor, WeakMember<T> self)
|
| {
|
| - // This can visit weak members as if they were strong. The reason we
|
| + // This can mark weak members as if they were strong. The reason we
|
| // need this is that we don't do weak processing unless we reach the
|
| // backing only through the hash table. Reaching it in any other way
|
| // makes it impossible to update the size and deleted slot count of the
|
| // table, and exposes us to weak processing during iteration issues.
|
| - visitor->visit(self.raw());
|
| + visitor->mark(self.raw());
|
| }
|
| };
|
|
|
| // Catch-all for things that have a way to trace. For things that contain weak
|
| // pointers they will generally be visited weakly even if
|
| -// visitWeakPointersStrongly is true. This is what you want.
|
| -template<bool isWeak, bool visitWeakPointersStrongly, typename T, typename Traits>
|
| -struct VisitCollectionBackingTrait<true, isWeak, visitWeakPointersStrongly, T, Traits> {
|
| - static void visit(WebCore::Visitor* visitor, T& t)
|
| +// markWeakPointersStrongly is true. This is what you want.
|
| +template<bool isWeak, bool markWeakPointersStrongly, typename T, typename Traits>
|
| +struct CollectionBackingTraceTrait<true, isWeak, markWeakPointersStrongly, T, Traits> {
|
| + static void mark(WebCore::Visitor* visitor, T& t)
|
| {
|
| TraceTrait<T>::trace(visitor, reinterpret_cast<void*>(&t));
|
| }
|
| @@ -1290,12 +1276,12 @@ struct TraceTrait<HeapVectorBacking<T, Traits> > {
|
| static void trace(WebCore::Visitor* visitor, void* self)
|
| {
|
| COMPILE_ASSERT(!Traits::isWeak, WeDontSupportWeaknessInHeapVectors);
|
| - if (Traits::needsVisiting)
|
| - VisitCollectionBackingTrait<Traits::needsVisiting, false, false, HeapVectorBacking<T, Traits>, void>::visit(visitor, self);
|
| + if (Traits::needsTracing)
|
| + CollectionBackingTraceTrait<Traits::needsTracing, false, false, HeapVectorBacking<T, Traits>, void>::mark(visitor, self);
|
| }
|
| - static void visit(Visitor* v, const Backing* p)
|
| + static void mark(Visitor* v, const Backing* p)
|
| {
|
| - v->visit(p, &trace);
|
| + v->mark(p, &trace);
|
| }
|
| static void checkTypeMarker(Visitor* visitor, const Backing* t)
|
| {
|
| @@ -1314,18 +1300,18 @@ struct TraceTrait<HeapVectorBacking<T, Traits> > {
|
| template<typename Key, typename Value, typename Extractor, typename Traits, typename KeyTraits>
|
| struct TraceTrait<HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits> > {
|
| typedef HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits> Backing;
|
| - static const bool needsVisiting = (Traits::needsVisiting || Traits::isWeak);
|
| + static const bool needsTracing = (Traits::needsTracing || Traits::isWeak);
|
| static void trace(WebCore::Visitor* visitor, void* self)
|
| {
|
| - if (needsVisiting)
|
| - VisitCollectionBackingTrait<Traits::needsVisiting, Traits::isWeak, true, HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits>, void>::visit(visitor, self);
|
| + if (needsTracing)
|
| + CollectionBackingTraceTrait<Traits::needsTracing, Traits::isWeak, true, HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTraits>, void>::mark(visitor, self);
|
| }
|
| - static void visit(Visitor* v, const Backing* p)
|
| + static void mark(Visitor* v, const Backing* p)
|
| {
|
| - if (needsVisiting)
|
| - v->visit(p, &trace);
|
| + if (needsTracing)
|
| + v->mark(p, &trace);
|
| else
|
| - v->visit(p, nullptr);
|
| + v->mark(p, nullptr);
|
| }
|
| static void checkTypeMarker(Visitor* visitor, const Backing* t)
|
| {
|
|
|