diff options
author | 2021-02-23 18:13:47 +0000 | |
---|---|---|
committer | 2021-03-04 11:30:53 +0000 | |
commit | 4e7b3c78854d9639758e2519ae29f86a6799857b (patch) | |
tree | 287f5211900b53e22f64f3364bd3cc44ce78e87a /runtime/class_table-inl.h | |
parent | 18839fe532ceae55e5cb6ae98b5aecb4217623fa (diff) |
Make some hash/equals operators inline.
Namely class descriptor hash/equals in ClassTable and
string hash/equals in InternTable.
This should reduce reliance on ThinLTO for performance.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 179799979
Bug: 179837605
Change-Id: Ie513b2312d30e1b52efefd705a26d13035789e4a
Diffstat (limited to 'runtime/class_table-inl.h')
-rw-r--r-- | runtime/class_table-inl.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/runtime/class_table-inl.h b/runtime/class_table-inl.h index d043af36fe..3645b647c4 100644 --- a/runtime/class_table-inl.h +++ b/runtime/class_table-inl.h @@ -20,6 +20,7 @@ #include "class_table.h" #include "base/mutex-inl.h" +#include "dex/utf.h" #include "gc_root-inl.h" #include "mirror/class.h" #include "oat_file.h" @@ -27,6 +28,44 @@ namespace art { +inline 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 + // with null and retrieval of constant primitive data. See ReadBarrierOption. + return ComputeModifiedUtf8Hash(slot.Read<kWithoutReadBarrier>()->GetDescriptor(&temp)); +} + +inline uint32_t ClassTable::ClassDescriptorHash::operator()(const DescriptorHashPair& pair) const { + DCHECK_EQ(ComputeModifiedUtf8Hash(pair.first), pair.second); + return pair.second; +} + +inline 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()) { + std::string temp; + DCHECK(!a.Read<kWithoutReadBarrier>()->DescriptorEquals( + b.Read<kWithoutReadBarrier>()->GetDescriptor(&temp))); + return false; + } + std::string temp; + return a.Read<kWithoutReadBarrier>()->DescriptorEquals( + b.Read<kWithoutReadBarrier>()->GetDescriptor(&temp)); +} + +inline 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)) { + DCHECK(!a.Read<kWithoutReadBarrier>()->DescriptorEquals(b.first)); + return false; + } + return a.Read<kWithoutReadBarrier>()->DescriptorEquals(b.first); +} + template<class Visitor> void ClassTable::VisitRoots(Visitor& visitor) { ReaderMutexLock mu(Thread::Current(), lock_); |