Create boot image profiles with the appropriate version

Bug: 139884006
Test: m test-art-host
Change-Id: I89227d980121d548ed4b9b1e8f3c6e2c78b5ef97
diff --git a/runtime/jit/profile_saver.cc b/runtime/jit/profile_saver.cc
index 9399470..a560dff 100644
--- a/runtime/jit/profile_saver.cc
+++ b/runtime/jit/profile_saver.cc
@@ -447,7 +447,8 @@
     if (info_it == profile_cache_.end()) {
       info_it = profile_cache_.Put(
           filename,
-          new ProfileCompilationInfo(Runtime::Current()->GetArenaPool()));
+          new ProfileCompilationInfo(
+              Runtime::Current()->GetArenaPool(), options_.GetProfileBootClassPath()));
     }
     ProfileCompilationInfo* cached_info = info_it->second;
 
@@ -552,7 +553,8 @@
       total_number_of_code_cache_queries_++;
     }
     {
-      ProfileCompilationInfo info(Runtime::Current()->GetArenaPool());
+      ProfileCompilationInfo info(
+          Runtime::Current()->GetArenaPool(), options_.GetProfileBootClassPath());
       if (!info.Load(filename, /*clear_if_invalid=*/ true)) {
         LOG(WARNING) << "Could not forcefully load profile " << filename;
         continue;
diff --git a/test/595-profile-saving/expected.txt b/test/595-profile-saving/expected.txt
index 6a5618e..9e28e07 100644
--- a/test/595-profile-saving/expected.txt
+++ b/test/595-profile-saving/expected.txt
@@ -1 +1,2 @@
 JNI_OnLoad called
+IsForBootImage: true
diff --git a/test/595-profile-saving/profile-saving.cc b/test/595-profile-saving/profile-saving.cc
index b22d61e..d6ca447 100644
--- a/test/595-profile-saving/profile-saving.cc
+++ b/test/595-profile-saving/profile-saving.cc
@@ -63,5 +63,16 @@
                                                      art_method->GetDexMethodIndex()));
 }
 
+extern "C" JNIEXPORT jboolean JNICALL Java_Main_isForBootImage(JNIEnv* env,
+                                                               jclass,
+                                                               jstring filename) {
+  ScopedUtfChars filename_chars(env, filename);
+  CHECK(filename_chars.c_str() != nullptr);
+
+  ProfileCompilationInfo info;
+  info.Load(std::string(filename_chars.c_str()), /*clear_if_invalid=*/ false);
+  return info.IsForBootImage();
+}
+
 }  // namespace
 }  // namespace art
diff --git a/test/595-profile-saving/src/Main.java b/test/595-profile-saving/src/Main.java
index 18c0598..e0952e1 100644
--- a/test/595-profile-saving/src/Main.java
+++ b/test/595-profile-saving/src/Main.java
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Method;
@@ -42,6 +41,8 @@
         System.out.println("Class loader does not match boot class");
       }
       testAddMethodToProfile(file, bootMethod);
+
+      System.out.println("IsForBootImage: " + isForBootImage(file.getPath()));
     } finally {
       if (file != null) {
         file.delete();
@@ -66,6 +67,8 @@
   public static native void ensureProfileProcessing();
   // Checks if the profiles saver knows about the method.
   public static native boolean presentInProfile(String profile, Method method);
+  // Returns true if the profile is for the boot image.
+  public static native boolean isForBootImage(String profile);
 
   private static final String TEMP_FILE_NAME_PREFIX = "dummy";
   private static final String TEMP_FILE_NAME_SUFFIX = "-file";