Chromium Code Reviews| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/heap/incremental-marking.h" | 7 #include "src/heap/incremental-marking.h" |
| 8 | 8 |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 bytes_scanned_(0), | 36 bytes_scanned_(0), |
| 37 allocated_(0), | 37 allocated_(0), |
| 38 write_barriers_invoked_since_last_step_(0), | 38 write_barriers_invoked_since_last_step_(0), |
| 39 idle_marking_delay_counter_(0), | 39 idle_marking_delay_counter_(0), |
| 40 no_marking_scope_depth_(0), | 40 no_marking_scope_depth_(0), |
| 41 unscanned_bytes_of_large_object_(0), | 41 unscanned_bytes_of_large_object_(0), |
| 42 was_activated_(false), | 42 was_activated_(false), |
| 43 weak_closure_was_overapproximated_(false), | 43 weak_closure_was_overapproximated_(false), |
| 44 weak_closure_approximation_rounds_(0), | 44 weak_closure_approximation_rounds_(0), |
| 45 request_type_(COMPLETE_MARKING), | 45 request_type_(COMPLETE_MARKING), |
| 46 gc_callback_flags_(kNoGCCallbackFlags) {} | 46 gc_callback_flags_(kNoGCCallbackFlags), |
| 47 pending_incremental_marking_task_(false) {} | |
| 47 | 48 |
| 48 | 49 |
| 49 void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot, | 50 void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot, |
| 50 Object* value) { | 51 Object* value) { |
| 51 if (BaseRecordWrite(obj, slot, value) && slot != NULL) { | 52 if (BaseRecordWrite(obj, slot, value) && slot != NULL) { |
| 52 MarkBit obj_bit = Marking::MarkBitFrom(obj); | 53 MarkBit obj_bit = Marking::MarkBitFrom(obj); |
| 53 if (Marking::IsBlack(obj_bit)) { | 54 if (Marking::IsBlack(obj_bit)) { |
| 54 // Object is not going to be rescanned we need to record the slot. | 55 // Object is not going to be rescanned we need to record the slot. |
| 55 heap_->mark_compact_collector()->RecordSlot(obj, slot, value); | 56 heap_->mark_compact_collector()->RecordSlot(obj, slot, value); |
| 56 } | 57 } |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 StartMarking(); | 494 StartMarking(); |
| 494 heap_->mark_compact_collector()->SetFlags(Heap::kNoGCFlags); | 495 heap_->mark_compact_collector()->SetFlags(Heap::kNoGCFlags); |
| 495 } else { | 496 } else { |
| 496 if (FLAG_trace_incremental_marking) { | 497 if (FLAG_trace_incremental_marking) { |
| 497 PrintF("[IncrementalMarking] Start sweeping.\n"); | 498 PrintF("[IncrementalMarking] Start sweeping.\n"); |
| 498 } | 499 } |
| 499 state_ = SWEEPING; | 500 state_ = SWEEPING; |
| 500 } | 501 } |
| 501 | 502 |
| 502 heap_->new_space()->LowerInlineAllocationLimit(kAllocatedThreshold); | 503 heap_->new_space()->LowerInlineAllocationLimit(kAllocatedThreshold); |
| 504 ScheduleIncrementalMarkingTask(); | |
| 503 } | 505 } |
| 504 | 506 |
| 505 | 507 |
| 506 void IncrementalMarking::StartMarking() { | 508 void IncrementalMarking::StartMarking() { |
| 507 if (FLAG_trace_incremental_marking) { | 509 if (FLAG_trace_incremental_marking) { |
| 508 PrintF("[IncrementalMarking] Start marking\n"); | 510 PrintF("[IncrementalMarking] Start marking\n"); |
| 509 } | 511 } |
| 510 | 512 |
| 511 is_compacting_ = !FLAG_never_compact && | 513 is_compacting_ = !FLAG_never_compact && |
| 512 heap_->mark_compact_collector()->StartCompaction( | 514 heap_->mark_compact_collector()->StartCompaction( |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 | 1025 |
| 1024 | 1026 |
| 1025 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1027 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
| 1026 idle_marking_delay_counter_++; | 1028 idle_marking_delay_counter_++; |
| 1027 } | 1029 } |
| 1028 | 1030 |
| 1029 | 1031 |
| 1030 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1032 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
| 1031 idle_marking_delay_counter_ = 0; | 1033 idle_marking_delay_counter_ = 0; |
| 1032 } | 1034 } |
| 1035 | |
| 1036 | |
| 1037 void IncrementalMarking::ScheduleIncrementalMarkingTask() { | |
| 1038 if (!pending_incremental_marking_task_) { | |
| 1039 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap_->isolate()); | |
| 1040 if (V8::GetCurrentPlatform()->IdleTasksEnabled(isolate)) { | |
| 1041 pending_incremental_marking_task_ = true; | |
| 1042 auto task = new IncrementalMarkingTask(heap_->isolate()); | |
| 1043 V8::GetCurrentPlatform()->CallIdleOnForegroundThread(isolate, task); | |
| 1044 } | |
| 1045 } | |
| 1046 } | |
| 1047 | |
| 1048 | |
| 1049 void IncrementalMarking::NotifyIncrementalMarkingTaskRunning() { | |
| 1050 pending_incremental_marking_task_ = false; | |
| 1051 } | |
| 1052 | |
| 1053 | |
| 1054 IncrementalMarkingTask::Progress IncrementalMarkingTask::Step( | |
| 1055 Heap* heap, double deadline_in_ms) { | |
| 1056 IncrementalMarking* incremental_marking = heap->incremental_marking(); | |
| 1057 MarkCompactCollector* mark_compact_collector = heap->mark_compact_collector(); | |
| 1058 if (incremental_marking->IsStopped()) { | |
| 1059 return kDone; | |
| 1060 } | |
| 1061 if (mark_compact_collector->sweeping_in_progress()) { | |
| 1062 if (mark_compact_collector->IsSweepingCompleted()) { | |
| 1063 mark_compact_collector->EnsureSweepingCompleted(); | |
| 1064 } | |
|
Hannes Payer (out of office)
2015/08/05 12:35:44
A follow-up CL could check if there is still time
ulan
2015/08/05 12:45:40
Acknowledged.
| |
| 1065 return kMoreWork; | |
| 1066 } | |
| 1067 const double remaining_idle_time_in_ms = heap->AdvanceIncrementalMarking( | |
|
Hannes Payer (out of office)
2015/08/05 12:35:44
AdvanceIncrementalMarking is always called with st
ulan
2015/08/05 12:45:40
I'll do it in a separate CL to avoid conflicts wit
| |
| 1068 0, deadline_in_ms, IncrementalMarking::NoForcedStepActions()); | |
| 1069 if (remaining_idle_time_in_ms > 0.0) { | |
| 1070 heap->TryFinalizeIdleIncrementalMarking(remaining_idle_time_in_ms); | |
| 1071 } | |
| 1072 return incremental_marking->IsStopped() ? kDone : kMoreWork; | |
| 1073 } | |
| 1074 | |
| 1075 | |
| 1076 void IncrementalMarkingTask::RunInternal(double deadline_in_seconds) { | |
| 1077 double deadline_in_ms = | |
| 1078 deadline_in_seconds * | |
| 1079 static_cast<double>(base::Time::kMillisecondsPerSecond); | |
| 1080 Heap* heap = isolate_->heap(); | |
| 1081 double start_ms = heap->MonotonicallyIncreasingTimeInMs(); | |
| 1082 heap->incremental_marking()->NotifyIncrementalMarkingTaskRunning(); | |
| 1083 if (Step(heap, deadline_in_ms) == kMoreWork) { | |
| 1084 heap->incremental_marking()->ScheduleIncrementalMarkingTask(); | |
| 1085 } | |
| 1086 if (FLAG_trace_idle_notification) { | |
| 1087 double current_time_ms = heap->MonotonicallyIncreasingTimeInMs(); | |
| 1088 double idle_time_in_ms = deadline_in_ms - start_ms; | |
| 1089 double deadline_difference = deadline_in_ms - current_time_ms; | |
| 1090 PrintIsolate(isolate_, "%8.0f ms: ", isolate_->time_millis_since_init()); | |
| 1091 PrintF( | |
| 1092 "Idle task: requested idle time %.2f ms, used idle time %.2f " | |
| 1093 "ms, deadline usage %.2f ms\n", | |
| 1094 idle_time_in_ms, idle_time_in_ms - deadline_difference, | |
| 1095 deadline_difference); | |
| 1096 } | |
| 1097 } | |
| 1098 | |
| 1033 } // namespace internal | 1099 } // namespace internal |
| 1034 } // namespace v8 | 1100 } // namespace v8 |
| OLD | NEW |