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/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 Loading... |
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 Loading... |
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() |
4730 action.additional_work = TryFinalizeIdleIncrementalMarking( | 4722 ->incremental_marking_job() |
4731 remaining_idle_time_in_ms, heap_state.size_of_objects, | 4723 ->NotifyIdleTaskProgress(); |
4732 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms); | 4724 result = IncrementalMarkingJob::IdleTask::Step(this, deadline_in_ms) == |
| 4725 IncrementalMarkingJob::IdleTask::kDone; |
4733 } | 4726 } |
4734 break; | 4727 break; |
4735 } | 4728 } |
4736 case DO_FULL_GC: { | 4729 case DO_FULL_GC: { |
4737 DCHECK(contexts_disposed_ > 0); | 4730 DCHECK(contexts_disposed_ > 0); |
4738 HistogramTimerScope scope(isolate_->counters()->gc_context()); | 4731 HistogramTimerScope scope(isolate_->counters()->gc_context()); |
4739 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed"); | 4732 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed"); |
4740 break; | 4733 break; |
4741 } | 4734 } |
4742 case DO_SCAVENGE: | 4735 case DO_SCAVENGE: |
4743 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); | 4736 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); |
4744 break; | 4737 break; |
4745 case DO_FINALIZE_SWEEPING: | |
4746 mark_compact_collector()->EnsureSweepingCompleted(); | |
4747 break; | |
4748 case DO_NOTHING: | 4738 case DO_NOTHING: |
4749 break; | 4739 break; |
4750 } | 4740 } |
4751 | 4741 |
4752 return result; | 4742 return result; |
4753 } | 4743 } |
4754 | 4744 |
4755 | 4745 |
4756 void Heap::IdleNotificationEpilogue(GCIdleTimeAction action, | 4746 void Heap::IdleNotificationEpilogue(GCIdleTimeAction action, |
4757 GCIdleTimeHandler::HeapState heap_state, | 4747 GCIdleTimeHandler::HeapState heap_state, |
(...skipping 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6671 *object_sub_type = "CODE_AGE/" #name; \ | 6661 *object_sub_type = "CODE_AGE/" #name; \ |
6672 return true; | 6662 return true; |
6673 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6663 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6674 #undef COMPARE_AND_RETURN_NAME | 6664 #undef COMPARE_AND_RETURN_NAME |
6675 } | 6665 } |
6676 return false; | 6666 return false; |
6677 } | 6667 } |
6678 | 6668 |
6679 } // namespace internal | 6669 } // namespace internal |
6680 } // namespace v8 | 6670 } // namespace v8 |
OLD | NEW |