| Index: third_party/WebKit/Source/platform/heap/ThreadState.h
|
| diff --git a/third_party/WebKit/Source/platform/heap/ThreadState.h b/third_party/WebKit/Source/platform/heap/ThreadState.h
|
| index 885b66d873b71857ada5e89ac651a984359bd560..b0923ab205e115612390a6953ec855bc8319c18a 100644
|
| --- a/third_party/WebKit/Source/platform/heap/ThreadState.h
|
| +++ b/third_party/WebKit/Source/platform/heap/ThreadState.h
|
| @@ -58,11 +58,12 @@ class GarbageCollectedMixinConstructorMarker;
|
| class HeapObjectHeader;
|
| class PersistentNode;
|
| class PersistentRegion;
|
| -class BaseHeap;
|
| +class BaseArena;
|
| class SafePointAwareMutexLocker;
|
| class SafePointBarrier;
|
| class ThreadState;
|
| class Visitor;
|
| +class Heap;
|
|
|
| // Declare that a class has a pre-finalizer. The pre-finalizer is called
|
| // before any object gets swept, so it is safe to touch on-heap objects
|
| @@ -174,14 +175,6 @@ public:
|
| ThreadState* m_state;
|
| };
|
|
|
| - // The set of ThreadStates for all threads attached to the Blink
|
| - // garbage collector.
|
| - using AttachedThreadStateSet = HashSet<ThreadState*>;
|
| - static AttachedThreadStateSet& attachedThreads();
|
| - static RecursiveMutex& threadAttachMutex();
|
| - static void lockThreadAttachMutex();
|
| - static void unlockThreadAttachMutex();
|
| -
|
| // Initialize threading infrastructure. Should be called from the main
|
| // thread.
|
| static void init();
|
| @@ -205,7 +198,8 @@ public:
|
|
|
| // Disassociate attached ThreadState from the current thread. The thread
|
| // can no longer use the garbage collected heap after this call.
|
| - static void detach();
|
| + static void detachCurrentThread();
|
| + void detach();
|
|
|
| static ThreadState* current()
|
| {
|
| @@ -233,11 +227,24 @@ public:
|
| return reinterpret_cast<ThreadState*>(s_mainThreadStateStorage);
|
| }
|
|
|
| + static ThreadState* fromObject(const void*);
|
| +
|
| bool isMainThread() const { return this == mainThreadState(); }
|
| #if ENABLE(ASSERT)
|
| bool checkThread() const { return m_thread == currentThread(); }
|
| #endif
|
|
|
| + Heap& heap() { return *m_heap; }
|
| +
|
| + // When ThreadState is detaching from non-main thread its
|
| + // heap is expected to be empty (because it is going away).
|
| + // Perform registered cleanup tasks and garbage collection
|
| + // to sweep away any objects that are left on this heap.
|
| + // We assert that nothing must remain after this cleanup.
|
| + // If assertion does not hold we crash as we are potentially
|
| + // in the dangling pointer situation.
|
| + void cleanup();
|
| +
|
| void performIdleGC(double deadlineSeconds);
|
| void performIdleLazySweep(double deadlineSeconds);
|
|
|
| @@ -329,10 +336,6 @@ public:
|
| // are not wrapped in a SafePointScope (e.g. BlinkGCInterruptor for JavaScript code)
|
| //
|
|
|
| - // Request all other threads to stop. Must only be called if the current thread is at safepoint.
|
| - static bool stopThreads();
|
| - static void resumeThreads();
|
| -
|
| // Check if GC is requested by another thread and pause this thread if this is the case.
|
| // Can only be called when current thread is in a consistent state.
|
| void safePoint(BlinkGC::StackState);
|
| @@ -353,11 +356,11 @@ public:
|
| // Get one of the heap structures for this thread.
|
| // The thread heap is split into multiple heap parts based on object types
|
| // and object sizes.
|
| - BaseHeap* heap(int heapIndex) const
|
| + BaseArena* arena(int arenaIndex) const
|
| {
|
| - ASSERT(0 <= heapIndex);
|
| - ASSERT(heapIndex < BlinkGC::NumberOfHeaps);
|
| - return m_heaps[heapIndex];
|
| + ASSERT(0 <= arenaIndex);
|
| + ASSERT(arenaIndex < BlinkGC::NumberOfArenas);
|
| + return m_arenas[arenaIndex];
|
| }
|
|
|
| #if ENABLE(ASSERT)
|
| @@ -456,8 +459,8 @@ public:
|
| }
|
| }
|
|
|
| - // vectorBackingHeap() returns a heap that the vector allocation should use.
|
| - // We have four vector heaps and want to choose the best heap here.
|
| + // vectorBackingArena() returns a arena that the vector allocation should use.
|
| + // We have four vector arenas and want to choose the best arena here.
|
| //
|
| // The goal is to improve the succession rate where expand and
|
| // promptlyFree happen at an allocation point. This is a key for reusing
|
| @@ -473,37 +476,37 @@ public:
|
| // Choose the heap where the vector is least likely to be expanded
|
| // nor promptly freed.
|
| //
|
| - // To implement the heuristics, we add a heapAge to each heap. The heapAge
|
| + // To implement the heuristics, we add a arenaAge to each arena. The arenaAge
|
| // is updated if:
|
| //
|
| - // - a vector on the heap is expanded; or
|
| - // - a vector that meets the condition (*) is allocated on the heap
|
| + // - a vector on the arena is expanded; or
|
| + // - a vector that meets the condition (*) is allocated on the arena
|
| //
|
| // (*) More than 33% of the same type of vectors have been promptly
|
| // freed since the last GC.
|
| //
|
| - BaseHeap* vectorBackingHeap(size_t gcInfoIndex)
|
| + BaseArena* vectorBackingArena(size_t gcInfoIndex)
|
| {
|
| ASSERT(checkThread());
|
| size_t entryIndex = gcInfoIndex & likelyToBePromptlyFreedArrayMask;
|
| --m_likelyToBePromptlyFreed[entryIndex];
|
| - int heapIndex = m_vectorBackingHeapIndex;
|
| + int arenaIndex = m_vectorBackingArenaIndex;
|
| // If m_likelyToBePromptlyFreed[entryIndex] > 0, that means that
|
| // more than 33% of vectors of the type have been promptly freed
|
| // since the last GC.
|
| if (m_likelyToBePromptlyFreed[entryIndex] > 0) {
|
| - m_heapAges[heapIndex] = ++m_currentHeapAges;
|
| - m_vectorBackingHeapIndex = heapIndexOfVectorHeapLeastRecentlyExpanded(BlinkGC::Vector1HeapIndex, BlinkGC::Vector4HeapIndex);
|
| + m_arenaAges[arenaIndex] = ++m_currentHeapAges;
|
| + m_vectorBackingArenaIndex = arenaIndexOfVectorHeapLeastRecentlyExpanded(BlinkGC::Vector1ArenaIndex, BlinkGC::Vector4ArenaIndex);
|
| }
|
| - ASSERT(isVectorHeapIndex(heapIndex));
|
| - return m_heaps[heapIndex];
|
| + ASSERT(isVectorArenaIndex(arenaIndex));
|
| + return m_arenas[arenaIndex];
|
| }
|
| - BaseHeap* expandedVectorBackingHeap(size_t gcInfoIndex);
|
| - static bool isVectorHeapIndex(int heapIndex)
|
| + BaseArena* expandedVectorBackingArena(size_t gcInfoIndex);
|
| + static bool isVectorArenaIndex(int arenaIndex)
|
| {
|
| - return BlinkGC::Vector1HeapIndex <= heapIndex && heapIndex <= BlinkGC::Vector4HeapIndex;
|
| + return BlinkGC::Vector1ArenaIndex <= arenaIndex && arenaIndex <= BlinkGC::Vector4ArenaIndex;
|
| }
|
| - void allocationPointAdjusted(int heapIndex);
|
| + void allocationPointAdjusted(int arenaIndex);
|
| void promptlyFreed(size_t gcInfoIndex);
|
|
|
| void accumulateSweepingTime(double time) { m_accumulatedSweepingTime += time; }
|
| @@ -585,14 +588,6 @@ private:
|
| void poisonAllHeaps();
|
| #endif
|
|
|
| - // When ThreadState is detaching from non-main thread its
|
| - // heap is expected to be empty (because it is going away).
|
| - // Perform registered cleanup tasks and garbage collection
|
| - // to sweep away any objects that are left on this heap.
|
| - // We assert that nothing must remain after this cleanup.
|
| - // If assertion does not hold we crash as we are potentially
|
| - // in the dangling pointer situation.
|
| - void cleanup();
|
| void cleanupPages();
|
|
|
| void prepareForThreadStateTermination();
|
| @@ -601,7 +596,7 @@ private:
|
|
|
| void takeSnapshot(SnapshotType);
|
| void clearHeapAges();
|
| - int heapIndexOfVectorHeapLeastRecentlyExpanded(int beginHeapIndex, int endHeapIndex);
|
| + int arenaIndexOfVectorHeapLeastRecentlyExpanded(int beginArenaIndex, int endArenaIndex);
|
|
|
| void reportMemoryToV8();
|
|
|
| @@ -615,7 +610,6 @@ private:
|
| static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific;
|
| static uintptr_t s_mainThreadStackStart;
|
| static uintptr_t s_mainThreadUnderestimatedStackSize;
|
| - static SafePointBarrier* s_safePointBarrier;
|
|
|
| // We can't create a static member of type ThreadState here
|
| // because it will introduce global constructor and destructor.
|
| @@ -626,6 +620,7 @@ private:
|
| // and lazily construct ThreadState in it using placement new.
|
| static uint8_t s_mainThreadStateStorage[];
|
|
|
| + Heap* m_heap;
|
| ThreadIdentifier m_thread;
|
| OwnPtr<PersistentRegion> m_persistentRegion;
|
| BlinkGC::StackState m_stackState;
|
| @@ -644,9 +639,9 @@ private:
|
| size_t m_gcForbiddenCount;
|
| double m_accumulatedSweepingTime;
|
|
|
| - BaseHeap* m_heaps[BlinkGC::NumberOfHeaps];
|
| - int m_vectorBackingHeapIndex;
|
| - size_t m_heapAges[BlinkGC::NumberOfHeaps];
|
| + BaseArena* m_arenas[BlinkGC::NumberOfArenas];
|
| + int m_vectorBackingArenaIndex;
|
| + size_t m_arenaAges[BlinkGC::NumberOfArenas];
|
| size_t m_currentHeapAges;
|
|
|
| bool m_isTerminating;
|
|
|