| 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 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 (collector == SCAVENGER) ? isolate_->counters()->gc_scavenger() | 900 (collector == SCAVENGER) ? isolate_->counters()->gc_scavenger() |
| 901 : isolate_->counters()->gc_compactor()); | 901 : isolate_->counters()->gc_compactor()); |
| 902 next_gc_likely_to_collect_more = | 902 next_gc_likely_to_collect_more = |
| 903 PerformGarbageCollection(collector, gc_callback_flags); | 903 PerformGarbageCollection(collector, gc_callback_flags); |
| 904 } | 904 } |
| 905 | 905 |
| 906 GarbageCollectionEpilogue(); | 906 GarbageCollectionEpilogue(); |
| 907 if (collector == MARK_COMPACTOR && FLAG_track_detached_contexts) { | 907 if (collector == MARK_COMPACTOR && FLAG_track_detached_contexts) { |
| 908 isolate()->CheckDetachedContextsAfterGC(); | 908 isolate()->CheckDetachedContextsAfterGC(); |
| 909 } | 909 } |
| 910 |
| 911 if (collector == MARK_COMPACTOR) { |
| 912 gc_idle_time_handler_.NotifyMarkCompact(); |
| 913 } else { |
| 914 gc_idle_time_handler_.NotifyScavenge(); |
| 915 } |
| 916 |
| 910 tracer()->Stop(collector); | 917 tracer()->Stop(collector); |
| 911 } | 918 } |
| 912 | 919 |
| 913 // Start incremental marking for the next cycle. The heap snapshot | 920 // Start incremental marking for the next cycle. The heap snapshot |
| 914 // generator needs incremental marking to stay off after it aborted. | 921 // generator needs incremental marking to stay off after it aborted. |
| 915 if (!mark_compact_collector()->abort_incremental_marking() && | 922 if (!mark_compact_collector()->abort_incremental_marking() && |
| 916 incremental_marking()->IsStopped() && | 923 incremental_marking()->IsStopped() && |
| 917 incremental_marking()->ShouldActivateEvenWithoutIdleNotification()) { | 924 incremental_marking()->ShouldActivateEvenWithoutIdleNotification()) { |
| 918 incremental_marking()->Start(); | 925 incremental_marking()->Start(); |
| 919 } | 926 } |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 new_space_.LowerInlineAllocationLimit( | 1634 new_space_.LowerInlineAllocationLimit( |
| 1628 new_space_.inline_allocation_limit_step()); | 1635 new_space_.inline_allocation_limit_step()); |
| 1629 | 1636 |
| 1630 // Update how much has survived scavenge. | 1637 // Update how much has survived scavenge. |
| 1631 IncrementYoungSurvivorsCounter(static_cast<int>( | 1638 IncrementYoungSurvivorsCounter(static_cast<int>( |
| 1632 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); | 1639 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); |
| 1633 | 1640 |
| 1634 LOG(isolate_, ResourceEvent("scavenge", "end")); | 1641 LOG(isolate_, ResourceEvent("scavenge", "end")); |
| 1635 | 1642 |
| 1636 gc_state_ = NOT_IN_GC; | 1643 gc_state_ = NOT_IN_GC; |
| 1637 | |
| 1638 gc_idle_time_handler_.NotifyScavenge(); | |
| 1639 } | 1644 } |
| 1640 | 1645 |
| 1641 | 1646 |
| 1642 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, | 1647 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, |
| 1643 Object** p) { | 1648 Object** p) { |
| 1644 MapWord first_word = HeapObject::cast(*p)->map_word(); | 1649 MapWord first_word = HeapObject::cast(*p)->map_word(); |
| 1645 | 1650 |
| 1646 if (!first_word.IsForwardingAddress()) { | 1651 if (!first_word.IsForwardingAddress()) { |
| 1647 // Unreachable external string can be finalized. | 1652 // Unreachable external string can be finalized. |
| 1648 heap->FinalizeExternalString(String::cast(*p)); | 1653 heap->FinalizeExternalString(String::cast(*p)); |
| (...skipping 2914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4563 static_cast<size_t>(idle_time_in_ms))))) { | 4568 static_cast<size_t>(idle_time_in_ms))))) { |
| 4564 OverApproximateWeakClosure( | 4569 OverApproximateWeakClosure( |
| 4565 "Idle notification: overapproximate weak closure"); | 4570 "Idle notification: overapproximate weak closure"); |
| 4566 return true; | 4571 return true; |
| 4567 } else if (incremental_marking()->IsComplete() || | 4572 } else if (incremental_marking()->IsComplete() || |
| 4568 (mark_compact_collector_.marking_deque()->IsEmpty() && | 4573 (mark_compact_collector_.marking_deque()->IsEmpty() && |
| 4569 gc_idle_time_handler_.ShouldDoFinalIncrementalMarkCompact( | 4574 gc_idle_time_handler_.ShouldDoFinalIncrementalMarkCompact( |
| 4570 static_cast<size_t>(idle_time_in_ms), size_of_objects, | 4575 static_cast<size_t>(idle_time_in_ms), size_of_objects, |
| 4571 final_incremental_mark_compact_speed_in_bytes_per_ms))) { | 4576 final_incremental_mark_compact_speed_in_bytes_per_ms))) { |
| 4572 CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental"); | 4577 CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental"); |
| 4578 gc_idle_time_handler_.NotifyIdleMarkCompact(); |
| 4573 ReduceNewSpaceSize(is_long_idle_notification); | 4579 ReduceNewSpaceSize(is_long_idle_notification); |
| 4574 return true; | 4580 return true; |
| 4575 } | 4581 } |
| 4576 return false; | 4582 return false; |
| 4577 } | 4583 } |
| 4578 | 4584 |
| 4579 | 4585 |
| 4580 static double MonotonicallyIncreasingTimeInMs() { | 4586 static double MonotonicallyIncreasingTimeInMs() { |
| 4581 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * | 4587 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * |
| 4582 static_cast<double>(base::Time::kMillisecondsPerSecond); | 4588 static_cast<double>(base::Time::kMillisecondsPerSecond); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4643 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( | 4649 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( |
| 4644 static_cast<int>(idle_time_in_ms)); | 4650 static_cast<int>(idle_time_in_ms)); |
| 4645 | 4651 |
| 4646 bool result = false; | 4652 bool result = false; |
| 4647 switch (action.type) { | 4653 switch (action.type) { |
| 4648 case DONE: | 4654 case DONE: |
| 4649 result = true; | 4655 result = true; |
| 4650 break; | 4656 break; |
| 4651 case DO_INCREMENTAL_MARKING: { | 4657 case DO_INCREMENTAL_MARKING: { |
| 4652 if (incremental_marking()->IsStopped()) { | 4658 if (incremental_marking()->IsStopped()) { |
| 4659 // TODO(ulan): take reduce_memory into account. |
| 4653 incremental_marking()->Start(); | 4660 incremental_marking()->Start(); |
| 4654 } | 4661 } |
| 4655 double remaining_idle_time_in_ms = 0.0; | 4662 double remaining_idle_time_in_ms = 0.0; |
| 4656 do { | 4663 do { |
| 4657 incremental_marking()->Step( | 4664 incremental_marking()->Step( |
| 4658 action.parameter, IncrementalMarking::NO_GC_VIA_STACK_GUARD, | 4665 action.parameter, IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
| 4659 IncrementalMarking::FORCE_MARKING, | 4666 IncrementalMarking::FORCE_MARKING, |
| 4660 IncrementalMarking::DO_NOT_FORCE_COMPLETION); | 4667 IncrementalMarking::DO_NOT_FORCE_COMPLETION); |
| 4661 remaining_idle_time_in_ms = | 4668 remaining_idle_time_in_ms = |
| 4662 deadline_in_ms - MonotonicallyIncreasingTimeInMs(); | 4669 deadline_in_ms - MonotonicallyIncreasingTimeInMs(); |
| (...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6434 static_cast<int>(object_sizes_last_time_[index])); | 6441 static_cast<int>(object_sizes_last_time_[index])); |
| 6435 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6442 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6436 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6443 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6437 | 6444 |
| 6438 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6445 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6439 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6446 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6440 ClearObjectStats(); | 6447 ClearObjectStats(); |
| 6441 } | 6448 } |
| 6442 } | 6449 } |
| 6443 } // namespace v8::internal | 6450 } // namespace v8::internal |
| OLD | NEW |