Chromium Code Reviews| Index: src/global-handles.cc |
| diff --git a/src/global-handles.cc b/src/global-handles.cc |
| index 4cd0a18ff8ece0cd658f744d19161269d5053de6..2ac2d8eb7b2740d58a831d654bef77feb8112732 100644 |
| --- a/src/global-handles.cc |
| +++ b/src/global-handles.cc |
| @@ -500,20 +500,33 @@ class GlobalHandles::PendingPhantomCallbacksSecondPassTask : public v8::Task { |
| // Takes ownership of the contents of pending_phantom_callbacks, leaving it in |
| // the same state it would be after a call to Clear(). |
| PendingPhantomCallbacksSecondPassTask( |
| + GlobalHandles* global_handles, |
| List<PendingPhantomCallback>* pending_phantom_callbacks, Isolate* isolate) |
| - : isolate_(isolate) { |
| + : global_handles_(global_handles), |
| + isolate_(isolate), |
| + heap_is_torn_down_(false) { |
| pending_phantom_callbacks_.Swap(pending_phantom_callbacks); |
| } |
| - ~PendingPhantomCallbacksSecondPassTask() override {} |
| + ~PendingPhantomCallbacksSecondPassTask() override { |
| + if (!heap_is_torn_down_) { |
| + global_handles_->ClearPhantomCallbacksTask(this); |
| + } |
| + } |
| void Run() override { |
| - InvokeSecondPassPhantomCallbacks(&pending_phantom_callbacks_, isolate_); |
| + if (!heap_is_torn_down_) { |
| + InvokeSecondPassPhantomCallbacks(&pending_phantom_callbacks_, isolate_); |
| + } |
| } |
| + void NotifyHeapTearDown() { heap_is_torn_down_ = true; } |
| + |
| private: |
| + GlobalHandles* global_handles_; |
| List<PendingPhantomCallback> pending_phantom_callbacks_; |
| Isolate* isolate_; |
| + bool heap_is_torn_down_; |
| DISALLOW_COPY_AND_ASSIGN(PendingPhantomCallbacksSecondPassTask); |
| }; |
| @@ -526,7 +539,8 @@ GlobalHandles::GlobalHandles(Isolate* isolate) |
| first_used_block_(NULL), |
| first_free_(NULL), |
| post_gc_processing_count_(0), |
| - object_group_connections_(kObjectGroupConnectionsCapacity) {} |
| + object_group_connections_(kObjectGroupConnectionsCapacity), |
| + phantom_callbacks_task_(nullptr) {} |
| GlobalHandles::~GlobalHandles() { |
| @@ -827,6 +841,14 @@ void GlobalHandles::UpdateListOfNewSpaceNodes() { |
| } |
| +void GlobalHandles::ClearPhantomCallbacksTask( |
| + PendingPhantomCallbacksSecondPassTask* task) { |
| + if (phantom_callbacks_task_ == task) { |
| + phantom_callbacks_task_ = nullptr; |
| + } |
| +} |
| + |
| + |
| int GlobalHandles::DispatchPendingPhantomCallbacks( |
| bool synchronous_second_pass) { |
| int freed_nodes = 0; |
| @@ -845,10 +867,10 @@ int GlobalHandles::DispatchPendingPhantomCallbacks( |
| if (synchronous_second_pass) { |
| InvokeSecondPassPhantomCallbacks(&pending_phantom_callbacks_, isolate()); |
| } else { |
| - auto* task = new PendingPhantomCallbacksSecondPassTask( |
| - &pending_phantom_callbacks_, isolate()); |
| + phantom_callbacks_task_ = new PendingPhantomCallbacksSecondPassTask( |
| + this, &pending_phantom_callbacks_, isolate()); |
| V8::GetCurrentPlatform()->CallOnForegroundThread( |
| - reinterpret_cast<v8::Isolate*>(isolate()), task); |
| + reinterpret_cast<v8::Isolate*>(isolate()), phantom_callbacks_task_); |
|
jochen (gone - plz use gerrit)
2015/07/20 09:58:17
there could be more than one task, no?
maybe it's
epertoso
2015/07/20 13:14:21
Done.
|
| } |
| } |
| pending_phantom_callbacks_.Clear(); |
| @@ -1100,6 +1122,9 @@ void GlobalHandles::RemoveImplicitRefGroups() { |
| void GlobalHandles::TearDown() { |
| + if (phantom_callbacks_task_) { |
| + phantom_callbacks_task_->NotifyHeapTearDown(); |
| + } |
| // TODO(1428): invoke weak callbacks. |
| } |