| 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 #ifndef VM_CLASS_TABLE_H_ | 5 #ifndef VM_CLASS_TABLE_H_ |
| 6 #define VM_CLASS_TABLE_H_ | 6 #define VM_CLASS_TABLE_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
| 10 #include "vm/globals.h" |
| 10 | 11 |
| 11 namespace dart { | 12 namespace dart { |
| 12 | 13 |
| 13 class Class; | 14 class Class; |
| 14 class ObjectPointerVisitor; | 15 class ObjectPointerVisitor; |
| 15 class RawClass; | 16 class RawClass; |
| 16 | 17 |
| 17 class ClassTable { | 18 class ClassTable { |
| 18 public: | 19 public: |
| 19 ClassTable(); | 20 ClassTable(); |
| 20 ~ClassTable(); | 21 ~ClassTable(); |
| 21 | 22 |
| 22 RawClass* At(intptr_t index) const { | 23 RawClass* At(intptr_t index) const { |
| 23 ASSERT(IsValidIndex(index)); | 24 ASSERT(IsValidIndex(index)); |
| 24 return table_[index]; | 25 return table_[index]; |
| 25 } | 26 } |
| 26 | 27 |
| 27 intptr_t IsValidIndex(intptr_t index) const { | 28 intptr_t IsValidIndex(intptr_t index) const { |
| 28 return (index > 0) && (index < top_); | 29 return (index > 0) && (index < top_); |
| 29 } | 30 } |
| 30 | 31 |
| 31 void Register(const Class& cls); | 32 void Register(const Class& cls); |
| 32 | 33 |
| 33 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 34 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 34 | 35 |
| 35 void Print(); | 36 void Print(); |
| 36 | 37 |
| 38 static intptr_t table_offset() { |
| 39 return OFFSET_OF(ClassTable, table_); |
| 40 } |
| 41 |
| 37 private: | 42 private: |
| 38 static const int initial_capacity_ = 512; | 43 static const int initial_capacity_ = 512; |
| 39 static const int capacity_increment_ = 256; | 44 static const int capacity_increment_ = 256; |
| 40 | 45 |
| 41 intptr_t top_; | 46 intptr_t top_; |
| 42 intptr_t capacity_; | 47 intptr_t capacity_; |
| 43 | 48 |
| 44 RawClass** table_; | 49 RawClass** table_; |
| 45 | 50 |
| 46 DISALLOW_COPY_AND_ASSIGN(ClassTable); | 51 DISALLOW_COPY_AND_ASSIGN(ClassTable); |
| 47 }; | 52 }; |
| 48 | 53 |
| 49 } // namespace dart | 54 } // namespace dart |
| 50 | 55 |
| 51 #endif // VM_CLASS_TABLE_H_ | 56 #endif // VM_CLASS_TABLE_H_ |
| OLD | NEW |