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

Unified Diff: src/heap/memory-reducer.cc

Issue 1230163002: Disable the pending task if the memory reducer is torn down. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix check Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/memory-reducer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/memory-reducer.cc
diff --git a/src/heap/memory-reducer.cc b/src/heap/memory-reducer.cc
index aa3abd0f21919cb5459e2125244082caef80b8a0..2e0ccb9de6a07ebac1ea37141af7e25c7586f487 100644
--- a/src/heap/memory-reducer.cc
+++ b/src/heap/memory-reducer.cc
@@ -18,6 +18,7 @@ const int MemoryReducer::kMaxNumberOfGCs = 3;
void MemoryReducer::TimerTask::Run() {
+ if (heap_is_torn_down_) return;
Heap* heap = memory_reducer_->heap();
Event event;
event.type = kTimer;
@@ -31,8 +32,10 @@ void MemoryReducer::TimerTask::Run() {
void MemoryReducer::NotifyTimer(const Event& event) {
+ DCHECK(nullptr != pending_task_);
DCHECK_EQ(kTimer, event.type);
DCHECK_EQ(kWait, state_.action);
+ pending_task_ = nullptr;
state_ = Step(state_, event);
if (state_.action == kRun) {
DCHECK(heap()->incremental_marking()->IsStopped());
@@ -167,9 +170,19 @@ void MemoryReducer::ScheduleTimer(double delay_ms) {
// Leave some room for precision error in task scheduler.
const double kSlackMs = 100;
v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap()->isolate());
+ DCHECK(nullptr == pending_task_);
+ pending_task_ = new MemoryReducer::TimerTask(this);
V8::GetCurrentPlatform()->CallDelayedOnForegroundThread(
- isolate, new MemoryReducer::TimerTask(this),
- (delay_ms + kSlackMs) / 1000.0);
+ isolate, pending_task_, (delay_ms + kSlackMs) / 1000.0);
+}
+
+
+void MemoryReducer::TearDown() {
+ if (pending_task_ != nullptr) {
+ pending_task_->NotifyHeapTearDown();
+ pending_task_ = nullptr;
+ }
+ state_ = State(kDone, 0, 0);
}
} // internal
« no previous file with comments | « src/heap/memory-reducer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698