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

Side by Side Diff: src/heap/heap.cc

Issue 1265423002: Use idle task to perform incremental marking steps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test 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 unified diff | Download patch
OLDNEW
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/heap.h" 5 #include "src/heap/heap.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 4617 matching lines...) Expand 10 before | Expand all | Expand 10 after
4628 (!incremental_marking()->weak_closure_was_overapproximated() && 4628 (!incremental_marking()->weak_closure_was_overapproximated() &&
4629 mark_compact_collector_.marking_deque()->IsEmpty()))) { 4629 mark_compact_collector_.marking_deque()->IsEmpty()))) {
4630 OverApproximateWeakClosure(comment); 4630 OverApproximateWeakClosure(comment);
4631 } else if (incremental_marking()->IsComplete() || 4631 } else if (incremental_marking()->IsComplete() ||
4632 (mark_compact_collector_.marking_deque()->IsEmpty())) { 4632 (mark_compact_collector_.marking_deque()->IsEmpty())) {
4633 CollectAllGarbage(current_gc_flags_, comment); 4633 CollectAllGarbage(current_gc_flags_, comment);
4634 } 4634 }
4635 } 4635 }
4636 4636
4637 4637
4638 bool Heap::TryFinalizeIdleIncrementalMarking( 4638 bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) {
4639 double idle_time_in_ms, size_t size_of_objects, 4639 size_t size_of_objects = static_cast<size_t>(SizeOfObjects());
4640 size_t final_incremental_mark_compact_speed_in_bytes_per_ms) { 4640 size_t final_incremental_mark_compact_speed_in_bytes_per_ms =
4641 if (FLAG_overapproximate_weak_closure && incremental_marking()->IsMarking() && 4641 static_cast<size_t>(
4642 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond());
4643 if (FLAG_overapproximate_weak_closure &&
4642 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || 4644 (incremental_marking()->IsReadyToOverApproximateWeakClosure() ||
4643 (!incremental_marking()->weak_closure_was_overapproximated() && 4645 (!incremental_marking()->weak_closure_was_overapproximated() &&
4644 mark_compact_collector_.marking_deque()->IsEmpty() && 4646 mark_compact_collector_.marking_deque()->IsEmpty() &&
4645 gc_idle_time_handler_.ShouldDoOverApproximateWeakClosure( 4647 gc_idle_time_handler_.ShouldDoOverApproximateWeakClosure(
4646 static_cast<size_t>(idle_time_in_ms))))) { 4648 static_cast<size_t>(idle_time_in_ms))))) {
4647 OverApproximateWeakClosure( 4649 OverApproximateWeakClosure(
4648 "Idle notification: overapproximate weak closure"); 4650 "Idle notification: overapproximate weak closure");
4649 return true; 4651 return true;
4650 } else if (incremental_marking()->IsComplete() || 4652 } else if (incremental_marking()->IsComplete() ||
4651 (mark_compact_collector_.marking_deque()->IsEmpty() && 4653 (mark_compact_collector_.marking_deque()->IsEmpty() &&
4652 gc_idle_time_handler_.ShouldDoFinalIncrementalMarkCompact( 4654 gc_idle_time_handler_.ShouldDoFinalIncrementalMarkCompact(
4653 static_cast<size_t>(idle_time_in_ms), size_of_objects, 4655 static_cast<size_t>(idle_time_in_ms), size_of_objects,
4654 final_incremental_mark_compact_speed_in_bytes_per_ms))) { 4656 final_incremental_mark_compact_speed_in_bytes_per_ms))) {
4655 CollectAllGarbage(current_gc_flags_, 4657 CollectAllGarbage(current_gc_flags_,
4656 "idle notification: finalize incremental"); 4658 "idle notification: finalize incremental");
4657 return true; 4659 return true;
4658 } 4660 }
4659 return false; 4661 return false;
4660 } 4662 }
4661 4663
4662 4664
4663 GCIdleTimeHandler::HeapState Heap::ComputeHeapState() { 4665 GCIdleTimeHandler::HeapState Heap::ComputeHeapState() {
4664 GCIdleTimeHandler::HeapState heap_state; 4666 GCIdleTimeHandler::HeapState heap_state;
4665 heap_state.contexts_disposed = contexts_disposed_; 4667 heap_state.contexts_disposed = contexts_disposed_;
4666 heap_state.contexts_disposal_rate = 4668 heap_state.contexts_disposal_rate =
4667 tracer()->ContextDisposalRateInMilliseconds(); 4669 tracer()->ContextDisposalRateInMilliseconds();
4668 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects());
4669 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); 4670 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped();
4670 heap_state.sweeping_in_progress =
4671 mark_compact_collector()->sweeping_in_progress();
4672 heap_state.sweeping_completed =
4673 mark_compact_collector()->IsSweepingCompleted();
4674 heap_state.mark_compact_speed_in_bytes_per_ms = 4671 heap_state.mark_compact_speed_in_bytes_per_ms =
4675 static_cast<size_t>(tracer()->MarkCompactSpeedInBytesPerMillisecond()); 4672 static_cast<size_t>(tracer()->MarkCompactSpeedInBytesPerMillisecond());
4676 heap_state.incremental_marking_speed_in_bytes_per_ms = static_cast<size_t>(
4677 tracer()->IncrementalMarkingSpeedInBytesPerMillisecond());
4678 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms =
4679 static_cast<size_t>(
4680 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond());
4681 heap_state.scavenge_speed_in_bytes_per_ms = 4673 heap_state.scavenge_speed_in_bytes_per_ms =
4682 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond()); 4674 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond());
4683 heap_state.used_new_space_size = new_space_.Size(); 4675 heap_state.used_new_space_size = new_space_.Size();
4684 heap_state.new_space_capacity = new_space_.Capacity(); 4676 heap_state.new_space_capacity = new_space_.Capacity();
4685 heap_state.new_space_allocation_throughput_in_bytes_per_ms = 4677 heap_state.new_space_allocation_throughput_in_bytes_per_ms =
4686 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond(); 4678 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond();
4687 return heap_state; 4679 return heap_state;
4688 } 4680 }
4689 4681
4690 4682
(...skipping 24 matching lines...) Expand all
4715 4707
4716 4708
4717 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, 4709 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action,
4718 GCIdleTimeHandler::HeapState heap_state, 4710 GCIdleTimeHandler::HeapState heap_state,
4719 double deadline_in_ms) { 4711 double deadline_in_ms) {
4720 bool result = false; 4712 bool result = false;
4721 switch (action.type) { 4713 switch (action.type) {
4722 case DONE: 4714 case DONE:
4723 result = true; 4715 result = true;
4724 break; 4716 break;
4725 case DO_INCREMENTAL_MARKING: { 4717 case DO_INCREMENTAL_STEP: {
4726 const double remaining_idle_time_in_ms = 4718 if (incremental_marking()->incremental_marking_job()->IdleTaskPending()) {
4727 AdvanceIncrementalMarking(action.parameter, deadline_in_ms, 4719 result = true;
4728 IncrementalMarking::IdleStepActions()); 4720 } else {
4729 if (remaining_idle_time_in_ms > 0.0) { 4721 incremental_marking()->incremental_marking_job()->NotifyProgress();
4730 action.additional_work = TryFinalizeIdleIncrementalMarking( 4722 result = IncrementalMarkingJob::IdleTask::Step(this, deadline_in_ms) ==
4731 remaining_idle_time_in_ms, heap_state.size_of_objects, 4723 IncrementalMarkingJob::IdleTask::kDone;
4732 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms);
4733 } 4724 }
4734 break; 4725 break;
4735 } 4726 }
4736 case DO_FULL_GC: { 4727 case DO_FULL_GC: {
4737 DCHECK(contexts_disposed_ > 0); 4728 DCHECK(contexts_disposed_ > 0);
4738 HistogramTimerScope scope(isolate_->counters()->gc_context()); 4729 HistogramTimerScope scope(isolate_->counters()->gc_context());
4739 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed"); 4730 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed");
4740 break; 4731 break;
4741 } 4732 }
4742 case DO_SCAVENGE: 4733 case DO_SCAVENGE:
4743 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); 4734 CollectGarbage(NEW_SPACE, "idle notification: scavenge");
4744 break; 4735 break;
4745 case DO_FINALIZE_SWEEPING:
4746 mark_compact_collector()->EnsureSweepingCompleted();
4747 break;
4748 case DO_NOTHING: 4736 case DO_NOTHING:
4749 break; 4737 break;
4750 } 4738 }
4751 4739
4752 return result; 4740 return result;
4753 } 4741 }
4754 4742
4755 4743
4756 void Heap::IdleNotificationEpilogue(GCIdleTimeAction action, 4744 void Heap::IdleNotificationEpilogue(GCIdleTimeAction action,
4757 GCIdleTimeHandler::HeapState heap_state, 4745 GCIdleTimeHandler::HeapState heap_state,
(...skipping 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after
6671 *object_sub_type = "CODE_AGE/" #name; \ 6659 *object_sub_type = "CODE_AGE/" #name; \
6672 return true; 6660 return true;
6673 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6661 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6674 #undef COMPARE_AND_RETURN_NAME 6662 #undef COMPARE_AND_RETURN_NAME
6675 } 6663 }
6676 return false; 6664 return false;
6677 } 6665 }
6678 6666
6679 } // namespace internal 6667 } // namespace internal
6680 } // namespace v8 6668 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698