Reviewers: jochen,
Description:
Don't run the second pass of the pending phantom callbacks if the heap has
been
torn down.
[email protected]
BUG=511204
Please review this at https://codereview.chromium.org/1246603002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+39, -7 lines):
M src/global-handles.h
M src/global-handles.cc
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_);
}
}
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.
}
Index: src/global-handles.h
diff --git a/src/global-handles.h b/src/global-handles.h
index
0ee8c20a375adaea6803c11034686b08d806f9d8..1b8994d4765b2fc1cf4e39527411c1c61e4b306f
100644
--- a/src/global-handles.h
+++ b/src/global-handles.h
@@ -304,6 +304,8 @@ class GlobalHandles {
class NodeIterator;
class PendingPhantomCallbacksSecondPassTask;
+ void ClearPhantomCallbacksTask(PendingPhantomCallbacksSecondPassTask*
task);
+
Isolate* isolate_;
// Field always containing the number of handles to global objects.
@@ -337,6 +339,11 @@ class GlobalHandles {
List<PendingPhantomCallback> pending_phantom_callbacks_;
+ // Scheduled task that runs the second pass of the phantom callbacks.
+ // We keep this pointer to send a notification when the heap is being
torn
+ // down.
+ PendingPhantomCallbacksSecondPassTask* phantom_callbacks_task_;
+
friend class Isolate;
DISALLOW_COPY_AND_ASSIGN(GlobalHandles);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.