| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/workers/WorkerBackingThread.h" | 5 #include "core/workers/WorkerBackingThread.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "bindings/core/v8/V8BindingForCore.h" | 8 #include "bindings/core/v8/V8BindingForCore.h" |
| 9 #include "bindings/core/v8/V8ContextSnapshot.h" | |
| 10 #include "bindings/core/v8/V8GCController.h" | 9 #include "bindings/core/v8/V8GCController.h" |
| 11 #include "bindings/core/v8/V8IdleTaskRunner.h" | 10 #include "bindings/core/v8/V8IdleTaskRunner.h" |
| 12 #include "bindings/core/v8/V8Initializer.h" | 11 #include "bindings/core/v8/V8Initializer.h" |
| 13 #include "core/inspector/WorkerThreadDebugger.h" | 12 #include "core/inspector/WorkerThreadDebugger.h" |
| 14 #include "core/workers/WorkerBackingThreadStartupData.h" | 13 #include "core/workers/WorkerBackingThreadStartupData.h" |
| 15 #include "platform/CrossThreadFunctional.h" | 14 #include "platform/CrossThreadFunctional.h" |
| 16 #include "platform/RuntimeEnabledFeatures.h" | 15 #include "platform/RuntimeEnabledFeatures.h" |
| 17 #include "platform/WebThreadSupportingGC.h" | 16 #include "platform/WebThreadSupportingGC.h" |
| 18 #include "platform/bindings/V8PerIsolateData.h" | 17 #include "platform/bindings/V8PerIsolateData.h" |
| 19 #include "platform/wtf/PtrUtil.h" | 18 #include "platform/wtf/PtrUtil.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 should_call_gc_on_shutdown_(should_call_gc_on_shutdown) {} | 57 should_call_gc_on_shutdown_(should_call_gc_on_shutdown) {} |
| 59 | 58 |
| 60 WorkerBackingThread::~WorkerBackingThread() {} | 59 WorkerBackingThread::~WorkerBackingThread() {} |
| 61 | 60 |
| 62 void WorkerBackingThread::InitializeOnBackingThread( | 61 void WorkerBackingThread::InitializeOnBackingThread( |
| 63 const WorkerBackingThreadStartupData& startup_data) { | 62 const WorkerBackingThreadStartupData& startup_data) { |
| 64 DCHECK(backing_thread_->IsCurrentThread()); | 63 DCHECK(backing_thread_->IsCurrentThread()); |
| 65 backing_thread_->InitializeOnThread(); | 64 backing_thread_->InitializeOnThread(); |
| 66 | 65 |
| 67 DCHECK(!isolate_); | 66 DCHECK(!isolate_); |
| 68 // TODO(peria): Replace GetReferenceTable with nullptr. | |
| 69 // (http://crbug.com/v8/6448) | |
| 70 isolate_ = V8PerIsolateData::Initialize( | 67 isolate_ = V8PerIsolateData::Initialize( |
| 71 backing_thread_->PlatformThread().GetWebTaskRunner(), | 68 backing_thread_->PlatformThread().GetWebTaskRunner()); |
| 72 V8ContextSnapshot::GetReferenceTable(), | |
| 73 V8PerIsolateData::V8ContextSnapshotMode::kDontUseSnapshot); | |
| 74 AddWorkerIsolate(isolate_); | 69 AddWorkerIsolate(isolate_); |
| 75 V8Initializer::InitializeWorker(isolate_); | 70 V8Initializer::InitializeWorker(isolate_); |
| 76 | 71 |
| 77 ThreadState::Current()->RegisterTraceDOMWrappers( | 72 ThreadState::Current()->RegisterTraceDOMWrappers( |
| 78 isolate_, V8GCController::TraceDOMWrappers, | 73 isolate_, V8GCController::TraceDOMWrappers, |
| 79 ScriptWrappableVisitor::InvalidateDeadObjectsInMarkingDeque, | 74 ScriptWrappableVisitor::InvalidateDeadObjectsInMarkingDeque, |
| 80 ScriptWrappableVisitor::PerformCleanup); | 75 ScriptWrappableVisitor::PerformCleanup); |
| 81 if (RuntimeEnabledFeatures::V8IdleTasksEnabled()) | 76 if (RuntimeEnabledFeatures::V8IdleTasksEnabled()) |
| 82 V8PerIsolateData::EnableIdleTasks( | 77 V8PerIsolateData::EnableIdleTasks( |
| 83 isolate_, WTF::WrapUnique(new V8IdleTaskRunner( | 78 isolate_, WTF::WrapUnique(new V8IdleTaskRunner( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 123 |
| 129 // static | 124 // static |
| 130 void WorkerBackingThread::SetRAILModeOnWorkerThreadIsolates( | 125 void WorkerBackingThread::SetRAILModeOnWorkerThreadIsolates( |
| 131 v8::RAILMode rail_mode) { | 126 v8::RAILMode rail_mode) { |
| 132 MutexLocker lock(IsolatesMutex()); | 127 MutexLocker lock(IsolatesMutex()); |
| 133 for (v8::Isolate* isolate : Isolates()) | 128 for (v8::Isolate* isolate : Isolates()) |
| 134 isolate->SetRAILMode(rail_mode); | 129 isolate->SetRAILMode(rail_mode); |
| 135 } | 130 } |
| 136 | 131 |
| 137 } // namespace blink | 132 } // namespace blink |
| OLD | NEW |