| 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 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 | 724 |
| 725 void Scavenger::FlushTLS() const { | 725 void Scavenger::FlushTLS() const { |
| 726 ASSERT(heap_ != NULL); | 726 ASSERT(heap_ != NULL); |
| 727 if (heap_->isolate()->IsMutatorThreadScheduled()) { | 727 if (heap_->isolate()->IsMutatorThreadScheduled()) { |
| 728 Thread* mutator_thread = heap_->isolate()->mutator_thread(); | 728 Thread* mutator_thread = heap_->isolate()->mutator_thread(); |
| 729 mutator_thread->heap()->new_space()->set_top(mutator_thread->top()); | 729 mutator_thread->heap()->new_space()->set_top(mutator_thread->top()); |
| 730 } | 730 } |
| 731 } | 731 } |
| 732 | 732 |
| 733 void Scavenger::VisitObjectPointers(ObjectPointerVisitor* visitor) const { | 733 void Scavenger::VisitObjectPointers(ObjectPointerVisitor* visitor) const { |
| 734 ASSERT(Thread::Current()->IsAtSafepoint() || |
| 735 (Thread::Current()->task_kind() == Thread::kMarkerTask)); |
| 734 FlushTLS(); | 736 FlushTLS(); |
| 735 uword cur = FirstObjectStart(); | 737 uword cur = FirstObjectStart(); |
| 736 while (cur < top_) { | 738 while (cur < top_) { |
| 737 RawObject* raw_obj = RawObject::FromAddr(cur); | 739 RawObject* raw_obj = RawObject::FromAddr(cur); |
| 738 cur += raw_obj->VisitPointers(visitor); | 740 cur += raw_obj->VisitPointers(visitor); |
| 739 } | 741 } |
| 740 } | 742 } |
| 741 | 743 |
| 742 void Scavenger::VisitObjects(ObjectVisitor* visitor) const { | 744 void Scavenger::VisitObjects(ObjectVisitor* visitor) const { |
| 745 ASSERT(Thread::Current()->IsAtSafepoint() || |
| 746 (Thread::Current()->task_kind() == Thread::kMarkerTask)); |
| 743 FlushTLS(); | 747 FlushTLS(); |
| 744 uword cur = FirstObjectStart(); | 748 uword cur = FirstObjectStart(); |
| 745 while (cur < top_) { | 749 while (cur < top_) { |
| 746 RawObject* raw_obj = RawObject::FromAddr(cur); | 750 RawObject* raw_obj = RawObject::FromAddr(cur); |
| 747 visitor->VisitObject(raw_obj); | 751 visitor->VisitObject(raw_obj); |
| 748 cur += raw_obj->Size(); | 752 cur += raw_obj->Size(); |
| 749 } | 753 } |
| 750 } | 754 } |
| 751 | 755 |
| 752 void Scavenger::AddRegionsToObjectSet(ObjectSet* set) const { | 756 void Scavenger::AddRegionsToObjectSet(ObjectSet* set) const { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 } | 923 } |
| 920 | 924 |
| 921 Scavenge(); | 925 Scavenge(); |
| 922 | 926 |
| 923 // It is possible for objects to stay in the new space | 927 // It is possible for objects to stay in the new space |
| 924 // if the VM cannot create more pages for these objects. | 928 // if the VM cannot create more pages for these objects. |
| 925 ASSERT((UsedInWords() == 0) || failed_to_promote_); | 929 ASSERT((UsedInWords() == 0) || failed_to_promote_); |
| 926 } | 930 } |
| 927 | 931 |
| 928 } // namespace dart | 932 } // namespace dart |
| OLD | NEW |