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

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: feedback. also a rebase 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 Isolate::ManagedLifeline* current = managed_lifelines_root_.next_;
2035 while (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_ptr) {
2064 DCHECK_NOT_NULL(lifeline_ptr);
2065 Isolate::ManagedLifeline* lifeline = *lifeline_ptr;
2066 DCHECK_NOT_NULL(lifeline->prev_);
2067
2068 lifeline->prev_->next_ = lifeline->next_;
2069 if (lifeline->next_ != nullptr) lifeline->next_->prev_ = lifeline->prev_;
2070 delete lifeline;
2071 *lifeline_ptr = nullptr;
2072 }
2033 2073
2034 Isolate::PerIsolateThreadData::~PerIsolateThreadData() { 2074 Isolate::PerIsolateThreadData::~PerIsolateThreadData() {
2035 #if defined(USE_SIMULATOR) 2075 #if defined(USE_SIMULATOR)
2036 delete simulator_; 2076 delete simulator_;
2037 #endif 2077 #endif
2038 } 2078 }
2039 2079
2040 2080
2041 Isolate::PerIsolateThreadData* 2081 Isolate::PerIsolateThreadData*
2042 Isolate::ThreadDataTable::Lookup(Isolate* isolate, 2082 Isolate::ThreadDataTable::Lookup(Isolate* isolate,
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 2432
2393 delete cpu_profiler_; 2433 delete cpu_profiler_;
2394 cpu_profiler_ = NULL; 2434 cpu_profiler_ = NULL;
2395 2435
2396 code_event_dispatcher_.reset(); 2436 code_event_dispatcher_.reset();
2397 2437
2398 delete root_index_map_; 2438 delete root_index_map_;
2399 root_index_map_ = NULL; 2439 root_index_map_ = NULL;
2400 2440
2401 ClearSerializerData(); 2441 ClearSerializerData();
2442 ReleaseManagedLifelines();
2402 } 2443 }
2403 2444
2404 2445
2405 void Isolate::SetIsolateThreadLocals(Isolate* isolate, 2446 void Isolate::SetIsolateThreadLocals(Isolate* isolate,
2406 PerIsolateThreadData* data) { 2447 PerIsolateThreadData* data) {
2407 base::Thread::SetThreadLocal(isolate_key_, isolate); 2448 base::Thread::SetThreadLocal(isolate_key_, isolate);
2408 base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data); 2449 base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data);
2409 } 2450 }
2410 2451
2411 2452
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
3653 // Then check whether this scope intercepts. 3694 // Then check whether this scope intercepts.
3654 if ((flag & intercept_mask_)) { 3695 if ((flag & intercept_mask_)) {
3655 intercepted_flags_ |= flag; 3696 intercepted_flags_ |= flag;
3656 return true; 3697 return true;
3657 } 3698 }
3658 return false; 3699 return false;
3659 } 3700 }
3660 3701
3661 } // namespace internal 3702 } // namespace internal
3662 } // namespace v8 3703 } // 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