| 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 #include "vm/globals.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 RawClass* At(intptr_t index) const { | 23 RawClass* At(intptr_t index) const { |
| 24 ASSERT(IsValidIndex(index)); | 24 ASSERT(IsValidIndex(index)); |
| 25 return table_[index]; | 25 return table_[index]; |
| 26 } | 26 } |
| 27 | 27 |
| 28 intptr_t IsValidIndex(intptr_t index) const { | 28 intptr_t IsValidIndex(intptr_t index) const { |
| 29 return (index > 0) && (index < top_); | 29 return (index > 0) && (index < top_); |
| 30 } | 30 } |
| 31 | 31 |
| 32 bool HasValidClassAt(intptr_t index) const { |
| 33 ASSERT(IsValidIndex(index)); |
| 34 return table_[index] != NULL; |
| 35 } |
| 36 |
| 37 intptr_t NumCids() const { return top_; } |
| 38 |
| 32 void Register(const Class& cls); | 39 void Register(const Class& cls); |
| 33 | 40 |
| 34 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 41 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 35 | 42 |
| 36 void Print(); | 43 void Print(); |
| 37 | 44 |
| 38 static intptr_t table_offset() { | 45 static intptr_t table_offset() { |
| 39 return OFFSET_OF(ClassTable, table_); | 46 return OFFSET_OF(ClassTable, table_); |
| 40 } | 47 } |
| 41 | 48 |
| 42 private: | 49 private: |
| 43 static const int initial_capacity_ = 512; | 50 static const int initial_capacity_ = 512; |
| 44 static const int capacity_increment_ = 256; | 51 static const int capacity_increment_ = 256; |
| 45 | 52 |
| 46 intptr_t top_; | 53 intptr_t top_; |
| 47 intptr_t capacity_; | 54 intptr_t capacity_; |
| 48 | 55 |
| 49 RawClass** table_; | 56 RawClass** table_; |
| 50 | 57 |
| 51 DISALLOW_COPY_AND_ASSIGN(ClassTable); | 58 DISALLOW_COPY_AND_ASSIGN(ClassTable); |
| 52 }; | 59 }; |
| 53 | 60 |
| 54 } // namespace dart | 61 } // namespace dart |
| 55 | 62 |
| 56 #endif // VM_CLASS_TABLE_H_ | 63 #endif // VM_CLASS_TABLE_H_ |
| OLD | NEW |