Code cleanup around compiler options and JIT.

Now support passing --verbose-methods and --dump-cfg.

Test: test.py
Test: ./out/host/linux-x86/bin/art -Xcompiler-option --dump-cfg=foo.cfg -Xcompiler-option --verbose-methods=run -Xcompiler-option --compiler-filter=quicken -Xusejit:true -cp benchmarks.dex benchmarks.DeltaBlue.java.DeltaBlue
Change-Id: I75ffed146ffff43ef70f3e9e80a160751e08cb04
diff --git a/compiler/driver/compiler_options.cc b/compiler/driver/compiler_options.cc
index a4e2083..76f0ae9 100644
--- a/compiler/driver/compiler_options.cc
+++ b/compiler/driver/compiler_options.cc
@@ -40,7 +40,7 @@
       implicit_so_checks_(true),
       implicit_suspend_checks_(false),
       compile_pic_(false),
-      verbose_methods_(nullptr),
+      verbose_methods_(),
       abort_on_hard_verifier_failure_(false),
       init_failure_output_(nullptr),
       dump_cfg_file_name_(""),
@@ -55,58 +55,6 @@
   // because we don't want to include the PassManagerOptions definition from the header file.
 }
 
-CompilerOptions::CompilerOptions(CompilerFilter::Filter compiler_filter,
-                                 size_t huge_method_threshold,
-                                 size_t large_method_threshold,
-                                 size_t small_method_threshold,
-                                 size_t tiny_method_threshold,
-                                 size_t num_dex_methods_threshold,
-                                 size_t inline_max_code_units,
-                                 const std::vector<const DexFile*>* no_inline_from,
-                                 double top_k_profile_threshold,
-                                 bool debuggable,
-                                 bool generate_debug_info,
-                                 bool implicit_null_checks,
-                                 bool implicit_so_checks,
-                                 bool implicit_suspend_checks,
-                                 bool compile_pic,
-                                 const std::vector<std::string>* verbose_methods,
-                                 std::ostream* init_failure_output,
-                                 bool abort_on_hard_verifier_failure,
-                                 const std::string& dump_cfg_file_name,
-                                 bool dump_cfg_append,
-                                 bool force_determinism,
-                                 RegisterAllocator::Strategy regalloc_strategy,
-                                 const std::vector<std::string>* passes_to_run)
-    : compiler_filter_(compiler_filter),
-      huge_method_threshold_(huge_method_threshold),
-      large_method_threshold_(large_method_threshold),
-      small_method_threshold_(small_method_threshold),
-      tiny_method_threshold_(tiny_method_threshold),
-      num_dex_methods_threshold_(num_dex_methods_threshold),
-      inline_max_code_units_(inline_max_code_units),
-      no_inline_from_(no_inline_from),
-      boot_image_(false),
-      app_image_(false),
-      top_k_profile_threshold_(top_k_profile_threshold),
-      debuggable_(debuggable),
-      generate_debug_info_(generate_debug_info),
-      generate_mini_debug_info_(kDefaultGenerateMiniDebugInfo),
-      generate_build_id_(false),
-      implicit_null_checks_(implicit_null_checks),
-      implicit_so_checks_(implicit_so_checks),
-      implicit_suspend_checks_(implicit_suspend_checks),
-      compile_pic_(compile_pic),
-      verbose_methods_(verbose_methods),
-      abort_on_hard_verifier_failure_(abort_on_hard_verifier_failure),
-      init_failure_output_(init_failure_output),
-      dump_cfg_file_name_(dump_cfg_file_name),
-      dump_cfg_append_(dump_cfg_append),
-      force_determinism_(force_determinism),
-      register_allocation_strategy_(regalloc_strategy),
-      passes_to_run_(passes_to_run) {
-}
-
 void CompilerOptions::ParseHugeMethodMax(const StringPiece& option, UsageFn Usage) {
   ParseUintOption(option, "--huge-method-max", &huge_method_threshold_, Usage);
 }
@@ -204,6 +152,11 @@
     dump_cfg_append_ = true;
   } else if (option.starts_with("--register-allocation-strategy=")) {
     ParseRegisterAllocationStrategy(option, Usage);
+  } else if (option.starts_with("--verbose-methods=")) {
+    // TODO: rather than switch off compiler logging, make all VLOG(compiler) messages
+    //       conditional on having verbose methods.
+    gLogVerbosity.compiler = false;
+    Split(option.substr(strlen("--verbose-methods=")).ToString(), ',', &verbose_methods_);
   } else {
     // Option not recognized.
     return false;
diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h
index 89c2537..b99263d 100644
--- a/compiler/driver/compiler_options.h
+++ b/compiler/driver/compiler_options.h
@@ -52,30 +52,6 @@
   CompilerOptions();
   ~CompilerOptions();
 
-  CompilerOptions(CompilerFilter::Filter compiler_filter,
-                  size_t huge_method_threshold,
-                  size_t large_method_threshold,
-                  size_t small_method_threshold,
-                  size_t tiny_method_threshold,
-                  size_t num_dex_methods_threshold,
-                  size_t inline_max_code_units,
-                  const std::vector<const DexFile*>* no_inline_from,
-                  double top_k_profile_threshold,
-                  bool debuggable,
-                  bool generate_debug_info,
-                  bool implicit_null_checks,
-                  bool implicit_so_checks,
-                  bool implicit_suspend_checks,
-                  bool compile_pic,
-                  const std::vector<std::string>* verbose_methods,
-                  std::ostream* init_failure_output,
-                  bool abort_on_hard_verifier_failure,
-                  const std::string& dump_cfg_file_name,
-                  bool dump_cfg_append,
-                  bool force_determinism,
-                  RegisterAllocator::Strategy regalloc_strategy,
-                  const std::vector<std::string>* passes_to_run);
-
   CompilerFilter::Filter GetCompilerFilter() const {
     return compiler_filter_;
   }
@@ -163,6 +139,10 @@
     return debuggable_;
   }
 
