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/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 4579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4590 } | 4590 } |
| 4591 | 4591 |
| 4592 | 4592 |
| 4593 bool Heap::IdleNotification(double deadline_in_seconds) { | 4593 bool Heap::IdleNotification(double deadline_in_seconds) { |
| 4594 CHECK(HasBeenSetUp()); // http://crbug.com/425035 | 4594 CHECK(HasBeenSetUp()); // http://crbug.com/425035 |
| 4595 double deadline_in_ms = | 4595 double deadline_in_ms = |
| 4596 deadline_in_seconds * | 4596 deadline_in_seconds * |
| 4597 static_cast<double>(base::Time::kMillisecondsPerSecond); | 4597 static_cast<double>(base::Time::kMillisecondsPerSecond); |
| 4598 HistogramTimerScope idle_notification_scope( | 4598 HistogramTimerScope idle_notification_scope( |
| 4599 isolate_->counters()->gc_idle_notification()); | 4599 isolate_->counters()->gc_idle_notification()); |
| 4600 double current_time = MonotonicallyIncreasingTimeInMs(); | |
| 4600 | 4601 |
| 4601 GCIdleTimeHandler::HeapState heap_state; | 4602 GCIdleTimeHandler::HeapState heap_state; |
| 4602 heap_state.contexts_disposed = contexts_disposed_; | 4603 heap_state.contexts_disposed = contexts_disposed_; |
| 4603 heap_state.contexts_disposal_rate = | 4604 heap_state.contexts_disposal_rate = |
| 4604 tracer()->ContextDisposalRateInMilliseconds(); | 4605 tracer()->ContextDisposalRateInMilliseconds(); |
| 4605 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects()); | 4606 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects()); |
| 4606 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); | 4607 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); |
| 4607 // TODO(ulan): Start incremental marking only for large heaps. | 4608 // TODO(ulan): Start incremental marking only for large heaps. |
| 4608 heap_state.can_start_incremental_marking = | 4609 heap_state.can_start_incremental_marking = |
| 4609 incremental_marking()->ShouldActivate() && FLAG_incremental_marking; | 4610 incremental_marking()->ShouldActivate() && FLAG_incremental_marking; |
| 4610 heap_state.sweeping_in_progress = | 4611 heap_state.sweeping_in_progress = |
| 4611 mark_compact_collector()->sweeping_in_progress(); | 4612 mark_compact_collector()->sweeping_in_progress(); |
| 4612 heap_state.mark_compact_speed_in_bytes_per_ms = | 4613 heap_state.mark_compact_speed_in_bytes_per_ms = |
| 4613 static_cast<size_t>(tracer()->MarkCompactSpeedInBytesPerMillisecond()); | 4614 static_cast<size_t>(tracer()->MarkCompactSpeedInBytesPerMillisecond()); |
| 4614 heap_state.incremental_marking_speed_in_bytes_per_ms = static_cast<size_t>( | 4615 heap_state.incremental_marking_speed_in_bytes_per_ms = static_cast<size_t>( |
| 4615 tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); | 4616 tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); |
| 4616 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms = | 4617 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms = |
| 4617 static_cast<size_t>( | 4618 static_cast<size_t>( |
| 4618 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); | 4619 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); |
| 4619 heap_state.scavenge_speed_in_bytes_per_ms = | 4620 heap_state.scavenge_speed_in_bytes_per_ms = |
| 4620 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond()); | 4621 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond()); |
| 4621 heap_state.used_new_space_size = new_space_.Size(); | 4622 heap_state.used_new_space_size = new_space_.Size(); |
| 4622 heap_state.new_space_capacity = new_space_.Capacity(); | 4623 heap_state.new_space_capacity = new_space_.Capacity(); |
| 4623 heap_state.new_space_allocation_throughput_in_bytes_per_ms = | 4624 heap_state.new_space_allocation_throughput_in_bytes_per_ms = |
| 4624 static_cast<size_t>( | 4625 static_cast<size_t>( |
| 4625 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond()); | 4626 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond()); |
| 4627 heap_state.last_mark_compact_time = | |
| 4628 mark_compact_collector()->last_mark_compact_time(); | |
| 4629 heap_state.current_time = static_cast<size_t>(current_time); | |
|
rmcilroy
2015/03/20 14:56:08
I'm slightly hesitent at setting current_time as a
| |
| 4626 | 4630 |
| 4627 double idle_time_in_ms = deadline_in_ms - MonotonicallyIncreasingTimeInMs(); | 4631 double idle_time_in_ms = deadline_in_ms - current_time; |
| 4628 GCIdleTimeAction action = | 4632 GCIdleTimeAction action = |
| 4629 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); | 4633 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); |
| 4630 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( | 4634 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( |
| 4631 static_cast<int>(idle_time_in_ms)); | 4635 static_cast<int>(idle_time_in_ms)); |
| 4632 | 4636 |
| 4633 bool result = false; | 4637 bool result = false; |
| 4634 switch (action.type) { | 4638 switch (action.type) { |
| 4635 case DONE: | 4639 case DONE: |
| 4636 result = true; | 4640 result = true; |
| 4637 break; | 4641 break; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4672 case DO_SCAVENGE: | 4676 case DO_SCAVENGE: |
| 4673 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); | 4677 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); |
| 4674 break; | 4678 break; |
| 4675 case DO_FINALIZE_SWEEPING: | 4679 case DO_FINALIZE_SWEEPING: |
| 4676 mark_compact_collector()->EnsureSweepingCompleted(); | 4680 mark_compact_collector()->EnsureSweepingCompleted(); |
| 4677 break; | 4681 break; |
| 4678 case DO_NOTHING: | 4682 case DO_NOTHING: |
| 4679 break; | 4683 break; |
| 4680 } | 4684 } |
| 4681 | 4685 |
| 4682 double current_time = MonotonicallyIncreasingTimeInMs(); | 4686 current_time = MonotonicallyIncreasingTimeInMs(); |
| 4683 last_idle_notification_time_ = current_time; | 4687 last_idle_notification_time_ = current_time; |
| 4684 double deadline_difference = deadline_in_ms - current_time; | 4688 double deadline_difference = deadline_in_ms - current_time; |
| 4685 | 4689 |
| 4686 if (deadline_difference >= 0) { | 4690 if (deadline_difference >= 0) { |
| 4687 if (action.type != DONE && action.type != DO_NOTHING) { | 4691 if (action.type != DONE && action.type != DO_NOTHING) { |
| 4688 isolate()->counters()->gc_idle_time_limit_undershot()->AddSample( | 4692 isolate()->counters()->gc_idle_time_limit_undershot()->AddSample( |
| 4689 static_cast<int>(deadline_difference)); | 4693 static_cast<int>(deadline_difference)); |
| 4690 } | 4694 } |
| 4691 } else { | 4695 } else { |
| 4692 isolate()->counters()->gc_idle_time_limit_overshot()->AddSample( | 4696 isolate()->counters()->gc_idle_time_limit_overshot()->AddSample( |
| (...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6385 static_cast<int>(object_sizes_last_time_[index])); | 6389 static_cast<int>(object_sizes_last_time_[index])); |
| 6386 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6390 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6387 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6391 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6388 | 6392 |
| 6389 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6393 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6390 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6394 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6391 ClearObjectStats(); | 6395 ClearObjectStats(); |
| 6392 } | 6396 } |
| 6393 } | 6397 } |
| 6394 } // namespace v8::internal | 6398 } // namespace v8::internal |
| OLD | NEW |