From df68c0a6f0d36728fa728049e5bcec20de2d0d5e Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Tue, 3 Jan 2023 14:01:00 +0000 Subject: Write classes in runtime-generated app image. Test: 845-data-image Bug: 260557058 Change-Id: I640b78942984ac3d3f8d24abda619d78154acd86 --- runtime/class_table.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'runtime/class_table.h') diff --git a/runtime/class_table.h b/runtime/class_table.h index 123c069f0e..7e263737c3 100644 --- a/runtime/class_table.h +++ b/runtime/class_table.h @@ -58,18 +58,31 @@ class ClassTable { explicit TableSlot(ObjPtr klass); TableSlot(ObjPtr 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; } @@ -168,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 UpdateClass(const char* descriptor, ObjPtr new_klass, -- cgit v1.2.3-59-g8ed1b