| 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/address_sanitizer.h" | 7 #include "platform/address_sanitizer.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/compiler_stats.h" | 9 #include "vm/compiler_stats.h" |
| 10 #include "vm/gc_marker.h" | 10 #include "vm/gc_marker.h" |
| (...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 const intptr_t limit = after.capacity_in_words + | 1242 const intptr_t limit = after.capacity_in_words + |
| 1243 (grow_heap_ * PageSpace::kPageSizeInWords); | 1243 (grow_heap_ * PageSpace::kPageSizeInWords); |
| 1244 const intptr_t allocated_before_next_gc = limit - after.used_in_words; | 1244 const intptr_t allocated_before_next_gc = limit - after.used_in_words; |
| 1245 const double estimated_garbage = k * allocated_before_next_gc; | 1245 const double estimated_garbage = k * allocated_before_next_gc; |
| 1246 if (t <= estimated_garbage / limit) { | 1246 if (t <= estimated_garbage / limit) { |
| 1247 max = local_grow_heap - 1; | 1247 max = local_grow_heap - 1; |
| 1248 } else { | 1248 } else { |
| 1249 min = local_grow_heap + 1; | 1249 min = local_grow_heap + 1; |
| 1250 } | 1250 } |
| 1251 } | 1251 } |
| 1252 local_grow_heap = (max + min) / 2; |
| 1252 grow_heap_ = local_grow_heap; | 1253 grow_heap_ = local_grow_heap; |
| 1253 ASSERT(grow_heap_ >= 0); | 1254 ASSERT(grow_heap_ >= 0); |
| 1254 // If we are going to grow by heap_grow_max_ then ensure that we | 1255 // If we are going to grow by heap_grow_max_ then ensure that we |
| 1255 // will be growing the heap at least by the growth ratio heuristics. | 1256 // will be growing the heap at least by the growth ratio heuristics. |
| 1256 if ((grow_heap_ == heap_growth_max_) && (grow_ratio > grow_heap_)) { | 1257 if (grow_heap_ >= heap_growth_max_) { |
| 1257 grow_heap_ = grow_ratio; | 1258 grow_heap_ = Utils::Maximum(grow_ratio, grow_heap_); |
| 1258 } | 1259 } |
| 1259 } | 1260 } |
| 1260 } else { | 1261 } else { |
| 1261 heap_->RecordData(PageSpace::kGarbageRatio, 100); | 1262 heap_->RecordData(PageSpace::kGarbageRatio, 100); |
| 1262 grow_heap_ = 0; | 1263 grow_heap_ = 0; |
| 1263 } | 1264 } |
| 1264 heap_->RecordData(PageSpace::kPageGrowth, grow_heap_); | 1265 heap_->RecordData(PageSpace::kPageGrowth, grow_heap_); |
| 1265 | 1266 |
| 1266 // Limit shrinkage: allow growth by at least half the pages freed by GC. | 1267 // Limit shrinkage: allow growth by at least half the pages freed by GC. |
| 1267 const intptr_t freed_pages = | 1268 const intptr_t freed_pages = |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1295 return 0; | 1296 return 0; |
| 1296 } else { | 1297 } else { |
| 1297 ASSERT(total_time >= gc_time); | 1298 ASSERT(total_time >= gc_time); |
| 1298 int result = static_cast<int>( | 1299 int result = static_cast<int>( |
| 1299 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); | 1300 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); |
| 1300 return result; | 1301 return result; |
| 1301 } | 1302 } |
| 1302 } | 1303 } |
| 1303 | 1304 |
| 1304 } // namespace dart | 1305 } // namespace dart |
| OLD | NEW |