| 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 "src/isolate.h" | 5 #include "src/isolate.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 2012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2023 } | 2023 } |
| 2024 | 2024 |
| 2025 | 2025 |
| 2026 Isolate::ThreadDataTable::~ThreadDataTable() { | 2026 Isolate::ThreadDataTable::~ThreadDataTable() { |
| 2027 // TODO(svenpanne) The assertion below would fire if an embedder does not | 2027 // TODO(svenpanne) The assertion below would fire if an embedder does not |
| 2028 // cleanly dispose all Isolates before disposing v8, so we are conservative | 2028 // cleanly dispose all Isolates before disposing v8, so we are conservative |
| 2029 // and leave it out for now. | 2029 // and leave it out for now. |
| 2030 // DCHECK_NULL(list_); | 2030 // DCHECK_NULL(list_); |
| 2031 } | 2031 } |
| 2032 | 2032 |
| 2033 void Isolate::ReleaseManagedObjects() { |
| 2034 Isolate::ManagedObjectFinalizer* current = |
| 2035 managed_object_finalizers_list_.next_; |
| 2036 while (current != nullptr) { |
| 2037 Isolate::ManagedObjectFinalizer* next = current->next_; |
| 2038 current->Dispose(); |
| 2039 delete current; |
| 2040 current = next; |
| 2041 } |
| 2042 } |
| 2043 |
| 2044 Isolate::ManagedObjectFinalizer* Isolate::RegisterForReleaseAtTeardown( |
| 2045 void* value, Isolate::ManagedObjectFinalizer::Deleter deleter) { |
| 2046 DCHECK_NOT_NULL(value); |
| 2047 DCHECK_NOT_NULL(deleter); |
| 2048 |
| 2049 Isolate::ManagedObjectFinalizer* ret = new Isolate::ManagedObjectFinalizer(); |
| 2050 ret->value_ = value; |
| 2051 ret->deleter_ = deleter; |
| 2052 // Insert at head. We keep the head alive for the lifetime of the Isolate |
| 2053 // because otherwise we can't reset the head, should we delete it before |
| 2054 // the isolate expires |
| 2055 Isolate::ManagedObjectFinalizer* next = managed_object_finalizers_list_.next_; |
| 2056 managed_object_finalizers_list_.next_ = ret; |
| 2057 ret->prev_ = &managed_object_finalizers_list_; |
| 2058 ret->next_ = next; |
| 2059 if (next != nullptr) next->prev_ = ret; |
| 2060 return ret; |
| 2061 } |
| 2062 |
| 2063 void Isolate::UnregisterFromReleaseAtTeardown( |
| 2064 Isolate::ManagedObjectFinalizer** finalizer_ptr) { |
| 2065 DCHECK_NOT_NULL(finalizer_ptr); |
| 2066 Isolate::ManagedObjectFinalizer* finalizer = *finalizer_ptr; |
| 2067 DCHECK_NOT_NULL(finalizer->prev_); |
| 2068 |
| 2069 finalizer->prev_->next_ = finalizer->next_; |
| 2070 if (finalizer->next_ != nullptr) finalizer->next_->prev_ = finalizer->prev_; |
| 2071 delete finalizer; |
| 2072 *finalizer_ptr = nullptr; |
| 2073 } |
| 2033 | 2074 |
| 2034 Isolate::PerIsolateThreadData::~PerIsolateThreadData() { | 2075 Isolate::PerIsolateThreadData::~PerIsolateThreadData() { |
| 2035 #if defined(USE_SIMULATOR) | 2076 #if defined(USE_SIMULATOR) |
| 2036 delete simulator_; | 2077 delete simulator_; |
| 2037 #endif | 2078 #endif |
| 2038 } | 2079 } |
| 2039 | 2080 |
| 2040 | 2081 |
| 2041 Isolate::PerIsolateThreadData* | 2082 Isolate::PerIsolateThreadData* |
| 2042 Isolate::ThreadDataTable::Lookup(Isolate* isolate, | 2083 Isolate::ThreadDataTable::Lookup(Isolate* isolate, |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2392 | 2433 |
| 2393 delete cpu_profiler_; | 2434 delete cpu_profiler_; |
| 2394 cpu_profiler_ = NULL; | 2435 cpu_profiler_ = NULL; |
| 2395 | 2436 |
| 2396 code_event_dispatcher_.reset(); | 2437 code_event_dispatcher_.reset(); |
| 2397 | 2438 |
| 2398 delete root_index_map_; | 2439 delete root_index_map_; |
| 2399 root_index_map_ = NULL; | 2440 root_index_map_ = NULL; |
| 2400 | 2441 |
| 2401 ClearSerializerData(); | 2442 ClearSerializerData(); |
| 2443 ReleaseManagedObjects(); |
| 2402 } | 2444 } |
| 2403 | 2445 |
| 2404 | 2446 |
| 2405 void Isolate::SetIsolateThreadLocals(Isolate* isolate, | 2447 void Isolate::SetIsolateThreadLocals(Isolate* isolate, |
| 2406 PerIsolateThreadData* data) { | 2448 PerIsolateThreadData* data) { |
| 2407 base::Thread::SetThreadLocal(isolate_key_, isolate); | 2449 base::Thread::SetThreadLocal(isolate_key_, isolate); |
| 2408 base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data); | 2450 base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data); |
| 2409 } | 2451 } |
| 2410 | 2452 |
| 2411 | 2453 |
| (...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3653 // Then check whether this scope intercepts. | 3695 // Then check whether this scope intercepts. |
| 3654 if ((flag & intercept_mask_)) { | 3696 if ((flag & intercept_mask_)) { |
| 3655 intercepted_flags_ |= flag; | 3697 intercepted_flags_ |= flag; |
| 3656 return true; | 3698 return true; |
| 3657 } | 3699 } |
| 3658 return false; | 3700 return false; |
| 3659 } | 3701 } |
| 3660 | 3702 |
| 3661 } // namespace internal | 3703 } // namespace internal |
| 3662 } // namespace v8 | 3704 } // namespace v8 |
| OLD | NEW |