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

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 6c163b391b07dcb30bc14cd5ca9b497d6ade0d47..0623934fa025f5200c945e7f736a8af161b172ba 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 = WebThreadRunner::create("WebCore: Worker");
m_thread->postTask(new Task(WTF::bind(&WorkerThread::initialize, this)));
}
@@ -246,11 +246,7 @@ void WorkerThread::initialize()
{
MutexLocker lock(m_threadCreationMutex);
- 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));
@@ -296,23 +292,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