From a23cf27371c4dba8fcc920d688b362926564107d Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 20 Apr 2022 17:21:21 +0100 Subject: Add comments about class/intern table search order. Also add a related comment about pruning classes only from the last class set in the `ClassTable` and move some local variables out of a loop. Test: Rely on TreeHugger. Bug: 181943478 Change-Id: Iba1296fb60fde2f90e1e256865bf02ebc3d8f292 --- runtime/class_table.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'runtime/class_table.cc') diff --git a/runtime/class_table.cc b/runtime/class_table.cc index a4bc1fbc00..10f60ab508 100644 --- a/runtime/class_table.cc +++ b/runtime/class_table.cc @@ -135,6 +135,11 @@ size_t ClassTable::NumReferencedNonZygoteClasses() const { ObjPtr ClassTable::Lookup(const char* descriptor, size_t hash) { DescriptorHashPair pair(descriptor, hash); ReaderMutexLock mu(Thread::Current(), lock_); + // Search from the last table, assuming that apps shall search for their own classes + // more often than for boot image classes. For prebuilt boot images, this also helps + // by searching the large table from the framework boot image extension compiled as + // single-image before the individual small tables from the primary boot image + // compiled as multi-image. for (ClassSet& class_set : ReverseRange(classes_)) { auto it = class_set.FindWithHash(pair, hash); if (it != class_set.end()) { -- cgit v1.2.3-59-g8ed1b