Rewrite profile file format.

The new format contains one mandatory section and several
optional sections. This allows extending the profile with
new sections that shall be ignored by old versions of ART.

We add an "extra descriptors" section to support class
references without a `dex::TypeId` in the referencing dex
file. Type indexes between the dex file's `NumTypeIds()`
and `DexFile::kDexNoIndex16` are used to index these extra
descriptors. This prepares for collecting array classes
which shall be tied to the element type's dex file even
when the array type is not needed by that dex file and has
been used only from another dex file. It also allows inline
caches to be self-contained, so we can remove the profile
index from data structures and serialized data.

The creation of the the binary profile from text files is
updated to correctly allow array types to be stored as the
profiled classes using the "extra descriptors". However,
the interface for filling in inline caches remains unchanged
for now, so we require a `TypeId` in one of the processed
dex files. The data collection by JIT has not been updated.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing --speed-profile
Test: boots.
Test: atest BootImageProfileTest
Bug: 148067697
Change-Id: Idd5f709bdc0ab4a3c7480d69d1dfac72d6e818fc
diff --git a/profman/profile_assistant.cc b/profman/profile_assistant.cc
index ba5be4d..614a736 100644
--- a/profman/profile_assistant.cc
+++ b/profman/profile_assistant.cc
@@ -53,7 +53,7 @@
 
   // Merge all current profiles.
   for (size_t i = 0; i < profile_files.size(); i++) {
-    ProfileCompilationInfo cur_info;
+    ProfileCompilationInfo cur_info(options.IsBootImageMerge());
     if (!cur_info.Load(profile_files[i]->Fd(), /*merge_classes=*/ true, filter_fn)) {
       LOG(WARNING) << "Could not load profile file at index " << i;
       if (options.IsForceMerge()) {
@@ -62,22 +62,12 @@
         // cleared lazily.
         continue;
       }
-      return kErrorBadProfiles;
-    }
-
-    // Check version mismatch.
-    // This may happen during profile analysis if one profile is regular and
-    // the other one is for the boot image. For example when switching on-off
-    // the boot image profiles.
-    if (!info.SameVersion(cur_info)) {
-      if (options.IsForceMerge()) {
-        // If we have to merge forcefully, ignore the current profile and
-        // continue to the next one.
-        continue;
-      } else {
-        // Otherwise, return an error.
+      // TODO: Do we really need to use a different error code for version mismatch?
+      ProfileCompilationInfo wrong_info(!options.IsBootImageMerge());
+      if (wrong_info.Load(profile_files[i]->Fd(), /*merge_classes=*/ true, filter_fn)) {
         return kErrorDifferentVersions;
       }
+      return kErrorBadProfiles;
     }
 
     if (!info.MergeWith(cur_info)) {