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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 last_idle_notification_time_(0.0), | 135 last_idle_notification_time_(0.0), |
136 last_gc_time_(0.0), | 136 last_gc_time_(0.0), |
137 mark_compact_collector_(this), | 137 mark_compact_collector_(this), |
138 store_buffer_(this), | 138 store_buffer_(this), |
139 marking_(this), | 139 marking_(this), |
140 incremental_marking_(this), | 140 incremental_marking_(this), |
141 gc_count_at_last_idle_gc_(0), | 141 gc_count_at_last_idle_gc_(0), |
142 full_codegen_bytes_generated_(0), | 142 full_codegen_bytes_generated_(0), |
143 crankshaft_codegen_bytes_generated_(0), | 143 crankshaft_codegen_bytes_generated_(0), |
144 new_space_allocation_counter_(0), | 144 new_space_allocation_counter_(0), |
| 145 old_generation_allocation_counter_(0), |
| 146 old_generation_size_at_last_gc_(0), |
145 gcs_since_last_deopt_(0), | 147 gcs_since_last_deopt_(0), |
146 allocation_sites_scratchpad_length_(0), | 148 allocation_sites_scratchpad_length_(0), |
147 promotion_queue_(this), | 149 promotion_queue_(this), |
148 configured_(false), | 150 configured_(false), |
149 external_string_table_(this), | 151 external_string_table_(this), |
150 chunks_queued_for_free_(NULL), | 152 chunks_queued_for_free_(NULL), |
151 gc_callbacks_depth_(0), | 153 gc_callbacks_depth_(0), |
152 deserialization_complete_(false), | 154 deserialization_complete_(false), |
153 concurrent_sweeping_enabled_(false), | 155 concurrent_sweeping_enabled_(false), |
154 strong_roots_list_(NULL) { | 156 strong_roots_list_(NULL) { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 isolate()->optimizing_compile_dispatcher()->AgeBufferedOsrJobs(); | 462 isolate()->optimizing_compile_dispatcher()->AgeBufferedOsrJobs(); |
461 } | 463 } |
462 | 464 |
463 if (new_space_.IsAtMaximumCapacity()) { | 465 if (new_space_.IsAtMaximumCapacity()) { |
464 maximum_size_scavenges_++; | 466 maximum_size_scavenges_++; |
465 } else { | 467 } else { |
466 maximum_size_scavenges_ = 0; | 468 maximum_size_scavenges_ = 0; |
467 } | 469 } |
468 CheckNewSpaceExpansionCriteria(); | 470 CheckNewSpaceExpansionCriteria(); |
469 UpdateNewSpaceAllocationCounter(); | 471 UpdateNewSpaceAllocationCounter(); |
| 472 UpdateOldGenerationAllocationCounter(); |
470 } | 473 } |
471 | 474 |
472 | 475 |
473 intptr_t Heap::SizeOfObjects() { | 476 intptr_t Heap::SizeOfObjects() { |
474 intptr_t total = 0; | 477 intptr_t total = 0; |
475 AllSpaces spaces(this); | 478 AllSpaces spaces(this); |
476 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { | 479 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { |
477 total += space->SizeOfObjects(); | 480 total += space->SizeOfObjects(); |
478 } | 481 } |
479 return total; | 482 return total; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 #ifdef DEBUG | 731 #ifdef DEBUG |
729 ReportStatisticsAfterGC(); | 732 ReportStatisticsAfterGC(); |
730 #endif // DEBUG | 733 #endif // DEBUG |
731 | 734 |
732 // Remember the last top pointer so that we can later find out | 735 // Remember the last top pointer so that we can later find out |
733 // whether we allocated in new space since the last GC. | 736 // whether we allocated in new space since the last GC. |
734 new_space_top_after_last_gc_ = new_space()->top(); | 737 new_space_top_after_last_gc_ = new_space()->top(); |
735 last_gc_time_ = MonotonicallyIncreasingTimeInMs(); | 738 last_gc_time_ = MonotonicallyIncreasingTimeInMs(); |
736 | 739 |
737 ReduceNewSpaceSize( | 740 ReduceNewSpaceSize( |
738 tracer()->CurrentNewSpaceAllocationThroughputInBytesPerMillisecond()); | 741 tracer()->CurrentAllocationThroughputInBytesPerMillisecond()); |
739 } | 742 } |
740 | 743 |
741 | 744 |
742 void Heap::PreprocessStackTraces() { | 745 void Heap::PreprocessStackTraces() { |
743 if (!weak_stack_trace_list()->IsWeakFixedArray()) return; | 746 if (!weak_stack_trace_list()->IsWeakFixedArray()) return; |
744 WeakFixedArray* array = WeakFixedArray::cast(weak_stack_trace_list()); | 747 WeakFixedArray* array = WeakFixedArray::cast(weak_stack_trace_list()); |
745 int length = array->Length(); | 748 int length = array->Length(); |
746 for (int i = 0; i < length; i++) { | 749 for (int i = 0; i < length; i++) { |
747 if (array->IsEmptySlot(i)) continue; | 750 if (array->IsEmptySlot(i)) continue; |
748 FixedArray* elements = FixedArray::cast(array->Get(i)); | 751 FixedArray* elements = FixedArray::cast(array->Get(i)); |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 // Temporarily set the limit for case when PostGarbageCollectionProcessing | 1219 // Temporarily set the limit for case when PostGarbageCollectionProcessing |
1217 // allocates and triggers GC. The real limit is set at after | 1220 // allocates and triggers GC. The real limit is set at after |
1218 // PostGarbageCollectionProcessing. | 1221 // PostGarbageCollectionProcessing. |
1219 SetOldGenerationAllocationLimit(PromotedSpaceSizeOfObjects(), 0); | 1222 SetOldGenerationAllocationLimit(PromotedSpaceSizeOfObjects(), 0); |
1220 old_gen_exhausted_ = false; | 1223 old_gen_exhausted_ = false; |
1221 old_generation_size_configured_ = true; | 1224 old_generation_size_configured_ = true; |
1222 } else { | 1225 } else { |
1223 Scavenge(); | 1226 Scavenge(); |
1224 } | 1227 } |
1225 | 1228 |
| 1229 // This should be updated before PostGarbageCollectionProcessing, which can |
| 1230 // cause another GC. |
| 1231 old_generation_size_at_last_gc_ = PromotedSpaceSizeOfObjects(); |
| 1232 |
1226 UpdateSurvivalStatistics(start_new_space_size); | 1233 UpdateSurvivalStatistics(start_new_space_size); |
1227 ConfigureInitialOldGenerationSize(); | 1234 ConfigureInitialOldGenerationSize(); |
1228 | 1235 |
1229 isolate_->counters()->objs_since_last_young()->Set(0); | 1236 isolate_->counters()->objs_since_last_young()->Set(0); |
1230 | 1237 |
1231 // Callbacks that fire after this point might trigger nested GCs and | 1238 // Callbacks that fire after this point might trigger nested GCs and |
1232 // restart incremental marking, the assertion can't be moved down. | 1239 // restart incremental marking, the assertion can't be moved down. |
1233 DCHECK(collector == SCAVENGER || incremental_marking()->IsStopped()); | 1240 DCHECK(collector == SCAVENGER || incremental_marking()->IsStopped()); |
1234 | 1241 |
1235 gc_post_processing_depth_++; | 1242 gc_post_processing_depth_++; |
(...skipping 3383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4619 tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); | 4626 tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); |
4620 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms = | 4627 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms = |
4621 static_cast<size_t>( | 4628 static_cast<size_t>( |
4622 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); | 4629 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); |
4623 heap_state.scavenge_speed_in_bytes_per_ms = | 4630 heap_state.scavenge_speed_in_bytes_per_ms = |
4624 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond()); | 4631 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond()); |
4625 heap_state.used_new_space_size = new_space_.Size(); | 4632 heap_state.used_new_space_size = new_space_.Size(); |
4626 heap_state.new_space_capacity = new_space_.Capacity(); | 4633 heap_state.new_space_capacity = new_space_.Capacity(); |
4627 heap_state.new_space_allocation_throughput_in_bytes_per_ms = | 4634 heap_state.new_space_allocation_throughput_in_bytes_per_ms = |
4628 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond(); | 4635 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond(); |
4629 heap_state.current_new_space_allocation_throughput_in_bytes_per_ms = | 4636 heap_state.current_allocation_throughput_in_bytes_per_ms = |
4630 tracer()->CurrentNewSpaceAllocationThroughputInBytesPerMillisecond(); | 4637 tracer()->CurrentAllocationThroughputInBytesPerMillisecond(); |
4631 intptr_t limit = old_generation_allocation_limit_; | 4638 intptr_t limit = old_generation_allocation_limit_; |
4632 if (HasLowAllocationRate( | 4639 if (HasLowAllocationRate( |
4633 heap_state.current_new_space_allocation_throughput_in_bytes_per_ms)) { | 4640 heap_state.current_allocation_throughput_in_bytes_per_ms)) { |
4634 limit = idle_old_generation_allocation_limit_; | 4641 limit = idle_old_generation_allocation_limit_; |
4635 } | 4642 } |
4636 heap_state.can_start_incremental_marking = | 4643 heap_state.can_start_incremental_marking = |
4637 incremental_marking()->CanBeActivated() && | 4644 incremental_marking()->CanBeActivated() && |
4638 HeapIsFullEnoughToStartIncrementalMarking(limit) && | 4645 HeapIsFullEnoughToStartIncrementalMarking(limit) && |
4639 !mark_compact_collector()->sweeping_in_progress(); | 4646 !mark_compact_collector()->sweeping_in_progress(); |
4640 return heap_state; | 4647 return heap_state; |
4641 } | 4648 } |
4642 | 4649 |
4643 | 4650 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4777 static_cast<double>(base::Time::kMillisecondsPerSecond); | 4784 static_cast<double>(base::Time::kMillisecondsPerSecond); |
4778 HistogramTimerScope idle_notification_scope( | 4785 HistogramTimerScope idle_notification_scope( |
4779 isolate_->counters()->gc_idle_notification()); | 4786 isolate_->counters()->gc_idle_notification()); |
4780 double start_ms = MonotonicallyIncreasingTimeInMs(); | 4787 double start_ms = MonotonicallyIncreasingTimeInMs(); |
4781 double idle_time_in_ms = deadline_in_ms - start_ms; | 4788 double idle_time_in_ms = deadline_in_ms - start_ms; |
4782 bool is_long_idle_notification = | 4789 bool is_long_idle_notification = |
4783 static_cast<size_t>(idle_time_in_ms) > | 4790 static_cast<size_t>(idle_time_in_ms) > |
4784 GCIdleTimeHandler::kMaxFrameRenderingIdleTime; | 4791 GCIdleTimeHandler::kMaxFrameRenderingIdleTime; |
4785 | 4792 |
4786 if (is_long_idle_notification) { | 4793 if (is_long_idle_notification) { |
4787 tracer()->SampleNewSpaceAllocation(start_ms, NewSpaceAllocationCounter()); | 4794 tracer()->SampleAllocation(start_ms, NewSpaceAllocationCounter(), |
| 4795 OldGenerationAllocationCounter()); |
4788 } | 4796 } |
4789 | 4797 |
4790 GCIdleTimeHandler::HeapState heap_state = ComputeHeapState(); | 4798 GCIdleTimeHandler::HeapState heap_state = ComputeHeapState(); |
4791 | 4799 |
4792 GCIdleTimeAction action = | 4800 GCIdleTimeAction action = |
4793 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); | 4801 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); |
4794 | 4802 |
4795 bool result = PerformIdleTimeAction(action, heap_state, deadline_in_ms, | 4803 bool result = PerformIdleTimeAction(action, heap_state, deadline_in_ms, |
4796 is_long_idle_notification); | 4804 is_long_idle_notification); |
4797 | 4805 |
(...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6586 *object_type = "CODE_TYPE"; \ | 6594 *object_type = "CODE_TYPE"; \ |
6587 *object_sub_type = "CODE_AGE/" #name; \ | 6595 *object_sub_type = "CODE_AGE/" #name; \ |
6588 return true; | 6596 return true; |
6589 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6597 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6590 #undef COMPARE_AND_RETURN_NAME | 6598 #undef COMPARE_AND_RETURN_NAME |
6591 } | 6599 } |
6592 return false; | 6600 return false; |
6593 } | 6601 } |
6594 } | 6602 } |
6595 } // namespace v8::internal | 6603 } // namespace v8::internal |
OLD | NEW |