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 | 6 |
7 #include "vm/atomic.h" | 7 #include "vm/atomic.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/freelist.h" | 9 #include "vm/freelist.h" |
10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 intptr_t index = cls.id(); | 117 intptr_t index = cls.id(); |
118 if (index != kIllegalCid) { | 118 if (index != kIllegalCid) { |
119 ASSERT(index > 0); | 119 ASSERT(index > 0); |
120 ASSERT(index < kNumPredefinedCids); | 120 ASSERT(index < kNumPredefinedCids); |
121 ASSERT(table_[index] == 0); | 121 ASSERT(table_[index] == 0); |
122 ASSERT(index < capacity_); | 122 ASSERT(index < capacity_); |
123 table_[index] = cls.raw(); | 123 table_[index] = cls.raw(); |
124 // Add the vtable for this predefined class into the static vtable registry | 124 // Add the vtable for this predefined class into the static vtable registry |
125 // if it has not been setup yet. | 125 // if it has not been setup yet. |
126 cpp_vtable cls_vtable = cls.handle_vtable(); | 126 cpp_vtable cls_vtable = cls.handle_vtable(); |
127 AtomicOperations::CompareAndSwapWord(&(Object::builtin_vtables_[index]), 0, | 127 cpp_vtable old_cls_vtable = AtomicOperations::CompareAndSwapWord( |
128 cls_vtable); | 128 &(Object::builtin_vtables_[index]), 0, cls_vtable); |
129 ASSERT(Object::builtin_vtables_[index] == cls_vtable); | 129 if (old_cls_vtable != 0) { |
| 130 ASSERT(old_cls_vtable == cls_vtable); |
| 131 } |
130 } else { | 132 } else { |
131 if (top_ == capacity_) { | 133 if (top_ == capacity_) { |
132 // Grow the capacity of the class table. | 134 // Grow the capacity of the class table. |
133 // TODO(koda): Add ClassTable::Grow to share code. | 135 // TODO(koda): Add ClassTable::Grow to share code. |
134 intptr_t new_capacity = capacity_ + capacity_increment_; | 136 intptr_t new_capacity = capacity_ + capacity_increment_; |
135 RawClass** new_table = reinterpret_cast<RawClass**>( | 137 RawClass** new_table = reinterpret_cast<RawClass**>( |
136 malloc(new_capacity * sizeof(RawClass*))); // NOLINT | 138 malloc(new_capacity * sizeof(RawClass*))); // NOLINT |
137 memmove(new_table, table_, capacity_ * sizeof(RawClass*)); | 139 memmove(new_table, table_, capacity_ * sizeof(RawClass*)); |
138 #ifndef PRODUCT | 140 #ifndef PRODUCT |
139 ClassHeapStats* new_stats_table = reinterpret_cast<ClassHeapStats*>( | 141 ClassHeapStats* new_stats_table = reinterpret_cast<ClassHeapStats*>( |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { | 591 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { |
590 ClassHeapStats* stats = PreliminaryStatsAt(cid); | 592 ClassHeapStats* stats = PreliminaryStatsAt(cid); |
591 ASSERT(stats != NULL); | 593 ASSERT(stats != NULL); |
592 ASSERT(size >= 0); | 594 ASSERT(size >= 0); |
593 stats->post_gc.AddNew(size); | 595 stats->post_gc.AddNew(size); |
594 } | 596 } |
595 #endif // !PRODUCT | 597 #endif // !PRODUCT |
596 | 598 |
597 | 599 |
598 } // namespace dart | 600 } // namespace dart |
OLD | NEW |