| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) { | 149 RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) { |
| 150 // Only executable pages can have RawInstructions objects. | 150 // Only executable pages can have RawInstructions objects. |
| 151 RawObject* raw_obj = old_space_->FindObject(visitor, HeapPage::kExecutable); | 151 RawObject* raw_obj = old_space_->FindObject(visitor, HeapPage::kExecutable); |
| 152 ASSERT((raw_obj == Object::null()) || | 152 ASSERT((raw_obj == Object::null()) || |
| 153 (raw_obj->GetClassId() == kInstructionsCid)); | 153 (raw_obj->GetClassId() == kInstructionsCid)); |
| 154 return reinterpret_cast<RawInstructions*>(raw_obj); | 154 return reinterpret_cast<RawInstructions*>(raw_obj); |
| 155 } | 155 } |
| 156 | 156 |
| 157 | 157 |
| 158 RawObject* Heap::FindOldObject(FindObjectVisitor* visitor) const { |
| 159 return old_space_->FindObject(visitor, HeapPage::kData); |
| 160 } |
| 161 |
| 162 |
| 158 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { | 163 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { |
| 159 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); | 164 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
| 160 switch (space) { | 165 switch (space) { |
| 161 case kNew: { | 166 case kNew: { |
| 162 RecordBeforeGC(kNew, kNewSpace); | 167 RecordBeforeGC(kNew, kNewSpace); |
| 163 new_space_->Scavenge(invoke_api_callbacks); | 168 new_space_->Scavenge(invoke_api_callbacks); |
| 164 RecordAfterGC(); | 169 RecordAfterGC(); |
| 165 PrintStats(); | 170 PrintStats(); |
| 166 if (new_space_->HadPromotionFailure()) { | 171 if (new_space_->HadPromotionFailure()) { |
| 167 // Old collections should call the API callbacks. | 172 // Old collections should call the API callbacks. |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 heap->DisableGrowthControl(); | 512 heap->DisableGrowthControl(); |
| 508 } | 513 } |
| 509 | 514 |
| 510 | 515 |
| 511 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 516 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
| 512 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 517 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
| 513 heap->SetGrowthControlState(current_growth_controller_state_); | 518 heap->SetGrowthControlState(current_growth_controller_state_); |
| 514 } | 519 } |
| 515 | 520 |
| 516 } // namespace dart | 521 } // namespace dart |
| OLD | NEW |