Chromium Code Reviews| 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 } | 398 } |
| 399 | 399 |
| 400 void Scavenger::Epilogue(Isolate* isolate, | 400 void Scavenger::Epilogue(Isolate* isolate, |
| 401 SemiSpace* from, | 401 SemiSpace* from, |
| 402 bool invoke_api_callbacks) { | 402 bool invoke_api_callbacks) { |
| 403 // All objects in the to space have been copied from the from space at this | 403 // All objects in the to space have been copied from the from space at this |
| 404 // moment. | 404 // moment. |
| 405 | 405 |
| 406 // Ensure the mutator thread will fail the next allocation. This will force | 406 // Ensure the mutator thread will fail the next allocation. This will force |
| 407 // mutator to allocate a new TLAB | 407 // mutator to allocate a new TLAB |
| 408 if (isolate->IsMutatorThreadScheduled()) { | 408 Thread* mutator_thread = isolate->mutator_thread(); |
| 409 Thread* mutator_thread = isolate->mutator_thread(); | 409 ASSERT((mutator_thread == NULL) || (!mutator_thread->HasActiveTLAB())); |
| 410 ASSERT(!mutator_thread->HasActiveTLAB()); | |
| 411 } | |
| 412 | 410 |
| 413 double avg_frac = stats_history_.Get(0).PromoCandidatesSuccessFraction(); | 411 double avg_frac = stats_history_.Get(0).PromoCandidatesSuccessFraction(); |
| 414 if (stats_history_.Size() >= 2) { | 412 if (stats_history_.Size() >= 2) { |
| 415 // Previous scavenge is only given half as much weight. | 413 // Previous scavenge is only given half as much weight. |
| 416 avg_frac += 0.5 * stats_history_.Get(1).PromoCandidatesSuccessFraction(); | 414 avg_frac += 0.5 * stats_history_.Get(1).PromoCandidatesSuccessFraction(); |
| 417 avg_frac /= 1.0 + 0.5; // Normalize. | 415 avg_frac /= 1.0 + 0.5; // Normalize. |
| 418 } | 416 } |
| 419 if (avg_frac < (FLAG_early_tenuring_threshold / 100.0)) { | 417 if (avg_frac < (FLAG_early_tenuring_threshold / 100.0)) { |
| 420 // Remember the limit to which objects have been copied. | 418 // Remember the limit to which objects have been copied. |
| 421 survivor_end_ = top_; | 419 survivor_end_ = top_; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 WeakProperty::Clear(cur_weak); | 707 WeakProperty::Clear(cur_weak); |
| 710 | 708 |
| 711 // Advance to next weak property in the queue. | 709 // Advance to next weak property in the queue. |
| 712 cur_weak = reinterpret_cast<RawWeakProperty*>(next_weak); | 710 cur_weak = reinterpret_cast<RawWeakProperty*>(next_weak); |
| 713 } | 711 } |
| 714 } | 712 } |
| 715 } | 713 } |
| 716 | 714 |
| 717 void Scavenger::MakeNewSpaceIterable() const { | 715 void Scavenger::MakeNewSpaceIterable() const { |
| 718 ASSERT(heap_ != NULL); | 716 ASSERT(heap_ != NULL); |
| 719 if (heap_->isolate()->IsMutatorThreadScheduled() && !scavenging_) { | 717 Thread* mutator_thread = heap_->isolate()->mutator_thread(); |
| 720 Thread* mutator_thread = heap_->isolate()->mutator_thread(); | 718 if (mutator_thread != NULL && !scavenging_) { |
| 721 if (mutator_thread->HasActiveTLAB()) { | 719 if (mutator_thread->HasActiveTLAB()) { |
| 722 ASSERT(mutator_thread->top() <= | 720 ASSERT(mutator_thread->top() <= |
| 723 mutator_thread->heap()->new_space()->top()); | 721 mutator_thread->heap()->new_space()->top()); |
| 724 heap_->FillRemainingTLAB(mutator_thread); | 722 heap_->FillRemainingTLAB(mutator_thread); |
| 725 } | 723 } |
| 726 } | 724 } |
| 727 } | 725 } |
| 728 | 726 |
| 729 void Scavenger::VisitObjectPointers(ObjectPointerVisitor* visitor) const { | 727 void Scavenger::VisitObjectPointers(ObjectPointerVisitor* visitor) const { |
| 730 MakeNewSpaceIterable(); | 728 MakeNewSpaceIterable(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 791 scavenging_ = true; | 789 scavenging_ = true; |
| 792 | 790 |
| 793 failed_to_promote_ = false; | 791 failed_to_promote_ = false; |
| 794 | 792 |
| 795 PageSpace* page_space = heap_->old_space(); | 793 PageSpace* page_space = heap_->old_space(); |
| 796 NoSafepointScope no_safepoints; | 794 NoSafepointScope no_safepoints; |
| 797 | 795 |
| 798 int64_t post_safe_point = OS::GetCurrentMonotonicMicros(); | 796 int64_t post_safe_point = OS::GetCurrentMonotonicMicros(); |
| 799 heap_->RecordTime(kSafePoint, post_safe_point - pre_safe_point); | 797 heap_->RecordTime(kSafePoint, post_safe_point - pre_safe_point); |
| 800 | 798 |
| 801 if (isolate->IsMutatorThreadScheduled()) { | 799 Thread* mutator_thread = isolate->mutator_thread(); |
|
rmacnak
2017/08/07 21:29:35
It looks like isolate->mutator_thread_ is NULL whi
danunez
2017/08/07 23:09:59
It looks like isolate->mutator_thread() returns th
| |
| 802 Thread* mutator_thread = isolate->mutator_thread(); | 800 if ((mutator_thread != NULL) && (mutator_thread->HasActiveTLAB())) { |
| 803 if (mutator_thread->HasActiveTLAB()) { | 801 heap_->AbandonRemainingTLAB(mutator_thread); |
| 804 heap_->AbandonRemainingTLAB(mutator_thread); | |
| 805 } | |
| 806 } | 802 } |
| 807 | 803 |
| 808 // TODO(koda): Make verification more compatible with concurrent sweep. | 804 // TODO(koda): Make verification more compatible with concurrent sweep. |
| 809 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { | 805 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { |
| 810 OS::PrintErr("Verifying before Scavenge..."); | 806 OS::PrintErr("Verifying before Scavenge..."); |
| 811 heap_->Verify(kForbidMarked); | 807 heap_->Verify(kForbidMarked); |
| 812 OS::PrintErr(" done.\n"); | 808 OS::PrintErr(" done.\n"); |
| 813 } | 809 } |
| 814 | 810 |
| 815 // Prepare for a scavenge. | 811 // Prepare for a scavenge. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 // if the VM cannot create more pages for these objects. | 918 // if the VM cannot create more pages for these objects. |
| 923 ASSERT((UsedInWords() == 0) || failed_to_promote_); | 919 ASSERT((UsedInWords() == 0) || failed_to_promote_); |
| 924 } | 920 } |
| 925 | 921 |
| 926 int64_t Scavenger::UsedInWords() const { | 922 int64_t Scavenger::UsedInWords() const { |
| 927 int64_t used_in_words = (top_ - FirstObjectStart()) >> kWordSizeLog2; | 923 int64_t used_in_words = (top_ - FirstObjectStart()) >> kWordSizeLog2; |
| 928 return used_in_words; | 924 return used_in_words; |
| 929 } | 925 } |
| 930 | 926 |
| 931 } // namespace dart | 927 } // namespace dart |
| OLD | NEW |