diff options
author | 2022-04-14 10:59:53 +0100 | |
---|---|---|
committer | 2022-04-21 11:01:45 +0000 | |
commit | 10137abcd09d51f263f56d64bb0b41fb4f8e5070 (patch) | |
tree | 5ed1f202dcaae81e60e24f32a3579731ba4a86f3 /runtime/class_table.cc | |
parent | 86f1b3f30fa72c3f3e712c930c4444c51054b615 (diff) |
Move descriptor hashing to `mirror::Class`.
We may want to reuse the hashing for image classes which are
not closely related with the `ClassTable` where the hashing
was previously.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 181943478
Change-Id: Icf1b51085829509f58e7685dc1e9cf2b0583d107
Diffstat (limited to 'runtime/class_table.cc')
-rw-r--r-- | runtime/class_table.cc | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/runtime/class_table.cc b/runtime/class_table.cc index 10f60ab508..429f9268ec 100644 --- a/runtime/class_table.cc +++ b/runtime/class_table.cc @@ -23,34 +23,6 @@ namespace art { -uint32_t ClassTable::TableSlot::UpdateHashForProxyClass( - uint32_t hash, ObjPtr<mirror::Class> proxy_class) { - // No read barrier needed, the `name` field is constant for proxy classes and - // the contents of the String are also constant. See ReadBarrierOption. - // Note: The `proxy_class` can be a from-space reference. - DCHECK(proxy_class->IsProxyClass()); - ObjPtr<mirror::String> name = proxy_class->GetName<kVerifyNone, kWithoutReadBarrier>(); - DCHECK(name != nullptr); - // Update hash for characters we would get from `DotToDescriptor(name->ToModifiedUtf8())`. - DCHECK_NE(name->GetLength(), 0); - DCHECK_NE(name->CharAt(0), '['); - hash = UpdateModifiedUtf8Hash(hash, 'L'); - if (name->IsCompressed()) { - std::string_view dot_name(reinterpret_cast<const char*>(name->GetValueCompressed()), - name->GetLength()); - for (char c : dot_name) { - hash = UpdateModifiedUtf8Hash(hash, (c != '.') ? c : '/'); - } - } else { - std::string dot_name = name->ToModifiedUtf8(); - for (char c : dot_name) { - hash = UpdateModifiedUtf8Hash(hash, (c != '.') ? c : '/'); - } - } - hash = UpdateModifiedUtf8Hash(hash, ';'); - return hash; -} - ClassTable::ClassTable() : lock_("Class loader classes", kClassLoaderClassesLock) { Runtime* const runtime = Runtime::Current(); classes_.push_back(ClassSet(runtime->GetHashTableMinLoadFactor(), @@ -150,7 +122,7 @@ ObjPtr<mirror::Class> ClassTable::Lookup(const char* descriptor, size_t hash) { } void ClassTable::Insert(ObjPtr<mirror::Class> klass) { - InsertWithHash(klass, TableSlot::HashDescriptor(klass)); + InsertWithHash(klass, klass->DescriptorHash()); } void ClassTable::InsertWithHash(ObjPtr<mirror::Class> klass, size_t hash) { |