| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 void Scavenger::VisitObjects(ObjectVisitor* visitor) const { | 664 void Scavenger::VisitObjects(ObjectVisitor* visitor) const { |
| 665 uword cur = FirstObjectStart(); | 665 uword cur = FirstObjectStart(); |
| 666 while (cur < top_) { | 666 while (cur < top_) { |
| 667 RawObject* raw_obj = RawObject::FromAddr(cur); | 667 RawObject* raw_obj = RawObject::FromAddr(cur); |
| 668 visitor->VisitObject(raw_obj); | 668 visitor->VisitObject(raw_obj); |
| 669 cur += raw_obj->Size(); | 669 cur += raw_obj->Size(); |
| 670 } | 670 } |
| 671 } | 671 } |
| 672 | 672 |
| 673 | 673 |
| 674 RawObject* Scavenger::FindObject(FindObjectVisitor* visitor) const { |
| 675 ASSERT(!scavenging_); |
| 676 uword cur = FirstObjectStart(); |
| 677 if (visitor->VisitRange(cur, top_)) { |
| 678 while (cur < top_) { |
| 679 RawObject* raw_obj = RawObject::FromAddr(cur); |
| 680 uword next = cur + raw_obj->Size(); |
| 681 if (visitor->VisitRange(cur, next) && raw_obj->FindObject(visitor)) { |
| 682 return raw_obj; // Found object, return it. |
| 683 } |
| 684 cur = next; |
| 685 } |
| 686 ASSERT(cur == top_); |
| 687 } |
| 688 return Object::null(); |
| 689 } |
| 690 |
| 691 |
| 674 void Scavenger::Scavenge() { | 692 void Scavenger::Scavenge() { |
| 675 // TODO(cshapiro): Add a decision procedure for determining when the | 693 // TODO(cshapiro): Add a decision procedure for determining when the |
| 676 // the API callbacks should be invoked. | 694 // the API callbacks should be invoked. |
| 677 Scavenge(false); | 695 Scavenge(false); |
| 678 } | 696 } |
| 679 | 697 |
| 680 | 698 |
| 681 void Scavenger::Scavenge(bool invoke_api_callbacks) { | 699 void Scavenger::Scavenge(bool invoke_api_callbacks) { |
| 682 // Scavenging is not reentrant. Make sure that is the case. | 700 // Scavenging is not reentrant. Make sure that is the case. |
| 683 ASSERT(!scavenging_); | 701 ASSERT(!scavenging_); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 | 779 |
| 762 | 780 |
| 763 void Scavenger::FreeExternal(intptr_t size) { | 781 void Scavenger::FreeExternal(intptr_t size) { |
| 764 ASSERT(size >= 0); | 782 ASSERT(size >= 0); |
| 765 external_size_ -= size; | 783 external_size_ -= size; |
| 766 ASSERT(external_size_ >= 0); | 784 ASSERT(external_size_ >= 0); |
| 767 end_ = Utils::Minimum(to_->end(), end_ + size); | 785 end_ = Utils::Minimum(to_->end(), end_ + size); |
| 768 } | 786 } |
| 769 | 787 |
| 770 } // namespace dart | 788 } // namespace dart |
| OLD | NEW |