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/class_table.h" | 5 #include "vm/class_table.h" |
| 6 #include "vm/flags.h" | 6 #include "vm/flags.h" |
| 7 #include "vm/freelist.h" | 7 #include "vm/freelist.h" |
| 8 #include "vm/heap.h" | 8 #include "vm/heap.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/raw_object.h" | 10 #include "vm/raw_object.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 new_capacity * sizeof(ClassHeapStats))); // NOLINT | 82 new_capacity * sizeof(ClassHeapStats))); // NOLINT |
| 83 for (intptr_t i = capacity_; i < new_capacity; i++) { | 83 for (intptr_t i = capacity_; i < new_capacity; i++) { |
| 84 new_table[i] = NULL; | 84 new_table[i] = NULL; |
| 85 new_stats_table[i].Initialize(); | 85 new_stats_table[i].Initialize(); |
| 86 } | 86 } |
| 87 capacity_ = new_capacity; | 87 capacity_ = new_capacity; |
| 88 table_ = new_table; | 88 table_ = new_table; |
| 89 class_heap_stats_table_ = new_stats_table; | 89 class_heap_stats_table_ = new_stats_table; |
| 90 } | 90 } |
| 91 ASSERT(top_ < capacity_); | 91 ASSERT(top_ < capacity_); |
| 92 if (!Class::is_valid_id(top_)) { | |
| 93 FATAL1("Fatal error in ClassTable::Register: invalid index %" Pd "\n", | |
|
Ivan Posva
2014/04/18 16:39:27
FATAL is OK for now, but we really should just thr
| |
| 94 top_); | |
| 95 } | |
| 92 cls.set_id(top_); | 96 cls.set_id(top_); |
| 93 table_[top_] = cls.raw(); | 97 table_[top_] = cls.raw(); |
| 94 top_++; // Increment next index. | 98 top_++; // Increment next index. |
| 95 } | 99 } |
| 96 } | 100 } |
| 97 | 101 |
| 98 | 102 |
| 99 void ClassTable::RegisterAt(intptr_t index, const Class& cls) { | 103 void ClassTable::RegisterAt(intptr_t index, const Class& cls) { |
| 100 ASSERT(index != kIllegalCid); | 104 ASSERT(index != kIllegalCid); |
| 101 ASSERT(index >= kNumPredefinedCids); | 105 ASSERT(index >= kNumPredefinedCids); |
| 102 if (index >= capacity_) { | 106 if (index >= capacity_) { |
| 103 // Grow the capacity of the class table. | 107 // Grow the capacity of the class table. |
| 104 intptr_t new_capacity = index + capacity_increment_; | 108 intptr_t new_capacity = index + capacity_increment_; |
| 105 if (new_capacity < capacity_) { | 109 if (!Class::is_valid_id(index) || new_capacity < capacity_) { |
| 106 FATAL1("Fatal error in ClassTable::Register: invalid index %" Pd "\n", | 110 FATAL1("Fatal error in ClassTable::Register: invalid index %" Pd "\n", |
| 107 index); | 111 index); |
| 108 } | 112 } |
| 109 RawClass** new_table = reinterpret_cast<RawClass**>( | 113 RawClass** new_table = reinterpret_cast<RawClass**>( |
| 110 realloc(table_, new_capacity * sizeof(RawClass*))); // NOLINT | 114 realloc(table_, new_capacity * sizeof(RawClass*))); // NOLINT |
| 111 ClassHeapStats* new_stats_table = reinterpret_cast<ClassHeapStats*>( | 115 ClassHeapStats* new_stats_table = reinterpret_cast<ClassHeapStats*>( |
| 112 realloc(class_heap_stats_table_, | 116 realloc(class_heap_stats_table_, |
| 113 new_capacity * sizeof(ClassHeapStats))); // NOLINT | 117 new_capacity * sizeof(ClassHeapStats))); // NOLINT |
| 114 for (intptr_t i = capacity_; i < new_capacity; i++) { | 118 for (intptr_t i = capacity_; i < new_capacity; i++) { |
| 115 new_table[i] = NULL; | 119 new_table[i] = NULL; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 | 430 |
| 427 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { | 431 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { |
| 428 ClassHeapStats* stats = StatsAt(cid); | 432 ClassHeapStats* stats = StatsAt(cid); |
| 429 ASSERT(stats != NULL); | 433 ASSERT(stats != NULL); |
| 430 ASSERT(size >= 0); | 434 ASSERT(size >= 0); |
| 431 stats->post_gc.AddNew(size); | 435 stats->post_gc.AddNew(size); |
| 432 } | 436 } |
| 433 | 437 |
| 434 | 438 |
| 435 } // namespace dart | 439 } // namespace dart |
| OLD | NEW |