Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: runtime/vm/pages.cc

Issue 1212943010: Safer interface for heap iteration. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/pages.h" 5 #include "vm/pages.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/compiler_stats.h" 8 #include "vm/compiler_stats.h"
9 #include "vm/gc_marker.h" 9 #include "vm/gc_marker.h"
10 #include "vm/gc_sweeper.h" 10 #include "vm/gc_sweeper.h"
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 771
772 if (FLAG_print_free_list_before_gc) { 772 if (FLAG_print_free_list_before_gc) {
773 OS::Print("Data Freelist (before GC):\n"); 773 OS::Print("Data Freelist (before GC):\n");
774 freelist_[HeapPage::kData].Print(); 774 freelist_[HeapPage::kData].Print();
775 OS::Print("Executable Freelist (before GC):\n"); 775 OS::Print("Executable Freelist (before GC):\n");
776 freelist_[HeapPage::kExecutable].Print(); 776 freelist_[HeapPage::kExecutable].Print();
777 } 777 }
778 778
779 if (FLAG_verify_before_gc) { 779 if (FLAG_verify_before_gc) {
780 OS::PrintErr("Verifying before marking..."); 780 OS::PrintErr("Verifying before marking...");
781 heap_->Verify(); 781 heap_->VerifyGC();
782 OS::PrintErr(" done.\n"); 782 OS::PrintErr(" done.\n");
783 } 783 }
784 784
785 const int64_t start = OS::GetCurrentTimeMicros(); 785 const int64_t start = OS::GetCurrentTimeMicros();
786 786
787 // Make code pages writable. 787 // Make code pages writable.
788 WriteProtectCode(false); 788 WriteProtectCode(false);
789 789
790 // Save old value before GCMarker visits the weak persistent handles. 790 // Save old value before GCMarker visits the weak persistent handles.
791 SpaceUsage usage_before = GetCurrentUsage(); 791 SpaceUsage usage_before = GetCurrentUsage();
(...skipping 11 matching lines...) Expand all
803 // Reset the freelists and setup sweeping. 803 // Reset the freelists and setup sweeping.
804 freelist_[HeapPage::kData].Reset(); 804 freelist_[HeapPage::kData].Reset();
805 freelist_[HeapPage::kExecutable].Reset(); 805 freelist_[HeapPage::kExecutable].Reset();
806 806
807 int64_t mid2 = OS::GetCurrentTimeMicros(); 807 int64_t mid2 = OS::GetCurrentTimeMicros();
808 int64_t mid3 = 0; 808 int64_t mid3 = 0;
809 809
810 { 810 {
811 if (FLAG_verify_before_gc) { 811 if (FLAG_verify_before_gc) {
812 OS::PrintErr("Verifying before sweeping..."); 812 OS::PrintErr("Verifying before sweeping...");
813 heap_->Verify(kAllowMarked); 813 heap_->VerifyGC(kAllowMarked);
814 OS::PrintErr(" done.\n"); 814 OS::PrintErr(" done.\n");
815 } 815 }
816 GCSweeper sweeper; 816 GCSweeper sweeper;
817 817
818 // During stop-the-world phases we should use bulk lock when adding elements 818 // During stop-the-world phases we should use bulk lock when adding elements
819 // to the free list. 819 // to the free list.
820 MutexLocker mld(freelist_[HeapPage::kData].mutex()); 820 MutexLocker mld(freelist_[HeapPage::kData].mutex());
821 MutexLocker mle(freelist_[HeapPage::kExecutable].mutex()); 821 MutexLocker mle(freelist_[HeapPage::kExecutable].mutex());
822 822
823 // Large and executable pages are always swept immediately. 823 // Large and executable pages are always swept immediately.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 if (page_in_use) { 864 if (page_in_use) {
865 prev_page = page; 865 prev_page = page;
866 } else { 866 } else {
867 FreePage(page, prev_page); 867 FreePage(page, prev_page);
868 } 868 }
869 // Advance to the next page. 869 // Advance to the next page.
870 page = next_page; 870 page = next_page;
871 } 871 }
872 if (FLAG_verify_after_gc) { 872 if (FLAG_verify_after_gc) {
873 OS::PrintErr("Verifying after sweeping..."); 873 OS::PrintErr("Verifying after sweeping...");
874 heap_->Verify(kForbidMarked); 874 heap_->VerifyGC(kForbidMarked);
875 OS::PrintErr(" done.\n"); 875 OS::PrintErr(" done.\n");
876 } 876 }
877 } else { 877 } else {
878 // Start the concurrent sweeper task now. 878 // Start the concurrent sweeper task now.
879 GCSweeper::SweepConcurrent( 879 GCSweeper::SweepConcurrent(
880 isolate, pages_, pages_tail_, &freelist_[HeapPage::kData]); 880 isolate, pages_, pages_tail_, &freelist_[HeapPage::kData]);
881 } 881 }
882 } 882 }
883 883
884 // Make code pages read-only. 884 // Make code pages read-only.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 return 0; 1134 return 0;
1135 } else { 1135 } else {
1136 ASSERT(total_time >= gc_time); 1136 ASSERT(total_time >= gc_time);
1137 int result = static_cast<int>((static_cast<double>(gc_time) / 1137 int result = static_cast<int>((static_cast<double>(gc_time) /
1138 static_cast<double>(total_time)) * 100); 1138 static_cast<double>(total_time)) * 100);
1139 return result; 1139 return result;
1140 } 1140 }
1141 } 1141 }
1142 1142
1143 } // namespace dart 1143 } // namespace dart
OLDNEW
« runtime/vm/heap.cc ('K') | « runtime/vm/object_test.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698