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/heap.h" | 5 #include "vm/heap.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
10 #include "vm/heap_histogram.h" | 10 #include "vm/heap_histogram.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 | 78 |
79 | 79 |
80 uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) { | 80 uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) { |
81 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0); | 81 ASSERT(Isolate::Current()->no_gc_scope_depth() == 0); |
82 uword addr = old_space_->TryAllocate(size, type); | 82 uword addr = old_space_->TryAllocate(size, type); |
83 if (addr == 0) { | 83 if (addr == 0) { |
84 CollectAllGarbage(); | 84 CollectAllGarbage(); |
85 addr = old_space_->TryAllocate(size, type, PageSpace::kForceGrowth); | 85 addr = old_space_->TryAllocate(size, type, PageSpace::kForceGrowth); |
86 if (addr == 0) { | 86 if (addr == 0) { |
87 OS::PrintErr("Exhausted heap space, trying to allocate %"Pd" bytes.\n", | 87 OS::PrintErr("Exhausted heap space, trying to allocate %" Pd " bytes.\n", |
88 size); | 88 size); |
89 return 0; | 89 return 0; |
90 } | 90 } |
91 } | 91 } |
92 return addr; | 92 return addr; |
93 } | 93 } |
94 | 94 |
95 | 95 |
96 bool Heap::Contains(uword addr) const { | 96 bool Heap::Contains(uword addr) const { |
97 return new_space_->Contains(addr) || | 97 return new_space_->Contains(addr) || |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 ObjectSet* allocated_set = isolate->heap()->CreateAllocatedObjectSet(); | 289 ObjectSet* allocated_set = isolate->heap()->CreateAllocatedObjectSet(); |
290 VerifyPointersVisitor visitor(isolate, allocated_set); | 290 VerifyPointersVisitor visitor(isolate, allocated_set); |
291 isolate->heap()->IteratePointers(&visitor); | 291 isolate->heap()->IteratePointers(&visitor); |
292 delete allocated_set; | 292 delete allocated_set; |
293 // Only returning a value so that Heap::Validate can be called from an ASSERT. | 293 // Only returning a value so that Heap::Validate can be called from an ASSERT. |
294 return true; | 294 return true; |
295 } | 295 } |
296 | 296 |
297 | 297 |
298 void Heap::PrintSizes() const { | 298 void Heap::PrintSizes() const { |
299 OS::PrintErr("New space (%"Pd"k of %"Pd"k) " | 299 OS::PrintErr("New space (%" Pd "k of %" Pd "k) " |
300 "Old space (%"Pd"k of %"Pd"k)\n", | 300 "Old space (%" Pd "k of %" Pd "k)\n", |
301 (Used(kNew) / KB), (Capacity(kNew) / KB), | 301 (Used(kNew) / KB), (Capacity(kNew) / KB), |
302 (Used(kOld) / KB), (Capacity(kOld) / KB)); | 302 (Used(kOld) / KB), (Capacity(kOld) / KB)); |
303 } | 303 } |
304 | 304 |
305 | 305 |
306 intptr_t Heap::Used(Space space) const { | 306 intptr_t Heap::Used(Space space) const { |
307 return space == kNew ? new_space_->in_use() : old_space_->in_use(); | 307 return space == kNew ? new_space_->in_use() : old_space_->in_use(); |
308 } | 308 } |
309 | 309 |
310 | 310 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 if ((FLAG_verbose_gc_hdr != 0) && | 460 if ((FLAG_verbose_gc_hdr != 0) && |
461 (((stats_.num_ - 1) % FLAG_verbose_gc_hdr) == 0)) { | 461 (((stats_.num_ - 1) % FLAG_verbose_gc_hdr) == 0)) { |
462 OS::PrintErr("[ GC | space | count | start | gc time | " | 462 OS::PrintErr("[ GC | space | count | start | gc time | " |
463 "new gen (KB) | old gen (KB) | timers | data ]\n" | 463 "new gen (KB) | old gen (KB) | timers | data ]\n" |
464 "[ (isolate)| (reason)| | (s) | (ms) | " | 464 "[ (isolate)| (reason)| | (s) | (ms) | " |
465 " used , cap | used , cap | (ms) | ]\n"); | 465 " used , cap | used , cap | (ms) | ]\n"); |
466 } | 466 } |
467 | 467 |
468 const char* space_str = stats_.space_ == kNew ? "Scavenge" : "Mark-Sweep"; | 468 const char* space_str = stats_.space_ == kNew ? "Scavenge" : "Mark-Sweep"; |
469 OS::PrintErr( | 469 OS::PrintErr( |
470 "[ GC(%"Pd64"): %s(%s), " // GC(isolate), space(reason) | 470 "[ GC(%" Pd64 "): %s(%s), " // GC(isolate), space(reason) |
471 "%"Pd", " // count | 471 "%" Pd ", " // count |
472 "%.3f, " // start time | 472 "%.3f, " // start time |
473 "%.3f, " // total time | 473 "%.3f, " // total time |
474 "%"Pd", %"Pd", %"Pd", %"Pd", " // new gen: in use, capacity before/after | 474 "%" Pd ", %" Pd ", " // new gen: in use before/after |
475 "%"Pd", %"Pd", %"Pd", %"Pd", " // old gen: in use, capacity before/after | 475 "%" Pd ", %" Pd ", " // new gen: capacity before/after |
| 476 "%" Pd ", %" Pd ", " // old gen: in use before/after |
| 477 "%" Pd ", %" Pd ", " // old gen: capacity before/after |
476 "%.3f, %.3f, %.3f, %.3f, " // times | 478 "%.3f, %.3f, %.3f, %.3f, " // times |
477 "%"Pd", %"Pd", %"Pd", %"Pd", " // data | 479 "%" Pd ", %" Pd ", %" Pd ", %" Pd ", " // data |
478 "]\n", // End with a comma to make it easier to import in spreadsheets. | 480 "]\n", // End with a comma to make it easier to import in spreadsheets. |
479 isolate->main_port(), space_str, GCReasonToString(stats_.reason_), | 481 isolate->main_port(), space_str, GCReasonToString(stats_.reason_), |
480 stats_.num_, | 482 stats_.num_, |
481 RoundToSecs(stats_.before_.micros_ - isolate->start_time()), | 483 RoundToSecs(stats_.before_.micros_ - isolate->start_time()), |
482 RoundToMillis(stats_.after_.micros_ - stats_.before_.micros_), | 484 RoundToMillis(stats_.after_.micros_ - stats_.before_.micros_), |
483 RoundToKB(stats_.before_.new_used_), RoundToKB(stats_.after_.new_used_), | 485 RoundToKB(stats_.before_.new_used_), RoundToKB(stats_.after_.new_used_), |
484 RoundToKB(stats_.before_.new_capacity_), | 486 RoundToKB(stats_.before_.new_capacity_), |
485 RoundToKB(stats_.after_.new_capacity_), | 487 RoundToKB(stats_.after_.new_capacity_), |
486 RoundToKB(stats_.before_.old_used_), RoundToKB(stats_.after_.old_used_), | 488 RoundToKB(stats_.before_.old_used_), RoundToKB(stats_.after_.old_used_), |
487 RoundToKB(stats_.before_.old_capacity_), | 489 RoundToKB(stats_.before_.old_capacity_), |
(...skipping 28 matching lines...) Expand all Loading... |
516 heap->DisableGrowthControl(); | 518 heap->DisableGrowthControl(); |
517 } | 519 } |
518 | 520 |
519 | 521 |
520 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 522 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
521 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 523 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
522 heap->SetGrowthControlState(current_growth_controller_state_); | 524 heap->SetGrowthControlState(current_growth_controller_state_); |
523 } | 525 } |
524 | 526 |
525 } // namespace dart | 527 } // namespace dart |
OLD | NEW |