OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/scavenger.h" | 5 #include "vm/scavenger.h" |
6 | 6 |
7 #include "vm/dart.h" | 7 #include "vm/dart.h" |
8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/lockers.h" | 10 #include "vm/lockers.h" |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 } | 774 } |
775 | 775 |
776 | 776 |
777 void Scavenger::Scavenge(bool invoke_api_callbacks) { | 777 void Scavenger::Scavenge(bool invoke_api_callbacks) { |
778 Isolate* isolate = heap_->isolate(); | 778 Isolate* isolate = heap_->isolate(); |
779 // Ensure that all threads for this isolate are at a safepoint (either stopped | 779 // Ensure that all threads for this isolate are at a safepoint (either stopped |
780 // or in native code). If two threads are racing at this point, the loser | 780 // or in native code). If two threads are racing at this point, the loser |
781 // will continue with its scavenge after waiting for the winner to complete. | 781 // will continue with its scavenge after waiting for the winner to complete. |
782 // TODO(koda): Consider moving SafepointThreads into allocation failure/retry | 782 // TODO(koda): Consider moving SafepointThreads into allocation failure/retry |
783 // logic to avoid needless collections. | 783 // logic to avoid needless collections. |
| 784 |
| 785 int64_t pre_safe_point = OS::GetCurrentMonotonicMicros(); |
| 786 |
784 Thread* thread = Thread::Current(); | 787 Thread* thread = Thread::Current(); |
785 SafepointOperationScope safepoint_scope(thread); | 788 SafepointOperationScope safepoint_scope(thread); |
786 | 789 |
787 // Scavenging is not reentrant. Make sure that is the case. | 790 // Scavenging is not reentrant. Make sure that is the case. |
788 ASSERT(!scavenging_); | 791 ASSERT(!scavenging_); |
789 scavenging_ = true; | 792 scavenging_ = true; |
790 | 793 |
791 PageSpace* page_space = heap_->old_space(); | 794 PageSpace* page_space = heap_->old_space(); |
792 NoSafepointScope no_safepoints; | 795 NoSafepointScope no_safepoints; |
793 | 796 |
| 797 int64_t post_safe_point = OS::GetCurrentMonotonicMicros(); |
| 798 heap_->RecordTime(kSafePoint, post_safe_point - pre_safe_point); |
| 799 |
794 // TODO(koda): Make verification more compatible with concurrent sweep. | 800 // TODO(koda): Make verification more compatible with concurrent sweep. |
795 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { | 801 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { |
796 OS::PrintErr("Verifying before Scavenge..."); | 802 OS::PrintErr("Verifying before Scavenge..."); |
797 heap_->Verify(kForbidMarked); | 803 heap_->Verify(kForbidMarked); |
798 OS::PrintErr(" done.\n"); | 804 OS::PrintErr(" done.\n"); |
799 } | 805 } |
800 | 806 |
801 // Prepare for a scavenge. | 807 // Prepare for a scavenge. |
802 SpaceUsage usage_before = GetCurrentUsage(); | 808 SpaceUsage usage_before = GetCurrentUsage(); |
803 intptr_t promo_candidate_words = | 809 intptr_t promo_candidate_words = |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 } | 905 } |
900 | 906 |
901 | 907 |
902 void Scavenger::FreeExternal(intptr_t size) { | 908 void Scavenger::FreeExternal(intptr_t size) { |
903 ASSERT(size >= 0); | 909 ASSERT(size >= 0); |
904 external_size_ -= size; | 910 external_size_ -= size; |
905 ASSERT(external_size_ >= 0); | 911 ASSERT(external_size_ >= 0); |
906 } | 912 } |
907 | 913 |
908 } // namespace dart | 914 } // namespace dart |
OLD | NEW |