| 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/V8GCController.h" | 9 #include "bindings/core/v8/V8GCController.h" |
| 10 #include "bindings/core/v8/V8IdleTaskRunner.h" | 10 #include "bindings/core/v8/V8IdleTaskRunner.h" |
| 11 #include "bindings/core/v8/V8Initializer.h" | 11 #include "bindings/core/v8/V8Initializer.h" |
| 12 #include "core/inspector/WorkerThreadDebugger.h" | 12 #include "core/inspector/WorkerThreadDebugger.h" |
| 13 #include "platform/CrossThreadFunctional.h" | 13 #include "platform/CrossThreadFunctional.h" |
| 14 #include "platform/RuntimeEnabledFeatures.h" | 14 #include "platform/RuntimeEnabledFeatures.h" |
| 15 #include "platform/WebThreadSupportingGC.h" | 15 #include "platform/WebThreadSupportingGC.h" |
| 16 #include "platform/bindings/V8PerIsolateData.h" | 16 #include "platform/bindings/V8PerIsolateData.h" |
| 17 #include "platform/wtf/PtrUtil.h" | 17 #include "platform/wtf/PtrUtil.h" |
| 18 #include "public/platform/Platform.h" | 18 #include "public/platform/Platform.h" |
| 19 #include "public/platform/WebTraceLocation.h" | 19 #include "public/platform/WebTraceLocation.h" |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 | 22 |
| 23 #define DEFINE_STATIC_LOCAL_WITH_LOCK(type, name, arguments) \ | |
| 24 ASSERT(IsolatesMutex().Locked()); \ | |
| 25 static type& name = *new type arguments | |
| 26 | |
| 27 static Mutex& IsolatesMutex() { | 23 static Mutex& IsolatesMutex() { |
| 28 DEFINE_THREAD_SAFE_STATIC_LOCAL(Mutex, mutex, new Mutex); | 24 DEFINE_THREAD_SAFE_STATIC_LOCAL(Mutex, mutex, new Mutex); |
| 29 return mutex; | 25 return mutex; |
| 30 } | 26 } |
| 31 | 27 |
| 32 static HashSet<v8::Isolate*>& Isolates() { | 28 static HashSet<v8::Isolate*>& Isolates() { |
| 33 DEFINE_STATIC_LOCAL_WITH_LOCK(HashSet<v8::Isolate*>, isolates, ()); | 29 #if DCHECK_IS_ON() |
| 30 DCHECK(IsolatesMutex().Locked()); |
| 31 #endif |
| 32 static HashSet<v8::Isolate*>& isolates = *new HashSet<v8::Isolate*>(); |
| 34 return isolates; | 33 return isolates; |
| 35 } | 34 } |
| 36 | 35 |
| 37 static void AddWorkerIsolate(v8::Isolate* isolate) { | 36 static void AddWorkerIsolate(v8::Isolate* isolate) { |
| 38 MutexLocker lock(IsolatesMutex()); | 37 MutexLocker lock(IsolatesMutex()); |
| 39 Isolates().insert(isolate); | 38 Isolates().insert(isolate); |
| 40 } | 39 } |
| 41 | 40 |
| 42 static void RemoveWorkerIsolate(v8::Isolate* isolate) { | 41 static void RemoveWorkerIsolate(v8::Isolate* isolate) { |
| 43 MutexLocker lock(IsolatesMutex()); | 42 MutexLocker lock(IsolatesMutex()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 107 |
| 109 // static | 108 // static |
| 110 void WorkerBackingThread::SetRAILModeOnWorkerThreadIsolates( | 109 void WorkerBackingThread::SetRAILModeOnWorkerThreadIsolates( |
| 111 v8::RAILMode rail_mode) { | 110 v8::RAILMode rail_mode) { |
| 112 MutexLocker lock(IsolatesMutex()); | 111 MutexLocker lock(IsolatesMutex()); |
| 113 for (v8::Isolate* isolate : Isolates()) | 112 for (v8::Isolate* isolate : Isolates()) |
| 114 isolate->SetRAILMode(rail_mode); | 113 isolate->SetRAILMode(rail_mode); |
| 115 } | 114 } |
| 116 | 115 |
| 117 } // namespace blink | 116 } // namespace blink |
| OLD | NEW |