Move profile compilation info to CompilerOptions.

Remove one HInliner dependency on the CompilerDriver.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: If6f0ab864095641b5697c8c6f5100520f91d5e53
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
index fc8cd52..599f4aa 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -188,13 +188,13 @@
   compiler_options_->compile_pic_ = false;  // Non-PIC boot image is a test configuration.
   compiler_options_->SetCompilerFilter(GetCompilerFilter());
   compiler_options_->image_classes_.swap(*GetImageClasses());
+  compiler_options_->profile_compilation_info_ = GetProfileCompilationInfo();
   compiler_driver_.reset(new CompilerDriver(compiler_options_.get(),
                                             verification_results_.get(),
                                             compiler_kind_,
                                             &compiler_options_->image_classes_,
                                             number_of_threads_,
-                                            /* swap_fd */ -1,
-                                            GetProfileCompilationInfo()));
+                                            /* swap_fd */ -1));
 }
 
 void CommonCompilerTest::SetUpRuntimeOptions(RuntimeOptions* options) {
diff --git a/compiler/driver/compiled_method_storage_test.cc b/compiler/driver/compiled_method_storage_test.cc
index 5e2f444..8b35bd3 100644
--- a/compiler/driver/compiled_method_storage_test.cc
+++ b/compiler/driver/compiled_method_storage_test.cc
@@ -33,8 +33,7 @@
                         Compiler::kOptimizing,
                         /* image_classes */ nullptr,
                         /* thread_count */ 1u,
-                        /* swap_fd */ -1,
-                        /* profile_compilation_info */ nullptr);
+                        /* swap_fd */ -1);
   CompiledMethodStorage* storage = driver.GetCompiledMethodStorage();
 
   ASSERT_TRUE(storage->DedupeEnabled());  // The default.
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 8c276bb..f8e2dff 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -248,8 +248,7 @@
     Compiler::Kind compiler_kind,
     HashSet<std::string>* image_classes,
     size_t thread_count,
-    int swap_fd,
-    const ProfileCompilationInfo* profile_compilation_info)
+    int swap_fd)
     : compiler_options_(compiler_options),
       verification_results_(verification_results),
       compiler_(Compiler::Create(this, compiler_kind)),
@@ -261,7 +260,6 @@
       stats_(new AOTCompilationStats),
       compiler_context_(nullptr),
       compiled_method_storage_(swap_fd),
-      profile_compilation_info_(profile_compilation_info),
       max_arena_alloc_(0),
       dex_to_dex_compiler_(this) {
   DCHECK(compiler_options_ != nullptr);
@@ -731,9 +729,11 @@
         continue;
       }
 
+      const ProfileCompilationInfo* profile_compilation_info =
+          GetCompilerOptions().GetProfileCompilationInfo();
       const bool is_startup_class =
-          profile_compilation_info_ != nullptr &&
-          profile_compilation_info_->ContainsClass(*dex_file, accessor.GetClassIdx());
+          profile_compilation_info != nullptr &&
+          profile_compilation_info->ContainsClass(*dex_file, accessor.GetClassIdx());
 
       for (const ClassAccessor::Method& method : accessor.GetMethods()) {
         const bool is_clinit = (method.GetAccessFlags() & kAccConstructor) != 0 &&
@@ -741,8 +741,8 @@
         const bool is_startup_clinit = is_startup_class && is_clinit;
 
         if (only_startup_strings &&
-            profile_compilation_info_ != nullptr &&
-            (!profile_compilation_info_->GetMethodHotness(method.GetReference()).IsStartup() &&
+            profile_compilation_info != nullptr &&
+            (!profile_compilation_info->GetMethodHotness(method.GetReference()).IsStartup() &&
              !is_startup_clinit)) {
           continue;
         }
@@ -981,12 +981,14 @@
     return true;
   }
   // If we are using a profile filter but do not have a profile compilation info, compile nothing.
-  if (profile_compilation_info_ == nullptr) {
+  const ProfileCompilationInfo* profile_compilation_info =
+      GetCompilerOptions().GetProfileCompilationInfo();
+  if (profile_compilation_info == nullptr) {
     return false;
   }
   // Compile only hot methods, it is the profile saver's job to decide what startup methods to mark
   // as hot.
-  bool result = profile_compilation_info_->GetMethodHotness(method_ref).IsHot();
+  bool result = profile_compilation_info->GetMethodHotness(method_ref).IsHot();
 
   if (kDebugProfileGuidedCompilation) {
     LOG(INFO) << "[ProfileGuidedCompilation] "
@@ -2644,10 +2646,12 @@
                              const std::vector<const DexFile*>& dex_files,
                              TimingLogger* timings) {
   if (kDebugProfileGuidedCompilation) {
+    const ProfileCompilationInfo* profile_compilation_info =
+        GetCompilerOptions().GetProfileCompilationInfo();
     LOG(INFO) << "[ProfileGuidedCompilation] " <<
-        ((profile_compilation_info_ == nullptr)
+        ((profile_compilation_info == nullptr)
             ? "null"
-            : profile_compilation_info_->DumpInfo(dex_files));
+            : profile_compilation_info->DumpInfo(dex_files));
   }
 
   dex_to_dex_compiler_.ClearState();
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index f42e555..b0f2dac 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -99,8 +99,7 @@
                  Compiler::Kind compiler_kind,
                  HashSet<std::string>* image_classes,
                  size_t thread_count,
-                 int swap_fd,
-                 const ProfileCompilationInfo* profile_compilation_info);
+                 int swap_fd);
 
   ~CompilerDriver();
 
@@ -266,10 +265,6 @@
     return &compiled_method_storage_;
   }
 
