| 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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 JSONObject space(object, "old"); | 697 JSONObject space(object, "old"); |
| 698 space.AddProperty("type", "HeapSpace"); | 698 space.AddProperty("type", "HeapSpace"); |
| 699 space.AddProperty("name", "old"); | 699 space.AddProperty("name", "old"); |
| 700 space.AddProperty("vmName", "PageSpace"); | 700 space.AddProperty("vmName", "PageSpace"); |
| 701 space.AddProperty("collections", collections()); | 701 space.AddProperty("collections", collections()); |
| 702 space.AddProperty64("used", UsedInWords() * kWordSize); | 702 space.AddProperty64("used", UsedInWords() * kWordSize); |
| 703 space.AddProperty64("capacity", CapacityInWords() * kWordSize); | 703 space.AddProperty64("capacity", CapacityInWords() * kWordSize); |
| 704 space.AddProperty64("external", ExternalInWords() * kWordSize); | 704 space.AddProperty64("external", ExternalInWords() * kWordSize); |
| 705 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros())); | 705 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros())); |
| 706 if (collections() > 0) { | 706 if (collections() > 0) { |
| 707 int64_t run_time = OS::GetCurrentTimeMicros() - isolate->start_time(); | 707 int64_t run_time = isolate->UptimeMicros(); |
| 708 run_time = Utils::Maximum(run_time, static_cast<int64_t>(0)); | 708 run_time = Utils::Maximum(run_time, static_cast<int64_t>(0)); |
| 709 double run_time_millis = MicrosecondsToMilliseconds(run_time); | 709 double run_time_millis = MicrosecondsToMilliseconds(run_time); |
| 710 double avg_time_between_collections = | 710 double avg_time_between_collections = |
| 711 run_time_millis / static_cast<double>(collections()); | 711 run_time_millis / static_cast<double>(collections()); |
| 712 space.AddProperty("avgCollectionPeriodMillis", | 712 space.AddProperty("avgCollectionPeriodMillis", |
| 713 avg_time_between_collections); | 713 avg_time_between_collections); |
| 714 } else { | 714 } else { |
| 715 space.AddProperty("avgCollectionPeriodMillis", 0.0); | 715 space.AddProperty("avgCollectionPeriodMillis", 0.0); |
| 716 } | 716 } |
| 717 } | 717 } |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 Utils::Maximum<intptr_t>(0, capacity_increase_in_words); | 1137 Utils::Maximum<intptr_t>(0, capacity_increase_in_words); |
| 1138 capacity_increase_in_words = | 1138 capacity_increase_in_words = |
| 1139 Utils::RoundUp(capacity_increase_in_words, PageSpace::kPageSizeInWords); | 1139 Utils::RoundUp(capacity_increase_in_words, PageSpace::kPageSizeInWords); |
| 1140 intptr_t capacity_increase_in_pages = | 1140 intptr_t capacity_increase_in_pages = |
| 1141 capacity_increase_in_words / PageSpace::kPageSizeInWords; | 1141 capacity_increase_in_words / PageSpace::kPageSizeInWords; |
| 1142 double multiplier = 1.0; | 1142 double multiplier = 1.0; |
| 1143 // To avoid waste, the first GC should be triggered before too long. After | 1143 // To avoid waste, the first GC should be triggered before too long. After |
| 1144 // kInitialTimeoutSeconds, gradually lower the capacity limit. | 1144 // kInitialTimeoutSeconds, gradually lower the capacity limit. |
| 1145 static const double kInitialTimeoutSeconds = 1.00; | 1145 static const double kInitialTimeoutSeconds = 1.00; |
| 1146 if (history_.IsEmpty()) { | 1146 if (history_.IsEmpty()) { |
| 1147 double seconds_since_init = MicrosecondsToSeconds( | 1147 double seconds_since_init = |
| 1148 OS::GetCurrentTimeMicros() - heap_->isolate()->start_time()); | 1148 MicrosecondsToSeconds(heap_->isolate()->UptimeMicros()); |
| 1149 if (seconds_since_init > kInitialTimeoutSeconds) { | 1149 if (seconds_since_init > kInitialTimeoutSeconds) { |
| 1150 multiplier *= seconds_since_init / kInitialTimeoutSeconds; | 1150 multiplier *= seconds_since_init / kInitialTimeoutSeconds; |
| 1151 } | 1151 } |
| 1152 } | 1152 } |
| 1153 bool needs_gc = capacity_increase_in_pages * multiplier > grow_heap_; | 1153 bool needs_gc = capacity_increase_in_pages * multiplier > grow_heap_; |
| 1154 if (FLAG_log_growth) { | 1154 if (FLAG_log_growth) { |
| 1155 OS::PrintErr("%s: %" Pd " * %f %s %" Pd "\n", | 1155 OS::PrintErr("%s: %" Pd " * %f %s %" Pd "\n", |
| 1156 needs_gc ? "NEEDS GC" : "grow", capacity_increase_in_pages, | 1156 needs_gc ? "NEEDS GC" : "grow", capacity_increase_in_pages, |
| 1157 multiplier, needs_gc ? ">" : "<=", grow_heap_); | 1157 multiplier, needs_gc ? ">" : "<=", grow_heap_); |
| 1158 } | 1158 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 return 0; | 1261 return 0; |
| 1262 } else { | 1262 } else { |
| 1263 ASSERT(total_time >= gc_time); | 1263 ASSERT(total_time >= gc_time); |
| 1264 int result = static_cast<int>( | 1264 int result = static_cast<int>( |
| 1265 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); | 1265 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); |
| 1266 return result; | 1266 return result; |
| 1267 } | 1267 } |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 } // namespace dart | 1270 } // namespace dart |
| OLD | NEW |