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/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 return reinterpret_cast<RawInstructions*>(raw_obj); | 169 return reinterpret_cast<RawInstructions*>(raw_obj); |
170 } | 170 } |
171 | 171 |
172 | 172 |
173 RawObject* Heap::FindOldObject(FindObjectVisitor* visitor) const { | 173 RawObject* Heap::FindOldObject(FindObjectVisitor* visitor) const { |
174 return old_space_->FindObject(visitor, HeapPage::kData); | 174 return old_space_->FindObject(visitor, HeapPage::kData); |
175 } | 175 } |
176 | 176 |
177 | 177 |
178 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { | 178 void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) { |
| 179 Isolate* isolate = Isolate::Current(); |
179 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); | 180 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); |
180 switch (space) { | 181 switch (space) { |
181 case kNew: { | 182 case kNew: { |
| 183 VMTagScope tagScope(isolate, VMTag::kGCNewSpaceTagId); |
182 RecordBeforeGC(kNew, kNewSpace); | 184 RecordBeforeGC(kNew, kNewSpace); |
183 UpdateClassHeapStatsBeforeGC(kNew); | 185 UpdateClassHeapStatsBeforeGC(kNew); |
184 new_space_->Scavenge(invoke_api_callbacks); | 186 new_space_->Scavenge(invoke_api_callbacks); |
185 RecordAfterGC(); | 187 RecordAfterGC(); |
186 PrintStats(); | 188 PrintStats(); |
187 if (new_space_->HadPromotionFailure()) { | 189 if (new_space_->HadPromotionFailure()) { |
188 // Old collections should call the API callbacks. | 190 // Old collections should call the API callbacks. |
189 CollectGarbage(kOld, kInvokeApiCallbacks); | 191 CollectGarbage(kOld, kInvokeApiCallbacks); |
190 } | 192 } |
191 break; | 193 break; |
192 } | 194 } |
193 case kOld: | 195 case kOld: |
194 case kCode: { | 196 case kCode: { |
| 197 VMTagScope tagScope(isolate, VMTag::kGCOldSpaceTagId); |
195 bool promotion_failure = new_space_->HadPromotionFailure(); | 198 bool promotion_failure = new_space_->HadPromotionFailure(); |
196 RecordBeforeGC(kOld, promotion_failure ? kPromotionFailure : kOldSpace); | 199 RecordBeforeGC(kOld, promotion_failure ? kPromotionFailure : kOldSpace); |
197 UpdateClassHeapStatsBeforeGC(kOld); | 200 UpdateClassHeapStatsBeforeGC(kOld); |
198 old_space_->MarkSweep(invoke_api_callbacks); | 201 old_space_->MarkSweep(invoke_api_callbacks); |
199 RecordAfterGC(); | 202 RecordAfterGC(); |
200 PrintStats(); | 203 PrintStats(); |
201 break; | 204 break; |
202 } | 205 } |
203 default: | 206 default: |
204 UNREACHABLE(); | 207 UNREACHABLE(); |
(...skipping 17 matching lines...) Expand all Loading... |
222 if (space == kOld) { | 225 if (space == kOld) { |
223 api_callbacks = kInvokeApiCallbacks; | 226 api_callbacks = kInvokeApiCallbacks; |
224 } else { | 227 } else { |
225 api_callbacks = kIgnoreApiCallbacks; | 228 api_callbacks = kIgnoreApiCallbacks; |
226 } | 229 } |
227 CollectGarbage(space, api_callbacks); | 230 CollectGarbage(space, api_callbacks); |
228 } | 231 } |
229 | 232 |
230 | 233 |
231 void Heap::CollectAllGarbage() { | 234 void Heap::CollectAllGarbage() { |
232 RecordBeforeGC(kNew, kFull); | 235 Isolate* isolate = Isolate::Current(); |
233 UpdateClassHeapStatsBeforeGC(kNew); | 236 { |
234 new_space_->Scavenge(kInvokeApiCallbacks); | 237 VMTagScope tagScope(isolate, VMTag::kGCNewSpaceTagId); |
235 RecordAfterGC(); | 238 RecordBeforeGC(kNew, kFull); |
236 PrintStats(); | 239 UpdateClassHeapStatsBeforeGC(kNew); |
237 RecordBeforeGC(kOld, kFull); | 240 new_space_->Scavenge(kInvokeApiCallbacks); |
238 UpdateClassHeapStatsBeforeGC(kOld); | 241 RecordAfterGC(); |
239 old_space_->MarkSweep(kInvokeApiCallbacks); | 242 PrintStats(); |
240 RecordAfterGC(); | 243 } |
241 PrintStats(); | 244 { |
| 245 VMTagScope tagScope(isolate, VMTag::kGCOldSpaceTagId); |
| 246 RecordBeforeGC(kOld, kFull); |
| 247 UpdateClassHeapStatsBeforeGC(kOld); |
| 248 old_space_->MarkSweep(kInvokeApiCallbacks); |
| 249 RecordAfterGC(); |
| 250 PrintStats(); |
| 251 } |
242 } | 252 } |
243 | 253 |
244 | 254 |
245 void Heap::SetGrowthControlState(bool state) { | 255 void Heap::SetGrowthControlState(bool state) { |
246 old_space_->SetGrowthControlState(state); | 256 old_space_->SetGrowthControlState(state); |
247 } | 257 } |
248 | 258 |
249 | 259 |
250 bool Heap::GrowthControlState() { | 260 bool Heap::GrowthControlState() { |
251 return old_space_->GrowthControlState(); | 261 return old_space_->GrowthControlState(); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 heap->DisableGrowthControl(); | 551 heap->DisableGrowthControl(); |
542 } | 552 } |
543 | 553 |
544 | 554 |
545 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 555 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
546 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 556 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
547 heap->SetGrowthControlState(current_growth_controller_state_); | 557 heap->SetGrowthControlState(current_growth_controller_state_); |
548 } | 558 } |
549 | 559 |
550 } // namespace dart | 560 } // namespace dart |
OLD | NEW |