diff options
Diffstat (limited to 'runtime/class_table.h')
| -rw-r--r-- | runtime/class_table.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/runtime/class_table.h b/runtime/class_table.h index 212a7d6631..7e263737c3 100644 --- a/runtime/class_table.h +++ b/runtime/class_table.h @@ -58,18 +58,31 @@ class ClassTable { explicit TableSlot(ObjPtr<mirror::Class> klass); TableSlot(ObjPtr<mirror::Class> klass, uint32_t descriptor_hash); + TableSlot(uint32_t ptr, uint32_t descriptor_hash); TableSlot& operator=(const TableSlot& copy) { data_.store(copy.data_.load(std::memory_order_relaxed), std::memory_order_relaxed); return *this; } + uint32_t Data() const { + return data_.load(std::memory_order_relaxed); + } + bool IsNull() const REQUIRES_SHARED(Locks::mutator_lock_); uint32_t Hash() const { return MaskHash(data_.load(std::memory_order_relaxed)); } + uint32_t NonHashData() const { + return RemoveHash(Data()); + } + + static uint32_t RemoveHash(uint32_t hash) { + return hash & ~kHashMask; + } + static uint32_t MaskHash(uint32_t hash) { return hash & kHashMask; } @@ -85,6 +98,9 @@ class ClassTable { template<typename Visitor> void VisitRoot(const Visitor& visitor) const NO_THREAD_SAFETY_ANALYSIS; + template<typename Visitor> + class ClassAndRootVisitor; + private: // Extract a raw pointer from an address. static ObjPtr<mirror::Class> ExtractPtr(uint32_t data) @@ -165,6 +181,11 @@ class ClassTable { REQUIRES(!lock_) REQUIRES_SHARED(Locks::mutator_lock_); + // Returns the number of classes in the class table. + size_t Size() const + REQUIRES(!lock_) + REQUIRES_SHARED(Locks::mutator_lock_); + // Update a class in the table with the new class. Returns the existing class which was replaced. ObjPtr<mirror::Class> UpdateClass(const char* descriptor, ObjPtr<mirror::Class> new_klass, @@ -185,6 +206,12 @@ class ClassTable { REQUIRES(!lock_) REQUIRES_SHARED(Locks::mutator_lock_); + template<class Visitor> + void VisitClassesAndRoots(Visitor& visitor) + NO_THREAD_SAFETY_ANALYSIS + REQUIRES(!lock_) + REQUIRES_SHARED(Locks::mutator_lock_); + // Stops visit if the visitor returns false. template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier, typename Visitor> bool Visit(Visitor& visitor) |