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

Unified Diff: src/heap/incremental-marking-job.h

Issue 1265423002: Use idle task to perform incremental marking steps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: More test fixes Created 5 years, 3 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/incremental-marking.cc ('k') | src/heap/incremental-marking-job.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/incremental-marking-job.h
diff --git a/src/heap/incremental-marking-job.h b/src/heap/incremental-marking-job.h
new file mode 100644
index 0000000000000000000000000000000000000000..fad46c124684050ab3701c071d96315935130789
--- /dev/null
+++ b/src/heap/incremental-marking-job.h
@@ -0,0 +1,81 @@
+// Copyright 2012 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_HEAP_INCREMENTAL_MARKING_JOB_H_
+#define V8_HEAP_INCREMENTAL_MARKING_JOB_H_
+
+#include "src/cancelable-task.h"
+
+namespace v8 {
+namespace internal {
+
+class Heap;
+class Isolate;
+
+// The incremental marking job uses platform tasks to perform incremental
+// marking steps. The job posts an idle and a delayed task with a large delay.
+// The delayed task performs steps only if the idle task is not making progress.
+// We expect this to be a rare event since incremental marking should finish
+// quickly with the help of the mutator and the idle task.
+// The delayed task guarantees that we eventually finish incremental marking
+// even if the mutator becomes idle and the platform stops running idle tasks,
+// which can happen for background tabs in Chrome.
+class IncrementalMarkingJob {
+ public:
+ class IdleTask : public CancelableIdleTask {
+ public:
+ explicit IdleTask(Isolate* isolate, IncrementalMarkingJob* job)
+ : CancelableIdleTask(isolate), job_(job) {}
+ enum Progress { kDone, kMoreWork };
+ static Progress Step(Heap* heap, double deadline_in_ms);
+ // CancelableIdleTask overrides.
+ void RunInternal(double deadline_in_seconds) override;
+
+ private:
+ IncrementalMarkingJob* job_;
+ };
+
+ class DelayedTask : public CancelableTask {
+ public:
+ explicit DelayedTask(Isolate* isolate, IncrementalMarkingJob* job)
+ : CancelableTask(isolate), job_(job) {}
+ static void Step(Heap* heap);
+ // CancelableTask overrides.
+ void RunInternal() override;
+
+ private:
+ IncrementalMarkingJob* job_;
+ };
+
+ // Delay of the delayed task.
+ static const int kDelayInSeconds = 5;
+
+ IncrementalMarkingJob()
+ : idle_task_pending_(false),
+ delayed_task_pending_(false),
+ made_progress_since_last_delayed_task_(false) {}
+
+ bool ShouldForceMarkingStep() {
+ return !made_progress_since_last_delayed_task_;
+ }
+
+ bool IdleTaskPending() { return idle_task_pending_; }
+
+ void Start(Heap* heap);
+
+ void NotifyIdleTask();
+ void NotifyDelayedTask();
+ void NotifyIdleTaskProgress();
+ void ScheduleIdleTask(Heap* heap);
+ void ScheduleDelayedTask(Heap* heap);
+
+ private:
+ bool idle_task_pending_;
+ bool delayed_task_pending_;
+ bool made_progress_since_last_delayed_task_;
+};
+}
+} // namespace v8::internal
+
+#endif // V8_HEAP_INCREMENTAL_MARKING_JOB_H_
« no previous file with comments | « src/heap/incremental-marking.cc ('k') | src/heap/incremental-marking-job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698