| 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 ee9d569a0fed30126fb19cb917bd437874046ee2..3a5c872d01be905a5a6b5025533ee8ecf8508561 100644
|
| --- a/third_party/WebKit/Source/platform/heap/ThreadState.h
|
| +++ b/third_party/WebKit/Source/platform/heap/ThreadState.h
|
| @@ -61,6 +61,7 @@ class PersistentRegion;
|
| class BaseArena;
|
| class SafePointAwareMutexLocker;
|
| class SafePointBarrier;
|
| +class ThreadHeap;
|
| class ThreadState;
|
| class Visitor;
|
|
|
| @@ -106,7 +107,7 @@ public: \
|
| static bool invokePreFinalizer(void* object) \
|
| { \
|
| Class* self = reinterpret_cast<Class*>(object); \
|
| - if (Heap::isHeapObjectAlive(self)) \
|
| + if (ThreadHeap::isHeapObjectAlive(self)) \
|
| return false; \
|
| self->Class::preFinalizer(); \
|
| return true; \
|
| @@ -174,30 +175,18 @@ 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();
|
| + void lockThreadAttachMutex();
|
| + void unlockThreadAttachMutex();
|
|
|
| // Initialize threading infrastructure. Should be called from the main
|
| // thread.
|
| static void init();
|
| - static void shutdown();
|
| bool isTerminating() { return m_isTerminating; }
|
|
|
| static void attachMainThread();
|
| static void detachMainThread();
|
| void cleanupMainThread();
|
|
|
| - // Trace all persistent roots, called when marking the managed heap objects.
|
| - static void visitPersistentRoots(Visitor*);
|
| -
|
| - // Trace all objects found on the stack, used when doing conservative GCs.
|
| - static void visitStackRoots(Visitor*);
|
| -
|
| // Associate ThreadState object with the current thread. After this
|
| // call thread can start using the garbage collected heap infrastructure.
|
| // It also has to periodically check for safepoints.
|
| @@ -205,7 +194,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 +223,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
|
|
|
| + ThreadHeap& 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 runThreadTerminationGC();
|
| +
|
| void performIdleGC(double deadlineSeconds);
|
| void performIdleLazySweep(double deadlineSeconds);
|
|
|
| @@ -261,7 +264,7 @@ public:
|
| //
|
| // 1) All threads park at safe points.
|
| // 2) The GCing thread calls preGC() for all ThreadStates.
|
| - // 3) The GCing thread calls Heap::collectGarbage().
|
| + // 3) The GCing thread calls ThreadHeap::collectGarbage().
|
| // This does marking but doesn't do sweeping.
|
| // 4) The GCing thread calls postGC() for all ThreadStates.
|
| // 5) The GCing thread resume all threads.
|
| @@ -329,10 +332,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);
|
| @@ -584,14 +583,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();
|
| @@ -614,7 +605,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.
|
| @@ -625,6 +615,7 @@ private:
|
| // and lazily construct ThreadState in it using placement new.
|
| static uint8_t s_mainThreadStateStorage[];
|
|
|
| + ThreadHeap* m_heap;
|
| ThreadIdentifier m_thread;
|
| OwnPtr<PersistentRegion> m_persistentRegion;
|
| BlinkGC::StackState m_stackState;
|
|
|