| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/heap/incremental-marking-job.h" | 5 #include "src/heap/incremental-marking-job.h" |
| 6 | 6 |
| 7 #include "src/base/platform/time.h" | 7 #include "src/base/platform/time.h" |
| 8 #include "src/heap/heap-inl.h" | 8 #include "src/heap/heap-inl.h" |
| 9 #include "src/heap/heap.h" | 9 #include "src/heap/heap.h" |
| 10 #include "src/heap/incremental-marking.h" | 10 #include "src/heap/incremental-marking.h" |
| 11 #include "src/isolate.h" | 11 #include "src/isolate.h" |
| 12 #include "src/v8.h" | 12 #include "src/v8.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 const double IncrementalMarkingJob::kLongDelayInSeconds = 5; |
| 18 const double IncrementalMarkingJob::kShortDelayInSeconds = 0.5; |
| 17 | 19 |
| 18 void IncrementalMarkingJob::Start(Heap* heap) { | 20 void IncrementalMarkingJob::Start(Heap* heap) { |
| 19 DCHECK(!heap->incremental_marking()->IsStopped()); | 21 DCHECK(!heap->incremental_marking()->IsStopped()); |
| 20 // We don't need to reset the flags because tasks from the previous job | 22 // We don't need to reset the flags because tasks from the previous job |
| 21 // can still be pending. We just want to ensure that tasks are posted | 23 // can still be pending. We just want to ensure that tasks are posted |
| 22 // if they are not pending. | 24 // if they are not pending. |
| 23 // If delayed task is pending and made_progress_since_last_delayed_task_ is | 25 // If delayed task is pending and made_progress_since_last_delayed_task_ is |
| 24 // true, then the delayed task will clear that flag when it is rescheduled. | 26 // true, then the delayed task will clear that flag when it is rescheduled. |
| 25 ScheduleIdleTask(heap); | 27 ScheduleIdleTask(heap); |
| 26 ScheduleDelayedTask(heap); | 28 ScheduleDelayedTask(heap); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 51 } | 53 } |
| 52 } | 54 } |
| 53 | 55 |
| 54 | 56 |
| 55 void IncrementalMarkingJob::ScheduleDelayedTask(Heap* heap) { | 57 void IncrementalMarkingJob::ScheduleDelayedTask(Heap* heap) { |
| 56 if (!delayed_task_pending_ && FLAG_memory_reducer) { | 58 if (!delayed_task_pending_ && FLAG_memory_reducer) { |
| 57 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap->isolate()); | 59 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap->isolate()); |
| 58 delayed_task_pending_ = true; | 60 delayed_task_pending_ = true; |
| 59 made_progress_since_last_delayed_task_ = false; | 61 made_progress_since_last_delayed_task_ = false; |
| 60 auto task = new DelayedTask(heap->isolate(), this); | 62 auto task = new DelayedTask(heap->isolate(), this); |
| 63 double delay = |
| 64 heap->HighMemoryPressure() ? kShortDelayInSeconds : kLongDelayInSeconds; |
| 61 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread(isolate, task, | 65 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread(isolate, task, |
| 62 kDelayInSeconds); | 66 delay); |
| 63 } | 67 } |
| 64 } | 68 } |
| 65 | 69 |
| 66 | 70 |
| 67 IncrementalMarkingJob::IdleTask::Progress IncrementalMarkingJob::IdleTask::Step( | 71 IncrementalMarkingJob::IdleTask::Progress IncrementalMarkingJob::IdleTask::Step( |
| 68 Heap* heap, double deadline_in_ms) { | 72 Heap* heap, double deadline_in_ms) { |
| 69 IncrementalMarking* incremental_marking = heap->incremental_marking(); | 73 IncrementalMarking* incremental_marking = heap->incremental_marking(); |
| 70 MarkCompactCollector* mark_compact_collector = heap->mark_compact_collector(); | 74 MarkCompactCollector* mark_compact_collector = heap->mark_compact_collector(); |
| 71 if (incremental_marking->IsStopped()) { | 75 if (incremental_marking->IsStopped()) { |
| 72 return kDone; | 76 return kDone; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 140 } |
| 137 // The Step() above could have finished incremental marking. | 141 // The Step() above could have finished incremental marking. |
| 138 if (!incremental_marking->IsStopped()) { | 142 if (!incremental_marking->IsStopped()) { |
| 139 job_->ScheduleDelayedTask(heap); | 143 job_->ScheduleDelayedTask(heap); |
| 140 } | 144 } |
| 141 } | 145 } |
| 142 } | 146 } |
| 143 | 147 |
| 144 } // namespace internal | 148 } // namespace internal |
| 145 } // namespace v8 | 149 } // namespace v8 |
| OLD | NEW |