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/atomic.h" | 5 #include "vm/atomic.h" |
6 #include "vm/class_table.h" | 6 #include "vm/class_table.h" |
7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
8 #include "vm/freelist.h" | 8 #include "vm/freelist.h" |
9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
10 #include "vm/heap.h" | 10 #include "vm/heap.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 } else { | 28 } else { |
29 // Duplicate the class table from the VM isolate. | 29 // Duplicate the class table from the VM isolate. |
30 ClassTable* vm_class_table = Dart::vm_isolate()->class_table(); | 30 ClassTable* vm_class_table = Dart::vm_isolate()->class_table(); |
31 capacity_ = vm_class_table->capacity_; | 31 capacity_ = vm_class_table->capacity_; |
32 table_ = reinterpret_cast<RawClass**>( | 32 table_ = reinterpret_cast<RawClass**>( |
33 calloc(capacity_, sizeof(RawClass*))); // NOLINT | 33 calloc(capacity_, sizeof(RawClass*))); // NOLINT |
34 for (intptr_t i = kObjectCid; i < kInstanceCid; i++) { | 34 for (intptr_t i = kObjectCid; i < kInstanceCid; i++) { |
35 table_[i] = vm_class_table->At(i); | 35 table_[i] = vm_class_table->At(i); |
36 } | 36 } |
37 table_[kFreeListElement] = vm_class_table->At(kFreeListElement); | 37 table_[kFreeListElement] = vm_class_table->At(kFreeListElement); |
| 38 table_[kForwardingCorpse] = vm_class_table->At(kForwardingCorpse); |
38 table_[kDynamicCid] = vm_class_table->At(kDynamicCid); | 39 table_[kDynamicCid] = vm_class_table->At(kDynamicCid); |
39 table_[kVoidCid] = vm_class_table->At(kVoidCid); | 40 table_[kVoidCid] = vm_class_table->At(kVoidCid); |
40 class_heap_stats_table_ = reinterpret_cast<ClassHeapStats*>( | 41 class_heap_stats_table_ = reinterpret_cast<ClassHeapStats*>( |
41 calloc(capacity_, sizeof(ClassHeapStats))); // NOLINT | 42 calloc(capacity_, sizeof(ClassHeapStats))); // NOLINT |
42 for (intptr_t i = 0; i < capacity_; i++) { | 43 for (intptr_t i = 0; i < capacity_; i++) { |
43 class_heap_stats_table_[i].Initialize(); | 44 class_heap_stats_table_[i].Initialize(); |
44 } | 45 } |
45 } | 46 } |
46 predefined_class_heap_stats_table_ = reinterpret_cast<ClassHeapStats*>( | 47 predefined_class_heap_stats_table_ = reinterpret_cast<ClassHeapStats*>( |
47 calloc(kNumPredefinedCids, sizeof(ClassHeapStats))); // NOLINT | 48 calloc(kNumPredefinedCids, sizeof(ClassHeapStats))); // NOLINT |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 212 |
212 | 213 |
213 void ClassTable::Print() { | 214 void ClassTable::Print() { |
214 Class& cls = Class::Handle(); | 215 Class& cls = Class::Handle(); |
215 String& name = String::Handle(); | 216 String& name = String::Handle(); |
216 | 217 |
217 for (intptr_t i = 1; i < top_; i++) { | 218 for (intptr_t i = 1; i < top_; i++) { |
218 if (!HasValidClassAt(i)) { | 219 if (!HasValidClassAt(i)) { |
219 continue; | 220 continue; |
220 } | 221 } |
221 if (i == kFreeListElement) { | |
222 continue; | |
223 } | |
224 cls = At(i); | 222 cls = At(i); |
225 if (cls.raw() != reinterpret_cast<RawClass*>(0)) { | 223 if (cls.raw() != reinterpret_cast<RawClass*>(0)) { |
226 name = cls.Name(); | 224 name = cls.Name(); |
227 OS::Print("%" Pd ": %s\n", i, name.ToCString()); | 225 OS::Print("%" Pd ": %s\n", i, name.ToCString()); |
228 } | 226 } |
229 } | 227 } |
230 } | 228 } |
231 | 229 |
232 | 230 |
233 void ClassTable::PrintToJSONObject(JSONObject* object) { | 231 void ClassTable::PrintToJSONObject(JSONObject* object) { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 ASSERT(cid > 0); | 386 ASSERT(cid > 0); |
389 if (cid < kNumPredefinedCids) { | 387 if (cid < kNumPredefinedCids) { |
390 return &predefined_class_heap_stats_table_[cid]; | 388 return &predefined_class_heap_stats_table_[cid]; |
391 } | 389 } |
392 ASSERT(cid < top_); | 390 ASSERT(cid < top_); |
393 return &class_heap_stats_table_[cid]; | 391 return &class_heap_stats_table_[cid]; |
394 } | 392 } |
395 | 393 |
396 | 394 |
397 ClassHeapStats* ClassTable::StatsWithUpdatedSize(intptr_t cid) { | 395 ClassHeapStats* ClassTable::StatsWithUpdatedSize(intptr_t cid) { |
398 if (!HasValidClassAt(cid) || (cid == kFreeListElement) || (cid == kSmiCid)) { | 396 if (!HasValidClassAt(cid) || |
| 397 (cid == kFreeListElement) || |
| 398 (cid == kForwardingCorpse) || |
| 399 (cid == kSmiCid)) { |
399 return NULL; | 400 return NULL; |
400 } | 401 } |
401 Class& cls = Class::Handle(At(cid)); | 402 Class& cls = Class::Handle(At(cid)); |
402 if (!(cls.is_finalized() || cls.is_prefinalized())) { | 403 if (!(cls.is_finalized() || cls.is_prefinalized())) { |
403 // Not finalized. | 404 // Not finalized. |
404 return NULL; | 405 return NULL; |
405 } | 406 } |
406 ClassHeapStats* stats = PreliminaryStatsAt(cid); | 407 ClassHeapStats* stats = PreliminaryStatsAt(cid); |
407 if (ShouldUpdateSizeForClassId(cid)) { | 408 if (ShouldUpdateSizeForClassId(cid)) { |
408 stats->UpdateSize(cls.instance_size()); | 409 stats->UpdateSize(cls.instance_size()); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 | 549 |
549 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { | 550 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { |
550 ClassHeapStats* stats = PreliminaryStatsAt(cid); | 551 ClassHeapStats* stats = PreliminaryStatsAt(cid); |
551 ASSERT(stats != NULL); | 552 ASSERT(stats != NULL); |
552 ASSERT(size >= 0); | 553 ASSERT(size >= 0); |
553 stats->post_gc.AddNew(size); | 554 stats->post_gc.AddNew(size); |
554 } | 555 } |
555 | 556 |
556 | 557 |
557 } // namespace dart | 558 } // namespace dart |
OLD | NEW |