| 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/compiler_stats.h" | 9 #include "vm/compiler_stats.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.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 // The code heap can only have RawInstructions objects. | 150 // The code heap can only have RawInstructions objects. |
| 151 RawObject* raw_obj = code_space_->FindObject(visitor); | 151 RawObject* raw_obj = code_space_->FindObject(visitor); |
| 152 ASSERT((raw_obj == Object::null()) || | 152 ASSERT((raw_obj == Object::null()) || |
| 153 (raw_obj->GetClassId() == kInstructions)); | 153 (raw_obj->GetClassId() == kInstructions)); |
| 154 return reinterpret_cast<RawInstructions*>(raw_obj); | 154 return reinterpret_cast<RawInstructions*>(raw_obj); |
| 155 } | 155 } |
| 156 | 156 |
| 157 | 157 |
| 158 void Heap::Scavenge(ApiCallbacks api_callbacks) { |
| 159 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
| 160 new_space_->Scavenge(invoke_api_callbacks); |
| 161 } |
| 162 |
| 163 |
| 158 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { | 164 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { |
| 159 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); | 165 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
| 160 switch (space) { | 166 switch (space) { |
| 161 case kNew: | 167 case kNew: |
| 162 new_space_->Scavenge(invoke_api_callbacks); | 168 new_space_->Scavenge(invoke_api_callbacks); |
| 163 if (new_space_->HadPromotionFailure()) { | 169 if (new_space_->HadPromotionFailure()) { |
| 164 old_space_->MarkSweep(true); | 170 old_space_->MarkSweep(true); |
| 165 } | 171 } |
| 166 break; | 172 break; |
| 167 case kOld: | 173 case kOld: |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 isolate()->IncrementNoGCScopeDepth(); | 271 isolate()->IncrementNoGCScopeDepth(); |
| 266 } | 272 } |
| 267 | 273 |
| 268 | 274 |
| 269 NoGCScope::~NoGCScope() { | 275 NoGCScope::~NoGCScope() { |
| 270 isolate()->DecrementNoGCScopeDepth(); | 276 isolate()->DecrementNoGCScopeDepth(); |
| 271 } | 277 } |
| 272 #endif // defined(DEBUG) | 278 #endif // defined(DEBUG) |
| 273 | 279 |
| 274 } // namespace dart | 280 } // namespace dart |
| OLD | NEW |