| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 storage->Unlink(); | 331 storage->Unlink(); |
| 332 storage->LinkTo(&free_list_); | 332 storage->LinkTo(&free_list_); |
| 333 } | 333 } |
| 334 | 334 |
| 335 Isolate* Isolate::default_isolate_ = NULL; | 335 Isolate* Isolate::default_isolate_ = NULL; |
| 336 Thread::LocalStorageKey Isolate::isolate_key_; | 336 Thread::LocalStorageKey Isolate::isolate_key_; |
| 337 Thread::LocalStorageKey Isolate::thread_id_key_; | 337 Thread::LocalStorageKey Isolate::thread_id_key_; |
| 338 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; | 338 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; |
| 339 Mutex* Isolate::process_wide_mutex_ = OS::CreateMutex(); | 339 Mutex* Isolate::process_wide_mutex_ = OS::CreateMutex(); |
| 340 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; | 340 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; |
| 341 | 341 Atomic32 Isolate::isolate_counter_ = 0; |
| 342 | 342 |
| 343 Isolate::PerIsolateThreadData* Isolate::AllocatePerIsolateThreadData( | 343 Isolate::PerIsolateThreadData* Isolate::AllocatePerIsolateThreadData( |
| 344 ThreadId thread_id) { | 344 ThreadId thread_id) { |
| 345 ASSERT(!thread_id.Equals(ThreadId::Invalid())); | 345 ASSERT(!thread_id.Equals(ThreadId::Invalid())); |
| 346 PerIsolateThreadData* per_thread = new PerIsolateThreadData(this, thread_id); | 346 PerIsolateThreadData* per_thread = new PerIsolateThreadData(this, thread_id); |
| 347 { | 347 { |
| 348 ScopedLock lock(process_wide_mutex_); | 348 ScopedLock lock(process_wide_mutex_); |
| 349 ASSERT(thread_data_table_->Lookup(this, thread_id) == NULL); | 349 ASSERT(thread_data_table_->Lookup(this, thread_id) == NULL); |
| 350 thread_data_table_->Insert(per_thread); | 350 thread_data_table_->Insert(per_thread); |
| 351 ASSERT(thread_data_table_->Lookup(this, thread_id) == per_thread); | 351 ASSERT(thread_data_table_->Lookup(this, thread_id) == per_thread); |
| (...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1617 if (data->isolate() == isolate) Remove(data); | 1617 if (data->isolate() == isolate) Remove(data); |
| 1618 data = next; | 1618 data = next; |
| 1619 } | 1619 } |
| 1620 } | 1620 } |
| 1621 | 1621 |
| 1622 | 1622 |
| 1623 #ifdef DEBUG | 1623 #ifdef DEBUG |
| 1624 #define TRACE_ISOLATE(tag) \ | 1624 #define TRACE_ISOLATE(tag) \ |
| 1625 do { \ | 1625 do { \ |
| 1626 if (FLAG_trace_isolates) { \ | 1626 if (FLAG_trace_isolates) { \ |
| 1627 PrintF("Isolate %p " #tag "\n", reinterpret_cast<void*>(this)); \ | 1627 PrintF("Isolate %p (id %d)" #tag "\n", \ |
| 1628 reinterpret_cast<void*>(this), id()); \ |
| 1628 } \ | 1629 } \ |
| 1629 } while (false) | 1630 } while (false) |
| 1630 #else | 1631 #else |
| 1631 #define TRACE_ISOLATE(tag) | 1632 #define TRACE_ISOLATE(tag) |
| 1632 #endif | 1633 #endif |
| 1633 | 1634 |
| 1634 | 1635 |
| 1635 Isolate::Isolate() | 1636 Isolate::Isolate() |
| 1636 : state_(UNINITIALIZED), | 1637 : state_(UNINITIALIZED), |
| 1637 embedder_data_(NULL), | 1638 embedder_data_(NULL), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1677 has_installed_extensions_(false), | 1678 has_installed_extensions_(false), |
| 1678 string_tracker_(NULL), | 1679 string_tracker_(NULL), |
| 1679 regexp_stack_(NULL), | 1680 regexp_stack_(NULL), |
| 1680 date_cache_(NULL), | 1681 date_cache_(NULL), |
| 1681 code_stub_interface_descriptors_(NULL), | 1682 code_stub_interface_descriptors_(NULL), |
| 1682 context_exit_happened_(false), | 1683 context_exit_happened_(false), |
| 1683 deferred_handles_head_(NULL), | 1684 deferred_handles_head_(NULL), |
| 1684 optimizing_compiler_thread_(this), | 1685 optimizing_compiler_thread_(this), |
| 1685 marking_thread_(NULL), | 1686 marking_thread_(NULL), |
| 1686 sweeper_thread_(NULL) { | 1687 sweeper_thread_(NULL) { |
| 1688 id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1); |
| 1687 TRACE_ISOLATE(constructor); | 1689 TRACE_ISOLATE(constructor); |
| 1688 | 1690 |
| 1689 memset(isolate_addresses_, 0, | 1691 memset(isolate_addresses_, 0, |
| 1690 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); | 1692 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); |
| 1691 | 1693 |
| 1692 heap_.isolate_ = this; | 1694 heap_.isolate_ = this; |
| 1693 stack_guard_.isolate_ = this; | 1695 stack_guard_.isolate_ = this; |
| 1694 | 1696 |
| 1695 // ThreadManager is initialized early to support locking an isolate | 1697 // ThreadManager is initialized early to support locking an isolate |
| 1696 // before it is entered. | 1698 // before it is entered. |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2304 } | 2306 } |
| 2305 if (deferred->next_ != NULL) { | 2307 if (deferred->next_ != NULL) { |
| 2306 deferred->next_->previous_ = deferred->previous_; | 2308 deferred->next_->previous_ = deferred->previous_; |
| 2307 } | 2309 } |
| 2308 if (deferred->previous_ != NULL) { | 2310 if (deferred->previous_ != NULL) { |
| 2309 deferred->previous_->next_ = deferred->next_; | 2311 deferred->previous_->next_ = deferred->next_; |
| 2310 } | 2312 } |
| 2311 } | 2313 } |
| 2312 | 2314 |
| 2313 | 2315 |
| 2316 HTracer* Isolate::GetHTracer() { |
| 2317 if (htracer() == NULL) set_htracer(new HTracer(id())); |
| 2318 return htracer(); |
| 2319 } |
| 2320 |
| 2321 |
| 2314 CodeStubInterfaceDescriptor* | 2322 CodeStubInterfaceDescriptor* |
| 2315 Isolate::code_stub_interface_descriptor(int index) { | 2323 Isolate::code_stub_interface_descriptor(int index) { |
| 2316 return code_stub_interface_descriptors_ + index; | 2324 return code_stub_interface_descriptors_ + index; |
| 2317 } | 2325 } |
| 2318 | 2326 |
| 2319 | 2327 |
| 2320 #ifdef DEBUG | 2328 #ifdef DEBUG |
| 2321 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2329 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
| 2322 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2330 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
| 2323 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2331 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
| 2324 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2332 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 2325 #undef ISOLATE_FIELD_OFFSET | 2333 #undef ISOLATE_FIELD_OFFSET |
| 2326 #endif | 2334 #endif |
| 2327 | 2335 |
| 2328 } } // namespace v8::internal | 2336 } } // namespace v8::internal |
| OLD | NEW |