Skip to content

Commit

Permalink
Faster BCP checksum verification.
Browse files Browse the repository at this point in the history
Avoid opening dex files for updatable BCP components.
Just collect the checksums from jar files using the
`DexFileLoader::GetMultiDexChecksums()` API.

(cherry picked from commit e020b7f)

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 191828947
Merged-In: Ib737fabc832c56bffef8a98382f689aabe588bd2
Change-Id: I23b6adc30c57182c56c713da94a77fe65c15bb45
  • Loading branch information
vmarko committed Jun 24, 2021
1 parent 306a39f commit cceaf01
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions runtime/gc/space/image_space.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3480,19 +3480,18 @@ bool ImageSpace::VerifyBootClassPathChecksums(std::string_view oat_checksums,
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(),
Expand Down

0 comments on commit cceaf01

Please sign in to comment.