Faster BCP checksum verification.
Avoid opening dex files for updatable BCP components.
Just collect the checksums from jar files using the
`DexFileLoader::GetMultiDexChecksums()` API.
(cherry picked from commit e020b7f4afc4d99cddfd52b3587280be9e3afd5d)
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 191828947
Merged-In: Ib737fabc832c56bffef8a98382f689aabe588bd2
Change-Id: I23b6adc30c57182c56c713da94a77fe65c15bb45
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index 51582ce..4eb7f25 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -3480,19 +3480,18 @@
oat_checksums.remove_prefix(1u);
const std::string& bcp_filename = boot_class_path[bcp_pos];
- std::vector<std::unique_ptr<const DexFile>> dex_files;
+ std::vector<uint32_t> checksums;
+ std::vector<std::string> dex_locations;
const ArtDexFileLoader dex_file_loader;
- if (!dex_file_loader.Open(bcp_filename.c_str(),
- bcp_filename, // The location does not matter here.
- /*verify=*/ false,
- /*verify_checksum=*/ false,
- error_msg,
- &dex_files)) {
+ if (!dex_file_loader.GetMultiDexChecksums(bcp_filename.c_str(),
+ &checksums,
+ &dex_locations,
+ error_msg)) {
return false;
}
- DCHECK(!dex_files.empty());
- for (const std::unique_ptr<const DexFile>& dex_file : dex_files) {
- std::string dex_file_checksum = StringPrintf("/%08x", dex_file->GetLocationChecksum());
+ DCHECK(!checksums.empty());
+ for (uint32_t checksum : checksums) {
+ std::string dex_file_checksum = StringPrintf("/%08x", checksum);
if (!StartsWith(oat_checksums, dex_file_checksum)) {
*error_msg = StringPrintf("Dex checksum mismatch, expected %s to start with %s",
std::string(oat_checksums).c_str(),