Index: Source/core/workers/WorkerThread.cpp |
diff --git a/Source/core/workers/WorkerThread.cpp b/Source/core/workers/WorkerThread.cpp |
index a08d7c5ec5afcd791cf69cdad1a0558aedfa4ffb..2a49ad36eca54674d50632780125bddf77d69efe 100644 |
--- a/Source/core/workers/WorkerThread.cpp |
+++ b/Source/core/workers/WorkerThread.cpp |
@@ -248,6 +248,7 @@ WorkerThread::WorkerThread(WorkerLoaderProxy& workerLoaderProxy, WorkerReporting |
, m_startupData(startupData) |
, m_shutdownEvent(adoptPtr(blink::Platform::current()->createWaitableEvent())) |
, m_terminationEvent(adoptPtr(blink::Platform::current()->createWaitableEvent())) |
+ , m_isolate(nullptr) |
{ |
MutexLocker lock(threadSetMutex()); |
workerThreads().add(this); |
@@ -265,7 +266,7 @@ void WorkerThread::start() |
if (m_thread) |
return; |
- m_thread = WebThreadSupportingGC::create("WebCore: Worker"); |
+ m_thread = createWebThreadSupportingGC(); |
m_thread->postTask(new Task(WTF::bind(&WorkerThread::initialize, this))); |
} |
@@ -283,6 +284,12 @@ PlatformThreadId WorkerThread::platformThreadId() const |
return m_thread->platformThread().threadId(); |
} |
+v8::Isolate* WorkerThread::isolate() const |
+{ |
+ ASSERT(isCurrentThread()); |
+ return m_isolate; |
+} |
+ |
void WorkerThread::initialize() |
{ |
KURL scriptURL = m_startupData->m_scriptURL; |
@@ -303,6 +310,9 @@ void WorkerThread::initialize() |
m_microtaskRunner = adoptPtr(new MicrotaskRunner); |
m_thread->addTaskObserver(m_microtaskRunner.get()); |
m_thread->attachGC(); |
+ |
+ m_isolate = initializeIsolate(); |
+ |
m_workerGlobalScope = createWorkerGlobalScope(m_startupData.release()); |
m_sharedTimer = adoptPtr(new WorkerSharedTimer(this)); |
@@ -329,6 +339,19 @@ void WorkerThread::initialize() |
postDelayedTask(createSameThreadTask(&WorkerThread::idleHandler, this), kShortIdleHandlerDelayMs); |
} |
+v8::Isolate* WorkerThread::initializeIsolate() |
+{ |
+ ASSERT(isCurrentThread()); |
+ v8::Isolate* isolate = V8PerIsolateData::initialize(); |
+ V8Initializer::initializeWorker(isolate); |
+ return isolate; |
+} |
+ |
+PassOwnPtr<WebThreadSupportingGC> WorkerThread::createWebThreadSupportingGC() |
+{ |
+ return WebThreadSupportingGC::create("WebCore: Worker"); |
+} |
+ |
void WorkerThread::cleanup() |
{ |