| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } | 340 } |
| 341 | 341 |
| 342 Isolate* Isolate::default_isolate_ = NULL; | 342 Isolate* Isolate::default_isolate_ = NULL; |
| 343 Thread::LocalStorageKey Isolate::isolate_key_; | 343 Thread::LocalStorageKey Isolate::isolate_key_; |
| 344 Thread::LocalStorageKey Isolate::thread_id_key_; | 344 Thread::LocalStorageKey Isolate::thread_id_key_; |
| 345 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; | 345 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; |
| 346 #ifdef DEBUG | 346 #ifdef DEBUG |
| 347 Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; | 347 Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; |
| 348 #endif // DEBUG | 348 #endif // DEBUG |
| 349 Mutex Isolate::process_wide_mutex_; | 349 Mutex Isolate::process_wide_mutex_; |
| 350 // TODO(dcarney): Remove with default isolate. |
| 351 enum DefaultIsolateStatus { |
| 352 kDefaultIsolateUninitialized, |
| 353 kDefaultIsolateInitialized, |
| 354 kDefaultIsolateCrashIfInitialized |
| 355 }; |
| 356 static DefaultIsolateStatus default_isolate_status_ |
| 357 = kDefaultIsolateUninitialized; |
| 350 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; | 358 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; |
| 351 Atomic32 Isolate::isolate_counter_ = 0; | 359 Atomic32 Isolate::isolate_counter_ = 0; |
| 352 | 360 |
| 353 Isolate::PerIsolateThreadData* | 361 Isolate::PerIsolateThreadData* |
| 354 Isolate::FindOrAllocatePerThreadDataForThisThread() { | 362 Isolate::FindOrAllocatePerThreadDataForThisThread() { |
| 355 ThreadId thread_id = ThreadId::Current(); | 363 ThreadId thread_id = ThreadId::Current(); |
| 356 PerIsolateThreadData* per_thread = NULL; | 364 PerIsolateThreadData* per_thread = NULL; |
| 357 { | 365 { |
| 358 LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 366 LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
| 359 per_thread = thread_data_table_->Lookup(this, thread_id); | 367 per_thread = thread_data_table_->Lookup(this, thread_id); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 377 ThreadId thread_id) { | 385 ThreadId thread_id) { |
| 378 PerIsolateThreadData* per_thread = NULL; | 386 PerIsolateThreadData* per_thread = NULL; |
| 379 { | 387 { |
| 380 LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 388 LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
| 381 per_thread = thread_data_table_->Lookup(this, thread_id); | 389 per_thread = thread_data_table_->Lookup(this, thread_id); |
| 382 } | 390 } |
| 383 return per_thread; | 391 return per_thread; |
| 384 } | 392 } |
| 385 | 393 |
| 386 | 394 |
| 395 void Isolate::SetCrashIfDefaultIsolateInitialized() { |
| 396 LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
| 397 CHECK(default_isolate_status_ != kDefaultIsolateInitialized); |
| 398 default_isolate_status_ = kDefaultIsolateCrashIfInitialized; |
| 399 } |
| 400 |
| 401 |
| 387 void Isolate::EnsureDefaultIsolate() { | 402 void Isolate::EnsureDefaultIsolate() { |
| 388 LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 403 LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
| 404 CHECK(default_isolate_status_ != kDefaultIsolateCrashIfInitialized); |
| 389 if (default_isolate_ == NULL) { | 405 if (default_isolate_ == NULL) { |
| 390 isolate_key_ = Thread::CreateThreadLocalKey(); | 406 isolate_key_ = Thread::CreateThreadLocalKey(); |
| 391 thread_id_key_ = Thread::CreateThreadLocalKey(); | 407 thread_id_key_ = Thread::CreateThreadLocalKey(); |
| 392 per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey(); | 408 per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey(); |
| 393 #ifdef DEBUG | 409 #ifdef DEBUG |
| 394 PerThreadAssertScopeBase::thread_local_key = Thread::CreateThreadLocalKey(); | 410 PerThreadAssertScopeBase::thread_local_key = Thread::CreateThreadLocalKey(); |
| 395 #endif // DEBUG | 411 #endif // DEBUG |
| 396 thread_data_table_ = new Isolate::ThreadDataTable(); | 412 thread_data_table_ = new Isolate::ThreadDataTable(); |
| 397 default_isolate_ = new Isolate(); | 413 default_isolate_ = new Isolate(); |
| 398 } | 414 } |
| (...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 thread_manager_(NULL), | 1789 thread_manager_(NULL), |
| 1774 fp_stubs_generated_(false), | 1790 fp_stubs_generated_(false), |
| 1775 has_installed_extensions_(false), | 1791 has_installed_extensions_(false), |
| 1776 string_tracker_(NULL), | 1792 string_tracker_(NULL), |
| 1777 regexp_stack_(NULL), | 1793 regexp_stack_(NULL), |
| 1778 date_cache_(NULL), | 1794 date_cache_(NULL), |
| 1779 code_stub_interface_descriptors_(NULL), | 1795 code_stub_interface_descriptors_(NULL), |
| 1780 // TODO(bmeurer) Initialized lazily because it depends on flags; can | 1796 // TODO(bmeurer) Initialized lazily because it depends on flags; can |
| 1781 // be fixed once the default isolate cleanup is done. | 1797 // be fixed once the default isolate cleanup is done. |
| 1782 random_number_generator_(NULL), | 1798 random_number_generator_(NULL), |
| 1799 // TODO(rmcilroy) Currently setting this based on |
| 1800 // FLAG_force_memory_constrained in Isolate::Init; move to here when |
| 1801 // isolate cleanup is done |
| 1783 is_memory_constrained_(false), | 1802 is_memory_constrained_(false), |
| 1784 has_fatal_error_(false), | 1803 has_fatal_error_(false), |
| 1785 use_crankshaft_(true), | 1804 use_crankshaft_(true), |
| 1786 initialized_from_snapshot_(false), | 1805 initialized_from_snapshot_(false), |
| 1787 cpu_profiler_(NULL), | 1806 cpu_profiler_(NULL), |
| 1788 heap_profiler_(NULL), | 1807 heap_profiler_(NULL), |
| 1789 function_entry_hook_(NULL), | 1808 function_entry_hook_(NULL), |
| 1790 deferred_handles_head_(NULL), | 1809 deferred_handles_head_(NULL), |
| 1791 optimizing_compiler_thread_(this), | 1810 optimizing_compiler_thread_(this), |
| 1792 marking_thread_(NULL), | 1811 marking_thread_(NULL), |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2133 Release_Store(&debugger_initialized_, true); | 2152 Release_Store(&debugger_initialized_, true); |
| 2134 #endif | 2153 #endif |
| 2135 } | 2154 } |
| 2136 | 2155 |
| 2137 | 2156 |
| 2138 bool Isolate::Init(Deserializer* des) { | 2157 bool Isolate::Init(Deserializer* des) { |
| 2139 ASSERT(state_ != INITIALIZED); | 2158 ASSERT(state_ != INITIALIZED); |
| 2140 TRACE_ISOLATE(init); | 2159 TRACE_ISOLATE(init); |
| 2141 | 2160 |
| 2142 stress_deopt_count_ = FLAG_deopt_every_n_times; | 2161 stress_deopt_count_ = FLAG_deopt_every_n_times; |
| 2162 if (FLAG_force_memory_constrained.has_value) |
| 2163 is_memory_constrained_ = FLAG_force_memory_constrained.value; |
| 2143 | 2164 |
| 2144 has_fatal_error_ = false; | 2165 has_fatal_error_ = false; |
| 2145 | 2166 |
| 2146 use_crankshaft_ = FLAG_crankshaft | 2167 use_crankshaft_ = FLAG_crankshaft |
| 2147 && !Serializer::enabled() | 2168 && !Serializer::enabled() |
| 2148 && CPU::SupportsCrankshaft(); | 2169 && CPU::SupportsCrankshaft(); |
| 2149 | 2170 |
| 2150 if (function_entry_hook() != NULL) { | 2171 if (function_entry_hook() != NULL) { |
| 2151 // When function entry hooking is in effect, we have to create the code | 2172 // When function entry hooking is in effect, we have to create the code |
| 2152 // stubs from scratch to get entry hooks, rather than loading the previously | 2173 // stubs from scratch to get entry hooks, rather than loading the previously |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2526 | 2547 |
| 2527 #ifdef DEBUG | 2548 #ifdef DEBUG |
| 2528 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2549 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
| 2529 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2550 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
| 2530 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2551 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
| 2531 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2552 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 2532 #undef ISOLATE_FIELD_OFFSET | 2553 #undef ISOLATE_FIELD_OFFSET |
| 2533 #endif | 2554 #endif |
| 2534 | 2555 |
| 2535 } } // namespace v8::internal | 2556 } } // namespace v8::internal |
| OLD | NEW |