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/once.h" | 9 #include "src/base/once.h" |
10 #include "src/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 PerformGarbageCollection(collector, gc_callback_flags); | 838 PerformGarbageCollection(collector, gc_callback_flags); |
839 } | 839 } |
840 | 840 |
841 GarbageCollectionEpilogue(); | 841 GarbageCollectionEpilogue(); |
842 tracer()->Stop(); | 842 tracer()->Stop(); |
843 } | 843 } |
844 | 844 |
845 // Start incremental marking for the next cycle. The heap snapshot | 845 // Start incremental marking for the next cycle. The heap snapshot |
846 // generator needs incremental marking to stay off after it aborted. | 846 // generator needs incremental marking to stay off after it aborted. |
847 if (!mark_compact_collector()->abort_incremental_marking() && | 847 if (!mark_compact_collector()->abort_incremental_marking() && |
848 incremental_marking()->IsStopped() && | 848 WorthActivatingIncrementalMarking()) { |
849 incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull()) { | |
850 incremental_marking()->Start(); | 849 incremental_marking()->Start(); |
851 } | 850 } |
852 | 851 |
853 return next_gc_likely_to_collect_more; | 852 return next_gc_likely_to_collect_more; |
854 } | 853 } |
855 | 854 |
856 | 855 |
857 int Heap::NotifyContextDisposed() { | 856 int Heap::NotifyContextDisposed() { |
858 if (isolate()->concurrent_recompilation_enabled()) { | 857 if (isolate()->concurrent_recompilation_enabled()) { |
859 // Flush the queued recompilation tasks. | 858 // Flush the queued recompilation tasks. |
(...skipping 3416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4276 gc_idle_time_handler_.NotifyIdleMarkCompact(); | 4275 gc_idle_time_handler_.NotifyIdleMarkCompact(); |
4277 gc_count_at_last_idle_gc_ = gc_count_; | 4276 gc_count_at_last_idle_gc_ = gc_count_; |
4278 if (uncommit) { | 4277 if (uncommit) { |
4279 new_space_.Shrink(); | 4278 new_space_.Shrink(); |
4280 UncommitFromSpace(); | 4279 UncommitFromSpace(); |
4281 } | 4280 } |
4282 } | 4281 } |
4283 } | 4282 } |
4284 | 4283 |
4285 | 4284 |
| 4285 bool Heap::WorthActivatingIncrementalMarking() { |
| 4286 return incremental_marking()->IsStopped() && |
| 4287 incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull(); |
| 4288 } |
| 4289 |
| 4290 |
4286 bool Heap::IdleNotification(int idle_time_in_ms) { | 4291 bool Heap::IdleNotification(int idle_time_in_ms) { |
4287 // If incremental marking is off, we do not perform idle notification. | 4292 // If incremental marking is off, we do not perform idle notification. |
4288 if (!FLAG_incremental_marking) return true; | 4293 if (!FLAG_incremental_marking) return true; |
4289 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( | 4294 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( |
4290 idle_time_in_ms); | 4295 idle_time_in_ms); |
4291 HistogramTimerScope idle_notification_scope( | 4296 HistogramTimerScope idle_notification_scope( |
4292 isolate_->counters()->gc_idle_notification()); | 4297 isolate_->counters()->gc_idle_notification()); |
4293 | 4298 |
4294 GCIdleTimeAction action = gc_idle_time_handler_.Compute( | 4299 GCIdleTimeHandler::HeapState heap_state; |
4295 idle_time_in_ms, contexts_disposed_, static_cast<size_t>(SizeOfObjects()), | 4300 heap_state.contexts_disposed = contexts_disposed_; |
4296 incremental_marking()->IsStopped(), tracer()); | 4301 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects()); |
| 4302 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); |
| 4303 heap_state.can_start_incremental_marking = |
| 4304 WorthActivatingIncrementalMarking(); |
| 4305 |
| 4306 GCIdleTimeAction action = |
| 4307 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state, tracer()); |
| 4308 |
4297 contexts_disposed_ = 0; | 4309 contexts_disposed_ = 0; |
4298 bool result = false; | 4310 bool result = false; |
4299 switch (action.type) { | 4311 switch (action.type) { |
4300 case DO_INCREMENTAL_MARKING: | 4312 case DO_INCREMENTAL_MARKING: |
4301 if (incremental_marking()->IsStopped()) { | 4313 if (incremental_marking()->IsStopped()) { |
4302 incremental_marking()->Start(); | 4314 incremental_marking()->Start(); |
4303 } | 4315 } |
4304 AdvanceIdleIncrementalMarking(action.parameter); | 4316 AdvanceIdleIncrementalMarking(action.parameter); |
4305 break; | 4317 break; |
4306 case DO_FULL_GC: { | 4318 case DO_FULL_GC: { |
(...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6100 static_cast<int>(object_sizes_last_time_[index])); | 6112 static_cast<int>(object_sizes_last_time_[index])); |
6101 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6113 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6102 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6114 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6103 | 6115 |
6104 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6116 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6105 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6117 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6106 ClearObjectStats(); | 6118 ClearObjectStats(); |
6107 } | 6119 } |
6108 } | 6120 } |
6109 } // namespace v8::internal | 6121 } // namespace v8::internal |
OLD | NEW |