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

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

Issue 1158443008: compositor-worker: Share a thread and an isolate for compositor workers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: harden-test Created 5 years, 7 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 883944ff2e4caeac2a8c5b0f951d687984b8da7e..6f3c60ec1d5555a2b07659681c6ea7709b7eb421 100644
--- a/Source/core/workers/WorkerThread.cpp
+++ b/Source/core/workers/WorkerThread.cpp
@@ -29,8 +29,6 @@
#include "core/workers/WorkerThread.h"
#include "bindings/core/v8/ScriptSourceCode.h"
-#include "bindings/core/v8/V8GCController.h"
-#include "bindings/core/v8/V8Initializer.h"
#include "core/dom/Microtask.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/WorkerInspectorController.h"
@@ -316,7 +314,7 @@ void WorkerThread::initialize(PassOwnPtr<WorkerThreadStartupData> startupData)
m_microtaskRunner = adoptPtr(new WorkerMicrotaskRunner(this));
backingThread().addTaskObserver(m_microtaskRunner.get());
- backingThread().initialize();
+ initializeBackingThread();
m_isolate = initializeIsolate();
m_workerGlobalScope = createWorkerGlobalScope(startupData);
@@ -373,7 +371,7 @@ void WorkerThread::shutdown()
m_workerGlobalScope = nullptr;
backingThread().removeTaskObserver(m_microtaskRunner.get());
- backingThread().shutdown();
+ shutdownBackingThread();
destroyIsolate();
m_microtaskRunner = nullptr;
@@ -457,6 +455,16 @@ void WorkerThread::didStopRunLoop()
Platform::current()->didStopWorkerRunLoop();
}
+void WorkerThread::initializeBackingThread()
+{
+ backingThread().initialize();
+}
+
+void WorkerThread::shutdownBackingThread()
+{
+ backingThread().shutdown();
+}
+
void WorkerThread::terminateAndWaitForAllWorkers()
{
// Keep this lock to prevent WorkerThread instances from being destroyed.
@@ -507,40 +515,31 @@ void WorkerThread::postDelayedTask(const WebTraceLocation& location, PassOwnPtr<
backingThread().postDelayedTask(location, WorkerThreadTask::create(*this, task, true).leakPtr(), delayMs);
}
-v8::Isolate* WorkerThread::initializeIsolate()
+PassOwnPtr<WorkerV8Isolate> WorkerThread::initializeIsolate()
{
ASSERT(isCurrentThread());
ASSERT(!m_isolate);
- v8::Isolate* isolate = V8PerIsolateData::initialize();
- V8Initializer::initializeWorker(isolate);
-
- m_interruptor = adoptPtr(new V8IsolateInterruptor(isolate));
- ThreadState::current()->addInterruptor(m_interruptor.get());
- ThreadState::current()->registerTraceDOMWrappers(isolate, V8GCController::traceDOMWrappers);
-
- return isolate;
+ return WorkerV8Isolate::createDefault();
}
void WorkerThread::willDestroyIsolate()
{
ASSERT(isCurrentThread());
ASSERT(m_isolate);
- V8PerIsolateData::willBeDestroyed(m_isolate);
- ThreadState::current()->removeInterruptor(m_interruptor.get());
+ m_isolate->willDestroy();
}
void WorkerThread::destroyIsolate()
{
ASSERT(isCurrentThread());
- V8PerIsolateData::destroy(m_isolate);
- m_isolate = nullptr;
+ m_isolate.clear();
}
void WorkerThread::terminateV8Execution()
{
ASSERT(isMainThread());
m_workerGlobalScope->script()->willScheduleExecutionTermination();
- v8::V8::TerminateExecution(m_isolate);
+ m_isolate->terminateExecution();
}
void WorkerThread::appendDebuggerTask(PassOwnPtr<WebThread::Task> task)

Powered by Google App Engine
This is Rietveld 408576698