| 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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 int64_t start = OS::GetCurrentMonotonicMicros(); | 510 int64_t start = OS::GetCurrentMonotonicMicros(); |
| 511 isolate->VisitObjectPointers(visitor, | 511 isolate->VisitObjectPointers(visitor, |
| 512 StackFrameIterator::kDontValidateFrames); | 512 StackFrameIterator::kDontValidateFrames); |
| 513 int64_t middle = OS::GetCurrentMonotonicMicros(); | 513 int64_t middle = OS::GetCurrentMonotonicMicros(); |
| 514 IterateStoreBuffers(isolate, visitor); | 514 IterateStoreBuffers(isolate, visitor); |
| 515 IterateObjectIdTable(isolate, visitor); | 515 IterateObjectIdTable(isolate, visitor); |
| 516 int64_t end = OS::GetCurrentMonotonicMicros(); | 516 int64_t end = OS::GetCurrentMonotonicMicros(); |
| 517 heap_->RecordData(kToKBAfterStoreBuffer, RoundWordsToKB(UsedInWords())); | 517 heap_->RecordData(kToKBAfterStoreBuffer, RoundWordsToKB(UsedInWords())); |
| 518 heap_->RecordTime(kVisitIsolateRoots, middle - start); | 518 heap_->RecordTime(kVisitIsolateRoots, middle - start); |
| 519 heap_->RecordTime(kIterateStoreBuffers, end - middle); | 519 heap_->RecordTime(kIterateStoreBuffers, end - middle); |
| 520 heap_->RecordTime(kDummyScavengeTime, 0); |
| 520 } | 521 } |
| 521 | 522 |
| 522 | 523 |
| 523 bool Scavenger::IsUnreachable(RawObject** p) { | 524 bool Scavenger::IsUnreachable(RawObject** p) { |
| 524 RawObject* raw_obj = *p; | 525 RawObject* raw_obj = *p; |
| 525 if (!raw_obj->IsHeapObject()) { | 526 if (!raw_obj->IsHeapObject()) { |
| 526 return false; | 527 return false; |
| 527 } | 528 } |
| 528 if (!raw_obj->IsNewObject()) { | 529 if (!raw_obj->IsNewObject()) { |
| 529 return false; | 530 return false; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 } | 775 } |
| 775 | 776 |
| 776 | 777 |
| 777 void Scavenger::Scavenge(bool invoke_api_callbacks) { | 778 void Scavenger::Scavenge(bool invoke_api_callbacks) { |
| 778 Isolate* isolate = heap_->isolate(); | 779 Isolate* isolate = heap_->isolate(); |
| 779 // Ensure that all threads for this isolate are at a safepoint (either stopped | 780 // 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 | 781 // 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. | 782 // will continue with its scavenge after waiting for the winner to complete. |
| 782 // TODO(koda): Consider moving SafepointThreads into allocation failure/retry | 783 // TODO(koda): Consider moving SafepointThreads into allocation failure/retry |
| 783 // logic to avoid needless collections. | 784 // logic to avoid needless collections. |
| 785 |
| 786 int64_t pre_safe_point = OS::GetCurrentMonotonicMicros(); |
| 787 |
| 784 Thread* thread = Thread::Current(); | 788 Thread* thread = Thread::Current(); |
| 785 SafepointOperationScope safepoint_scope(thread); | 789 SafepointOperationScope safepoint_scope(thread); |
| 786 | 790 |
| 787 // Scavenging is not reentrant. Make sure that is the case. | 791 // Scavenging is not reentrant. Make sure that is the case. |
| 788 ASSERT(!scavenging_); | 792 ASSERT(!scavenging_); |
| 789 scavenging_ = true; | 793 scavenging_ = true; |
| 790 | 794 |
| 791 PageSpace* page_space = heap_->old_space(); | 795 PageSpace* page_space = heap_->old_space(); |
| 792 NoSafepointScope no_safepoints; | 796 NoSafepointScope no_safepoints; |
| 793 | 797 |
| 798 int64_t post_safe_point = OS::GetCurrentMonotonicMicros(); |
| 799 heap_->RecordTime(kSafePoint, post_safe_point - pre_safe_point); |
| 800 |
| 794 // TODO(koda): Make verification more compatible with concurrent sweep. | 801 // TODO(koda): Make verification more compatible with concurrent sweep. |
| 795 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { | 802 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { |
| 796 OS::PrintErr("Verifying before Scavenge..."); | 803 OS::PrintErr("Verifying before Scavenge..."); |
| 797 heap_->Verify(kForbidMarked); | 804 heap_->Verify(kForbidMarked); |
| 798 OS::PrintErr(" done.\n"); | 805 OS::PrintErr(" done.\n"); |
| 799 } | 806 } |
| 800 | 807 |
| 801 // Prepare for a scavenge. | 808 // Prepare for a scavenge. |
| 802 SpaceUsage usage_before = GetCurrentUsage(); | 809 SpaceUsage usage_before = GetCurrentUsage(); |
| 803 intptr_t promo_candidate_words = | 810 intptr_t promo_candidate_words = |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 } | 906 } |
| 900 | 907 |
| 901 | 908 |
| 902 void Scavenger::FreeExternal(intptr_t size) { | 909 void Scavenger::FreeExternal(intptr_t size) { |
| 903 ASSERT(size >= 0); | 910 ASSERT(size >= 0); |
| 904 external_size_ -= size; | 911 external_size_ -= size; |
| 905 ASSERT(external_size_ >= 0); | 912 ASSERT(external_size_ >= 0); |
| 906 } | 913 } |
| 907 | 914 |
| 908 } // namespace dart | 915 } // namespace dart |
| OLD | NEW |