Cache boot classpath checksums at runtime init.
To speed up oat file checksums check.
Test: test.py
Bug: 191828947
Change-Id: I2fe97a5626220470ec3edf457a3a24e7d50ce6d7
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index f323647..1518195 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -646,15 +646,24 @@
Runtime* runtime = Runtime::Current();
std::string error_msg;
- bool result = gc::space::ImageSpace::VerifyBootClassPathChecksums(
- oat_boot_class_path_checksums_view,
- oat_boot_class_path_view,
- ArrayRef<const std::string>(runtime->GetImageLocations()),
- ArrayRef<const std::string>(runtime->GetBootClassPathLocations()),
- ArrayRef<const std::string>(runtime->GetBootClassPath()),
- ArrayRef<const int>(runtime->GetBootClassPathFds()),
- isa_,
- &error_msg);
+ bool result = false;
+ // Fast path when the runtime boot classpath cheksums and boot classpath
+ // locations directly match.
+ if (oat_boot_class_path_checksums_view == runtime->GetBootClassPathChecksums() &&
+ isa_ == kRuntimeISA &&
+ oat_boot_class_path_view == android::base::Join(runtime->GetBootClassPathLocations(), ":")) {
+ result = true;
+ } else {
+ result = gc::space::ImageSpace::VerifyBootClassPathChecksums(
+ oat_boot_class_path_checksums_view,
+ oat_boot_class_path_view,
+ ArrayRef<const std::string>(runtime->GetImageLocations()),
+ ArrayRef<const std::string>(runtime->GetBootClassPathLocations()),
+ ArrayRef<const std::string>(runtime->GetBootClassPath()),
+ ArrayRef<const int>(runtime->GetBootClassPathFds()),
+ isa_,
+ &error_msg);
+ }
if (!result) {
VLOG(oat) << "Failed to verify checksums of oat file " << oat_file.GetLocation()
<< " error: " << error_msg;