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 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2015 } | 2015 } |
2016 | 2016 |
2017 | 2017 |
2018 Isolate::ThreadDataTable::~ThreadDataTable() { | 2018 Isolate::ThreadDataTable::~ThreadDataTable() { |
2019 // TODO(svenpanne) The assertion below would fire if an embedder does not | 2019 // TODO(svenpanne) The assertion below would fire if an embedder does not |
2020 // cleanly dispose all Isolates before disposing v8, so we are conservative | 2020 // cleanly dispose all Isolates before disposing v8, so we are conservative |
2021 // and leave it out for now. | 2021 // and leave it out for now. |
2022 // DCHECK_NULL(list_); | 2022 // DCHECK_NULL(list_); |
2023 } | 2023 } |
2024 | 2024 |
2025 void Isolate::ManagedLifeline::CallDeleter() { | |
2026 DCHECK_NOT_NULL(value_); | |
2027 // deleter_ may be null in test scenarios. | |
2028 if (deleter_ != nullptr) { | |
2029 deleter_(value_); | |
2030 } | |
2031 } | |
2032 | |
2033 Isolate::ManagedLifeline::~ManagedLifeline() { | |
2034 // when we delete the Isolate, the destructor will be called for the | |
2035 // managed_list_root_; | |
2036 if (prev_ == nullptr) return; | |
2037 DCHECK_NOT_NULL(value_); | |
2038 | |
2039 prev_->next_ = next_; | |
2040 if (next_ != nullptr) next_->prev_ = prev_; | |
2041 // Used in test - where the memory is allocated by the test. | |
2042 CallDeleter(); | |
2043 } | |
2044 | |
2045 void Isolate::ManagedLifeline::Clear() { | |
titzer
2017/02/08 23:32:47
Something seems weird with this. Why are we using
Mircea Trofin
2017/02/08 23:52:35
This clears the whole list. The destructor deletes
titzer
2017/02/09 04:25:18
Sure, but I don't think it's necessary to have a d
| |
2046 // Should be called from the head of the dlinked list. We don't have a reason | |
2047 // to do otherwise. | |
2048 DCHECK_NULL(prev_); | |
2049 | |
2050 for (Isolate::ManagedLifeline* current = next_; current != nullptr;) { | |
2051 Isolate::ManagedLifeline* next = current->next_; | |
2052 // This also relinks the list, which is redundant in this case, | |
2053 // but that's at most 2 assignments per node. | |
2054 delete current; | |
2055 current = next; | |
2056 } | |
2057 } | |
2058 | |
2059 Isolate::ManagedLifeline* Isolate::AddManagedObject( | |
2060 void* value, Isolate::ManagedLifeline::Deleter deleter) { | |
2061 Isolate::ManagedLifeline* ret = new Isolate::ManagedLifeline(); | |
2062 ret->value_ = value; | |
2063 ret->deleter_ = deleter; | |
2064 // Insert at head. We keep the head alive for the lifetime of the Isolate | |
2065 // because otherwise we can't | |
2066 // reset the head, should we delete it before the isolate expires | |
2067 Isolate::ManagedLifeline* next = managed_lifelines_root_.next_; | |
2068 managed_lifelines_root_.next_ = ret; | |
2069 ret->prev_ = &managed_lifelines_root_; | |
2070 ret->next_ = next; | |
2071 if (next != nullptr) next->prev_ = ret; | |
2072 return ret; | |
2073 } | |
2025 | 2074 |
2026 Isolate::PerIsolateThreadData::~PerIsolateThreadData() { | 2075 Isolate::PerIsolateThreadData::~PerIsolateThreadData() { |
2027 #if defined(USE_SIMULATOR) | 2076 #if defined(USE_SIMULATOR) |
2028 delete simulator_; | 2077 delete simulator_; |
2029 #endif | 2078 #endif |
2030 } | 2079 } |
2031 | 2080 |
2032 | 2081 |
2033 Isolate::PerIsolateThreadData* | 2082 Isolate::PerIsolateThreadData* |
2034 Isolate::ThreadDataTable::Lookup(Isolate* isolate, | 2083 Isolate::ThreadDataTable::Lookup(Isolate* isolate, |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2384 | 2433 |
2385 delete cpu_profiler_; | 2434 delete cpu_profiler_; |
2386 cpu_profiler_ = NULL; | 2435 cpu_profiler_ = NULL; |
2387 | 2436 |
2388 code_event_dispatcher_.reset(); | 2437 code_event_dispatcher_.reset(); |
2389 | 2438 |
2390 delete root_index_map_; | 2439 delete root_index_map_; |
2391 root_index_map_ = NULL; | 2440 root_index_map_ = NULL; |
2392 | 2441 |
2393 ClearSerializerData(); | 2442 ClearSerializerData(); |
2443 managed_lifelines_root_.Clear(); | |
2394 } | 2444 } |
2395 | 2445 |
2396 | 2446 |
2397 void Isolate::SetIsolateThreadLocals(Isolate* isolate, | 2447 void Isolate::SetIsolateThreadLocals(Isolate* isolate, |
2398 PerIsolateThreadData* data) { | 2448 PerIsolateThreadData* data) { |
2399 base::Thread::SetThreadLocal(isolate_key_, isolate); | 2449 base::Thread::SetThreadLocal(isolate_key_, isolate); |
2400 base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data); | 2450 base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data); |
2401 } | 2451 } |
2402 | 2452 |
2403 | 2453 |
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3648 // Then check whether this scope intercepts. | 3698 // Then check whether this scope intercepts. |
3649 if ((flag & intercept_mask_)) { | 3699 if ((flag & intercept_mask_)) { |
3650 intercepted_flags_ |= flag; | 3700 intercepted_flags_ |= flag; |
3651 return true; | 3701 return true; |
3652 } | 3702 } |
3653 return false; | 3703 return false; |
3654 } | 3704 } |
3655 | 3705 |
3656 } // namespace internal | 3706 } // namespace internal |
3657 } // namespace v8 | 3707 } // namespace v8 |
OLD | NEW |