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_histogram.h" |
10 #include "vm/heap_profiler.h" | 11 #include "vm/heap_profiler.h" |
11 #include "vm/isolate.h" | 12 #include "vm/isolate.h" |
12 #include "vm/object.h" | 13 #include "vm/object.h" |
13 #include "vm/object_set.h" | 14 #include "vm/object_set.h" |
14 #include "vm/os.h" | 15 #include "vm/os.h" |
15 #include "vm/pages.h" | 16 #include "vm/pages.h" |
16 #include "vm/raw_object.h" | 17 #include "vm/raw_object.h" |
17 #include "vm/scavenger.h" | 18 #include "vm/scavenger.h" |
18 #include "vm/stack_frame.h" | 19 #include "vm/stack_frame.h" |
19 #include "vm/verifier.h" | 20 #include "vm/verifier.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 } | 156 } |
156 break; | 157 break; |
157 } | 158 } |
158 case kOld: | 159 case kOld: |
159 case kCode: { | 160 case kCode: { |
160 bool promotion_failure = new_space_->HadPromotionFailure(); | 161 bool promotion_failure = new_space_->HadPromotionFailure(); |
161 RecordBeforeGC(kOld, promotion_failure ? kPromotionFailure : kOldSpace); | 162 RecordBeforeGC(kOld, promotion_failure ? kPromotionFailure : kOldSpace); |
162 old_space_->MarkSweep(invoke_api_callbacks); | 163 old_space_->MarkSweep(invoke_api_callbacks); |
163 RecordAfterGC(); | 164 RecordAfterGC(); |
164 PrintStats(); | 165 PrintStats(); |
| 166 UpdateObjectHistogram(); |
165 break; | 167 break; |
166 } | 168 } |
167 default: | 169 default: |
168 UNREACHABLE(); | 170 UNREACHABLE(); |
169 } | 171 } |
170 } | 172 } |
171 | 173 |
172 | 174 |
| 175 void Heap::UpdateObjectHistogram() { |
| 176 Isolate* isolate = Isolate::Current(); |
| 177 if (isolate->object_histogram() == NULL) return; |
| 178 isolate->object_histogram()->Collect(); |
| 179 } |
| 180 |
| 181 |
173 void Heap::CollectGarbage(Space space) { | 182 void Heap::CollectGarbage(Space space) { |
174 ApiCallbacks api_callbacks; | 183 ApiCallbacks api_callbacks; |
175 if (space == kOld) { | 184 if (space == kOld) { |
176 api_callbacks = kInvokeApiCallbacks; | 185 api_callbacks = kInvokeApiCallbacks; |
177 } else { | 186 } else { |
178 api_callbacks = kIgnoreApiCallbacks; | 187 api_callbacks = kIgnoreApiCallbacks; |
179 } | 188 } |
180 CollectGarbage(space, api_callbacks); | 189 CollectGarbage(space, api_callbacks); |
181 } | 190 } |
182 | 191 |
183 | 192 |
184 void Heap::CollectAllGarbage() { | 193 void Heap::CollectAllGarbage() { |
185 RecordBeforeGC(kNew, kFull); | 194 RecordBeforeGC(kNew, kFull); |
186 new_space_->Scavenge(kInvokeApiCallbacks); | 195 new_space_->Scavenge(kInvokeApiCallbacks); |
187 RecordAfterGC(); | 196 RecordAfterGC(); |
188 PrintStats(); | 197 PrintStats(); |
189 RecordBeforeGC(kOld, kFull); | 198 RecordBeforeGC(kOld, kFull); |
190 old_space_->MarkSweep(kInvokeApiCallbacks); | 199 old_space_->MarkSweep(kInvokeApiCallbacks); |
191 RecordAfterGC(); | 200 RecordAfterGC(); |
192 PrintStats(); | 201 PrintStats(); |
| 202 UpdateObjectHistogram(); |
193 } | 203 } |
194 | 204 |
195 | 205 |
196 void Heap::SetGrowthControlState(bool state) { | 206 void Heap::SetGrowthControlState(bool state) { |
197 old_space_->SetGrowthControlState(state); | 207 old_space_->SetGrowthControlState(state); |
198 } | 208 } |
199 | 209 |
200 | 210 |
201 bool Heap::GrowthControlState() { | 211 bool Heap::GrowthControlState() { |
202 return old_space_->GrowthControlState(); | 212 return old_space_->GrowthControlState(); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 heap->DisableGrowthControl(); | 497 heap->DisableGrowthControl(); |
488 } | 498 } |
489 | 499 |
490 | 500 |
491 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { | 501 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { |
492 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); | 502 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); |
493 heap->SetGrowthControlState(current_growth_controller_state_); | 503 heap->SetGrowthControlState(current_growth_controller_state_); |
494 } | 504 } |
495 | 505 |
496 } // namespace dart | 506 } // namespace dart |
OLD | NEW |