Add a profiling library

Move profile_compilation_info to a separate library.  Another step
towards building many of our tools without libart[d].

Bug: 78459333
Test: make -j 50 checkbuild
Change-Id: Ib281d3d1fde6d06ebb429c5d39d62a7038af0f44
diff --git a/Android.bp b/Android.bp
index e09b774..32a96e1 100644
--- a/Android.bp
+++ b/Android.bp
@@ -37,6 +37,7 @@
     "imgdiag",
     "libartbase",
     "libdexfile",
+    "libprofile",
     "oatdump",
     "openjdkjvm",
     "openjdkjvmti",
diff --git a/compiler/Android.bp b/compiler/Android.bp
index ec9fef7..5884a54 100644
--- a/compiler/Android.bp
+++ b/compiler/Android.bp
@@ -244,6 +244,7 @@
     },
     shared_libs: [
         "libart",
+        "libprofile",
         "libdexfile",
     ],
 
@@ -292,6 +293,7 @@
     },
     shared_libs: [
         "libartd",
+        "libprofiled",
         "libdexfiled",
     ],
 }
@@ -408,6 +410,7 @@
     ],
 
     shared_libs: [
+        "libprofiled",
         "libartd-compiler",
         "libartd-simulator-container",
         "libvixld-arm",
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 41b7e7b..fbbb4e9 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -57,7 +57,6 @@
 #include "gc/space/space.h"
 #include "handle_scope-inl.h"
 #include "intrinsics_enum.h"
-#include "jit/profile_compilation_info.h"
 #include "jni_internal.h"
 #include "linker/linker_patch.h"
 #include "mirror/class-inl.h"
@@ -69,6 +68,7 @@
 #include "mirror/throwable.h"
 #include "nativehelper/ScopedLocalRef.h"
 #include "object_lock.h"
+#include "profile/profile_compilation_info.h"
 #include "runtime.h"
 #include "runtime_intrinsics.h"
 #include "scoped_thread_state_change-inl.h"
diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc
index 1332280..856cb36 100644
--- a/compiler/driver/compiler_driver_test.cc
+++ b/compiler/driver/compiler_driver_test.cc
@@ -30,12 +30,12 @@
 #include "dex/dex_file_types.h"
 #include "gc/heap.h"
 #include "handle_scope-inl.h"
-#include "jit/profile_compilation_info.h"
 #include "mirror/class-inl.h"
 #include "mirror/class_loader.h"
 #include "mirror/dex_cache-inl.h"
 #include "mirror/object-inl.h"
 #include "mirror/object_array-inl.h"
+#include "profile/profile_compilation_info.h"
 #include "scoped_thread_state_change-inl.h"
 
 namespace art {
diff --git a/compiler/optimizing/inliner.h b/compiler/optimizing/inliner.h
index 02465d3..6db3b13 100644
--- a/compiler/optimizing/inliner.h
+++ b/compiler/optimizing/inliner.h
@@ -19,8 +19,8 @@
 
 #include "dex/dex_file_types.h"
 #include "dex/invoke_type.h"
-#include "jit/profile_compilation_info.h"
 #include "optimization.h"
+#include "profile/profile_compilation_info.h"
 
 namespace art {
 
diff --git a/dex2oat/Android.bp b/dex2oat/Android.bp
index 623732f..4fafca9 100644
--- a/dex2oat/Android.bp
+++ b/dex2oat/Android.bp
@@ -70,6 +70,7 @@
     },
     generated_sources: ["art_dex2oat_operator_srcs"],
     shared_libs: [
+        "libprofile",
         "libbase",
         "liblz4",
         "liblzma",
@@ -196,6 +197,7 @@
         "dex2oat-pgo-defaults",
     ],
     shared_libs: [
+        "libprofile",
         "libart-compiler",
         "libart-dexlayout",
         "libart",
@@ -232,6 +234,7 @@
         "dex2oat-defaults",
     ],
     shared_libs: [
+        "libprofiled",
         "libartd-compiler",
         "libartd-dexlayout",
         "libartd",
@@ -264,6 +267,7 @@
         "-z muldefs",
     ],
     static_libs: [
+        "libprofile",
         "libart-dex2oat",
         "libart-compiler",
         "libart-dexlayout",
@@ -303,6 +307,7 @@
         "libartd-compiler",
         "libartd-dexlayout",
         "libartd",
+        "libprofiled",
         "libdexfiled",
         "libvixld-arm",
         "libvixld-arm64",
@@ -364,6 +369,7 @@
         "external/zlib",
     ],
     shared_libs: [
+        "libprofiled",
         "libartd-compiler",
         "libartd-dexlayout",
         "libbase",
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 3fe9c47..df38ee3 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -79,7 +79,6 @@
 #include "gc/verification.h"
 #include "interpreter/unstarted_runtime.h"
 #include "java_vm_ext.h"
-#include "jit/profile_compilation_info.h"
 #include "linker/buffered_output_stream.h"
 #include "linker/elf_writer.h"
 #include "linker/elf_writer_quick.h"
@@ -93,6 +92,7 @@
 #include "mirror/object_array-inl.h"
 #include "oat_file.h"
 #include "oat_file_assistant.h"
+#include "profile/profile_compilation_info.h"
 #include "runtime.h"
 #include "runtime_options.h"
 #include "scoped_thread_state_change-inl.h"
diff --git a/dex2oat/dex2oat_image_test.cc b/dex2oat/dex2oat_image_test.cc
index 11c0c95..0366467 100644
--- a/dex2oat/dex2oat_image_test.cc
+++ b/dex2oat/dex2oat_image_test.cc
@@ -34,7 +34,7 @@
 #include "dex/dex_file-inl.h"
 #include "dex/dex_file_loader.h"
 #include "dex/method_reference.h"
-#include "jit/profile_compilation_info.h"
+#include "profile/profile_compilation_info.h"
 #include "runtime.h"
 
 namespace art {
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index a229d7d..2fe16f7 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -38,9 +38,9 @@
 #include "dex/dex_file_loader.h"
 #include "dex2oat_environment_test.h"
 #include "dex2oat_return_codes.h"
-#include "jit/profile_compilation_info.h"
 #include "oat.h"
 #include "oat_file.h"
+#include "profile/profile_compilation_info.h"
 #include "vdex_file.h"
 #include "ziparchive/zip_writer.h"
 
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index d3f4754..4046dc1 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -51,7 +51,6 @@
 #include "gc/space/space.h"
 #include "handle_scope-inl.h"
 #include "image_writer.h"
-#include "jit/profile_compilation_info.h"
 #include "linker/buffered_output_stream.h"
 #include "linker/file_output_stream.h"
 #include "linker/index_bss_mapping_encoder.h"
@@ -63,6 +62,7 @@
 #include "mirror/dex_cache-inl.h"
 #include "mirror/object-inl.h"
 #include "oat_quick_method_header.h"
+#include "profile/profile_compilation_info.h"
 #include "quicken_info.h"
 #include "scoped_thread_state_change-inl.h"
 #include "utils/dex_cache_arrays_layout-inl.h"
diff --git a/dex2oat/linker/oat_writer_test.cc b/dex2oat/linker/oat_writer_test.cc
index 208e96f..1699153 100644
--- a/dex2oat/linker/oat_writer_test.cc
+++ b/dex2oat/linker/oat_writer_test.cc
@@ -33,7 +33,6 @@
 #include "driver/compiler_driver.h"
 #include "driver/compiler_options.h"
 #include "entrypoints/quick/quick_entrypoints.h"
-#include "jit/profile_compilation_info.h"
 #include "linker/buffered_output_stream.h"
 #include "linker/elf_writer.h"
 #include "linker/elf_writer_quick.h"
@@ -45,6 +44,7 @@
 #include "mirror/object_array-inl.h"
 #include "oat_file-inl.h"
 #include "oat_writer.h"
+#include "profile/profile_compilation_info.h"
 #include "scoped_thread_state_change-inl.h"
 #include "vdex_file.h"
 
diff --git a/dexlayout/Android.bp b/dexlayout/Android.bp
index 33ba58f..b009774 100644
--- a/dexlayout/Android.bp
+++ b/dexlayout/Android.bp
@@ -41,6 +41,7 @@
     shared_libs: [
         "libart",
         "libdexfile",
+        "libprofile",
     ],
 
     target: {
@@ -61,6 +62,7 @@
     shared_libs: [
         "libartd",
         "libdexfiled",
+        "libprofiled",
     ],
 }
 
@@ -78,6 +80,7 @@
     name: "dexlayout",
     defaults: ["dexlayout-defaults"],
     shared_libs: [
+        "libprofile",
         "libart",
         "libart-dexlayout",
     ],
@@ -90,6 +93,7 @@
         "dexlayout-defaults",
     ],
     shared_libs: [
+        "libprofiled",
         "libartd",
         "libartd-dexlayout",
     ],
@@ -98,7 +102,10 @@
 art_cc_test {
     name: "art_dexlayout_tests",
     defaults: ["art_gtest_defaults"],
-    shared_libs: ["libart-dexlayout"],
+    shared_libs: [
+        "libprofiled",
+        "libartd-dexlayout",
+    ],
     srcs: ["dexlayout_test.cc"],
 }
 
diff --git a/dexlayout/dex_visualize.cc b/dexlayout/dex_visualize.cc
index 516a338..c8aac94 100644
--- a/dexlayout/dex_visualize.cc
+++ b/dexlayout/dex_visualize.cc
@@ -33,7 +33,7 @@
 
 #include "dex_ir.h"
 #include "dexlayout.h"
-#include "jit/profile_compilation_info.h"
+#include "profile/profile_compilation_info.h"
 
 namespace art {
 
diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc
index 7a8c31b..62dd1a9 100644
--- a/dexlayout/dexlayout.cc
+++ b/dexlayout/dexlayout.cc
@@ -49,7 +49,7 @@
 #include "dex_verify.h"
 #include "dex_visualize.h"
 #include "dex_writer.h"
-#include "jit/profile_compilation_info.h"
+#include "profile/profile_compilation_info.h"
 
 namespace art {
 
diff --git a/dexlayout/dexlayout_main.cc b/dexlayout/dexlayout_main.cc
index f81d16c..185c142 100644
--- a/dexlayout/dexlayout_main.cc
+++ b/dexlayout/dexlayout_main.cc
@@ -33,7 +33,7 @@
 
 #include "base/logging.h"  // For InitLogging.
 #include "base/mem_map.h"
-#include "jit/profile_compilation_info.h"
+#include "profile/profile_compilation_info.h"
 #include "runtime.h"
 
 namespace art {
diff --git a/dexlayout/dexlayout_test.cc b/dexlayout/dexlayout_test.cc
index 6719d08..f148b94 100644
--- a/dexlayout/dexlayout_test.cc
+++ b/dexlayout/dexlayout_test.cc
@@ -31,7 +31,7 @@
 #include "dex/dex_file_loader.h"
 #include "dexlayout.h"
 #include "exec_utils.h"
-#include "jit/profile_compilation_info.h"
+#include "profile/profile_compilation_info.h"
 
 namespace art {
 
diff --git a/libprofile/Android.bp b/libprofile/Android.bp
new file mode 100644
index 0000000..bcb90cb
--- /dev/null
+++ b/libprofile/Android.bp
@@ -0,0 +1,102 @@
+//
+// Copyright (C) 2018 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_defaults {
+    name: "libprofile_defaults",
+    defaults: ["art_defaults"],
+    host_supported: true,
+    srcs: [
+        "profile/profile_compilation_info.cc",
+    ],
+    target: {
+        android: {
+            static_libs: [
+                // ZipArchive support, the order matters here to get all symbols.
+                "libziparchive",
+                "libz",
+            ],
+	    shared_libs: [
+	        // For android::FileMap used by libziparchive.
+                "libutils",
+	    ],
+        },
+        host: {
+            shared_libs: [
+                "libziparchive",
+                "libz",
+            ],
+        },
+    },
+    //generated_sources: ["art_libartbase_operator_srcs"],
+    cflags: ["-DBUILDING_LIBART=1"],
+    shared_libs: [
+        "libartbase",
+        "libdexfile",
+	// For atrace.
+        "libcutils",
+    ],
+    export_include_dirs: ["."],
+    // ART's macros.h depends on libbase's macros.h.
+    // Note: runtime_options.h depends on cmdline. But we don't really want to export this
+    //       generically. dex2oat takes care of it itself.
+    export_shared_lib_headers: ["libbase"],
+}
+
+art_cc_library {
+    name: "libprofile",
+    defaults: ["libprofile_defaults"],
+    // Leave the symbols in the shared library so that stack unwinders can
+    // produce meaningful name resolution.
+    strip: {
+        keep_symbols: true,
+    },
+    shared_libs: [
+        "libbase",
+        "libziparchive",
+    ],
+    export_shared_lib_headers: ["libbase"],
+}
+
+art_cc_library {
+    name: "libprofiled",
+    defaults: [
+        "art_debug_defaults",
+        "libprofile_defaults",
+    ],
+    shared_libs: [
+        "libbase",
+        "libziparchive",
+    ],
+    export_shared_lib_headers: ["libbase"],
+}
+
+// For now many of these tests still use CommonRuntimeTest, almost universally because of
+// ScratchFile and related.
+// TODO: Remove CommonRuntimeTest dependency from these tests.
+art_cc_test {
+    name: "art_libprofile_tests",
+    defaults: [
+        "art_gtest_defaults",
+    ],
+    srcs: [
+        "profile/profile_compilation_info_test.cc",
+    ],
+    shared_libs: [
+        "libartbased",
+        "libdexfiled",
+        "libziparchive",
+    ],
+}
diff --git a/runtime/jit/profile_compilation_info.cc b/libprofile/profile/profile_compilation_info.cc
similarity index 98%
rename from runtime/jit/profile_compilation_info.cc
rename to libprofile/profile/profile_compilation_info.cc
index d27465d..0e0c3c5 100644
--- a/runtime/jit/profile_compilation_info.cc
+++ b/libprofile/profile/profile_compilation_info.cc
@@ -46,7 +46,6 @@
 #include "base/utils.h"
 #include "base/zip_archive.h"
 #include "dex/dex_file_loader.h"
-#include "jit/profiling_info.h"
 
 namespace art {
 
@@ -70,12 +69,12 @@
 static constexpr uint8_t kIsMissingTypesEncoding = 6;
 static constexpr uint8_t kIsMegamorphicEncoding = 7;
 
-static_assert(sizeof(InlineCache::kIndividualCacheSize) == sizeof(uint8_t),
-              "InlineCache::kIndividualCacheSize does not have the expect type size");
-static_assert(InlineCache::kIndividualCacheSize < kIsMegamorphicEncoding,
-              "InlineCache::kIndividualCacheSize is larger than expected");
-static_assert(InlineCache::kIndividualCacheSize < kIsMissingTypesEncoding,
-              "InlineCache::kIndividualCacheSize is larger than expected");
+static_assert(sizeof(ProfileCompilationInfo::kIndividualInlineCacheSize) == sizeof(uint8_t),
+              "InlineCache::kIndividualInlineCacheSize does not have the expect type size");
+static_assert(ProfileCompilationInfo::kIndividualInlineCacheSize < kIsMegamorphicEncoding,
+              "InlineCache::kIndividualInlineCacheSize is larger than expected");
+static_assert(ProfileCompilationInfo::kIndividualInlineCacheSize < kIsMissingTypesEncoding,
+              "InlineCache::kIndividualInlineCacheSize is larger than expected");
 
 static bool ChecksumMatch(uint32_t dex_file_checksum, uint32_t checksum) {
   return kDebugIgnoreChecksum || dex_file_checksum == checksum;
@@ -120,7 +119,7 @@
   }
 
   // Check if the adding the type will cause the cache to become megamorphic.
-  if (classes.size() + 1 >= InlineCache::kIndividualCacheSize) {
+  if (classes.size() + 1 >= ProfileCompilationInfo::kIndividualInlineCacheSize) {
     is_megamorphic = true;
     classes.clear();
     return;
@@ -503,7 +502,7 @@
       continue;
     }
 
-    DCHECK_LT(classes.size(), InlineCache::kIndividualCacheSize);
+    DCHECK_LT(classes.size(), ProfileCompilationInfo::kIndividualInlineCacheSize);
     DCHECK_NE(classes.size(), 0u) << "InlineCache contains a dex_pc with 0 classes";
 
     SafeMap<uint8_t, std::vector<dex::TypeIndex>> dex_to_classes_map;
diff --git a/runtime/jit/profile_compilation_info.h b/libprofile/profile/profile_compilation_info.h
similarity index 98%
rename from runtime/jit/profile_compilation_info.h
rename to libprofile/profile/profile_compilation_info.h
index f4c8c72..32c796c 100644
--- a/runtime/jit/profile_compilation_info.h
+++ b/libprofile/profile/profile_compilation_info.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef ART_RUNTIME_JIT_PROFILE_COMPILATION_INFO_H_
-#define ART_RUNTIME_JIT_PROFILE_COMPILATION_INFO_H_
+#ifndef ART_LIBPROFILE_PROFILE_PROFILE_COMPILATION_INFO_H_
+#define ART_LIBPROFILE_PROFILE_PROFILE_COMPILATION_INFO_H_
 
 #include <set>
 #include <vector>
@@ -75,6 +75,8 @@
 
   static const char* kDexMetadataProfileEntry;
 
+  static constexpr uint8_t kIndividualInlineCacheSize = 5;
+
   // Data structures for encoding the offline representation of inline caches.
   // This is exposed as public in order to make it available to dex2oat compilations
   // (see compiler/optimizing/inliner.cc).
@@ -809,4 +811,4 @@
 
 }  // namespace art
 
-#endif  // ART_RUNTIME_JIT_PROFILE_COMPILATION_INFO_H_
+#endif  // ART_LIBPROFILE_PROFILE_PROFILE_COMPILATION_INFO_H_
diff --git a/runtime/jit/profile_compilation_info_test.cc b/libprofile/profile/profile_compilation_info_test.cc
similarity index 99%
rename from runtime/jit/profile_compilation_info_test.cc
rename to libprofile/profile/profile_compilation_info_test.cc
index 0ebadc0..b0f9649 100644
--- a/runtime/jit/profile_compilation_info_test.cc
+++ b/libprofile/profile/profile_compilation_info_test.cc
@@ -26,10 +26,10 @@
 #include "dex/method_reference.h"
 #include "dex/type_reference.h"
 #include "handle_scope-inl.h"
-#include "jit/profile_compilation_info.h"
 #include "linear_alloc.h"
 #include "mirror/class-inl.h"
 #include "mirror/class_loader.h"
+#include "profile/profile_compilation_info.h"
 #include "scoped_thread_state_change-inl.h"
 #include "ziparchive/zip_writer.h"
 
diff --git a/oatdump/Android.bp b/oatdump/Android.bp
index 8c21538..be12c8e 100644
--- a/oatdump/Android.bp
+++ b/oatdump/Android.bp
@@ -37,6 +37,7 @@
         "libart-compiler",
         "libart-disassembler",
         "libdexfile",
+        "libprofile",
         "libbase",
     ],
 }
@@ -52,6 +53,7 @@
         "libartd-compiler",
         "libartd-disassembler",
         "libdexfiled",
+        "libprofiled",
         "libbase",
     ],
 }
@@ -77,6 +79,7 @@
     static_libs: [
         "libart",
         "libdexfile",
+        "libprofile",
         "libart-compiler",
         "libart-disassembler",
         "libvixl-arm",
@@ -111,6 +114,7 @@
     static_libs: [
         "libartd",
         "libdexfiled",
+        "libprofiled",
         "libartd-compiler",
         "libartd-disassembler",
         "libvixld-arm",
diff --git a/profman/Android.bp b/profman/Android.bp
index 163be2b..3c8c72c 100644
--- a/profman/Android.bp
+++ b/profman/Android.bp
@@ -40,6 +40,7 @@
     defaults: ["profman-defaults"],
     shared_libs: [
         "libart",
+        "libprofile",
         "libdexfile",
     ],
 }
@@ -52,6 +53,7 @@
     ],
     shared_libs: [
         "libartd",
+        "libprofiled",
         "libdexfiled",
     ],
 }
@@ -61,5 +63,8 @@
     defaults: [
         "art_gtest_defaults",
     ],
+    shared_libs: [
+        "libprofiled",
+    ],
     srcs: ["profile_assistant_test.cc"],
 }
diff --git a/profman/boot_image_profile.cc b/profman/boot_image_profile.cc
index 60238e2..89c9eb8 100644
--- a/profman/boot_image_profile.cc
+++ b/profman/boot_image_profile.cc
@@ -21,7 +21,7 @@
 #include "dex/dex_file-inl.h"
 #include "dex/method_reference.h"
 #include "dex/type_reference.h"
-#include "jit/profile_compilation_info.h"
+#include "profile/profile_compilation_info.h"
 
 namespace art {
 
diff --git a/profman/profile_assistant.h b/profman/profile_assistant.h
index ee55584..c1d6f8e 100644
--- a/profman/profile_assistant.h
+++ b/profman/profile_assistant.h
@@ -21,7 +21,7 @@
 #include <vector>
 
 #include "base/scoped_flock.h"
-#include "jit/profile_compilation_info.h"
+#include "profile/profile_compilation_info.h"
 
 namespace art {
 
diff --git a/profman/profile_assistant_test.cc b/profman/profile_assistant_test.cc
index 72c285a..17b7af1 100644
--- a/profman/profile_assistant_test.cc
+++ b/profman/profile_assistant_test.cc
@@ -23,10 +23,10 @@
 #include "common_runtime_test.h"
 #include "dex/descriptors_names.h"
 #include "exec_utils.h"
-#include "jit/profile_compilation_info.h"
 #include "linear_alloc.h"
 #include "mirror/class-inl.h"
 #include "obj_ptr-inl.h"
+#include "profile/profile_compilation_info.h"
 #include "profile_assistant.h"
 #include "scoped_thread_state_change-inl.h"
 
diff --git a/profman/profman.cc b/profman/profman.cc
index 0ecc88c..12bcdc6 100644
--- a/profman/profman.cc
+++ b/profman/profman.cc
@@ -33,7 +33,6 @@
 
 #include "base/dumpable.h"
 #include "base/logging.h"  // For InitLogging.
-#include "base/mutex.h"
 #include "base/scoped_flock.h"
 #include "base/stringpiece.h"
 #include "base/time_utils.h"
@@ -48,7 +47,7 @@
 #include "dex/dex_file_loader.h"
 #include "dex/dex_file_types.h"
 #include "dex/type_reference.h"
-#include "jit/profile_compilation_info.h"
+#include "profile/profile_compilation_info.h"
 #include "profile_assistant.h"
 #include "runtime.h"
 
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 6b43205..f395623 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -112,7 +112,6 @@
         "jit/debugger_interface.cc",
         "jit/jit.cc",
         "jit/jit_code_cache.cc",
-        "jit/profile_compilation_info.cc",
         "jit/profiling_info.cc",
         "jit/profile_saver.cc",
         "jni_internal.cc",
@@ -471,6 +470,7 @@
     ],
     shared_libs: [
         "libdexfile",
+        "libprofile",
     ],
     export_shared_lib_headers: [
         "libdexfile",
@@ -495,6 +495,7 @@
     ],
     shared_libs: [
         "libdexfiled",
+        "libprofiled",
     ],
     export_shared_lib_headers: [
         "libdexfiled",
@@ -579,7 +580,6 @@
         "interpreter/unstarted_runtime_test.cc",
         "jdwp/jdwp_options_test.cc",
         "java_vm_ext_test.cc",
-        "jit/profile_compilation_info_test.cc",
         "method_handles_test.cc",
         "mirror/dex_cache_test.cc",
         "mirror/method_type_test.cc",
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 3f33f79..57c0d9d 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -83,7 +83,6 @@
 #include "jit/debugger_interface.h"
 #include "jit/jit.h"
 #include "jit/jit_code_cache.h"
-#include "jit/profile_compilation_info.h"
 #include "jni_internal.h"
 #include "linear_alloc.h"
 #include "mirror/call_site.h"
@@ -116,6 +115,7 @@
 #include "oat_file_assistant.h"
 #include "oat_file_manager.h"
 #include "object_lock.h"
+#include "profile/profile_compilation_info.h"
 #include "runtime.h"
 #include "runtime_callbacks.h"
 #include "scoped_thread_state_change-inl.h"
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 813430f..d20f760 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -31,7 +31,7 @@
 #include "jit_code_cache.h"
 #include "oat_file_manager.h"
 #include "oat_quick_method_header.h"
-#include "profile_compilation_info.h"
+#include "profile/profile_compilation_info.h"
 #include "profile_saver.h"
 #include "runtime.h"
 #include "runtime_options.h"
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 6dcc871..1c8c26c 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -41,7 +41,7 @@
 #include "oat_file-inl.h"
 #include "oat_quick_method_header.h"
 #include "object_callbacks.h"
-#include "profile_compilation_info.h"
+#include "profile/profile_compilation_info.h"
 #include "scoped_thread_state_change-inl.h"
 #include "stack.h"
 #include "thread-current-inl.h"
diff --git a/runtime/jit/profile_saver.cc b/runtime/jit/profile_saver.cc
index 53f4864..618fde8 100644
--- a/runtime/jit/profile_saver.cc
+++ b/runtime/jit/profile_saver.cc
@@ -37,8 +37,9 @@
 #include "gc/collector_type.h"
 #include "gc/gc_cause.h"
 #include "gc/scoped_gc_critical_section.h"
-#include "jit/profile_compilation_info.h"
+#include "jit/profiling_info.h"
 #include "oat_file_manager.h"
+#include "profile/profile_compilation_info.h"
 #include "scoped_thread_state_change-inl.h"
 
 namespace art {
@@ -46,6 +47,10 @@
 ProfileSaver* ProfileSaver::instance_ = nullptr;
 pthread_t ProfileSaver::profiler_pthread_ = 0U;
 
+static_assert(ProfileCompilationInfo::kIndividualInlineCacheSize ==
+              InlineCache::kIndividualCacheSize,
+              "InlineCache and ProfileCompilationInfo do not agree on kIndividualCacheSize");
+
 // At what priority to schedule the saver threads. 9 is the lowest foreground priority on device.
 static constexpr int kProfileSaverPthreadPriority = 9;
 
diff --git a/runtime/jit/profile_saver.h b/runtime/jit/profile_saver.h
index afbb3c1..02c8cd1 100644
--- a/runtime/jit/profile_saver.h
+++ b/runtime/jit/profile_saver.h
@@ -21,7 +21,7 @@
 #include "base/safe_map.h"
 #include "dex/method_reference.h"
 #include "jit_code_cache.h"
-#include "profile_compilation_info.h"
+#include "profile/profile_compilation_info.h"
 #include "profile_saver_options.h"
 
 namespace art {
diff --git a/test/595-profile-saving/profile-saving.cc b/test/595-profile-saving/profile-saving.cc
index bb9ab84..b22d61e 100644
--- a/test/595-profile-saving/profile-saving.cc
+++ b/test/595-profile-saving/profile-saving.cc
@@ -18,7 +18,6 @@
 
 #include "art_method-inl.h"
 #include "dex/method_reference.h"
-#include "jit/profile_compilation_info.h"
 #include "jit/profile_saver.h"
 #include "jni.h"
 #include "mirror/class-inl.h"
@@ -26,6 +25,7 @@
 #include "nativehelper/ScopedUtfChars.h"
 #include "oat_file_assistant.h"
 #include "oat_file_manager.h"
+#include "profile/profile_compilation_info.h"
 #include "scoped_thread_state_change-inl.h"
 #include "thread.h"
 
diff --git a/test/Android.bp b/test/Android.bp
index b9312c8..16d14cd 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -63,6 +63,7 @@
         "libvixld-arm64",
         "libart-gtest",
         "libdexfiled",
+        "libprofiled",
 
         "libbase",
         "libicuuc",
@@ -115,6 +116,7 @@
         "libartd",
         "libartd-compiler",
         "libdexfiled",
+        "libprofiled",
     ],
     static_libs: [
         "libgtest",
@@ -152,6 +154,7 @@
         "libartd",
         "libartd-compiler",
         "libdexfiled",
+        "libprofiled",
         "libbase",
         "libbacktrace",
     ],
@@ -182,6 +185,7 @@
     shared_libs: [
         "libart",
         "libdexfile",
+        "libprofile",
     ],
 }
 
@@ -195,6 +199,7 @@
     shared_libs: [
         "libartd",
         "libdexfiled",
+        "libprofiled",
     ],
 }
 
@@ -315,6 +320,7 @@
     shared_libs: [
         "libart",
         "libdexfile",
+        "libprofile",
     ],
 }
 
@@ -327,6 +333,7 @@
     shared_libs: [
         "libartd",
         "libdexfiled",
+        "libprofiled",
     ],
 }
 
@@ -458,6 +465,7 @@
     shared_libs: [
         "libart",
         "libdexfile",
+        "libprofile",
     ],
 }
 
@@ -470,6 +478,7 @@
     shared_libs: [
         "libartd",
         "libdexfiled",
+        "libprofiled",
     ],
 }
 
diff --git a/test/common/runtime_state.cc b/test/common/runtime_state.cc
index 2203bdc..a55cc79 100644
--- a/test/common/runtime_state.cc
+++ b/test/common/runtime_state.cc
@@ -25,12 +25,12 @@
 #include "instrumentation.h"
 #include "jit/jit.h"
 #include "jit/jit_code_cache.h"
-#include "jit/profile_compilation_info.h"
 #include "jit/profiling_info.h"
 #include "mirror/class-inl.h"
 #include "nativehelper/ScopedUtfChars.h"
 #include "oat_file.h"
 #include "oat_quick_method_header.h"
+#include "profile/profile_compilation_info.h"
 #include "runtime.h"
 #include "scoped_thread_state_change-inl.h"
 #include "thread-current-inl.h"