Chromium Code Reviews| 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 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 RecursiveMutex Isolate::process_wide_mutex_; | 346 RecursiveMutex Isolate::process_wide_mutex_; |
| 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( | |
| 351 ThreadId thread_id) { | |
| 352 ASSERT(!thread_id.Equals(ThreadId::Invalid())); | |
| 353 PerIsolateThreadData* per_thread = new PerIsolateThreadData(this, thread_id); | |
| 354 { | |
| 355 LockGuard<RecursiveMutex> lock_guard(&process_wide_mutex_); | |
| 356 ASSERT(thread_data_table_->Lookup(this, thread_id) == NULL); | |
| 357 thread_data_table_->Insert(per_thread); | |
| 358 ASSERT(thread_data_table_->Lookup(this, thread_id) == per_thread); | |
| 359 } | |
| 360 return per_thread; | |
| 361 } | |
| 362 | |
| 363 | |
| 364 Isolate::PerIsolateThreadData* | 350 Isolate::PerIsolateThreadData* |
| 365 Isolate::FindOrAllocatePerThreadDataForThisThread() { | 351 Isolate::FindOrAllocatePerThreadDataForThisThread() { |
| 366 ThreadId thread_id = ThreadId::Current(); | 352 ThreadId thread_id = ThreadId::Current(); |
| 367 PerIsolateThreadData* per_thread = NULL; | 353 PerIsolateThreadData* per_thread = NULL; |
| 368 { | 354 { |
| 369 LockGuard<RecursiveMutex> lock_guard(&process_wide_mutex_); | 355 LockGuard<RecursiveMutex> lock_guard(&process_wide_mutex_); |
| 370 per_thread = thread_data_table_->Lookup(this, thread_id); | 356 per_thread = thread_data_table_->Lookup(this, thread_id); |
| 371 if (per_thread == NULL) { | 357 if (per_thread == NULL) { |
| 372 per_thread = AllocatePerIsolateThreadData(thread_id); | 358 per_thread = new PerIsolateThreadData(this, thread_id); |
| 359 thread_data_table_->Insert(per_thread); | |
|
Benedikt Meurer
2013/09/06 12:54:08
With this change, the process_wide_mutex_ can be t
| |
| 373 } | 360 } |
| 374 } | 361 } |
| 362 ASSERT(thread_data_table_->Lookup(this, thread_id) == per_thread); | |
| 375 return per_thread; | 363 return per_thread; |
| 376 } | 364 } |
| 377 | 365 |
| 378 | 366 |
| 379 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThisThread() { | 367 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThisThread() { |
| 380 ThreadId thread_id = ThreadId::Current(); | 368 ThreadId thread_id = ThreadId::Current(); |
| 381 return FindPerThreadDataForThread(thread_id); | 369 return FindPerThreadDataForThread(thread_id); |
| 382 } | 370 } |
| 383 | 371 |
| 384 | 372 |
| (...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1710 | 1698 |
| 1711 | 1699 |
| 1712 void Isolate::ThreadDataTable::Remove(PerIsolateThreadData* data) { | 1700 void Isolate::ThreadDataTable::Remove(PerIsolateThreadData* data) { |
| 1713 if (list_ == data) list_ = data->next_; | 1701 if (list_ == data) list_ = data->next_; |
| 1714 if (data->next_ != NULL) data->next_->prev_ = data->prev_; | 1702 if (data->next_ != NULL) data->next_->prev_ = data->prev_; |
| 1715 if (data->prev_ != NULL) data->prev_->next_ = data->next_; | 1703 if (data->prev_ != NULL) data->prev_->next_ = data->next_; |
| 1716 delete data; | 1704 delete data; |
| 1717 } | 1705 } |
| 1718 | 1706 |
| 1719 | 1707 |
| 1720 void Isolate::ThreadDataTable::Remove(Isolate* isolate, | |
| 1721 ThreadId thread_id) { | |
| 1722 PerIsolateThreadData* data = Lookup(isolate, thread_id); | |
| 1723 if (data != NULL) { | |
| 1724 Remove(data); | |
| 1725 } | |
| 1726 } | |
| 1727 | |
| 1728 | |
| 1729 void Isolate::ThreadDataTable::RemoveAllThreads(Isolate* isolate) { | 1708 void Isolate::ThreadDataTable::RemoveAllThreads(Isolate* isolate) { |
| 1730 PerIsolateThreadData* data = list_; | 1709 PerIsolateThreadData* data = list_; |
| 1731 while (data != NULL) { | 1710 while (data != NULL) { |
| 1732 PerIsolateThreadData* next = data->next_; | 1711 PerIsolateThreadData* next = data->next_; |
| 1733 if (data->isolate() == isolate) Remove(data); | 1712 if (data->isolate() == isolate) Remove(data); |
| 1734 data = next; | 1713 data = next; |
| 1735 } | 1714 } |
| 1736 } | 1715 } |
| 1737 | 1716 |
| 1738 | 1717 |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2534 | 2513 |
| 2535 #ifdef DEBUG | 2514 #ifdef DEBUG |
| 2536 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2515 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
| 2537 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2516 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
| 2538 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2517 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
| 2539 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2518 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 2540 #undef ISOLATE_FIELD_OFFSET | 2519 #undef ISOLATE_FIELD_OFFSET |
| 2541 #endif | 2520 #endif |
| 2542 | 2521 |
| 2543 } } // namespace v8::internal | 2522 } } // namespace v8::internal |
| OLD | NEW |