| 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" | |
| 11 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| 12 #include "vm/object.h" | 11 #include "vm/object.h" |
| 13 #include "vm/object_set.h" | 12 #include "vm/object_set.h" |
| 14 #include "vm/os.h" | 13 #include "vm/os.h" |
| 15 #include "vm/pages.h" | 14 #include "vm/pages.h" |
| 16 #include "vm/raw_object.h" | 15 #include "vm/raw_object.h" |
| 17 #include "vm/scavenger.h" | 16 #include "vm/scavenger.h" |
| 18 #include "vm/stack_frame.h" | 17 #include "vm/stack_frame.h" |
| 19 #include "vm/verifier.h" | 18 #include "vm/verifier.h" |
| 20 #include "vm/virtual_memory.h" | 19 #include "vm/virtual_memory.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 break; | 174 break; |
| 176 } | 175 } |
| 177 case kOld: | 176 case kOld: |
| 178 case kCode: { | 177 case kCode: { |
| 179 bool promotion_failure = new_space_->HadPromotionFailure(); | 178 bool promotion_failure = new_space_->HadPromotionFailure(); |
| 180 RecordBeforeGC(kOld, promotion_failure ? kPromotionFailure : kOldSpace); | 179 RecordBeforeGC(kOld, promotion_failure ? kPromotionFailure : kOldSpace); |
| 181 UpdateClassHeapStatsBeforeGC(kOld); | 180 UpdateClassHeapStatsBeforeGC(kOld); |
| 182 old_space_->MarkSweep(invoke_api_callbacks); | 181 old_space_->MarkSweep(invoke_api_callbacks); |
| 183 RecordAfterGC(); | 182 RecordAfterGC(); |
| 184 PrintStats(); | 183 PrintStats(); |
| 185 UpdateObjectHistogram(); | |
| 186 break; | 184 break; |
| 187 } | 185 } |
| 188 default: | 186 default: |
| 189 UNREACHABLE(); | 187 UNREACHABLE(); |
| 190 } | 188 } |
| 191 } | 189 } |
| 192 | 190 |
| 193 | 191 |
| 194 void Heap::UpdateObjectHistogram() { | |
| 195 Isolate* isolate = Isolate::Current(); | |
| 196 if (isolate->object_histogram() == NULL) return; | |
| 197 isolate->object_histogram()->Collect(); | |
| 198 } | |
| 199 | |
| 200 | |
| 201 void Heap::UpdateClassHeapStatsBeforeGC(Heap::Space space) { | 192 void Heap::UpdateClassHeapStatsBeforeGC(Heap::Space space) { |
| 202 Isolate* isolate = Isolate::Current(); | 193 Isolate* isolate = Isolate::Current(); |
| 203 ClassTable* class_table = isolate->class_table(); | 194 ClassTable* class_table = isolate->class_table(); |
| 204 if (space == kNew) { | 195 if (space == kNew) { |
| 205 class_table->ResetCountersNew(); | 196 class_table->ResetCountersNew(); |
| 206 } else { | 197 } else { |
| 207 class_table->ResetCountersOld(); | 198 class_table->ResetCountersOld(); |
| 208 } | 199 } |
| 209 } | 200 } |
| 210 | 201 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 224 RecordBeforeGC(kNew, kFull); | 215 RecordBeforeGC(kNew, kFull); |
| 225 UpdateClassHeapStatsBeforeGC(kNew); | 216 UpdateClassHeapStatsBeforeGC(kNew); |
| 226 new_space_->Scavenge(kInvokeApiCallbacks); | 217 new_space_->Scavenge(kInvokeApiCallbacks); |
| 227 RecordAfterGC(); | 218 RecordAfterGC(); |
| 228 PrintStats(); | 219 PrintStats(); |
| 229 RecordBeforeGC(kOld, kFull); | 220 RecordBeforeGC(kOld, kFull); |
| 230 UpdateClassHeapStatsBeforeGC(kOld); | 221 UpdateClassHeapStatsBeforeGC(kOld); |
| 231 old_space_->MarkSweep(kInvokeApiCallbacks); | 222 old_space_->MarkSweep(kInvokeApiCallbacks); |
| 232 RecordAfterGC(); | 223 RecordAfterGC(); |
| 233 PrintStats(); | 224 PrintStats(); |
| 234 UpdateObjectHistogram(); | |
| 235 } | 225 } |
| 236 | 226 |
| 237 | 227 |
| 238 void Heap::SetGrowthControlState(bool state) { | 228 void Heap::SetGrowthControlState(bool state) { |
| 239 old_space_->SetGrowthControlState(state); | 229 old_space_->SetGrowthControlState(state); |
| 240 } | 230 } |
| 241 | 231 |
| 242 | 232 |
| 243 bool Heap::GrowthControlState() { | 233 bool Heap::GrowthControlState() { |
| 244 return old_space_->GrowthControlState(); | 234 return old_space_->GrowthControlState(); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 heap->DisableGrowthControl(); | 510 heap->DisableGrowthControl(); |
| 521 } | 511 } |
| 522 | 512 |
| 523 | 513 |
| 524 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 514 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
| 525 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 515 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
| 526 heap->SetGrowthControlState(current_growth_controller_state_); | 516 heap->SetGrowthControlState(current_growth_controller_state_); |
| 527 } | 517 } |
| 528 | 518 |
| 529 } // namespace dart | 519 } // namespace dart |
| OLD | NEW |