OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project 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 "src/isolate.h" | 5 #include "src/isolate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "src/wasm/wasm-module.h" | 55 #include "src/wasm/wasm-module.h" |
56 #include "src/wasm/wasm-objects.h" | 56 #include "src/wasm/wasm-objects.h" |
57 #include "src/zone/accounting-allocator.h" | 57 #include "src/zone/accounting-allocator.h" |
58 | 58 |
59 namespace v8 { | 59 namespace v8 { |
60 namespace internal { | 60 namespace internal { |
61 | 61 |
62 base::Atomic32 ThreadId::highest_thread_id_ = 0; | 62 base::Atomic32 ThreadId::highest_thread_id_ = 0; |
63 | 63 |
64 int ThreadId::AllocateThreadId() { | 64 int ThreadId::AllocateThreadId() { |
65 int new_id = base::NoBarrier_AtomicIncrement(&highest_thread_id_, 1); | 65 int new_id = base::Relaxed_AtomicIncrement(&highest_thread_id_, 1); |
66 return new_id; | 66 return new_id; |
67 } | 67 } |
68 | 68 |
69 | 69 |
70 int ThreadId::GetCurrentThreadId() { | 70 int ThreadId::GetCurrentThreadId() { |
71 int thread_id = base::Thread::GetThreadLocalInt(Isolate::thread_id_key_); | 71 int thread_id = base::Thread::GetThreadLocalInt(Isolate::thread_id_key_); |
72 if (thread_id == 0) { | 72 if (thread_id == 0) { |
73 thread_id = AllocateThreadId(); | 73 thread_id = AllocateThreadId(); |
74 base::Thread::SetThreadLocalInt(Isolate::thread_id_key_, thread_id); | 74 base::Thread::SetThreadLocalInt(Isolate::thread_id_key_, thread_id); |
75 } | 75 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 } | 182 } |
183 return per_thread; | 183 return per_thread; |
184 } | 184 } |
185 | 185 |
186 | 186 |
187 void Isolate::InitializeOncePerProcess() { | 187 void Isolate::InitializeOncePerProcess() { |
188 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); | 188 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); |
189 CHECK(thread_data_table_ == NULL); | 189 CHECK(thread_data_table_ == NULL); |
190 isolate_key_ = base::Thread::CreateThreadLocalKey(); | 190 isolate_key_ = base::Thread::CreateThreadLocalKey(); |
191 #if DEBUG | 191 #if DEBUG |
192 base::NoBarrier_Store(&isolate_key_created_, 1); | 192 base::Relaxed_Store(&isolate_key_created_, 1); |
193 #endif | 193 #endif |
194 thread_id_key_ = base::Thread::CreateThreadLocalKey(); | 194 thread_id_key_ = base::Thread::CreateThreadLocalKey(); |
195 per_isolate_thread_data_key_ = base::Thread::CreateThreadLocalKey(); | 195 per_isolate_thread_data_key_ = base::Thread::CreateThreadLocalKey(); |
196 thread_data_table_ = new Isolate::ThreadDataTable(); | 196 thread_data_table_ = new Isolate::ThreadDataTable(); |
197 } | 197 } |
198 | 198 |
199 | 199 |
200 Address Isolate::get_address_from_id(Isolate::AddressId id) { | 200 Address Isolate::get_address_from_id(Isolate::AddressId id) { |
201 return isolate_addresses_[id]; | 201 return isolate_addresses_[id]; |
202 } | 202 } |
(...skipping 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2337 is_running_microtasks_(false), | 2337 is_running_microtasks_(false), |
2338 use_counter_callback_(NULL), | 2338 use_counter_callback_(NULL), |
2339 basic_block_profiler_(NULL), | 2339 basic_block_profiler_(NULL), |
2340 cancelable_task_manager_(new CancelableTaskManager()), | 2340 cancelable_task_manager_(new CancelableTaskManager()), |
2341 abort_on_uncaught_exception_callback_(NULL), | 2341 abort_on_uncaught_exception_callback_(NULL), |
2342 total_regexp_code_generated_(0) { | 2342 total_regexp_code_generated_(0) { |
2343 { | 2343 { |
2344 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); | 2344 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); |
2345 CHECK(thread_data_table_); | 2345 CHECK(thread_data_table_); |
2346 } | 2346 } |
2347 id_ = base::NoBarrier_AtomicIncrement(&isolate_counter_, 1); | 2347 id_ = base::Relaxed_AtomicIncrement(&isolate_counter_, 1); |
2348 TRACE_ISOLATE(constructor); | 2348 TRACE_ISOLATE(constructor); |
2349 | 2349 |
2350 memset(isolate_addresses_, 0, | 2350 memset(isolate_addresses_, 0, |
2351 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); | 2351 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); |
2352 | 2352 |
2353 heap_.isolate_ = this; | 2353 heap_.isolate_ = this; |
2354 stack_guard_.isolate_ = this; | 2354 stack_guard_.isolate_ = this; |
2355 | 2355 |
2356 // ThreadManager is initialized early to support locking an isolate | 2356 // ThreadManager is initialized early to support locking an isolate |
2357 // before it is entered. | 2357 // before it is entered. |
(...skipping 25 matching lines...) Expand all Loading... |
2383 | 2383 |
2384 | 2384 |
2385 void Isolate::TearDown() { | 2385 void Isolate::TearDown() { |
2386 TRACE_ISOLATE(tear_down); | 2386 TRACE_ISOLATE(tear_down); |
2387 | 2387 |
2388 // Temporarily set this isolate as current so that various parts of | 2388 // Temporarily set this isolate as current so that various parts of |
2389 // the isolate can access it in their destructors without having a | 2389 // the isolate can access it in their destructors without having a |
2390 // direct pointer. We don't use Enter/Exit here to avoid | 2390 // direct pointer. We don't use Enter/Exit here to avoid |
2391 // initializing the thread data. | 2391 // initializing the thread data. |
2392 PerIsolateThreadData* saved_data = CurrentPerIsolateThreadData(); | 2392 PerIsolateThreadData* saved_data = CurrentPerIsolateThreadData(); |
2393 DCHECK(base::NoBarrier_Load(&isolate_key_created_) == 1); | 2393 DCHECK(base::Relaxed_Load(&isolate_key_created_) == 1); |
2394 Isolate* saved_isolate = | 2394 Isolate* saved_isolate = |
2395 reinterpret_cast<Isolate*>(base::Thread::GetThreadLocal(isolate_key_)); | 2395 reinterpret_cast<Isolate*>(base::Thread::GetThreadLocal(isolate_key_)); |
2396 SetIsolateThreadLocals(this, NULL); | 2396 SetIsolateThreadLocals(this, NULL); |
2397 | 2397 |
2398 Deinit(); | 2398 Deinit(); |
2399 | 2399 |
2400 { | 2400 { |
2401 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); | 2401 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); |
2402 thread_data_table_->RemoveAllThreads(this); | 2402 thread_data_table_->RemoveAllThreads(this); |
2403 } | 2403 } |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3768 // Then check whether this scope intercepts. | 3768 // Then check whether this scope intercepts. |
3769 if ((flag & intercept_mask_)) { | 3769 if ((flag & intercept_mask_)) { |
3770 intercepted_flags_ |= flag; | 3770 intercepted_flags_ |= flag; |
3771 return true; | 3771 return true; |
3772 } | 3772 } |
3773 return false; | 3773 return false; |
3774 } | 3774 } |
3775 | 3775 |
3776 } // namespace internal | 3776 } // namespace internal |
3777 } // namespace v8 | 3777 } // namespace v8 |
OLD | NEW |