| 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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 had_promotion_failure_ = false; | 704 had_promotion_failure_ = false; |
| 705 Isolate* isolate = Isolate::Current(); | 705 Isolate* isolate = Isolate::Current(); |
| 706 NoHandleScope no_handles(isolate); | 706 NoHandleScope no_handles(isolate); |
| 707 | 707 |
| 708 if (FLAG_verify_before_gc) { | 708 if (FLAG_verify_before_gc) { |
| 709 OS::PrintErr("Verifying before Scavenge..."); | 709 OS::PrintErr("Verifying before Scavenge..."); |
| 710 heap_->Verify(); | 710 heap_->Verify(); |
| 711 OS::PrintErr(" done.\n"); | 711 OS::PrintErr(" done.\n"); |
| 712 } | 712 } |
| 713 | 713 |
| 714 // During from/to flip and promoted stack use, move external allocation | |
| 715 // out of tospace temporarily. | |
| 716 intptr_t saved_external = external_size_; | |
| 717 FreeExternal(saved_external); | |
| 718 | |
| 719 // Setup the visitor and run a scavenge. | 714 // Setup the visitor and run a scavenge. |
| 720 ScavengerVisitor visitor(isolate, this); | 715 ScavengerVisitor visitor(isolate, this); |
| 721 Prologue(isolate, invoke_api_callbacks); | 716 Prologue(isolate, invoke_api_callbacks); |
| 722 const bool prologue_weak_are_strong = !invoke_api_callbacks; | 717 const bool prologue_weak_are_strong = !invoke_api_callbacks; |
| 723 IterateRoots(isolate, &visitor, prologue_weak_are_strong); | 718 IterateRoots(isolate, &visitor, prologue_weak_are_strong); |
| 724 int64_t start = OS::GetCurrentTimeMicros(); | 719 int64_t start = OS::GetCurrentTimeMicros(); |
| 725 ProcessToSpace(&visitor); | 720 ProcessToSpace(&visitor); |
| 726 int64_t middle = OS::GetCurrentTimeMicros(); | 721 int64_t middle = OS::GetCurrentTimeMicros(); |
| 727 IterateWeakReferences(isolate, &visitor); | 722 IterateWeakReferences(isolate, &visitor); |
| 728 // Done with promoted stack; restore external allocation. | |
| 729 ASSERT(!PromotedStackHasMore()); | |
| 730 AllocateExternal(saved_external); | |
| 731 ScavengerWeakVisitor weak_visitor(this, prologue_weak_are_strong); | 723 ScavengerWeakVisitor weak_visitor(this, prologue_weak_are_strong); |
| 732 // Include the prologue weak handles, since we must process any promotion. | 724 // Include the prologue weak handles, since we must process any promotion. |
| 733 const bool visit_prologue_weak_handles = true; | 725 const bool visit_prologue_weak_handles = true; |
| 734 IterateWeakRoots(isolate, &weak_visitor, visit_prologue_weak_handles); | 726 IterateWeakRoots(isolate, &weak_visitor, visit_prologue_weak_handles); |
| 735 visitor.Finalize(); | 727 visitor.Finalize(); |
| 736 ProcessWeakTables(); | 728 ProcessWeakTables(); |
| 737 int64_t end = OS::GetCurrentTimeMicros(); | 729 int64_t end = OS::GetCurrentTimeMicros(); |
| 738 heap_->RecordTime(kProcessToSpace, middle - start); | 730 heap_->RecordTime(kProcessToSpace, middle - start); |
| 739 heap_->RecordTime(kIterateWeaks, end - middle); | 731 heap_->RecordTime(kIterateWeaks, end - middle); |
| 740 Epilogue(isolate, &visitor, invoke_api_callbacks); | 732 Epilogue(isolate, &visitor, invoke_api_callbacks); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 767 space.AddProperty("used", UsedInWords() * kWordSize); | 759 space.AddProperty("used", UsedInWords() * kWordSize); |
| 768 space.AddProperty("capacity", CapacityInWords() * kWordSize); | 760 space.AddProperty("capacity", CapacityInWords() * kWordSize); |
| 769 space.AddProperty("external", ExternalInWords() * kWordSize); | 761 space.AddProperty("external", ExternalInWords() * kWordSize); |
| 770 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros())); | 762 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros())); |
| 771 } | 763 } |
| 772 | 764 |
| 773 | 765 |
| 774 void Scavenger::AllocateExternal(intptr_t size) { | 766 void Scavenger::AllocateExternal(intptr_t size) { |
| 775 ASSERT(size >= 0); | 767 ASSERT(size >= 0); |
| 776 external_size_ += size; | 768 external_size_ += size; |
| 777 intptr_t remaining = end_ - top_; | |
| 778 end_ -= Utils::Minimum(remaining, size); | |
| 779 } | 769 } |
| 780 | 770 |
| 781 | 771 |
| 782 void Scavenger::FreeExternal(intptr_t size) { | 772 void Scavenger::FreeExternal(intptr_t size) { |
| 783 ASSERT(size >= 0); | 773 ASSERT(size >= 0); |
| 784 external_size_ -= size; | 774 external_size_ -= size; |
| 785 ASSERT(external_size_ >= 0); | 775 ASSERT(external_size_ >= 0); |
| 786 end_ = Utils::Minimum(to_->end(), end_ + size); | |
| 787 } | 776 } |
| 788 | 777 |
| 789 } // namespace dart | 778 } // namespace dart |
| OLD | NEW |