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/heap_class_stats.h" |
10 #include "vm/heap_histogram.h" | 11 #include "vm/heap_histogram.h" |
11 #include "vm/heap_profiler.h" | 12 #include "vm/heap_profiler.h" |
12 #include "vm/isolate.h" | 13 #include "vm/isolate.h" |
13 #include "vm/object.h" | 14 #include "vm/object.h" |
14 #include "vm/object_set.h" | 15 #include "vm/object_set.h" |
15 #include "vm/os.h" | 16 #include "vm/os.h" |
16 #include "vm/pages.h" | 17 #include "vm/pages.h" |
17 #include "vm/raw_object.h" | 18 #include "vm/raw_object.h" |
18 #include "vm/scavenger.h" | 19 #include "vm/scavenger.h" |
19 #include "vm/stack_frame.h" | 20 #include "vm/stack_frame.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 break; | 171 break; |
171 } | 172 } |
172 case kOld: | 173 case kOld: |
173 case kCode: { | 174 case kCode: { |
174 bool promotion_failure = new_space_->HadPromotionFailure(); | 175 bool promotion_failure = new_space_->HadPromotionFailure(); |
175 RecordBeforeGC(kOld, promotion_failure ? kPromotionFailure : kOldSpace); | 176 RecordBeforeGC(kOld, promotion_failure ? kPromotionFailure : kOldSpace); |
176 old_space_->MarkSweep(invoke_api_callbacks); | 177 old_space_->MarkSweep(invoke_api_callbacks); |
177 RecordAfterGC(); | 178 RecordAfterGC(); |
178 PrintStats(); | 179 PrintStats(); |
179 UpdateObjectHistogram(); | 180 UpdateObjectHistogram(); |
| 181 UpdateHeapClassStats(); |
180 break; | 182 break; |
181 } | 183 } |
182 default: | 184 default: |
183 UNREACHABLE(); | 185 UNREACHABLE(); |
184 } | 186 } |
185 } | 187 } |
186 | 188 |
187 | 189 |
188 void Heap::UpdateObjectHistogram() { | 190 void Heap::UpdateObjectHistogram() { |
189 Isolate* isolate = Isolate::Current(); | 191 Isolate* isolate = Isolate::Current(); |
190 if (isolate->object_histogram() == NULL) return; | 192 if (isolate->object_histogram() == NULL) return; |
191 isolate->object_histogram()->Collect(); | 193 isolate->object_histogram()->Collect(); |
192 } | 194 } |
193 | 195 |
194 | 196 |
| 197 void Heap::UpdateHeapClassStats() { |
| 198 Isolate* isolate = Isolate::Current(); |
| 199 if (isolate->heap_class_stats() == NULL) { |
| 200 return; |
| 201 } |
| 202 isolate->heap_class_stats()->Collect(); |
| 203 } |
| 204 |
| 205 |
195 void Heap::CollectGarbage(Space space) { | 206 void Heap::CollectGarbage(Space space) { |
196 ApiCallbacks api_callbacks; | 207 ApiCallbacks api_callbacks; |
197 if (space == kOld) { | 208 if (space == kOld) { |
198 api_callbacks = kInvokeApiCallbacks; | 209 api_callbacks = kInvokeApiCallbacks; |
199 } else { | 210 } else { |
200 api_callbacks = kIgnoreApiCallbacks; | 211 api_callbacks = kIgnoreApiCallbacks; |
201 } | 212 } |
202 CollectGarbage(space, api_callbacks); | 213 CollectGarbage(space, api_callbacks); |
203 } | 214 } |
204 | 215 |
205 | 216 |
206 void Heap::CollectAllGarbage() { | 217 void Heap::CollectAllGarbage() { |
207 RecordBeforeGC(kNew, kFull); | 218 RecordBeforeGC(kNew, kFull); |
208 new_space_->Scavenge(kInvokeApiCallbacks); | 219 new_space_->Scavenge(kInvokeApiCallbacks); |
209 RecordAfterGC(); | 220 RecordAfterGC(); |
210 PrintStats(); | 221 PrintStats(); |
211 RecordBeforeGC(kOld, kFull); | 222 RecordBeforeGC(kOld, kFull); |
212 old_space_->MarkSweep(kInvokeApiCallbacks); | 223 old_space_->MarkSweep(kInvokeApiCallbacks); |
213 RecordAfterGC(); | 224 RecordAfterGC(); |
214 PrintStats(); | 225 PrintStats(); |
215 UpdateObjectHistogram(); | 226 UpdateObjectHistogram(); |
| 227 UpdateHeapClassStats(); |
216 } | 228 } |
217 | 229 |
218 | 230 |
219 void Heap::SetGrowthControlState(bool state) { | 231 void Heap::SetGrowthControlState(bool state) { |
220 old_space_->SetGrowthControlState(state); | 232 old_space_->SetGrowthControlState(state); |
221 } | 233 } |
222 | 234 |
223 | 235 |
224 bool Heap::GrowthControlState() { | 236 bool Heap::GrowthControlState() { |
225 return old_space_->GrowthControlState(); | 237 return old_space_->GrowthControlState(); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 heap->DisableGrowthControl(); | 530 heap->DisableGrowthControl(); |
519 } | 531 } |
520 | 532 |
521 | 533 |
522 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 534 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
523 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 535 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
524 heap->SetGrowthControlState(current_growth_controller_state_); | 536 heap->SetGrowthControlState(current_growth_controller_state_); |
525 } | 537 } |
526 | 538 |
527 } // namespace dart | 539 } // namespace dart |
OLD | NEW |