Chromium Code Reviews| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 ASSERT((raw_obj == Object::null()) || | 171 ASSERT((raw_obj == Object::null()) || |
| 172 (raw_obj->GetClassId() == kInstructionsCid)); | 172 (raw_obj->GetClassId() == kInstructionsCid)); |
| 173 return reinterpret_cast<RawInstructions*>(raw_obj); | 173 return reinterpret_cast<RawInstructions*>(raw_obj); |
| 174 } | 174 } |
| 175 | 175 |
| 176 | 176 |
| 177 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { | 177 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { |
| 178 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); | 178 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
| 179 switch (space) { | 179 switch (space) { |
| 180 case kNew: | 180 case kNew: |
| 181 new_space_->Scavenge(invoke_api_callbacks); | 181 new_space_->Scavenge(invoke_api_callbacks, "new space"); |
| 182 if (new_space_->HadPromotionFailure()) { | 182 if (new_space_->HadPromotionFailure()) { |
| 183 old_space_->MarkSweep(true); | 183 old_space_->MarkSweep(true, "promotion failure"); |
| 184 } | 184 } |
| 185 break; | 185 break; |
| 186 case kOld: | 186 case kOld: |
| 187 old_space_->MarkSweep(invoke_api_callbacks); | 187 old_space_->MarkSweep(invoke_api_callbacks, "old space"); |
| 188 break; | 188 break; |
| 189 case kCode: | 189 case kCode: |
| 190 UNIMPLEMENTED(); | 190 UNIMPLEMENTED(); |
| 191 code_space_->MarkSweep(invoke_api_callbacks); | 191 code_space_->MarkSweep(invoke_api_callbacks, "code space"); |
|
siva
2012/08/27 16:54:49
Can we list these reasons in heap.h as static cons
Ivan Posva
2012/08/27 22:04:23
I like the suggestion of having the different reas
| |
| 192 break; | 192 break; |
| 193 default: | 193 default: |
| 194 UNREACHABLE(); | 194 UNREACHABLE(); |
| 195 } | 195 } |
| 196 if (FLAG_verbose_gc) { | 196 if (FLAG_verbose_gc) { |
| 197 PrintSizes(); | 197 PrintSizes(); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 | 201 |
| 202 void Heap::CollectGarbage(Space space) { | 202 void Heap::CollectGarbage(Space space) { |
| 203 ApiCallbacks api_callbacks; | 203 ApiCallbacks api_callbacks; |
| 204 if (space == kOld) { | 204 if (space == kOld) { |
| 205 api_callbacks = kInvokeApiCallbacks; | 205 api_callbacks = kInvokeApiCallbacks; |
| 206 } else { | 206 } else { |
| 207 api_callbacks = kIgnoreApiCallbacks; | 207 api_callbacks = kIgnoreApiCallbacks; |
| 208 } | 208 } |
| 209 CollectGarbage(space, api_callbacks); | 209 CollectGarbage(space, api_callbacks); |
| 210 } | 210 } |
| 211 | 211 |
| 212 | 212 |
| 213 void Heap::CollectAllGarbage() { | 213 void Heap::CollectAllGarbage() { |
| 214 new_space_->Scavenge(kInvokeApiCallbacks); | 214 new_space_->Scavenge(kInvokeApiCallbacks, "full"); |
| 215 old_space_->MarkSweep(kInvokeApiCallbacks); | 215 old_space_->MarkSweep(kInvokeApiCallbacks, "full"); |
| 216 // TODO(iposva): Merge old and code space. | 216 // TODO(iposva): Merge old and code space. |
| 217 // code_space_->MarkSweep(kInvokeApiCallbacks); | 217 // code_space_->MarkSweep(kInvokeApiCallbacks, "full"); |
| 218 if (FLAG_verbose_gc) { | 218 if (FLAG_verbose_gc) { |
| 219 PrintSizes(); | 219 PrintSizes(); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 | 223 |
| 224 void Heap::EnableGrowthControl() { | 224 void Heap::EnableGrowthControl() { |
| 225 old_space_->EnableGrowthControl(); | 225 old_space_->EnableGrowthControl(); |
| 226 } | 226 } |
| 227 | 227 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 isolate()->IncrementNoGCScopeDepth(); | 338 isolate()->IncrementNoGCScopeDepth(); |
| 339 } | 339 } |
| 340 | 340 |
| 341 | 341 |
| 342 NoGCScope::~NoGCScope() { | 342 NoGCScope::~NoGCScope() { |
| 343 isolate()->DecrementNoGCScopeDepth(); | 343 isolate()->DecrementNoGCScopeDepth(); |
| 344 } | 344 } |
| 345 #endif // defined(DEBUG) | 345 #endif // defined(DEBUG) |
| 346 | 346 |
| 347 } // namespace dart | 347 } // namespace dart |
| OLD | NEW |