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/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 if (i == kFreeListElement || i == kForwardingCorpse) { |
|
Cutch
2016/06/02 14:09:53
This continue shouldn't be necessary anymore becau
rmacnak
2016/06/02 17:57:06
Done.
| |
| 222 continue; | 223 continue; |
| 223 } | 224 } |
| 224 cls = At(i); | 225 cls = At(i); |
| 225 if (cls.raw() != reinterpret_cast<RawClass*>(0)) { | 226 if (cls.raw() != reinterpret_cast<RawClass*>(0)) { |
| 226 name = cls.Name(); | 227 name = cls.Name(); |
| 227 OS::Print("%" Pd ": %s\n", i, name.ToCString()); | 228 OS::Print("%" Pd ": %s\n", i, name.ToCString()); |
| 228 } | 229 } |
| 229 } | 230 } |
| 230 } | 231 } |
| 231 | 232 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 ASSERT(cid > 0); | 389 ASSERT(cid > 0); |
| 389 if (cid < kNumPredefinedCids) { | 390 if (cid < kNumPredefinedCids) { |
| 390 return &predefined_class_heap_stats_table_[cid]; | 391 return &predefined_class_heap_stats_table_[cid]; |
| 391 } | 392 } |
| 392 ASSERT(cid < top_); | 393 ASSERT(cid < top_); |
| 393 return &class_heap_stats_table_[cid]; | 394 return &class_heap_stats_table_[cid]; |
| 394 } | 395 } |
| 395 | 396 |
| 396 | 397 |
| 397 ClassHeapStats* ClassTable::StatsWithUpdatedSize(intptr_t cid) { | 398 ClassHeapStats* ClassTable::StatsWithUpdatedSize(intptr_t cid) { |
| 398 if (!HasValidClassAt(cid) || (cid == kFreeListElement) || (cid == kSmiCid)) { | 399 if (!HasValidClassAt(cid) || |
| 400 (cid == kFreeListElement) || | |
| 401 (cid == kForwardingCorpse) || | |
| 402 (cid == kSmiCid)) { | |
| 399 return NULL; | 403 return NULL; |
| 400 } | 404 } |
| 401 Class& cls = Class::Handle(At(cid)); | 405 Class& cls = Class::Handle(At(cid)); |
| 402 if (!(cls.is_finalized() || cls.is_prefinalized())) { | 406 if (!(cls.is_finalized() || cls.is_prefinalized())) { |
| 403 // Not finalized. | 407 // Not finalized. |
| 404 return NULL; | 408 return NULL; |
| 405 } | 409 } |
| 406 ClassHeapStats* stats = PreliminaryStatsAt(cid); | 410 ClassHeapStats* stats = PreliminaryStatsAt(cid); |
| 407 if (ShouldUpdateSizeForClassId(cid)) { | 411 if (ShouldUpdateSizeForClassId(cid)) { |
| 408 stats->UpdateSize(cls.instance_size()); | 412 stats->UpdateSize(cls.instance_size()); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 | 552 |
| 549 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { | 553 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { |
| 550 ClassHeapStats* stats = PreliminaryStatsAt(cid); | 554 ClassHeapStats* stats = PreliminaryStatsAt(cid); |
| 551 ASSERT(stats != NULL); | 555 ASSERT(stats != NULL); |
| 552 ASSERT(size >= 0); | 556 ASSERT(size >= 0); |
| 553 stats->post_gc.AddNew(size); | 557 stats->post_gc.AddNew(size); |
| 554 } | 558 } |
| 555 | 559 |
| 556 | 560 |
| 557 } // namespace dart | 561 } // namespace dart |
| OLD | NEW |