Index: src/heap/incremental-marking-job.cc |
diff --git a/src/heap/incremental-marking-job.cc b/src/heap/incremental-marking-job.cc |
index 799a1e2a1aaf90bb66b53144effea9d16e5afeaa..c20cffcdef75b259dc1d22b6991b8b16c57823c1 100644 |
--- a/src/heap/incremental-marking-job.cc |
+++ b/src/heap/incremental-marking-job.cc |
@@ -14,132 +14,41 @@ |
namespace v8 { |
namespace internal { |
-const double IncrementalMarkingJob::kLongDelayInSeconds = 5; |
-const double IncrementalMarkingJob::kShortDelayInSeconds = 0.5; |
- |
void IncrementalMarkingJob::Start(Heap* heap) { |
DCHECK(!heap->incremental_marking()->IsStopped()); |
- // We don't need to reset the flags because tasks from the previous job |
- // can still be pending. We just want to ensure that tasks are posted |
- // if they are not pending. |
- // If delayed task is pending and made_progress_since_last_delayed_task_ is |
- // true, then the delayed task will clear that flag when it is rescheduled. |
- ScheduleIdleTask(heap); |
- ScheduleDelayedTask(heap); |
-} |
- |
- |
-void IncrementalMarkingJob::NotifyIdleTask() { idle_task_pending_ = false; } |
- |
- |
-void IncrementalMarkingJob::NotifyDelayedTask() { |
- delayed_task_pending_ = false; |
-} |
- |
- |
-void IncrementalMarkingJob::NotifyIdleTaskProgress() { |
- made_progress_since_last_delayed_task_ = true; |
-} |
- |
- |
-void IncrementalMarkingJob::ScheduleIdleTask(Heap* heap) { |
- if (!idle_task_pending_) { |
- v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap->isolate()); |
- if (V8::GetCurrentPlatform()->IdleTasksEnabled(isolate)) { |
- idle_task_pending_ = true; |
- auto task = new IdleTask(heap->isolate(), this); |
- V8::GetCurrentPlatform()->CallIdleOnForegroundThread(isolate, task); |
- } |
- } |
+ ScheduleTask(heap); |
} |
+void IncrementalMarkingJob::NotifyTask() { task_pending_ = false; } |
-void IncrementalMarkingJob::ScheduleDelayedTask(Heap* heap) { |
- if (!delayed_task_pending_ && FLAG_memory_reducer) { |
+void IncrementalMarkingJob::ScheduleTask(Heap* heap) { |
+ if (!task_pending_) { |
v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap->isolate()); |
- delayed_task_pending_ = true; |
- made_progress_since_last_delayed_task_ = false; |
- auto task = new DelayedTask(heap->isolate(), this); |
- double delay = |
- heap->HighMemoryPressure() ? kShortDelayInSeconds : kLongDelayInSeconds; |
- V8::GetCurrentPlatform()->CallDelayedOnForegroundThread(isolate, task, |
- delay); |
+ task_pending_ = true; |
+ auto task = new Task(heap->isolate(), this); |
+ V8::GetCurrentPlatform()->CallOnForegroundThread(isolate, task); |
} |
} |
- |
-IncrementalMarkingJob::IdleTask::Progress IncrementalMarkingJob::IdleTask::Step( |
- Heap* heap, double deadline_in_ms) { |
- IncrementalMarking* incremental_marking = heap->incremental_marking(); |
- if (incremental_marking->IsStopped()) { |
- return kDone; |
- } |
- if (incremental_marking->IsSweeping()) { |
- incremental_marking->FinalizeSweeping(); |
- // TODO(hpayer): We can continue here if enough idle time is left. |
- return kMoreWork; |
- } |
- const double remaining_idle_time_in_ms = |
- incremental_marking->AdvanceIncrementalMarking( |
- deadline_in_ms, IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
- IncrementalMarking::DO_NOT_FORCE_COMPLETION); |
- if (remaining_idle_time_in_ms > 0.0) { |
- heap->TryFinalizeIdleIncrementalMarking( |
- remaining_idle_time_in_ms, |
- GarbageCollectionReason::kFinalizeMarkingViaTask); |
- } |
- return incremental_marking->IsStopped() ? kDone : kMoreWork; |
-} |
- |
- |
-void IncrementalMarkingJob::IdleTask::RunInternal(double deadline_in_seconds) { |
- double deadline_in_ms = |
- deadline_in_seconds * |
- static_cast<double>(base::Time::kMillisecondsPerSecond); |
- Heap* heap = isolate()->heap(); |
- double start_ms = heap->MonotonicallyIncreasingTimeInMs(); |
- job_->NotifyIdleTask(); |
- job_->NotifyIdleTaskProgress(); |
- if (Step(heap, deadline_in_ms) == kMoreWork) { |
- job_->ScheduleIdleTask(heap); |
- } |
- if (FLAG_trace_idle_notification) { |
- double current_time_ms = heap->MonotonicallyIncreasingTimeInMs(); |
- double idle_time_in_ms = deadline_in_ms - start_ms; |
- double deadline_difference = deadline_in_ms - current_time_ms; |
- PrintIsolate(isolate(), "%8.0f ms: ", isolate()->time_millis_since_init()); |
- PrintF( |
- "Idle task: requested idle time %.2f ms, used idle time %.2f " |
- "ms, deadline usage %.2f ms\n", |
- idle_time_in_ms, idle_time_in_ms - deadline_difference, |
- deadline_difference); |
- } |
-} |
- |
- |
-void IncrementalMarkingJob::DelayedTask::Step(Heap* heap) { |
- const int kIncrementalMarkingDelayMs = 50; |
+void IncrementalMarkingJob::Task::Step(Heap* heap) { |
+ const int kIncrementalMarkingDelayMs = 1; |
double deadline = |
heap->MonotonicallyIncreasingTimeInMs() + kIncrementalMarkingDelayMs; |
heap->incremental_marking()->AdvanceIncrementalMarking( |
- deadline, IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
- IncrementalMarking::FORCE_COMPLETION); |
+ deadline, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
+ i::IncrementalMarking::FORCE_COMPLETION, i::StepOrigin::kTask); |
heap->FinalizeIncrementalMarkingIfComplete( |
GarbageCollectionReason::kFinalizeMarkingViaTask); |
} |
- |
-void IncrementalMarkingJob::DelayedTask::RunInternal() { |
+void IncrementalMarkingJob::Task::RunInternal() { |
Heap* heap = isolate()->heap(); |
- job_->NotifyDelayedTask(); |
+ job_->NotifyTask(); |
IncrementalMarking* incremental_marking = heap->incremental_marking(); |
if (!incremental_marking->IsStopped()) { |
- if (job_->ShouldForceMarkingStep()) { |
- Step(heap); |
- } |
- // The Step() above could have finished incremental marking. |
+ Step(heap); |
if (!incremental_marking->IsStopped()) { |
- job_->ScheduleDelayedTask(heap); |
+ job_->ScheduleTask(heap); |
} |
} |
} |