| 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 "v8.h" | 7 #include "v8.h" |
| 8 | 8 |
| 9 #include "ast.h" | 9 #include "ast.h" |
| 10 #include "bootstrapper.h" | 10 #include "bootstrapper.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 #endif | 96 #endif |
| 97 thread_id_ = ThreadId::Current(); | 97 thread_id_ = ThreadId::Current(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 | 100 |
| 101 v8::TryCatch* ThreadLocalTop::TryCatchHandler() { | 101 v8::TryCatch* ThreadLocalTop::TryCatchHandler() { |
| 102 return TRY_CATCH_FROM_ADDRESS(try_catch_handler_address()); | 102 return TRY_CATCH_FROM_ADDRESS(try_catch_handler_address()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 | 105 |
| 106 Isolate* Isolate::default_isolate_ = NULL; | |
| 107 Thread::LocalStorageKey Isolate::isolate_key_; | 106 Thread::LocalStorageKey Isolate::isolate_key_; |
| 108 Thread::LocalStorageKey Isolate::thread_id_key_; | 107 Thread::LocalStorageKey Isolate::thread_id_key_; |
| 109 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; | 108 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; |
| 110 #ifdef DEBUG | 109 #ifdef DEBUG |
| 111 Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; | 110 Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; |
| 112 #endif // DEBUG | 111 #endif // DEBUG |
| 113 Mutex Isolate::process_wide_mutex_; | 112 Mutex Isolate::process_wide_mutex_; |
| 114 // TODO(dcarney): Remove with default isolate. | 113 // TODO(dcarney): Remove with default isolate. |
| 115 enum DefaultIsolateStatus { | 114 enum DefaultIsolateStatus { |
| 116 kDefaultIsolateUninitialized, | 115 kDefaultIsolateUninitialized, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 void Isolate::SetCrashIfDefaultIsolateInitialized() { | 158 void Isolate::SetCrashIfDefaultIsolateInitialized() { |
| 160 LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 159 LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
| 161 CHECK(default_isolate_status_ != kDefaultIsolateInitialized); | 160 CHECK(default_isolate_status_ != kDefaultIsolateInitialized); |
| 162 default_isolate_status_ = kDefaultIsolateCrashIfInitialized; | 161 default_isolate_status_ = kDefaultIsolateCrashIfInitialized; |
| 163 } | 162 } |
| 164 | 163 |
| 165 | 164 |
| 166 void Isolate::EnsureDefaultIsolate() { | 165 void Isolate::EnsureDefaultIsolate() { |
| 167 LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 166 LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
| 168 CHECK(default_isolate_status_ != kDefaultIsolateCrashIfInitialized); | 167 CHECK(default_isolate_status_ != kDefaultIsolateCrashIfInitialized); |
| 169 if (default_isolate_ == NULL) { | 168 if (thread_data_table_ == NULL) { |
| 170 isolate_key_ = Thread::CreateThreadLocalKey(); | 169 isolate_key_ = Thread::CreateThreadLocalKey(); |
| 171 thread_id_key_ = Thread::CreateThreadLocalKey(); | 170 thread_id_key_ = Thread::CreateThreadLocalKey(); |
| 172 per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey(); | 171 per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey(); |
| 173 #ifdef DEBUG | 172 #ifdef DEBUG |
| 174 PerThreadAssertScopeBase::thread_local_key = Thread::CreateThreadLocalKey(); | 173 PerThreadAssertScopeBase::thread_local_key = Thread::CreateThreadLocalKey(); |
| 175 #endif // DEBUG | 174 #endif // DEBUG |
| 176 thread_data_table_ = new Isolate::ThreadDataTable(); | 175 thread_data_table_ = new Isolate::ThreadDataTable(); |
| 177 default_isolate_ = new Isolate(); | |
| 178 } | |
| 179 // Can't use SetIsolateThreadLocals(default_isolate_, NULL) here | |
| 180 // because a non-null thread data may be already set. | |
| 181 if (Thread::GetThreadLocal(isolate_key_) == NULL) { | |
| 182 Thread::SetThreadLocal(isolate_key_, default_isolate_); | |
| 183 } | 176 } |
| 184 } | 177 } |
| 185 | 178 |
| 186 struct StaticInitializer { | 179 struct StaticInitializer { |
| 187 StaticInitializer() { | 180 StaticInitializer() { |
| 188 Isolate::EnsureDefaultIsolate(); | 181 Isolate::EnsureDefaultIsolate(); |
| 189 } | 182 } |
| 190 } static_initializer; | 183 } static_initializer; |
| 191 | 184 |
| 192 | 185 |
| (...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 | 1509 |
| 1517 { LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 1510 { LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
| 1518 thread_data_table_->RemoveAllThreads(this); | 1511 thread_data_table_->RemoveAllThreads(this); |
| 1519 } | 1512 } |
| 1520 | 1513 |
| 1521 if (serialize_partial_snapshot_cache_ != NULL) { | 1514 if (serialize_partial_snapshot_cache_ != NULL) { |
| 1522 delete[] serialize_partial_snapshot_cache_; | 1515 delete[] serialize_partial_snapshot_cache_; |
| 1523 serialize_partial_snapshot_cache_ = NULL; | 1516 serialize_partial_snapshot_cache_ = NULL; |
| 1524 } | 1517 } |
| 1525 | 1518 |
| 1526 if (!IsDefaultIsolate()) { | 1519 delete this; |
| 1527 delete this; | |
| 1528 } | |
| 1529 | 1520 |
| 1530 // Restore the previous current isolate. | 1521 // Restore the previous current isolate. |
| 1531 SetIsolateThreadLocals(saved_isolate, saved_data); | 1522 SetIsolateThreadLocals(saved_isolate, saved_data); |
| 1532 } | 1523 } |
| 1533 | 1524 |
| 1534 | 1525 |
| 1535 void Isolate::GlobalTearDown() { | 1526 void Isolate::GlobalTearDown() { |
| 1536 delete thread_data_table_; | 1527 delete thread_data_table_; |
| 1537 } | 1528 } |
| 1538 | 1529 |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2248 ASSERT(handle_scope_implementer()->CallDepthIsZero()); | 2239 ASSERT(handle_scope_implementer()->CallDepthIsZero()); |
| 2249 | 2240 |
| 2250 // Increase call depth to prevent recursive callbacks. | 2241 // Increase call depth to prevent recursive callbacks. |
| 2251 handle_scope_implementer()->IncrementCallDepth(); | 2242 handle_scope_implementer()->IncrementCallDepth(); |
| 2252 Execution::RunMicrotasks(this); | 2243 Execution::RunMicrotasks(this); |
| 2253 handle_scope_implementer()->DecrementCallDepth(); | 2244 handle_scope_implementer()->DecrementCallDepth(); |
| 2254 } | 2245 } |
| 2255 | 2246 |
| 2256 | 2247 |
| 2257 } } // namespace v8::internal | 2248 } } // namespace v8::internal |
| OLD | NEW |