Index: src/isolate.cc |
diff --git a/src/isolate.cc b/src/isolate.cc |
index 142ff8eb1e08dbe253326c7276ccc0df1c394346..d78783c5759388e8695e140c22675960e716ab5e 100644 |
--- a/src/isolate.cc |
+++ b/src/isolate.cc |
@@ -2025,6 +2025,44 @@ Isolate::ThreadDataTable::~ThreadDataTable() { |
// DCHECK_NULL(list_); |
} |
+void Isolate::ReleaseManagedLifelines() { |
+ for (Isolate::ManagedLifeline* current = managed_lifelines_root_.next_; |
+ current != nullptr;) { |
+ Isolate::ManagedLifeline* next = current->next_; |
+ current->Dispose(); |
+ delete current; |
Eric Holk
2017/02/11 02:19:29
Out of curiosity, would it make sense to just rely
Mircea Trofin
2017/02/11 02:29:32
You mean, instead of a separate Dispose?
Mircea Trofin
2017/02/11 02:29:32
You mean, instead of a separate Dispose?
Eric Holk
2017/02/13 21:55:35
Sure, although I was referring to the Deleter in i
|
+ current = next; |
+ } |
+} |
+ |
+Isolate::ManagedLifeline* Isolate::RegisterForReleaseAtTeardown( |
+ void* value, Isolate::ManagedLifeline::Deleter deleter) { |
+ DCHECK_NOT_NULL(value); |
+ DCHECK_NOT_NULL(deleter); |
+ |
+ Isolate::ManagedLifeline* ret = new Isolate::ManagedLifeline(); |
+ ret->value_ = value; |
+ ret->deleter_ = deleter; |
+ // Insert at head. We keep the head alive for the lifetime of the Isolate |
+ // because otherwise we can't reset the head, should we delete it before |
+ // the isolate expires |
+ Isolate::ManagedLifeline* next = managed_lifelines_root_.next_; |
+ managed_lifelines_root_.next_ = ret; |
+ ret->prev_ = &managed_lifelines_root_; |
+ ret->next_ = next; |
+ if (next != nullptr) next->prev_ = ret; |
+ return ret; |
+} |
+ |
+void Isolate::UnregisterFromReleaseAtTeardown( |
+ Isolate::ManagedLifeline*& lifeline) { |
+ DCHECK_NOT_NULL(lifeline->prev_); |
+ |
+ lifeline->prev_->next_ = lifeline->next_; |
+ if (lifeline->next_ != nullptr) lifeline->next_->prev_ = lifeline->prev_; |
+ delete lifeline; |
+ lifeline = nullptr; |
+} |
Isolate::PerIsolateThreadData::~PerIsolateThreadData() { |
#if defined(USE_SIMULATOR) |
@@ -2394,6 +2432,7 @@ void Isolate::Deinit() { |
root_index_map_ = NULL; |
ClearSerializerData(); |
+ ReleaseManagedLifelines(); |
} |