+  void SetDebuggable(bool value) {
+    debuggable_ = value;
+  }
+
   bool GetNativeDebuggable() const {
     return GetDebuggable() && GetGenerateDebugInfo();
   }
@@ -211,11 +191,11 @@
   }
 
   bool HasVerboseMethods() const {
-    return verbose_methods_ != nullptr && !verbose_methods_->empty();
+    return !verbose_methods_.empty();
   }
 
   bool IsVerboseMethod(const std::string& pretty_method) const {
-    for (const std::string& cur_method : *verbose_methods_) {
+    for (const std::string& cur_method : verbose_methods_) {
       if (pretty_method.find(cur_method) != std::string::npos) {
         return true;
       }
@@ -299,7 +279,7 @@
   bool compile_pic_;
 
   // Vector of methods to have verbose output enabled for.
-  const std::vector<std::string>* verbose_methods_;
+  std::vector<std::string> verbose_methods_;
 
   // Abort compilation with an error if we find a class that fails verification with a hard
   // failure.
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc
index 6613541..715d973 100644
--- a/compiler/jit/jit_compiler.cc
+++ b/compiler/jit/jit_compiler.cc
@@ -90,36 +90,16 @@
 }
 
 JitCompiler::JitCompiler() {
-  compiler_options_.reset(new CompilerOptions(
-      CompilerFilter::kDefaultCompilerFilter,
-      CompilerOptions::kDefaultHugeMethodThreshold,
-      CompilerOptions::kDefaultLargeMethodThreshold,
-      CompilerOptions::kDefaultSmallMethodThreshold,
-      CompilerOptions::kDefaultTinyMethodThreshold,
-      CompilerOptions::kDefaultNumDexMethodsThreshold,
-      CompilerOptions::kDefaultInlineMaxCodeUnits,
-      /* no_inline_from */ nullptr,
-      CompilerOptions::kDefaultTopKProfileThreshold,
-      Runtime::Current()->IsJavaDebuggable(),
-      CompilerOptions::kDefaultGenerateDebugInfo,
-      /* implicit_null_checks */ true,
-      /* implicit_so_checks */ true,
-      /* implicit_suspend_checks */ false,
-      /* pic */ false,
-      /* verbose_methods */ nullptr,
-      /* init_failure_output */ nullptr,
-      /* abort_on_hard_verifier_failure */ false,
-      /* dump_cfg_file_name */ "",
-      /* dump_cfg_append */ false,
-      /* force_determinism */ false,
-      RegisterAllocator::kRegisterAllocatorDefault,
-      /* passes_to_run */ nullptr));
+  compiler_options_.reset(new CompilerOptions());
   for (const std::string& argument : Runtime::Current()->GetCompilerOptions()) {
     compiler_options_->ParseCompilerOption(argument, Usage);
   }
   // JIT is never PIC, no matter what the runtime compiler options specify.
   compiler_options_->SetNonPic();
 
+  // Set debuggability based on the runtime value.
+  compiler_options_->SetDebuggable(Runtime::Current()->IsJavaDebuggable());
+
   const InstructionSet instruction_set = kRuntimeISA;
   for (const StringPiece option : Runtime::Current()->GetCompilerOptions()) {
     VLOG(compiler) << "JIT compiler option " << option;
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 92d60b2..ca0bae1 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -925,8 +925,6 @@
         break;
     }
 
-    compiler_options_->verbose_methods_ = verbose_methods_.empty() ? nullptr : &verbose_methods_;
-
     if (!IsBootImage() && multi_image_) {
       Usage("--multi-image can only be used when creating boot images");
     }
@@ -1262,11 +1260,6 @@
         app_image_file_name_ = option.substr(strlen("--app-image-file=")).data();
       } else if (option.starts_with("--app-image-fd=")) {
         ParseUintOption(option, "--app-image-fd", &app_image_fd_, Usage);
-      } else if (option.starts_with("--verbose-methods=")) {
-        // TODO: rather than switch off compiler logging, make all VLOG(compiler) messages
-        //       conditional on having verbost methods.
-        gLogVerbosity.compiler = false;
-        Split(option.substr(strlen("--verbose-methods=")).ToString(), ',', &verbose_methods_);
       } else if (option == "--multi-image") {
         multi_image_ = true;
       } else if (option.starts_with("--no-inline-from=")) {
@@ -2804,7 +2797,6 @@
 
   std::vector<const DexFile*> no_inline_from_dex_files_;
 
-  std::vector<std::string> verbose_methods_;
   bool dump_stats_;
   bool dump_passes_;
   bool dump_timing_;