| 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_profiler.h" | 10 #include "vm/heap_profiler.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { | 152 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { |
| 153 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); | 153 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
| 154 switch (space) { | 154 switch (space) { |
| 155 case kNew: { | 155 case kNew: { |
| 156 RecordBeforeGC(kNew, kNewSpace); | 156 RecordBeforeGC(kNew, kNewSpace); |
| 157 new_space_->Scavenge(invoke_api_callbacks); | 157 new_space_->Scavenge(invoke_api_callbacks); |
| 158 RecordAfterGC(); | 158 RecordAfterGC(); |
| 159 PrintStats(); | 159 PrintStats(); |
| 160 if (new_space_->HadPromotionFailure()) { | 160 if (new_space_->HadPromotionFailure()) { |
| 161 CollectGarbage(kOld, api_callbacks); | 161 // Old collections should call the API callbacks. |
| 162 CollectGarbage(kOld, kInvokeApiCallbacks); |
| 162 } | 163 } |
| 163 break; | 164 break; |
| 164 } | 165 } |
| 165 case kOld: | 166 case kOld: |
| 166 case kCode: { | 167 case kCode: { |
| 167 bool promotion_failure = new_space_->HadPromotionFailure(); | 168 bool promotion_failure = new_space_->HadPromotionFailure(); |
| 168 RecordBeforeGC(kOld, promotion_failure ? kPromotionFailure : kOldSpace); | 169 RecordBeforeGC(kOld, promotion_failure ? kPromotionFailure : kOldSpace); |
| 169 old_space_->MarkSweep(invoke_api_callbacks); | 170 old_space_->MarkSweep(invoke_api_callbacks); |
| 170 RecordAfterGC(); | 171 RecordAfterGC(); |
| 171 PrintStats(); | 172 PrintStats(); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 isolate()->IncrementNoGCScopeDepth(); | 476 isolate()->IncrementNoGCScopeDepth(); |
| 476 } | 477 } |
| 477 | 478 |
| 478 | 479 |
| 479 NoGCScope::~NoGCScope() { | 480 NoGCScope::~NoGCScope() { |
| 480 isolate()->DecrementNoGCScopeDepth(); | 481 isolate()->DecrementNoGCScopeDepth(); |
| 481 } | 482 } |
| 482 #endif // defined(DEBUG) | 483 #endif // defined(DEBUG) |
| 483 | 484 |
| 484 } // namespace dart | 485 } // namespace dart |
| OLD | NEW |