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

Unified Diff: Source/core/workers/WorkerThread.cpp

Issue 469683002: Implement WebThreadSupportingGC, which wraps a WebThread attached to Oilpan's GC (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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: Source/core/workers/WorkerThread.cpp
diff --git a/Source/core/workers/WorkerThread.cpp b/Source/core/workers/WorkerThread.cpp
index 7205e54255b53fed4bf2b1fa0e88a1b50d25f090..b97b25be6f6f75a35391af97ab872c5ca8edf0aa 100644
--- a/Source/core/workers/WorkerThread.cpp
+++ b/Source/core/workers/WorkerThread.cpp
@@ -224,7 +224,7 @@ void WorkerThread::start()
if (m_thread)
return;
- m_thread = adoptPtr(blink::Platform::current()->createThread("WebCore: Worker"));
+ m_thread = WebThreadSupportingGC::create("WebCore: Worker");
m_thread->postTask(new Task(WTF::bind(&WorkerThread::initialize, this)));
}
@@ -254,11 +254,7 @@ void WorkerThread::initialize()
m_microtaskRunner = adoptPtr(new MicrotaskRunner);
m_thread->addTaskObserver(m_microtaskRunner.get());
- m_pendingGCRunner = adoptPtr(new PendingGCRunner);
- m_messageLoopInterruptor = adoptPtr(new MessageLoopInterruptor(m_thread.get()));
- m_thread->addTaskObserver(m_pendingGCRunner.get());
- ThreadState::attach();
- ThreadState::current()->addInterruptor(m_messageLoopInterruptor.get());
+ m_thread->attachGC();
m_workerGlobalScope = createWorkerGlobalScope(m_startupData.release());
m_sharedTimer = adoptPtr(new WorkerSharedTimer(this));
@@ -298,23 +294,10 @@ void WorkerThread::cleanup()
m_workerGlobalScope->dispose();
m_workerGlobalScope = nullptr;
- ThreadState::current()->removeInterruptor(m_messageLoopInterruptor.get());
-
- // Detach the ThreadState, cleaning out the thread's heap by
- // performing a final GC. The cleanup operation will at the end
- // assert that the heap is empty. If the heap does not become
- // empty, there are still pointers into the heap and those
- // pointers will be dangling after thread termination because we
- // are destroying the heap. It is important to detach while the
- // thread is still valid. In particular, finalizers for objects in
- // the heap for this thread will need to access thread local data.
- ThreadState::detach();
+ m_thread->detachGC();
m_thread->removeTaskObserver(m_microtaskRunner.get());
m_microtaskRunner = nullptr;
- m_thread->removeTaskObserver(m_pendingGCRunner.get());
- m_pendingGCRunner = nullptr;
- m_messageLoopInterruptor = nullptr;
// Notify the proxy that the WorkerGlobalScope has been disposed of.
// This can free this thread object, hence it must not be touched afterwards.

Powered by Google App Engine
This is Rietveld 408576698