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 UsedInWords() * kWordSize); |
| 561 } |
| 562 |
| 563 |
550 bool PageSpace::Contains(uword addr) const { | 564 bool PageSpace::Contains(uword addr) const { |
551 for (ExclusivePageIterator it(this); !it.Done(); it.Advance()) { | 565 for (ExclusivePageIterator it(this); !it.Done(); it.Advance()) { |
552 if (it.page()->Contains(addr)) { | 566 if (it.page()->Contains(addr)) { |
553 return true; | 567 return true; |
554 } | 568 } |
555 } | 569 } |
556 return false; | 570 return false; |
557 } | 571 } |
558 | 572 |
559 | 573 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 | 669 |
656 | 670 |
657 void PageSpace::PrintToJSONObject(JSONObject* object) const { | 671 void PageSpace::PrintToJSONObject(JSONObject* object) const { |
658 Isolate* isolate = Isolate::Current(); | 672 Isolate* isolate = Isolate::Current(); |
659 ASSERT(isolate != NULL); | 673 ASSERT(isolate != NULL); |
660 JSONObject space(object, "old"); | 674 JSONObject space(object, "old"); |
661 space.AddProperty("type", "HeapSpace"); | 675 space.AddProperty("type", "HeapSpace"); |
662 space.AddProperty("name", "old"); | 676 space.AddProperty("name", "old"); |
663 space.AddProperty("vmName", "PageSpace"); | 677 space.AddProperty("vmName", "PageSpace"); |
664 space.AddProperty("collections", collections()); | 678 space.AddProperty("collections", collections()); |
665 space.AddProperty("used", UsedInWords() * kWordSize); | 679 space.AddProperty64("used", UsedInWords() * kWordSize); |
666 space.AddProperty("capacity", CapacityInWords() * kWordSize); | 680 space.AddProperty64("capacity", CapacityInWords() * kWordSize); |
667 space.AddProperty("external", ExternalInWords() * kWordSize); | 681 space.AddProperty64("external", ExternalInWords() * kWordSize); |
668 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros())); | 682 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros())); |
669 if (collections() > 0) { | 683 if (collections() > 0) { |
670 int64_t run_time = OS::GetCurrentTimeMicros() - isolate->start_time(); | 684 int64_t run_time = OS::GetCurrentTimeMicros() - isolate->start_time(); |
671 run_time = Utils::Maximum(run_time, static_cast<int64_t>(0)); | 685 run_time = Utils::Maximum(run_time, static_cast<int64_t>(0)); |
672 double run_time_millis = MicrosecondsToMilliseconds(run_time); | 686 double run_time_millis = MicrosecondsToMilliseconds(run_time); |
673 double avg_time_between_collections = | 687 double avg_time_between_collections = |
674 run_time_millis / static_cast<double>(collections()); | 688 run_time_millis / static_cast<double>(collections()); |
675 space.AddProperty("avgCollectionPeriodMillis", | 689 space.AddProperty("avgCollectionPeriodMillis", |
676 avg_time_between_collections); | 690 avg_time_between_collections); |
677 } else { | 691 } else { |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 heap_->RecordTime(kSweepPages, mid3 - mid2); | 939 heap_->RecordTime(kSweepPages, mid3 - mid2); |
926 heap_->RecordTime(kSweepLargePages, end - mid3); | 940 heap_->RecordTime(kSweepLargePages, end - mid3); |
927 | 941 |
928 if (FLAG_print_free_list_after_gc) { | 942 if (FLAG_print_free_list_after_gc) { |
929 OS::Print("Data Freelist (after GC):\n"); | 943 OS::Print("Data Freelist (after GC):\n"); |
930 freelist_[HeapPage::kData].Print(); | 944 freelist_[HeapPage::kData].Print(); |
931 OS::Print("Executable Freelist (after GC):\n"); | 945 OS::Print("Executable Freelist (after GC):\n"); |
932 freelist_[HeapPage::kExecutable].Print(); | 946 freelist_[HeapPage::kExecutable].Print(); |
933 } | 947 } |
934 | 948 |
| 949 UpdateMaxUsed(); |
| 950 if (heap_ != NULL) { |
| 951 heap_->UpdateGlobalMaxUsed(); |
| 952 } |
| 953 |
935 isolate->thread_registry()->ResumeAllThreads(); | 954 isolate->thread_registry()->ResumeAllThreads(); |
936 | 955 |
937 // Done, reset the task count. | 956 // Done, reset the task count. |
938 { | 957 { |
939 MonitorLocker ml(tasks_lock()); | 958 MonitorLocker ml(tasks_lock()); |
940 set_tasks(tasks() - 1); | 959 set_tasks(tasks() - 1); |
941 ml.Notify(); | 960 ml.Notify(); |
942 } | 961 } |
943 } | 962 } |
944 | 963 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 return 0; | 1213 return 0; |
1195 } else { | 1214 } else { |
1196 ASSERT(total_time >= gc_time); | 1215 ASSERT(total_time >= gc_time); |
1197 int result = static_cast<int>((static_cast<double>(gc_time) / | 1216 int result = static_cast<int>((static_cast<double>(gc_time) / |
1198 static_cast<double>(total_time)) * 100); | 1217 static_cast<double>(total_time)) * 100); |
1199 return result; | 1218 return result; |
1200 } | 1219 } |
1201 } | 1220 } |
1202 | 1221 |
1203 } // namespace dart | 1222 } // namespace dart |
OLD | NEW |