| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 old_space_->VisitObjectPointers(visitor); | 122 old_space_->VisitObjectPointers(visitor); |
| 123 code_space_->VisitObjectPointers(visitor); | 123 code_space_->VisitObjectPointers(visitor); |
| 124 } | 124 } |
| 125 | 125 |
| 126 | 126 |
| 127 void Heap::IterateCodePointers(ObjectPointerVisitor* visitor) { | 127 void Heap::IterateCodePointers(ObjectPointerVisitor* visitor) { |
| 128 code_space_->VisitObjectPointers(visitor); | 128 code_space_->VisitObjectPointers(visitor); |
| 129 } | 129 } |
| 130 | 130 |
| 131 | 131 |
| 132 void Heap::CollectGarbage(Space space) { | 132 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { |
| 133 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
| 133 switch (space) { | 134 switch (space) { |
| 134 case kNew: | 135 case kNew: |
| 135 new_space_->Scavenge(); | 136 new_space_->Scavenge(invoke_api_callbacks); |
| 136 break; | 137 break; |
| 137 case kOld: | 138 case kOld: |
| 138 old_space_->MarkSweep(); | 139 old_space_->MarkSweep(invoke_api_callbacks); |
| 139 break; | 140 break; |
| 140 case kExecutable: | 141 case kExecutable: |
| 141 UNIMPLEMENTED(); | 142 UNIMPLEMENTED(); |
| 142 code_space_->MarkSweep(); | 143 code_space_->MarkSweep(invoke_api_callbacks); |
| 143 break; | 144 break; |
| 144 default: | 145 default: |
| 145 UNREACHABLE(); | 146 UNREACHABLE(); |
| 146 } | 147 } |
| 147 } | 148 } |
| 148 | 149 |
| 149 | 150 |
| 151 void Heap::CollectGarbage(Space space) { |
| 152 ApiCallbacks api_callbacks; |
| 153 if (space == kNew || space == kExecutable) { |
| 154 api_callbacks = kIgnoreApiCallbacks; |
| 155 } else { |
| 156 api_callbacks = kInvokeApiCallbacks; |
| 157 } |
| 158 CollectGarbage(space, api_callbacks); |
| 159 } |
| 160 |
| 161 |
| 150 void Heap::CollectAllGarbage() { | 162 void Heap::CollectAllGarbage() { |
| 151 new_space_->Scavenge(); | 163 new_space_->Scavenge(kInvokeApiCallbacks); |
| 152 old_space_->MarkSweep(); | 164 old_space_->MarkSweep(kInvokeApiCallbacks); |
| 153 // TODO(iposva): Merge old and code space. | 165 // TODO(iposva): Merge old and code space. |
| 154 // code_space_->MarkSweep(); | 166 // code_space_->MarkSweep(kInvokeApiCallbacks); |
| 155 } | 167 } |
| 156 | 168 |
| 157 | 169 |
| 158 uword Heap::TopAddress() { | 170 uword Heap::TopAddress() { |
| 159 return reinterpret_cast<uword>(new_space_->TopAddress()); | 171 return reinterpret_cast<uword>(new_space_->TopAddress()); |
| 160 } | 172 } |
| 161 | 173 |
| 162 | 174 |
| 163 uword Heap::EndAddress() { | 175 uword Heap::EndAddress() { |
| 164 return reinterpret_cast<uword>(new_space_->EndAddress()); | 176 return reinterpret_cast<uword>(new_space_->EndAddress()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 187 isolate()->IncrementNoGCScopeDepth(); | 199 isolate()->IncrementNoGCScopeDepth(); |
| 188 } | 200 } |
| 189 | 201 |
| 190 | 202 |
| 191 NoGCScope::~NoGCScope() { | 203 NoGCScope::~NoGCScope() { |
| 192 isolate()->DecrementNoGCScopeDepth(); | 204 isolate()->DecrementNoGCScopeDepth(); |
| 193 } | 205 } |
| 194 #endif // defined(DEBUG) | 206 #endif // defined(DEBUG) |
| 195 | 207 |
| 196 } // namespace dart | 208 } // namespace dart |
| OLD | NEW |