summaryrefslogtreecommitdiff
path: root/runtime/class_table.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2019-04-10 11:40:01 +0100
committer Vladimir Marko <vmarko@google.com> 2019-05-08 08:19:28 +0000
commitc6934e36d33ab402b7b51c78d46c319fc33e8ef3 (patch)
treecec68ac35886015369bca93d5987889552327ac6 /runtime/class_table.cc
parent552ba72fce139aa2b0a80d1a2b920c5e8fadaf58 (diff)
Avoid some read barriers in ClassTable.
And clean up ClassTable. Test: m test-art-host-gtest Test: testrunner.py --host --interpreter Bug: 119486698 Change-Id: Ie413bc5a56eb548352ae1fed0976b75c44e0c0d4
Diffstat (limited to 'runtime/class_table.cc')
-rw-r--r--runtime/class_table.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/runtime/class_table.cc b/runtime/class_table.cc
index 8d8e93aab0..58f3674804 100644
--- a/runtime/class_table.cc
+++ b/runtime/class_table.cc
@@ -34,15 +34,7 @@ void ClassTable::FreezeSnapshot() {
}
bool ClassTable::Contains(ObjPtr<mirror::Class> klass) {
- ReaderMutexLock mu(Thread::Current(), lock_);
- TableSlot slot(klass);
- for (ClassSet& class_set : classes_) {
- auto it = class_set.find(slot);
- if (it != class_set.end()) {
- return it->Read() == klass;
- }
- }
- return false;
+ return LookupByDescriptor(klass) == klass;
}
mirror::Class* ClassTable::LookupByDescriptor(ObjPtr<mirror::Class> klass) {
@@ -191,27 +183,35 @@ bool ClassTable::Remove(const char* descriptor) {
uint32_t ClassTable::ClassDescriptorHashEquals::operator()(const TableSlot& slot)
const {
std::string temp;
- return ComputeModifiedUtf8Hash(slot.Read()->GetDescriptor(&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));
}
bool ClassTable::ClassDescriptorHashEquals::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()->DescriptorEquals(b.Read()->GetDescriptor(&temp)));
+ DCHECK(!a.Read<kWithoutReadBarrier>()->DescriptorEquals(
+ b.Read<kWithoutReadBarrier>()->GetDescriptor(&temp)));
return false;
}
std::string temp;
- return a.Read()->DescriptorEquals(b.Read()->GetDescriptor(&temp));
+ return a.Read<kWithoutReadBarrier>()->DescriptorEquals(
+ b.Read<kWithoutReadBarrier>()->GetDescriptor(&temp));
}
bool ClassTable::ClassDescriptorHashEquals::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()->DescriptorEquals(b.first));
+ DCHECK(!a.Read<kWithoutReadBarrier>()->DescriptorEquals(b.first));
return false;
}
- return a.Read()->DescriptorEquals(b.first);
+ return a.Read<kWithoutReadBarrier>()->DescriptorEquals(b.first);
}
uint32_t ClassTable::ClassDescriptorHashEquals::operator()(const DescriptorHashPair& pair) const {