Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/isolate.cc

Issue 2676513008: [wasm] Managed<T> ensures T's lifetime does not leak past Isolate's (Closed)
Patch Set: link Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/isolate.h ('K') | « src/isolate.h ('k') | src/managed.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::ReleaseManagedLifelines() {
2034 for (Isolate::ManagedLifeline* current = managed_lifelines_root_.next_;
2035 current != nullptr;) {
2036 Isolate::ManagedLifeline* next = current->next_;
2037 current->Dispose();
2038 delete current;
2039 current = next;
2040 }
2041 }
2042
2043 Isolate::ManagedLifeline* Isolate::RegisterForReleaseAtTeardown(
2044 void* value, Isolate::ManagedLifeline::Deleter deleter) {
2045 DCHECK_NOT_NULL(value);
2046 DCHECK_NOT_NULL(deleter);
2047
2048 Isolate::ManagedLifeline* ret = new Isolate::ManagedLifeline();
2049 ret->value_ = value;
2050 ret->deleter_ = deleter;
2051 // Insert at head. We keep the head alive for the lifetime of the Isolate
2052 // because otherwise we can't reset the head, should we delete it before
2053 // the isolate expires
2054 Isolate::ManagedLifeline* next = managed_lifelines_root_.next_;
2055 managed_lifelines_root_.next_ = ret;
2056 ret->prev_ = &managed_lifelines_root_;
2057 ret->next_ = next;
2058 if (next != nullptr) next->prev_ = ret;
2059 return ret;
2060 }
2061
2062 void Isolate::UnregisterFromReleaseAtTeardown(
2063 Isolate::ManagedLifeline*& lifeline) {
2064 DCHECK_NOT_NULL(lifeline->prev_);
2065
2066 lifeline->prev_->next_ = lifeline->next_;
2067 if (lifeline->next_ != nullptr) lifeline->next_->prev_ = lifeline->prev_;
2068 delete lifeline;
2069 lifeline = nullptr;
2070 }
2033 2071
2034 Isolate::PerIsolateThreadData::~PerIsolateThreadData() { 2072 Isolate::PerIsolateThreadData::~PerIsolateThreadData() {
2035 #if defined(USE_SIMULATOR) 2073 #if defined(USE_SIMULATOR)
2036 delete simulator_; 2074 delete simulator_;
2037 #endif 2075 #endif
2038 } 2076 }
2039 2077
2040 2078
2041 Isolate::PerIsolateThreadData* 2079 Isolate::PerIsolateThreadData*
2042 Isolate::ThreadDataTable::Lookup(Isolate* isolate, 2080 Isolate::ThreadDataTable::Lookup(Isolate* isolate,
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 2430
2393 delete cpu_profiler_; 2431 delete cpu_profiler_;
2394 cpu_profiler_ = NULL; 2432 cpu_profiler_ = NULL;
2395 2433
2396 code_event_dispatcher_.reset(); 2434 code_event_dispatcher_.reset();
2397 2435
2398 delete root_index_map_; 2436 delete root_index_map_;
2399 root_index_map_ = NULL; 2437 root_index_map_ = NULL;
2400 2438
2401 ClearSerializerData(); 2439 ClearSerializerData();
2440 ReleaseManagedLifelines();
2402 } 2441 }
2403 2442
2404 2443
2405 void Isolate::SetIsolateThreadLocals(Isolate* isolate, 2444 void Isolate::SetIsolateThreadLocals(Isolate* isolate,
2406 PerIsolateThreadData* data) { 2445 PerIsolateThreadData* data) {
2407 base::Thread::SetThreadLocal(isolate_key_, isolate); 2446 base::Thread::SetThreadLocal(isolate_key_, isolate);
2408 base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data); 2447 base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data);
2409 } 2448 }
2410 2449
2411 2450
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
3653 // Then check whether this scope intercepts. 3692 // Then check whether this scope intercepts.
3654 if ((flag & intercept_mask_)) { 3693 if ((flag & intercept_mask_)) {
3655 intercepted_flags_ |= flag; 3694 intercepted_flags_ |= flag;
3656 return true; 3695 return true;
3657 } 3696 }
3658 return false; 3697 return false;
3659 } 3698 }
3660 3699
3661 } // namespace internal 3700 } // namespace internal
3662 } // namespace v8 3701 } // namespace v8
OLDNEW
« src/isolate.h ('K') | « src/isolate.h ('k') | src/managed.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698