summaryrefslogtreecommitdiff
path: root/runtime/class_table.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/class_table.cc')
-rw-r--r--runtime/class_table.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/runtime/class_table.cc b/runtime/class_table.cc
index 4bc2fe6833..a4bc1fbc00 100644
--- a/runtime/class_table.cc
+++ b/runtime/class_table.cc
@@ -135,7 +135,7 @@ size_t ClassTable::NumReferencedNonZygoteClasses() const {
ObjPtr<mirror::Class> ClassTable::Lookup(const char* descriptor, size_t hash) {
DescriptorHashPair pair(descriptor, hash);
ReaderMutexLock mu(Thread::Current(), lock_);
- for (ClassSet& class_set : classes_) {
+ for (ClassSet& class_set : ReverseRange(classes_)) {
auto it = class_set.FindWithHash(pair, hash);
if (it != class_set.end()) {
return it->Read();
@@ -196,7 +196,12 @@ size_t ClassTable::ReadFromMemory(uint8_t* ptr) {
void ClassTable::AddClassSet(ClassSet&& set) {
WriterMutexLock mu(Thread::Current(), lock_);
- classes_.insert(classes_.begin(), std::move(set));
+ // Insert before the last (unfrozen) table since we add new classes into the back.
+ // Keep the order of previous frozen tables unchanged, so that we can can remember
+ // the number of searched frozen tables and not search them again.
+ // TODO: Make use of this in `ClassLinker::FindClass()`.
+ DCHECK(!classes_.empty());
+ classes_.insert(classes_.end() - 1, std::move(set));
}
void ClassTable::ClearStrongRoots() {