| 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" |
| 11 #include "vm/isolate.h" | 11 #include "vm/isolate.h" |
| 12 #include "vm/object.h" |
| 12 #include "vm/os.h" | 13 #include "vm/os.h" |
| 13 #include "vm/pages.h" | 14 #include "vm/pages.h" |
| 14 #include "vm/scavenger.h" | 15 #include "vm/scavenger.h" |
| 15 #include "vm/verifier.h" | 16 #include "vm/verifier.h" |
| 16 #include "vm/virtual_memory.h" | 17 #include "vm/virtual_memory.h" |
| 17 | 18 |
| 18 namespace dart { | 19 namespace dart { |
| 19 | 20 |
| 20 DEFINE_FLAG(bool, verbose_gc, false, "Enables verbose GC."); | 21 DEFINE_FLAG(bool, verbose_gc, false, "Enables verbose GC."); |
| 21 DEFINE_FLAG(bool, verify_before_gc, false, | 22 DEFINE_FLAG(bool, verify_before_gc, false, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 130 |
| 130 | 131 |
| 131 void Heap::IterateCodePointers(ObjectPointerVisitor* visitor) { | 132 void Heap::IterateCodePointers(ObjectPointerVisitor* visitor) { |
| 132 code_space_->VisitObjectPointers(visitor); | 133 code_space_->VisitObjectPointers(visitor); |
| 133 } | 134 } |
| 134 | 135 |
| 135 | 136 |
| 136 RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) { | 137 RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) { |
| 137 // The code heap can only have RawInstructions objects. | 138 // The code heap can only have RawInstructions objects. |
| 138 RawObject* raw_obj = code_space_->FindObject(visitor); | 139 RawObject* raw_obj = code_space_->FindObject(visitor); |
| 139 ASSERT(raw_obj->ptr()->class_->ptr()->instance_kind_ == kInstructions); | 140 ASSERT((raw_obj == Object::null()) || |
| 141 (raw_obj->ptr()->class_->ptr()->instance_kind_ == kInstructions)); |
| 140 return reinterpret_cast<RawInstructions*>(raw_obj); | 142 return reinterpret_cast<RawInstructions*>(raw_obj); |
| 141 } | 143 } |
| 142 | 144 |
| 143 | 145 |
| 144 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { | 146 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { |
| 145 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); | 147 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
| 146 switch (space) { | 148 switch (space) { |
| 147 case kNew: | 149 case kNew: |
| 148 new_space_->Scavenge(invoke_api_callbacks); | 150 new_space_->Scavenge(invoke_api_callbacks); |
| 149 break; | 151 break; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 isolate()->IncrementNoGCScopeDepth(); | 213 isolate()->IncrementNoGCScopeDepth(); |
| 212 } | 214 } |
| 213 | 215 |
| 214 | 216 |
| 215 NoGCScope::~NoGCScope() { | 217 NoGCScope::~NoGCScope() { |
| 216 isolate()->DecrementNoGCScopeDepth(); | 218 isolate()->DecrementNoGCScopeDepth(); |
| 217 } | 219 } |
| 218 #endif // defined(DEBUG) | 220 #endif // defined(DEBUG) |
| 219 | 221 |
| 220 } // namespace dart | 222 } // namespace dart |
| OLD | NEW |