| 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 WorthActivatingIncrementalMarking()) { | 848 incremental_marking()->IsStopped() && |
| 849 incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull()) { |
| 849 incremental_marking()->Start(); | 850 incremental_marking()->Start(); |
| 850 } | 851 } |
| 851 | 852 |
| 852 return next_gc_likely_to_collect_more; | 853 return next_gc_likely_to_collect_more; |
| 853 } | 854 } |
| 854 | 855 |
| 855 | 856 |
| 856 int Heap::NotifyContextDisposed() { | 857 int Heap::NotifyContextDisposed() { |
| 857 if (isolate()->concurrent_recompilation_enabled()) { | 858 if (isolate()->concurrent_recompilation_enabled()) { |
| 858 // Flush the queued recompilation tasks. | 859 // Flush the queued recompilation tasks. |
| (...skipping 3410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4269 gc_idle_time_handler_.NotifyIdleMarkCompact(); | 4270 gc_idle_time_handler_.NotifyIdleMarkCompact(); |
| 4270 gc_count_at_last_idle_gc_ = gc_count_; | 4271 gc_count_at_last_idle_gc_ = gc_count_; |
| 4271 if (uncommit) { | 4272 if (uncommit) { |
| 4272 new_space_.Shrink(); | 4273 new_space_.Shrink(); |
| 4273 UncommitFromSpace(); | 4274 UncommitFromSpace(); |
| 4274 } | 4275 } |
| 4275 } | 4276 } |
| 4276 } | 4277 } |
| 4277 | 4278 |
| 4278 | 4279 |
| 4279 bool Heap::WorthActivatingIncrementalMarking() { | |
| 4280 return incremental_marking()->IsStopped() && | |
| 4281 incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull(); | |
| 4282 } | |
| 4283 | |
| 4284 | |
| 4285 bool Heap::IdleNotification(int idle_time_in_ms) { | 4280 bool Heap::IdleNotification(int idle_time_in_ms) { |
| 4286 // If incremental marking is off, we do not perform idle notification. | 4281 // If incremental marking is off, we do not perform idle notification. |
| 4287 if (!FLAG_incremental_marking) return true; | 4282 if (!FLAG_incremental_marking) return true; |
| 4288 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( | 4283 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( |
| 4289 idle_time_in_ms); | 4284 idle_time_in_ms); |
| 4290 HistogramTimerScope idle_notification_scope( | 4285 HistogramTimerScope idle_notification_scope( |
| 4291 isolate_->counters()->gc_idle_notification()); | 4286 isolate_->counters()->gc_idle_notification()); |
| 4292 | 4287 |
| 4293 GCIdleTimeHandler::HeapState heap_state; | 4288 GCIdleTimeAction action = gc_idle_time_handler_.Compute( |
| 4294 heap_state.contexts_disposed = contexts_disposed_; | 4289 idle_time_in_ms, contexts_disposed_, static_cast<size_t>(SizeOfObjects()), |
| 4295 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects()); | 4290 incremental_marking()->IsStopped(), tracer()); |
| 4296 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); | |
| 4297 heap_state.can_start_incremental_marking = | |
| 4298 WorthActivatingIncrementalMarking(); | |
| 4299 | |
| 4300 GCIdleTimeAction action = | |
| 4301 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state, tracer()); | |
| 4302 | |
| 4303 contexts_disposed_ = 0; | 4291 contexts_disposed_ = 0; |
| 4304 bool result = false; | 4292 bool result = false; |
| 4305 switch (action.type) { | 4293 switch (action.type) { |
| 4306 case DO_INCREMENTAL_MARKING: | 4294 case DO_INCREMENTAL_MARKING: |
| 4307 if (incremental_marking()->IsStopped()) { | 4295 if (incremental_marking()->IsStopped()) { |
| 4308 incremental_marking()->Start(); | 4296 incremental_marking()->Start(); |
| 4309 } | 4297 } |
| 4310 AdvanceIdleIncrementalMarking(action.parameter); | 4298 AdvanceIdleIncrementalMarking(action.parameter); |
| 4311 break; | 4299 break; |
| 4312 case DO_FULL_GC: { | 4300 case DO_FULL_GC: { |
| (...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6106 static_cast<int>(object_sizes_last_time_[index])); | 6094 static_cast<int>(object_sizes_last_time_[index])); |
| 6107 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6095 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6108 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6096 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6109 | 6097 |
| 6110 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6098 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6111 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6099 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6112 ClearObjectStats(); | 6100 ClearObjectStats(); |
| 6113 } | 6101 } |
| 6114 } | 6102 } |
| 6115 } // namespace v8::internal | 6103 } // namespace v8::internal |
| OLD | NEW |