summaryrefslogtreecommitdiff
path: root/runtime/class_table.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2021-02-05 13:33:28 +0000
committer Vladimir Marko <vmarko@google.com> 2021-02-08 10:49:38 +0000
commiteae6a7121925b95477b92b404d85645e665bc948 (patch)
tree1a2155272c19c5aa60ad5eebe27e881f87e63088 /runtime/class_table.cc
parent1ee12675375f97790f2ad2bbd0196c1847f858fb (diff)
Avoid an unnecessary ComputeModifiedUtf8Hash().
The DescriptorHashPair already has the hash as the member `second`, so avoid recalculating it in release mode. Also split "HashEquals" classes into separate "Hash" and "Equals" classes to disambiguate their operators in traces. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 175869411 Change-Id: I87cbe613778c7d310ba5c2bf437729244780472c
Diffstat (limited to 'runtime/class_table.cc')
-rw-r--r--runtime/class_table.cc18
1 files changed, 9 insertions, 9 deletions
diff --git a/runtime/class_table.cc b/runtime/class_table.cc
index 65d976828d..fc2640c2cc 100644
--- a/runtime/class_table.cc
+++ b/runtime/class_table.cc
@@ -164,7 +164,7 @@ bool ClassTable::Remove(const char* descriptor) {
return false;
}
-uint32_t ClassTable::ClassDescriptorHashEquals::operator()(const TableSlot& slot)
+uint32_t ClassTable::ClassDescriptorHash::operator()(const TableSlot& slot)
const {
std::string temp;
// No read barrier needed, we're reading a chain of constant references for comparison
@@ -172,8 +172,12 @@ uint32_t ClassTable::ClassDescriptorHashEquals::operator()(const TableSlot& slot
return ComputeModifiedUtf8Hash(slot.Read<kWithoutReadBarrier>()->GetDescriptor(&temp));
}
-bool ClassTable::ClassDescriptorHashEquals::operator()(const TableSlot& a,
- const TableSlot& b) const {
+uint32_t ClassTable::ClassDescriptorHash::operator()(const DescriptorHashPair& pair) const {
+ DCHECK_EQ(ComputeModifiedUtf8Hash(pair.first), pair.second);
+ return pair.second;
+}
+
+bool ClassTable::ClassDescriptorEquals::operator()(const TableSlot& a, const TableSlot& b) const {
// No read barrier needed, we're reading a chain of constant references for comparison
// with null and retrieval of constant primitive data. See ReadBarrierOption.
if (a.Hash() != b.Hash()) {
@@ -187,8 +191,8 @@ bool ClassTable::ClassDescriptorHashEquals::operator()(const TableSlot& a,
b.Read<kWithoutReadBarrier>()->GetDescriptor(&temp));
}
-bool ClassTable::ClassDescriptorHashEquals::operator()(const TableSlot& a,
- const DescriptorHashPair& b) const {
+bool ClassTable::ClassDescriptorEquals::operator()(const TableSlot& a,
+ const DescriptorHashPair& b) const {
// No read barrier needed, we're reading a chain of constant references for comparison
// with null and retrieval of constant primitive data. See ReadBarrierOption.
if (!a.MaskedHashEquals(b.second)) {
@@ -198,10 +202,6 @@ bool ClassTable::ClassDescriptorHashEquals::operator()(const TableSlot& a,
return a.Read<kWithoutReadBarrier>()->DescriptorEquals(b.first);
}
-uint32_t ClassTable::ClassDescriptorHashEquals::operator()(const DescriptorHashPair& pair) const {
- return ComputeModifiedUtf8Hash(pair.first);
-}
-
bool ClassTable::InsertStrongRoot(ObjPtr<mirror::Object> obj) {
WriterMutexLock mu(Thread::Current(), lock_);
DCHECK(obj != nullptr);