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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "src/stub-cache.h" | 30 #include "src/stub-cache.h" |
31 #include "src/sweeper-thread.h" | 31 #include "src/sweeper-thread.h" |
32 #include "src/utils/random-number-generator.h" | 32 #include "src/utils/random-number-generator.h" |
33 #include "src/version.h" | 33 #include "src/version.h" |
34 #include "src/vm-state-inl.h" | 34 #include "src/vm-state-inl.h" |
35 | 35 |
36 | 36 |
37 namespace v8 { | 37 namespace v8 { |
38 namespace internal { | 38 namespace internal { |
39 | 39 |
40 Atomic32 ThreadId::highest_thread_id_ = 0; | 40 base::Atomic32 ThreadId::highest_thread_id_ = 0; |
41 | 41 |
42 int ThreadId::AllocateThreadId() { | 42 int ThreadId::AllocateThreadId() { |
43 int new_id = NoBarrier_AtomicIncrement(&highest_thread_id_, 1); | 43 int new_id = base::NoBarrier_AtomicIncrement(&highest_thread_id_, 1); |
44 return new_id; | 44 return new_id; |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 int ThreadId::GetCurrentThreadId() { | 48 int ThreadId::GetCurrentThreadId() { |
49 int thread_id = Thread::GetThreadLocalInt(Isolate::thread_id_key_); | 49 int thread_id = Thread::GetThreadLocalInt(Isolate::thread_id_key_); |
50 if (thread_id == 0) { | 50 if (thread_id == 0) { |
51 thread_id = AllocateThreadId(); | 51 thread_id = AllocateThreadId(); |
52 Thread::SetThreadLocalInt(Isolate::thread_id_key_, thread_id); | 52 Thread::SetThreadLocalInt(Isolate::thread_id_key_, thread_id); |
53 } | 53 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 Mutex Isolate::process_wide_mutex_; | 107 Mutex Isolate::process_wide_mutex_; |
108 // TODO(dcarney): Remove with default isolate. | 108 // TODO(dcarney): Remove with default isolate. |
109 enum DefaultIsolateStatus { | 109 enum DefaultIsolateStatus { |
110 kDefaultIsolateUninitialized, | 110 kDefaultIsolateUninitialized, |
111 kDefaultIsolateInitialized, | 111 kDefaultIsolateInitialized, |
112 kDefaultIsolateCrashIfInitialized | 112 kDefaultIsolateCrashIfInitialized |
113 }; | 113 }; |
114 static DefaultIsolateStatus default_isolate_status_ | 114 static DefaultIsolateStatus default_isolate_status_ |
115 = kDefaultIsolateUninitialized; | 115 = kDefaultIsolateUninitialized; |
116 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; | 116 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; |
117 Atomic32 Isolate::isolate_counter_ = 0; | 117 base::Atomic32 Isolate::isolate_counter_ = 0; |
118 | 118 |
119 Isolate::PerIsolateThreadData* | 119 Isolate::PerIsolateThreadData* |
120 Isolate::FindOrAllocatePerThreadDataForThisThread() { | 120 Isolate::FindOrAllocatePerThreadDataForThisThread() { |
121 ThreadId thread_id = ThreadId::Current(); | 121 ThreadId thread_id = ThreadId::Current(); |
122 PerIsolateThreadData* per_thread = NULL; | 122 PerIsolateThreadData* per_thread = NULL; |
123 { | 123 { |
124 LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 124 LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
125 per_thread = thread_data_table_->Lookup(this, thread_id); | 125 per_thread = thread_data_table_->Lookup(this, thread_id); |
126 if (per_thread == NULL) { | 126 if (per_thread == NULL) { |
127 per_thread = new PerIsolateThreadData(this, thread_id); | 127 per_thread = new PerIsolateThreadData(this, thread_id); |
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 initialized_from_snapshot_(false), | 1480 initialized_from_snapshot_(false), |
1481 cpu_profiler_(NULL), | 1481 cpu_profiler_(NULL), |
1482 heap_profiler_(NULL), | 1482 heap_profiler_(NULL), |
1483 function_entry_hook_(NULL), | 1483 function_entry_hook_(NULL), |
1484 deferred_handles_head_(NULL), | 1484 deferred_handles_head_(NULL), |
1485 optimizing_compiler_thread_(NULL), | 1485 optimizing_compiler_thread_(NULL), |
1486 sweeper_thread_(NULL), | 1486 sweeper_thread_(NULL), |
1487 num_sweeper_threads_(0), | 1487 num_sweeper_threads_(0), |
1488 stress_deopt_count_(0), | 1488 stress_deopt_count_(0), |
1489 next_optimization_id_(0) { | 1489 next_optimization_id_(0) { |
1490 id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1); | 1490 id_ = base::NoBarrier_AtomicIncrement(&isolate_counter_, 1); |
1491 TRACE_ISOLATE(constructor); | 1491 TRACE_ISOLATE(constructor); |
1492 | 1492 |
1493 memset(isolate_addresses_, 0, | 1493 memset(isolate_addresses_, 0, |
1494 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); | 1494 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); |
1495 | 1495 |
1496 heap_.isolate_ = this; | 1496 heap_.isolate_ = this; |
1497 stack_guard_.isolate_ = this; | 1497 stack_guard_.isolate_ = this; |
1498 | 1498 |
1499 // ThreadManager is initialized early to support locking an isolate | 1499 // ThreadManager is initialized early to support locking an isolate |
1500 // before it is entered. | 1500 // before it is entered. |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2333 v8::ToCData<v8::MicrotaskCallback>(callback_info->callback()); | 2333 v8::ToCData<v8::MicrotaskCallback>(callback_info->callback()); |
2334 void* data = v8::ToCData<void*>(callback_info->data()); | 2334 void* data = v8::ToCData<void*>(callback_info->data()); |
2335 callback(data); | 2335 callback(data); |
2336 } | 2336 } |
2337 } | 2337 } |
2338 } | 2338 } |
2339 } | 2339 } |
2340 | 2340 |
2341 | 2341 |
2342 } } // namespace v8::internal | 2342 } } // namespace v8::internal |
OLD | NEW |