Rewrite profile file format.
The new format contains one mandatory section and several
optional sections. This allows extending the profile with
new sections that shall be ignored by old versions of ART.
We add an "extra descriptors" section to support class
references without a `dex::TypeId` in the referencing dex
file. Type indexes between the dex file's `NumTypeIds()`
and `DexFile::kDexNoIndex16` are used to index these extra
descriptors. This prepares for collecting array classes
which shall be tied to the element type's dex file even
when the array type is not needed by that dex file and has
been used only from another dex file. It also allows inline
caches to be self-contained, so we can remove the profile
index from data structures and serialized data.
The creation of the the binary profile from text files is
updated to correctly allow array types to be stored as the
profiled classes using the "extra descriptors". However,
the interface for filling in inline caches remains unchanged
for now, so we require a `TypeId` in one of the processed
dex files. The data collection by JIT has not been updated.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing --speed-profile
Test: boots.
Test: atest BootImageProfileTest
Bug: 148067697
Change-Id: Idd5f709bdc0ab4a3c7480d69d1dfac72d6e818fc
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 0f5f139..2df7d23 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -8948,6 +8948,16 @@
ObjPtr<mirror::ClassLoader> class_loader) {
const DexFile& dex_file = *dex_cache->GetDexFile();
const char* descriptor = dex_file.StringByTypeIdx(type_idx);
+ ObjPtr<mirror::Class> type = LookupResolvedType(descriptor, class_loader);
+ if (type != nullptr) {
+ DCHECK(type->IsResolved());
+ dex_cache->SetResolvedType(type_idx, type);
+ }
+ return type;
+}
+
+ObjPtr<mirror::Class> ClassLinker::LookupResolvedType(const char* descriptor,
+ ObjPtr<mirror::ClassLoader> class_loader) {
DCHECK_NE(*descriptor, '\0') << "descriptor is empty string";
ObjPtr<mirror::Class> type = nullptr;
if (descriptor[1] == '\0') {
@@ -8961,14 +8971,7 @@
// Find the class in the loaded classes table.
type = LookupClass(self, descriptor, hash, class_loader);
}
- if (type != nullptr) {
- if (type->IsResolved()) {
- dex_cache->SetResolvedType(type_idx, type);
- } else {
- type = nullptr;
- }
- }
- return type;
+ return (type != nullptr && type->IsResolved()) ? type : nullptr;
}
template <typename RefType>