OLD | NEW |
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 iterating_thread_(NULL), | 164 iterating_thread_(NULL), |
165 #endif | 165 #endif |
166 page_space_controller_(heap, | 166 page_space_controller_(heap, |
167 FLAG_old_gen_growth_space_ratio, | 167 FLAG_old_gen_growth_space_ratio, |
168 FLAG_old_gen_growth_rate, | 168 FLAG_old_gen_growth_rate, |
169 FLAG_old_gen_growth_time_ratio), | 169 FLAG_old_gen_growth_time_ratio), |
170 gc_time_micros_(0), | 170 gc_time_micros_(0), |
171 collections_(0) { | 171 collections_(0) { |
172 // We aren't holding the lock but no one can reference us yet. | 172 // We aren't holding the lock but no one can reference us yet. |
173 UpdateMaxCapacityLocked(); | 173 UpdateMaxCapacityLocked(); |
| 174 UpdateMaxUsed(); |
174 } | 175 } |
175 | 176 |
176 | 177 |
177 PageSpace::~PageSpace() { | 178 PageSpace::~PageSpace() { |
178 { | 179 { |
179 MonitorLocker ml(tasks_lock()); | 180 MonitorLocker ml(tasks_lock()); |
180 while (tasks() > 0) { | 181 while (tasks() > 0) { |
181 ml.Wait(); | 182 ml.Wait(); |
182 } | 183 } |
183 } | 184 } |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 return; | 541 return; |
541 } | 542 } |
542 ASSERT(heap_ != NULL); | 543 ASSERT(heap_ != NULL); |
543 ASSERT(heap_->isolate() != NULL); | 544 ASSERT(heap_->isolate() != NULL); |
544 Isolate* isolate = heap_->isolate(); | 545 Isolate* isolate = heap_->isolate(); |
545 isolate->GetHeapOldCapacityMaxMetric()->SetValue( | 546 isolate->GetHeapOldCapacityMaxMetric()->SetValue( |
546 static_cast<int64_t>(usage_.capacity_in_words) * kWordSize); | 547 static_cast<int64_t>(usage_.capacity_in_words) * kWordSize); |
547 } | 548 } |
548 | 549 |
549 | 550 |
| 551 void PageSpace::UpdateMaxUsed() { |
| 552 if (heap_ == NULL) { |
| 553 // Some unit tests. |
| 554 return; |
| 555 } |
| 556 ASSERT(heap_ != NULL); |
| 557 ASSERT(heap_->isolate() != NULL); |
| 558 Isolate* isolate = heap_->isolate(); |
| 559 isolate->GetHeapOldUsedMaxMetric()->SetValue( |
| 560 static_cast<int64_t>(UsedInWords()) * kWordSize); |
| 561 } |
| 562 |
| 563 |
| 564 void PageSpace::UpdateGlobalMaxUsed() { |
| 565 if (heap_ == NULL) { |
| 566 // Some unit tests. |
| 567 return; |
| 568 } |
| 569 ASSERT(heap_ != NULL); |
| 570 ASSERT(heap_->isolate() != NULL); |
| 571 Isolate* isolate = heap_->isolate(); |
| 572 isolate->GetHeapGlobalUsedMaxMetric()->SetValue( |
| 573 (static_cast<int64_t>(heap_->UsedInWords(Heap::kNew)) * kWordSize) + |
| 574 (static_cast<int64_t>(heap_->UsedInWords(Heap::kOld)) * kWordSize)); |
| 575 } |
| 576 |
| 577 |
550 bool PageSpace::Contains(uword addr) const { | 578 bool PageSpace::Contains(uword addr) const { |
551 for (ExclusivePageIterator it(this); !it.Done(); it.Advance()) { | 579 for (ExclusivePageIterator it(this); !it.Done(); it.Advance()) { |
552 if (it.page()->Contains(addr)) { | 580 if (it.page()->Contains(addr)) { |
553 return true; | 581 return true; |
554 } | 582 } |
555 } | 583 } |
556 return false; | 584 return false; |
557 } | 585 } |
558 | 586 |
559 | 587 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 heap_->RecordTime(kSweepPages, mid3 - mid2); | 953 heap_->RecordTime(kSweepPages, mid3 - mid2); |
926 heap_->RecordTime(kSweepLargePages, end - mid3); | 954 heap_->RecordTime(kSweepLargePages, end - mid3); |
927 | 955 |
928 if (FLAG_print_free_list_after_gc) { | 956 if (FLAG_print_free_list_after_gc) { |
929 OS::Print("Data Freelist (after GC):\n"); | 957 OS::Print("Data Freelist (after GC):\n"); |
930 freelist_[HeapPage::kData].Print(); | 958 freelist_[HeapPage::kData].Print(); |
931 OS::Print("Executable Freelist (after GC):\n"); | 959 OS::Print("Executable Freelist (after GC):\n"); |
932 freelist_[HeapPage::kExecutable].Print(); | 960 freelist_[HeapPage::kExecutable].Print(); |
933 } | 961 } |
934 | 962 |
| 963 UpdateMaxUsed(); |
| 964 UpdateGlobalMaxUsed(); |
| 965 |
935 isolate->thread_registry()->ResumeAllThreads(); | 966 isolate->thread_registry()->ResumeAllThreads(); |
936 | 967 |
937 // Done, reset the task count. | 968 // Done, reset the task count. |
938 { | 969 { |
939 MonitorLocker ml(tasks_lock()); | 970 MonitorLocker ml(tasks_lock()); |
940 set_tasks(tasks() - 1); | 971 set_tasks(tasks() - 1); |
941 ml.Notify(); | 972 ml.Notify(); |
942 } | 973 } |
943 } | 974 } |
944 | 975 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 return 0; | 1225 return 0; |
1195 } else { | 1226 } else { |
1196 ASSERT(total_time >= gc_time); | 1227 ASSERT(total_time >= gc_time); |
1197 int result = static_cast<int>((static_cast<double>(gc_time) / | 1228 int result = static_cast<int>((static_cast<double>(gc_time) / |
1198 static_cast<double>(total_time)) * 100); | 1229 static_cast<double>(total_time)) * 100); |
1199 return result; | 1230 return result; |
1200 } | 1231 } |
1201 } | 1232 } |
1202 | 1233 |
1203 } // namespace dart | 1234 } // namespace dart |
OLD | NEW |