diff options
Diffstat (limited to 'runtime/class_table-inl.h')
-rw-r--r-- | runtime/class_table-inl.h | 39 |
1 files changed, 5 insertions, 34 deletions
diff --git a/runtime/class_table-inl.h b/runtime/class_table-inl.h index ff775d774f..071376cd77 100644 --- a/runtime/class_table-inl.h +++ b/runtime/class_table-inl.h @@ -29,41 +29,12 @@ namespace art { inline ClassTable::TableSlot::TableSlot(ObjPtr<mirror::Class> klass) - : TableSlot(klass, HashDescriptor(klass)) {} - -inline uint32_t ClassTable::TableSlot::HashDescriptor(ObjPtr<mirror::Class> klass) { - // No read barriers needed, we're reading a chain of constant references for comparison with null - // and retrieval of constant primitive data. See `ReadBarrierOption` and `Class::GetDescriptor()`. - DCHECK(klass != nullptr); - ObjPtr<mirror::Class> orig_klass = klass; // For debug check. - uint32_t hash = StartModifiedUtf8Hash(); - while (klass->IsArrayClass()) { - klass = klass->GetComponentType<kDefaultVerifyFlags, kWithoutReadBarrier>(); - hash = UpdateModifiedUtf8Hash(hash, '['); - } - if (UNLIKELY(klass->IsProxyClass())) { - hash = UpdateHashForProxyClass(hash, klass); - } else if (klass->IsPrimitive()) { - hash = UpdateModifiedUtf8Hash(hash, Primitive::Descriptor(klass->GetPrimitiveType())[0]); - } else { - const DexFile& dex_file = klass->GetDexFile(); - const dex::TypeId& type_id = dex_file.GetTypeId(klass->GetDexTypeIndex()); - std::string_view descriptor = dex_file.GetTypeDescriptorView(type_id); - hash = UpdateModifiedUtf8Hash(hash, descriptor); - } - - if (kIsDebugBuild) { - std::string temp; - CHECK_EQ(hash, ComputeModifiedUtf8Hash(orig_klass->GetDescriptor(&temp))); - } - - return hash; -} + : TableSlot(klass, klass->DescriptorHash()) {} inline uint32_t ClassTable::ClassDescriptorHash::operator()(const TableSlot& slot) const { // No read barriers needed, we're reading a chain of constant references for comparison with null - // and retrieval of constant primitive data. See `ReadBarrierOption` and `Class::GetDescriptor()`. - return TableSlot::HashDescriptor(slot.Read<kWithoutReadBarrier>()); + // and retrieval of constant primitive data. See `ReadBarrierOption` and `Class::DescriptorHash()`. + return slot.Read<kWithoutReadBarrier>()->DescriptorHash(); } inline uint32_t ClassTable::ClassDescriptorHash::operator()(const DescriptorHashPair& pair) const { @@ -202,7 +173,7 @@ inline uint32_t ClassTable::TableSlot::Encode(ObjPtr<mirror::Class> klass, uint3 inline ClassTable::TableSlot::TableSlot(ObjPtr<mirror::Class> klass, uint32_t descriptor_hash) : data_(Encode(klass, MaskHash(descriptor_hash))) { - DCHECK_EQ(descriptor_hash, HashDescriptor(klass)); + DCHECK_EQ(descriptor_hash, klass->DescriptorHash()); } template <typename Filter> @@ -213,9 +184,9 @@ inline void ClassTable::RemoveStrongRoots(const Filter& filter) { } inline ObjPtr<mirror::Class> ClassTable::LookupByDescriptor(ObjPtr<mirror::Class> klass) { + uint32_t hash = klass->DescriptorHash(); std::string temp; const char* descriptor = klass->GetDescriptor(&temp); - uint32_t hash = TableSlot::HashDescriptor(klass); return Lookup(descriptor, hash); } |