Compute oat and odex filenames eagerly.

Because we almost always need both of them anyway, and they aren't
expensive to compute.

Test: oat file assistant tests.
Change-Id: I328ea51da6eb8700329f829a0458b02e12d1ee9e
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index ac329a3..8700a90 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -81,11 +81,18 @@
     load_executable_ = false;
   }
 
-  // If the user gave a target oat location, save that as the cached oat
-  // location now so we won't try to construct the default location later.
+  std::string error_msg;
+  if (!DexLocationToOdexFilename(dex_location_, isa_, &odex_file_name_, &error_msg)) {
+    LOG(WARNING) << "Failed to determine odex file name: " << error_msg;
+  }
+
   if (oat_location != nullptr) {
-    cached_oat_file_name_ = std::string(oat_location);
-    cached_oat_file_name_attempted_ = true;
+    oat_file_name_ = std::string(oat_location);
+  } else {
+    if (!DexLocationToOatFilename(dex_location_, isa_, &oat_file_name_, &error_msg)) {
+      LOG(WARNING) << "Failed to determine oat file name for dex location "
+        << dex_location_ << ": " << error_msg;
+    }
   }
 }
 
@@ -351,17 +358,7 @@
 }
 
 const std::string* OatFileAssistant::OdexFileName() {
-  if (!cached_odex_file_name_attempted_) {
-    cached_odex_file_name_attempted_ = true;
-
-    std::string error_msg;
-    if (!DexLocationToOdexFilename(dex_location_, isa_, &cached_odex_file_name_, &error_msg)) {
-      // If we can't figure out the odex file, we treat it as if the odex
-      // file was inaccessible.
-      LOG(WARNING) << "Failed to determine odex file name: " << error_msg;
-    }
-  }
-  return cached_odex_file_name_.empty() ? nullptr : &cached_odex_file_name_;
+  return odex_file_name_.empty() ? nullptr : &odex_file_name_;
 }
 
 bool OatFileAssistant::OdexFileExists() {
@@ -412,18 +409,7 @@
 }
 
 const std::string* OatFileAssistant::OatFileName() {
-  if (!cached_oat_file_name_attempted_) {
-    cached_oat_file_name_attempted_ = true;
-
-    std::string error_msg;
-    if (!DexLocationToOatFilename(dex_location_, isa_, &cached_oat_file_name_, &error_msg)) {
-      // If we can't determine the oat file name, we treat the oat file as
-      // inaccessible.
-      LOG(WARNING) << "Failed to determine oat file name for dex location "
-        << dex_location_ << ": " << error_msg;
-    }
-  }
-  return cached_oat_file_name_.empty() ? nullptr : &cached_oat_file_name_;
+  return oat_file_name_.empty() ? nullptr : &oat_file_name_;
 }
 
 bool OatFileAssistant::OatFileExists() {
diff --git a/runtime/oat_file_assistant.h b/runtime/oat_file_assistant.h
index 95a6687..04bd20c 100644
--- a/runtime/oat_file_assistant.h
+++ b/runtime/oat_file_assistant.h
@@ -391,12 +391,9 @@
   bool required_dex_checksum_found_;
   bool has_original_dex_files_;
 
-  // Cached value of the odex file name.
-  // This should be accessed only by the OdexFileName() method.
   // The sentinel value "" is used if the odex file name could not be
   // determined.
-  bool cached_odex_file_name_attempted_ = false;
-  std::string cached_odex_file_name_;
+  std::string odex_file_name_;
 
   // Cached value of the loaded odex file.
   // Use the GetOdexFile method rather than accessing this directly, unless you
@@ -408,12 +405,9 @@
   bool odex_file_status_attempted_ = false;
   OatStatus cached_odex_file_status_;
 
-  // Cached value of the oat file name.
-  // This should be accessed only by the OatFileName() method.
   // The sentinel value "" is used if the oat file name could not be
   // determined.
-  bool cached_oat_file_name_attempted_ = false;
-  std::string cached_oat_file_name_;
+  std::string oat_file_name_;
 
   // Cached value of the loaded oat file.
   // Use the GetOatFile method rather than accessing this directly, unless you