Reviewers: jochen,

Message:
PTAL

Description:
Correctly handle the case when TimerTask is destroyed with being run.

This is follow-up for a5616e.

BUG=chromium:508584
LOG=NO

Please review this at https://codereview.chromium.org/1234513003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+13, -2 lines):
  M src/heap/memory-reducer.h
  M src/heap/memory-reducer.cc


Index: src/heap/memory-reducer.cc
diff --git a/src/heap/memory-reducer.cc b/src/heap/memory-reducer.cc
index 2e0ccb9de6a07ebac1ea37141af7e25c7586f487..c89d1424e7c5e78e303ae64b7043669571bb4035 100644
--- a/src/heap/memory-reducer.cc
+++ b/src/heap/memory-reducer.cc
@@ -177,6 +177,13 @@ void MemoryReducer::ScheduleTimer(double delay_ms) {
 }


+void MemoryReducer::ClearTask(v8::Task* task) {
+  if (pending_task_ == task) {
+    pending_task_ = nullptr;
+  }
+}
+
+
 void MemoryReducer::TearDown() {
   if (pending_task_ != nullptr) {
     pending_task_->NotifyHeapTearDown();
Index: src/heap/memory-reducer.h
diff --git a/src/heap/memory-reducer.h b/src/heap/memory-reducer.h
index 4d15afa2e2dc5eee75680b820796da1b5a78c74c..0371f9d1b807062964a680a4da0177c133dd99e2 100644
--- a/src/heap/memory-reducer.h
+++ b/src/heap/memory-reducer.h
@@ -114,7 +114,7 @@ class MemoryReducer {
   // Posts a timer task that will call NotifyTimer after the given delay.
   void ScheduleTimer(double delay_ms);
   void TearDown();
-
+  void ClearTask(v8::Task* task);
   static const int kLongDelayMs;
   static const int kShortDelayMs;
   static const int kMaxNumberOfGCs;
@@ -126,7 +126,11 @@ class MemoryReducer {
    public:
     explicit TimerTask(MemoryReducer* memory_reducer)
         : memory_reducer_(memory_reducer), heap_is_torn_down_(false) {}
-    virtual ~TimerTask() {}
+    virtual ~TimerTask() {
+      if (!heap_is_torn_down_) {
+        memory_reducer_->ClearTask(this);
+      }
+    }
     void NotifyHeapTearDown() { heap_is_torn_down_ = true; }

    private:


--
--
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.

Reply via email to