-  const ProfileCompilationInfo* GetProfileCompilationInfo() const {
-    return profile_compilation_info_;
-  }
-
   // Is `boot_image_filename` the name of a core image (small boot
   // image used for ART testing only)?
   static bool IsCoreImageFilename(const std::string& boot_image_filename) {
@@ -419,9 +414,6 @@
 
   CompiledMethodStorage compiled_method_storage_;
 
-  // Info for profile guided compilation.
-  const ProfileCompilationInfo* const profile_compilation_info_;
-
   size_t max_arena_alloc_;
 
   // Compiler for dex to dex (quickening).
diff --git a/compiler/driver/compiler_options.cc b/compiler/driver/compiler_options.cc
index 6b0e456..be8e10e 100644
--- a/compiler/driver/compiler_options.cc
+++ b/compiler/driver/compiler_options.cc
@@ -60,6 +60,7 @@
       dump_pass_timings_(false),
       dump_stats_(false),
       top_k_profile_threshold_(kDefaultTopKProfileThreshold),
+      profile_compilation_info_(nullptr),
       verbose_methods_(),
       abort_on_hard_verifier_failure_(false),
       abort_on_soft_verifier_failure_(false),
diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h
index 4a6bbfa..77f8482 100644
--- a/compiler/driver/compiler_options.h
+++ b/compiler/driver/compiler_options.h
@@ -42,6 +42,7 @@
 class DexFile;
 enum class InstructionSet;
 class InstructionSetFeatures;
+class ProfileCompilationInfo;
 
 class CompilerOptions final {
  public:
@@ -218,6 +219,10 @@
     return compile_pic_;
   }
 
+  const ProfileCompilationInfo* GetProfileCompilationInfo() const {
+    return profile_compilation_info_;
+  }
+
   bool HasVerboseMethods() const {
     return !verbose_methods_.empty();
   }
@@ -370,6 +375,9 @@
   // When using a profile file only the top K% of the profiled samples will be compiled.
   double top_k_profile_threshold_;
 
+  // Info for profile guided compilation.
+  const ProfileCompilationInfo* profile_compilation_info_;
+
   // Vector of methods to have verbose output enabled for.
   std::vector<std::string> verbose_methods_;
 
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc
index bc8641a..f22f61f 100644
--- a/compiler/jit/jit_compiler.cc
+++ b/compiler/jit/jit_compiler.cc
@@ -151,8 +151,7 @@
       Compiler::kOptimizing,
       /* image_classes */ nullptr,
       /* thread_count */ 1,
-      /* swap_fd */ -1,
-      /* profile_compilation_info */ nullptr));
+      /* swap_fd */ -1));
   // Disable dedupe so we can remove compiled methods.
   compiler_driver_->SetDedupeEnabled(false);
 
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index f56f9cb..c1daf95 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -680,7 +680,7 @@
     /*out*/Handle<mirror::ObjectArray<mirror::Class>>* inline_cache)
     REQUIRES_SHARED(Locks::mutator_lock_) {
   DCHECK(Runtime::Current()->IsAotCompiler());
-  const ProfileCompilationInfo* pci = compiler_driver_->GetProfileCompilationInfo();
+  const ProfileCompilationInfo* pci = codegen_->GetCompilerOptions().GetProfileCompilationInfo();
   if (pci == nullptr) {
     return kInlineCacheNoData;
   }
@@ -1647,7 +1647,7 @@
         }
       }
       if (needs_constructor_barrier) {
-        // See CompilerDriver::RequiresConstructorBarrier for more details.
+        // See DexCompilationUnit::RequiresConstructorBarrier for more details.
         DCHECK(obj != nullptr) << "only non-static methods can have a constructor fence";
 
         HConstructorFence* constructor_fence =
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index f0f2b3e..db610f1 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1792,14 +1792,14 @@
         compiler_options_->no_inline_from_.swap(no_inline_from_dex_files);
       }
     }
+    compiler_options_->profile_compilation_info_ = profile_compilation_info_.get();
 
     driver_.reset(new CompilerDriver(compiler_options_.get(),
                                      verification_results_.get(),
                                      compiler_kind_,
                                      &compiler_options_->image_classes_,
                                      thread_count_,
-                                     swap_fd_,
-                                     profile_compilation_info_.get()));
+                                     swap_fd_));
     if (!IsBootImage()) {
       driver_->SetClasspathDexFiles(class_loader_context_->FlattenOpenedDexFiles());
     }