Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: third_party/WebKit/Source/platform/heap/ThreadState.h

Issue 1892713003: Prepare for multiple ThreadHeaps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 342683935239134fa042edb524937b220a121acc..5efb062e0440de514e82a783ef6717ecc6df3377 100644
--- a/third_party/WebKit/Source/platform/heap/ThreadState.h
+++ b/third_party/WebKit/Source/platform/heap/ThreadState.h
@@ -62,6 +62,7 @@ class PersistentRegion;
class BaseArena;
class SafePointAwareMutexLocker;
class SafePointBarrier;
+class ThreadHeap;
class ThreadState;
class Visitor;
@@ -169,38 +170,23 @@ 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();
- static void shutdown();
+ void lockThreadAttachMutex();
+ void unlockThreadAttachMutex();
+
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.
- static void attach();
+ static void attachCurrentThread();
// 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();
static ThreadState* current()
{
@@ -228,11 +214,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 runTerminationGC();
+
void performIdleGC(double deadlineSeconds);
void performIdleLazySweep(double deadlineSeconds);
@@ -324,10 +323,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);
@@ -523,6 +518,8 @@ public:
void decreaseAllocatedObjectSize(size_t);
void increaseMarkedObjectSize(size_t);
+ void callThreadShutdownHooks();
+
private:
enum SnapshotType {
HeapSnapshot,
@@ -583,14 +580,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();
@@ -613,7 +602,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.
@@ -624,6 +612,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;
« no previous file with comments | « third_party/WebKit/Source/platform/heap/SafePoint.cpp ('k') | third_party/WebKit/Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698