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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 storage->LinkTo(&free_list_); | 336 storage->LinkTo(&free_list_); |
337 } | 337 } |
338 | 338 |
339 Isolate* Isolate::default_isolate_ = NULL; | 339 Isolate* Isolate::default_isolate_ = NULL; |
340 Thread::LocalStorageKey Isolate::isolate_key_; | 340 Thread::LocalStorageKey Isolate::isolate_key_; |
341 Thread::LocalStorageKey Isolate::thread_id_key_; | 341 Thread::LocalStorageKey Isolate::thread_id_key_; |
342 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; | 342 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; |
343 #ifdef DEBUG | 343 #ifdef DEBUG |
344 Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; | 344 Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; |
345 #endif // DEBUG | 345 #endif // DEBUG |
346 Mutex Isolate::process_wide_mutex_; | 346 Mutex* Isolate::process_wide_mutex_ = OS::CreateMutex(); |
347 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; | 347 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; |
348 Atomic32 Isolate::isolate_counter_ = 0; | 348 Atomic32 Isolate::isolate_counter_ = 0; |
349 | 349 |
350 Isolate::PerIsolateThreadData* Isolate::AllocatePerIsolateThreadData( | 350 Isolate::PerIsolateThreadData* Isolate::AllocatePerIsolateThreadData( |
351 ThreadId thread_id) { | 351 ThreadId thread_id) { |
352 ASSERT(!thread_id.Equals(ThreadId::Invalid())); | 352 ASSERT(!thread_id.Equals(ThreadId::Invalid())); |
353 PerIsolateThreadData* per_thread = new PerIsolateThreadData(this, thread_id); | 353 PerIsolateThreadData* per_thread = new PerIsolateThreadData(this, thread_id); |
354 { | 354 { |
355 ScopedLock lock(&process_wide_mutex_); | 355 ScopedLock lock(process_wide_mutex_); |
356 ASSERT(thread_data_table_->Lookup(this, thread_id) == NULL); | 356 ASSERT(thread_data_table_->Lookup(this, thread_id) == NULL); |
357 thread_data_table_->Insert(per_thread); | 357 thread_data_table_->Insert(per_thread); |
358 ASSERT(thread_data_table_->Lookup(this, thread_id) == per_thread); | 358 ASSERT(thread_data_table_->Lookup(this, thread_id) == per_thread); |
359 } | 359 } |
360 return per_thread; | 360 return per_thread; |
361 } | 361 } |
362 | 362 |
363 | 363 |
364 Isolate::PerIsolateThreadData* | 364 Isolate::PerIsolateThreadData* |
365 Isolate::FindOrAllocatePerThreadDataForThisThread() { | 365 Isolate::FindOrAllocatePerThreadDataForThisThread() { |
366 ThreadId thread_id = ThreadId::Current(); | 366 ThreadId thread_id = ThreadId::Current(); |
367 PerIsolateThreadData* per_thread = NULL; | 367 PerIsolateThreadData* per_thread = NULL; |
368 { | 368 { |
369 ScopedLock lock(&process_wide_mutex_); | 369 ScopedLock lock(process_wide_mutex_); |
370 per_thread = thread_data_table_->Lookup(this, thread_id); | 370 per_thread = thread_data_table_->Lookup(this, thread_id); |
371 } | 371 if (per_thread == NULL) { |
372 if (per_thread == NULL) { | 372 per_thread = AllocatePerIsolateThreadData(thread_id); |
373 per_thread = AllocatePerIsolateThreadData(thread_id); | 373 } |
374 } | 374 } |
375 return per_thread; | 375 return per_thread; |
376 } | 376 } |
377 | 377 |
378 | 378 |
379 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThisThread() { | 379 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThisThread() { |
380 ThreadId thread_id = ThreadId::Current(); | 380 ThreadId thread_id = ThreadId::Current(); |
381 return FindPerThreadDataForThread(thread_id); | 381 return FindPerThreadDataForThread(thread_id); |
382 } | 382 } |
383 | 383 |
384 | 384 |
385 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThread( | 385 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThread( |
386 ThreadId thread_id) { | 386 ThreadId thread_id) { |
387 PerIsolateThreadData* per_thread = NULL; | 387 PerIsolateThreadData* per_thread = NULL; |
388 { | 388 { |
389 ScopedLock lock(&process_wide_mutex_); | 389 ScopedLock lock(process_wide_mutex_); |
390 per_thread = thread_data_table_->Lookup(this, thread_id); | 390 per_thread = thread_data_table_->Lookup(this, thread_id); |
391 } | 391 } |
392 return per_thread; | 392 return per_thread; |
393 } | 393 } |
394 | 394 |
395 | 395 |
396 void Isolate::EnsureDefaultIsolate() { | 396 void Isolate::EnsureDefaultIsolate() { |
397 ScopedLock lock(&process_wide_mutex_); | 397 ScopedLock lock(process_wide_mutex_); |
398 if (default_isolate_ == NULL) { | 398 if (default_isolate_ == NULL) { |
399 isolate_key_ = Thread::CreateThreadLocalKey(); | 399 isolate_key_ = Thread::CreateThreadLocalKey(); |
400 thread_id_key_ = Thread::CreateThreadLocalKey(); | 400 thread_id_key_ = Thread::CreateThreadLocalKey(); |
401 per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey(); | 401 per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey(); |
402 #ifdef DEBUG | 402 #ifdef DEBUG |
403 PerThreadAssertScopeBase::thread_local_key = Thread::CreateThreadLocalKey(); | 403 PerThreadAssertScopeBase::thread_local_key = Thread::CreateThreadLocalKey(); |
404 #endif // DEBUG | 404 #endif // DEBUG |
405 thread_data_table_ = new Isolate::ThreadDataTable(); | 405 thread_data_table_ = new Isolate::ThreadDataTable(); |
406 default_isolate_ = new Isolate(); | 406 default_isolate_ = new Isolate(); |
407 } | 407 } |
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1742 stack_trace_nesting_level_(0), | 1742 stack_trace_nesting_level_(0), |
1743 incomplete_message_(NULL), | 1743 incomplete_message_(NULL), |
1744 preallocated_memory_thread_(NULL), | 1744 preallocated_memory_thread_(NULL), |
1745 preallocated_message_space_(NULL), | 1745 preallocated_message_space_(NULL), |
1746 bootstrapper_(NULL), | 1746 bootstrapper_(NULL), |
1747 runtime_profiler_(NULL), | 1747 runtime_profiler_(NULL), |
1748 compilation_cache_(NULL), | 1748 compilation_cache_(NULL), |
1749 counters_(NULL), | 1749 counters_(NULL), |
1750 code_range_(NULL), | 1750 code_range_(NULL), |
1751 // Must be initialized early to allow v8::SetResourceConstraints calls. | 1751 // Must be initialized early to allow v8::SetResourceConstraints calls. |
| 1752 break_access_(OS::CreateMutex()), |
1752 debugger_initialized_(false), | 1753 debugger_initialized_(false), |
1753 // Must be initialized early to allow v8::Debug calls. | 1754 // Must be initialized early to allow v8::Debug calls. |
| 1755 debugger_access_(OS::CreateMutex()), |
1754 logger_(NULL), | 1756 logger_(NULL), |
1755 stats_table_(NULL), | 1757 stats_table_(NULL), |
1756 stub_cache_(NULL), | 1758 stub_cache_(NULL), |
1757 deoptimizer_data_(NULL), | 1759 deoptimizer_data_(NULL), |
1758 capture_stack_trace_for_uncaught_exceptions_(false), | 1760 capture_stack_trace_for_uncaught_exceptions_(false), |
1759 stack_trace_for_uncaught_exceptions_frame_limit_(0), | 1761 stack_trace_for_uncaught_exceptions_frame_limit_(0), |
1760 stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview), | 1762 stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview), |
1761 transcendental_cache_(NULL), | 1763 transcendental_cache_(NULL), |
1762 memory_allocator_(NULL), | 1764 memory_allocator_(NULL), |
1763 keyed_lookup_cache_(NULL), | 1765 keyed_lookup_cache_(NULL), |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1844 // Temporarily set this isolate as current so that various parts of | 1846 // Temporarily set this isolate as current so that various parts of |
1845 // the isolate can access it in their destructors without having a | 1847 // the isolate can access it in their destructors without having a |
1846 // direct pointer. We don't use Enter/Exit here to avoid | 1848 // direct pointer. We don't use Enter/Exit here to avoid |
1847 // initializing the thread data. | 1849 // initializing the thread data. |
1848 PerIsolateThreadData* saved_data = CurrentPerIsolateThreadData(); | 1850 PerIsolateThreadData* saved_data = CurrentPerIsolateThreadData(); |
1849 Isolate* saved_isolate = UncheckedCurrent(); | 1851 Isolate* saved_isolate = UncheckedCurrent(); |
1850 SetIsolateThreadLocals(this, NULL); | 1852 SetIsolateThreadLocals(this, NULL); |
1851 | 1853 |
1852 Deinit(); | 1854 Deinit(); |
1853 | 1855 |
1854 { ScopedLock lock(&process_wide_mutex_); | 1856 { ScopedLock lock(process_wide_mutex_); |
1855 thread_data_table_->RemoveAllThreads(this); | 1857 thread_data_table_->RemoveAllThreads(this); |
1856 } | 1858 } |
1857 | 1859 |
1858 if (serialize_partial_snapshot_cache_ != NULL) { | 1860 if (serialize_partial_snapshot_cache_ != NULL) { |
1859 delete[] serialize_partial_snapshot_cache_; | 1861 delete[] serialize_partial_snapshot_cache_; |
1860 serialize_partial_snapshot_cache_ = NULL; | 1862 serialize_partial_snapshot_cache_ = NULL; |
1861 } | 1863 } |
1862 | 1864 |
1863 if (!IsDefaultIsolate()) { | 1865 if (!IsDefaultIsolate()) { |
1864 delete this; | 1866 delete this; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 stats_table_ = NULL; | 2017 stats_table_ = NULL; |
2016 | 2018 |
2017 delete logger_; | 2019 delete logger_; |
2018 logger_ = NULL; | 2020 logger_ = NULL; |
2019 | 2021 |
2020 delete counters_; | 2022 delete counters_; |
2021 counters_ = NULL; | 2023 counters_ = NULL; |
2022 | 2024 |
2023 delete handle_scope_implementer_; | 2025 delete handle_scope_implementer_; |
2024 handle_scope_implementer_ = NULL; | 2026 handle_scope_implementer_ = NULL; |
| 2027 delete break_access_; |
| 2028 break_access_ = NULL; |
| 2029 delete debugger_access_; |
| 2030 debugger_access_ = NULL; |
2025 | 2031 |
2026 delete compilation_cache_; | 2032 delete compilation_cache_; |
2027 compilation_cache_ = NULL; | 2033 compilation_cache_ = NULL; |
2028 delete bootstrapper_; | 2034 delete bootstrapper_; |
2029 bootstrapper_ = NULL; | 2035 bootstrapper_ = NULL; |
2030 delete inner_pointer_to_code_cache_; | 2036 delete inner_pointer_to_code_cache_; |
2031 inner_pointer_to_code_cache_ = NULL; | 2037 inner_pointer_to_code_cache_ = NULL; |
2032 delete write_iterator_; | 2038 delete write_iterator_; |
2033 write_iterator_ = NULL; | 2039 write_iterator_ = NULL; |
2034 | 2040 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2114 logger_ = new Logger(this); | 2120 logger_ = new Logger(this); |
2115 } | 2121 } |
2116 if (counters_ == NULL) { | 2122 if (counters_ == NULL) { |
2117 counters_ = new Counters(this); | 2123 counters_ = new Counters(this); |
2118 } | 2124 } |
2119 } | 2125 } |
2120 | 2126 |
2121 | 2127 |
2122 void Isolate::InitializeDebugger() { | 2128 void Isolate::InitializeDebugger() { |
2123 #ifdef ENABLE_DEBUGGER_SUPPORT | 2129 #ifdef ENABLE_DEBUGGER_SUPPORT |
2124 ScopedLock lock(&debugger_access_); | 2130 ScopedLock lock(debugger_access_); |
2125 if (NoBarrier_Load(&debugger_initialized_)) return; | 2131 if (NoBarrier_Load(&debugger_initialized_)) return; |
2126 InitializeLoggingAndCounters(); | 2132 InitializeLoggingAndCounters(); |
2127 debug_ = new Debug(this); | 2133 debug_ = new Debug(this); |
2128 debugger_ = new Debugger(this); | 2134 debugger_ = new Debugger(this); |
2129 Release_Store(&debugger_initialized_, true); | 2135 Release_Store(&debugger_initialized_, true); |
2130 #endif | 2136 #endif |
2131 } | 2137 } |
2132 | 2138 |
2133 | 2139 |
2134 bool Isolate::Init(Deserializer* des) { | 2140 bool Isolate::Init(Deserializer* des) { |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2516 | 2522 |
2517 #ifdef DEBUG | 2523 #ifdef DEBUG |
2518 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2524 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
2519 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2525 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
2520 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2526 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
2521 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2527 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
2522 #undef ISOLATE_FIELD_OFFSET | 2528 #undef ISOLATE_FIELD_OFFSET |
2523 #endif | 2529 #endif |
2524 | 2530 |
2525 } } // namespace v8::internal | 2531 } } // namespace v8::internal |
OLD | NEW |