| 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/object.h" | 7 #include "vm/object.h" |
| 8 #include "vm/raw_object.h" | 8 #include "vm/raw_object.h" |
| 9 #include "vm/visitor.h" | 9 #include "vm/visitor.h" |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 | 41 |
| 42 void ClassTable::Register(const Class& cls) { | 42 void ClassTable::Register(const Class& cls) { |
| 43 intptr_t index = cls.id(); | 43 intptr_t index = cls.id(); |
| 44 if (index != kIllegalObjectKind) { | 44 if (index != kIllegalObjectKind) { |
| 45 ASSERT(index > 0); | 45 ASSERT(index > 0); |
| 46 ASSERT(index < kNumPredefinedKinds); | 46 ASSERT(index < kNumPredefinedKinds); |
| 47 ASSERT(table_[index] == 0); | 47 ASSERT(table_[index] == 0); |
| 48 ASSERT(index < capacity_); | 48 ASSERT(index < capacity_); |
| 49 table_[index] = cls.raw(); | 49 table_[index] = cls.raw(); |
| 50 // Add the vtable for this predefined class into the static vtable registry |
| 51 // if it has not been setup yet. |
| 52 cpp_vtable cls_vtable = cls.handle_vtable(); |
| 53 cpp_vtable table_entry = Object::builtin_vtables_[index]; |
| 54 ASSERT((table_entry == 0) || (table_entry == cls_vtable)); |
| 55 if (table_entry == 0) { |
| 56 Object::builtin_vtables_[index] = cls_vtable; |
| 57 } |
| 50 } else { | 58 } else { |
| 51 if (top_ == capacity_) { | 59 if (top_ == capacity_) { |
| 52 // Grow the capacity of the class table. | 60 // Grow the capacity of the class table. |
| 53 intptr_t new_capacity = capacity_ + capacity_increment_; | 61 intptr_t new_capacity = capacity_ + capacity_increment_; |
| 54 RawClass** new_table = reinterpret_cast<RawClass**>( | 62 RawClass** new_table = reinterpret_cast<RawClass**>( |
| 55 realloc(table_, new_capacity * sizeof(RawClass*))); // NOLINT | 63 realloc(table_, new_capacity * sizeof(RawClass*))); // NOLINT |
| 56 for (intptr_t i = capacity_; i < new_capacity; i++) { | 64 for (intptr_t i = capacity_; i < new_capacity; i++) { |
| 57 new_table[i] = NULL; | 65 new_table[i] = NULL; |
| 58 } | 66 } |
| 59 capacity_ = new_capacity; | 67 capacity_ = new_capacity; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 80 for (intptr_t i = 1; i < top_; i++) { | 88 for (intptr_t i = 1; i < top_; i++) { |
| 81 cls = At(i); | 89 cls = At(i); |
| 82 if (cls.raw() != reinterpret_cast<RawClass*>(0)) { | 90 if (cls.raw() != reinterpret_cast<RawClass*>(0)) { |
| 83 name = cls.Name(); | 91 name = cls.Name(); |
| 84 OS::Print("%d: %s\n", i, name.ToCString()); | 92 OS::Print("%d: %s\n", i, name.ToCString()); |
| 85 } | 93 } |
| 86 } | 94 } |
| 87 } | 95 } |
| 88 | 96 |
| 89 } // namespace dart | 97 } // namespace dart |
| OLD | NEW |