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

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: Fix assertion. 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
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 pages_(NULL), 152 pages_(NULL),
153 pages_tail_(NULL), 153 pages_tail_(NULL),
154 exec_pages_(NULL), 154 exec_pages_(NULL),
155 exec_pages_tail_(NULL), 155 exec_pages_tail_(NULL),
156 large_pages_(NULL), 156 large_pages_(NULL),
157 bump_top_(0), 157 bump_top_(0),
158 bump_end_(0), 158 bump_end_(0),
159 max_capacity_in_words_(max_capacity_in_words), 159 max_capacity_in_words_(max_capacity_in_words),
160 max_external_in_words_(max_external_in_words), 160 max_external_in_words_(max_external_in_words),
161 tasks_lock_(new Monitor()), 161 tasks_lock_(new Monitor()),
162 tasks_(0), 162 tasks_(0),
siva 2015/07/07 22:53:42 #if defined(DEBUG)
163 is_iterating_(false),
siva 2015/07/07 22:53:42 #endif
163 page_space_controller_(heap, 164 page_space_controller_(heap,
164 FLAG_old_gen_growth_space_ratio, 165 FLAG_old_gen_growth_space_ratio,
165 FLAG_old_gen_growth_rate, 166 FLAG_old_gen_growth_rate,
166 FLAG_old_gen_growth_time_ratio), 167 FLAG_old_gen_growth_time_ratio),
167 gc_time_micros_(0), 168 gc_time_micros_(0),
168 collections_(0) { 169 collections_(0) {
169 } 170 }
170 171
171 172
172 PageSpace::~PageSpace() { 173 PageSpace::~PageSpace() {
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 772
772 if (FLAG_print_free_list_before_gc) { 773 if (FLAG_print_free_list_before_gc) {
773 OS::Print("Data Freelist (before GC):\n"); 774 OS::Print("Data Freelist (before GC):\n");
774 freelist_[HeapPage::kData].Print(); 775 freelist_[HeapPage::kData].Print();
775 OS::Print("Executable Freelist (before GC):\n"); 776 OS::Print("Executable Freelist (before GC):\n");
776 freelist_[HeapPage::kExecutable].Print(); 777 freelist_[HeapPage::kExecutable].Print();
777 } 778 }
778 779
779 if (FLAG_verify_before_gc) { 780 if (FLAG_verify_before_gc) {
780 OS::PrintErr("Verifying before marking..."); 781 OS::PrintErr("Verifying before marking...");
781 heap_->Verify(); 782 heap_->VerifyGC();
782 OS::PrintErr(" done.\n"); 783 OS::PrintErr(" done.\n");
783 } 784 }
784 785
785 const int64_t start = OS::GetCurrentTimeMicros(); 786 const int64_t start = OS::GetCurrentTimeMicros();
786 787
787 // Make code pages writable. 788 // Make code pages writable.
788 WriteProtectCode(false); 789 WriteProtectCode(false);
789 790
790 // Save old value before GCMarker visits the weak persistent handles. 791 // Save old value before GCMarker visits the weak persistent handles.
791 SpaceUsage usage_before = GetCurrentUsage(); 792 SpaceUsage usage_before = GetCurrentUsage();
(...skipping 11 matching lines...) Expand all
803 // Reset the freelists and setup sweeping. 804 // Reset the freelists and setup sweeping.
804 freelist_[HeapPage::kData].Reset(); 805 freelist_[HeapPage::kData].Reset();
805 freelist_[HeapPage::kExecutable].Reset(); 806 freelist_[HeapPage::kExecutable].Reset();
806 807
807 int64_t mid2 = OS::GetCurrentTimeMicros(); 808 int64_t mid2 = OS::GetCurrentTimeMicros();
808 int64_t mid3 = 0; 809 int64_t mid3 = 0;
809 810
810 { 811 {
811 if (FLAG_verify_before_gc) { 812 if (FLAG_verify_before_gc) {
812 OS::PrintErr("Verifying before sweeping..."); 813 OS::PrintErr("Verifying before sweeping...");
813 heap_->Verify(kAllowMarked); 814 heap_->VerifyGC(kAllowMarked);
814 OS::PrintErr(" done.\n"); 815 OS::PrintErr(" done.\n");
815 } 816 }
816 GCSweeper sweeper; 817 GCSweeper sweeper;
817 818
818 // During stop-the-world phases we should use bulk lock when adding elements 819 // During stop-the-world phases we should use bulk lock when adding elements
819 // to the free list. 820 // to the free list.
820 MutexLocker mld(freelist_[HeapPage::kData].mutex()); 821 MutexLocker mld(freelist_[HeapPage::kData].mutex());
821 MutexLocker mle(freelist_[HeapPage::kExecutable].mutex()); 822 MutexLocker mle(freelist_[HeapPage::kExecutable].mutex());
822 823
823 // Large and executable pages are always swept immediately. 824 // 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) { 865 if (page_in_use) {
865 prev_page = page; 866 prev_page = page;
866 } else { 867 } else {
867 FreePage(page, prev_page); 868 FreePage(page, prev_page);
868 } 869 }
869 // Advance to the next page. 870 // Advance to the next page.
870 page = next_page; 871 page = next_page;
871 } 872 }
872 if (FLAG_verify_after_gc) { 873 if (FLAG_verify_after_gc) {
873 OS::PrintErr("Verifying after sweeping..."); 874 OS::PrintErr("Verifying after sweeping...");
874 heap_->Verify(kForbidMarked); 875 heap_->VerifyGC(kForbidMarked);
875 OS::PrintErr(" done.\n"); 876 OS::PrintErr(" done.\n");
876 } 877 }
877 } else { 878 } else {
878 // Start the concurrent sweeper task now. 879 // Start the concurrent sweeper task now.
879 GCSweeper::SweepConcurrent( 880 GCSweeper::SweepConcurrent(
880 isolate, pages_, pages_tail_, &freelist_[HeapPage::kData]); 881 isolate, pages_, pages_tail_, &freelist_[HeapPage::kData]);
881 } 882 }
882 } 883 }
883 884
884 // Make code pages read-only. 885 // Make code pages read-only.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 return 0; 1135 return 0;
1135 } else { 1136 } else {
1136 ASSERT(total_time >= gc_time); 1137 ASSERT(total_time >= gc_time);
1137 int result = static_cast<int>((static_cast<double>(gc_time) / 1138 int result = static_cast<int>((static_cast<double>(gc_time) /
1138 static_cast<double>(total_time)) * 100); 1139 static_cast<double>(total_time)) * 100);
1139 return result; 1140 return result;
1140 } 1141 }
1141 } 1142 }
1142 1143
1143 } // namespace dart 1144 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698