| 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/object.h" | 8 #include "vm/object.h" |
| 8 #include "vm/raw_object.h" | 9 #include "vm/raw_object.h" |
| 9 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
| 10 | 11 |
| 11 namespace dart { | 12 namespace dart { |
| 12 | 13 |
| 13 DEFINE_FLAG(bool, print_class_table, false, "Print initial class table."); | 14 DEFINE_FLAG(bool, print_class_table, false, "Print initial class table."); |
| 14 | 15 |
| 15 ClassTable::ClassTable() | 16 ClassTable::ClassTable() |
| 16 : top_(kNumPredefinedKinds), capacity_(0), table_(NULL) { | 17 : top_(kNumPredefinedKinds), capacity_(0), table_(NULL) { |
| 17 if (Dart::vm_isolate() == NULL) { | 18 if (Dart::vm_isolate() == NULL) { |
| 18 capacity_ = initial_capacity_; | 19 capacity_ = initial_capacity_; |
| 19 table_ = reinterpret_cast<RawClass**>( | 20 table_ = reinterpret_cast<RawClass**>( |
| 20 calloc(capacity_, sizeof(RawClass*))); // NOLINT | 21 calloc(capacity_, sizeof(RawClass*))); // NOLINT |
| 21 } else { | 22 } else { |
| 22 // Duplicate the class table from the VM isolate. | 23 // Duplicate the class table from the VM isolate. |
| 23 ClassTable* vm_class_table = Dart::vm_isolate()->class_table(); | 24 ClassTable* vm_class_table = Dart::vm_isolate()->class_table(); |
| 24 capacity_ = vm_class_table->capacity_; | 25 capacity_ = vm_class_table->capacity_; |
| 25 table_ = reinterpret_cast<RawClass**>( | 26 table_ = reinterpret_cast<RawClass**>( |
| 26 calloc(capacity_, sizeof(RawClass*))); // NOLINT | 27 calloc(capacity_, sizeof(RawClass*))); // NOLINT |
| 27 for (intptr_t i = kObject; i < kInstance; i++) { | 28 for (intptr_t i = kObject; i < kInstance; i++) { |
| 28 table_[i] = vm_class_table->At(i); | 29 table_[i] = vm_class_table->At(i); |
| 29 } | 30 } |
| 31 table_[kFreeListElement] = vm_class_table->At(kFreeListElement); |
| 30 table_[kNullClassId] = vm_class_table->At(kNullClassId); | 32 table_[kNullClassId] = vm_class_table->At(kNullClassId); |
| 31 table_[kDynamicClassId] = vm_class_table->At(kDynamicClassId); | 33 table_[kDynamicClassId] = vm_class_table->At(kDynamicClassId); |
| 32 table_[kVoidClassId] = vm_class_table->At(kVoidClassId); | 34 table_[kVoidClassId] = vm_class_table->At(kVoidClassId); |
| 33 } | 35 } |
| 34 } | 36 } |
| 35 | 37 |
| 36 | 38 |
| 37 ClassTable::~ClassTable() { | 39 ClassTable::~ClassTable() { |
| 38 free(table_); | 40 free(table_); |
| 39 } | 41 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 for (intptr_t i = 1; i < top_; i++) { | 90 for (intptr_t i = 1; i < top_; i++) { |
| 89 cls = At(i); | 91 cls = At(i); |
| 90 if (cls.raw() != reinterpret_cast<RawClass*>(0)) { | 92 if (cls.raw() != reinterpret_cast<RawClass*>(0)) { |
| 91 name = cls.Name(); | 93 name = cls.Name(); |
| 92 OS::Print("%d: %s\n", i, name.ToCString()); | 94 OS::Print("%d: %s\n", i, name.ToCString()); |
| 93 } | 95 } |
| 94 } | 96 } |
| 95 } | 97 } |
| 96 | 98 |
| 97 } // namespace dart | 99 } // namespace dart |
| OLD | NEW |