Chromium Code Reviews| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 if (new_space_->HadPromotionFailure()) { | 166 if (new_space_->HadPromotionFailure()) { |
| 167 // Old collections should call the API callbacks. | 167 // Old collections should call the API callbacks. |
| 168 CollectGarbage(kOld, kInvokeApiCallbacks); | 168 CollectGarbage(kOld, kInvokeApiCallbacks); |
| 169 } | 169 } |
| 170 break; | 170 break; |
| 171 } | 171 } |
| 172 case kOld: | 172 case kOld: |
| 173 case kCode: { | 173 case kCode: { |
| 174 bool promotion_failure = new_space_->HadPromotionFailure(); | 174 bool promotion_failure = new_space_->HadPromotionFailure(); |
| 175 RecordBeforeGC(kOld, promotion_failure ? kPromotionFailure : kOldSpace); | 175 RecordBeforeGC(kOld, promotion_failure ? kPromotionFailure : kOldSpace); |
| 176 UpdateClassStats(); | |
|
Ivan Posva
2013/12/12 13:53:24
Why isn't this being done as part of new collectio
Cutch
2013/12/13 01:31:09
Agreed. Let's discuss this Friday morning.
| |
| 176 old_space_->MarkSweep(invoke_api_callbacks); | 177 old_space_->MarkSweep(invoke_api_callbacks); |
| 177 RecordAfterGC(); | 178 RecordAfterGC(); |
| 178 PrintStats(); | 179 PrintStats(); |
| 179 UpdateObjectHistogram(); | 180 UpdateObjectHistogram(); |
| 180 break; | 181 break; |
| 181 } | 182 } |
| 182 default: | 183 default: |
| 183 UNREACHABLE(); | 184 UNREACHABLE(); |
| 184 } | 185 } |
| 185 } | 186 } |
| 186 | 187 |
| 187 | 188 |
| 188 void Heap::UpdateObjectHistogram() { | 189 void Heap::UpdateObjectHistogram() { |
| 189 Isolate* isolate = Isolate::Current(); | 190 Isolate* isolate = Isolate::Current(); |
| 190 if (isolate->object_histogram() == NULL) return; | 191 if (isolate->object_histogram() == NULL) return; |
| 191 isolate->object_histogram()->Collect(); | 192 isolate->object_histogram()->Collect(); |
| 192 } | 193 } |
| 193 | 194 |
| 194 | 195 |
| 196 void Heap::UpdateClassStats() { | |
| 197 Isolate* isolate = Isolate::Current(); | |
| 198 ClassTable* class_table = isolate->class_table(); | |
| 199 class_table->Collect(); | |
| 200 } | |
| 201 | |
| 202 | |
| 195 void Heap::CollectGarbage(Space space) { | 203 void Heap::CollectGarbage(Space space) { |
| 196 ApiCallbacks api_callbacks; | 204 ApiCallbacks api_callbacks; |
| 197 if (space == kOld) { | 205 if (space == kOld) { |
| 198 api_callbacks = kInvokeApiCallbacks; | 206 api_callbacks = kInvokeApiCallbacks; |
| 199 } else { | 207 } else { |
| 200 api_callbacks = kIgnoreApiCallbacks; | 208 api_callbacks = kIgnoreApiCallbacks; |
| 201 } | 209 } |
| 202 CollectGarbage(space, api_callbacks); | 210 CollectGarbage(space, api_callbacks); |
| 203 } | 211 } |
| 204 | 212 |
| 205 | 213 |
| 206 void Heap::CollectAllGarbage() { | 214 void Heap::CollectAllGarbage() { |
| 207 RecordBeforeGC(kNew, kFull); | 215 RecordBeforeGC(kNew, kFull); |
| 216 UpdateClassStats(); | |
| 208 new_space_->Scavenge(kInvokeApiCallbacks); | 217 new_space_->Scavenge(kInvokeApiCallbacks); |
| 209 RecordAfterGC(); | 218 RecordAfterGC(); |
| 210 PrintStats(); | 219 PrintStats(); |
| 211 RecordBeforeGC(kOld, kFull); | 220 RecordBeforeGC(kOld, kFull); |
| 212 old_space_->MarkSweep(kInvokeApiCallbacks); | 221 old_space_->MarkSweep(kInvokeApiCallbacks); |
| 213 RecordAfterGC(); | 222 RecordAfterGC(); |
| 214 PrintStats(); | 223 PrintStats(); |
| 215 UpdateObjectHistogram(); | 224 UpdateObjectHistogram(); |
| 216 } | 225 } |
| 217 | 226 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 heap->DisableGrowthControl(); | 527 heap->DisableGrowthControl(); |
| 519 } | 528 } |
| 520 | 529 |
| 521 | 530 |
| 522 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 531 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
| 523 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 532 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
| 524 heap->SetGrowthControlState(current_growth_controller_state_); | 533 heap->SetGrowthControlState(current_growth_controller_state_); |
| 525 } | 534 } |
| 526 | 535 |
| 527 } // namespace dart | 536 } // namespace dart |
| OLD | NEW |