ART: Use core image to speed up some gtests.

Host timing of
  art_compiler_tests --no_isolate --gtest_filter='<pattern>'
for different patterns:
  "ms total"                    before after
  LoadStoreEliminationTest*      16945  4750
  LoadStoreAnalysisTest*          2647   689
  ReferenceTypePropagationTest*  13542  3929
  InstructionSimplifierTest*      1452   406

Host timing of
  art_runtime_tests --no_isolate --gtest_filter='<pattern>'
for different patterns:
  "ms total"                    before after
  RegType*Test*                   2976  1675
  DexCacheTest*                    265    74
  JavaVmExtTest*                   785   230

Host timing of
  art_libartbase_tests --no_isolate --gtest_filter='<pattern>'
for different patterns:
  "ms total"                    before after
  FlagsTests*                      691   214

Host timing of
  art_dex2oat_tests --no_isolate --gtest_filter='<pattern>'
for different patterns:
  "ms total"                    before after
  VerifierDepsTest*               3567   874

Test: m test-art-host-gtest
Change-Id: I20df90e3d38aaa286e22ba070c7845bcb09e3bca
diff --git a/compiler/optimizing/instruction_simplifier_test.cc b/compiler/optimizing/instruction_simplifier_test.cc
index 2063eed..c7c5b12 100644
--- a/compiler/optimizing/instruction_simplifier_test.cc
+++ b/compiler/optimizing/instruction_simplifier_test.cc
@@ -36,6 +36,10 @@
 template<typename SuperClass>
 class InstructionSimplifierTestBase : public SuperClass, public OptimizingUnitTestHelper {
  public:
+  InstructionSimplifierTestBase() {
+    this->use_boot_image_ = true;  // Make the Runtime creation cheaper.
+  }
+
   void SetUp() override {
     SuperClass::SetUp();
     gLogVerbosity.compiler = true;
diff --git a/compiler/optimizing/load_store_analysis_test.cc b/compiler/optimizing/load_store_analysis_test.cc
index c6d2208..3c26c8d 100644
--- a/compiler/optimizing/load_store_analysis_test.cc
+++ b/compiler/optimizing/load_store_analysis_test.cc
@@ -40,7 +40,9 @@
 
 class LoadStoreAnalysisTest : public CommonCompilerTest, public OptimizingUnitTestHelper {
  public:
-  LoadStoreAnalysisTest() {}
+  LoadStoreAnalysisTest() {
+    use_boot_image_ = true;  // Make the Runtime creation cheaper.
+  }
 
   AdjacencyListGraph SetupFromAdjacencyList(
       const std::string_view entry_name,
diff --git a/compiler/optimizing/load_store_elimination_test.cc b/compiler/optimizing/load_store_elimination_test.cc
index 812a32a..7d68c9f 100644
--- a/compiler/optimizing/load_store_elimination_test.cc
+++ b/compiler/optimizing/load_store_elimination_test.cc
@@ -48,6 +48,10 @@
 template <typename SuperTest>
 class LoadStoreEliminationTestBase : public SuperTest, public OptimizingUnitTestHelper {
  public:
+  LoadStoreEliminationTestBase() {
+    this->use_boot_image_ = true;  // Make the Runtime creation cheaper.
+  }
+
   void SetUp() override {
     SuperTest::SetUp();
     gLogVerbosity.compiler = true;
diff --git a/compiler/optimizing/reference_type_propagation_test.cc b/compiler/optimizing/reference_type_propagation_test.cc
index d90567a..d1bcab0 100644
--- a/compiler/optimizing/reference_type_propagation_test.cc
+++ b/compiler/optimizing/reference_type_propagation_test.cc
@@ -39,7 +39,9 @@
 template<typename SuperTest>
 class ReferenceTypePropagationTestBase : public SuperTest, public OptimizingUnitTestHelper {
  public:
-  ReferenceTypePropagationTestBase() : graph_(nullptr), propagation_(nullptr) { }
+  ReferenceTypePropagationTestBase() : graph_(nullptr), propagation_(nullptr) {
+    this->use_boot_image_ = true;  // Make the Runtime creation cheaper.
+  }
 
   ~ReferenceTypePropagationTestBase() { }
 
diff --git a/dex2oat/verifier_deps_test.cc b/dex2oat/verifier_deps_test.cc
index 62eae8a..708af04 100644
--- a/dex2oat/verifier_deps_test.cc
+++ b/dex2oat/verifier_deps_test.cc
@@ -58,6 +58,10 @@
 
 class VerifierDepsTest : public CommonCompilerDriverTest {
  public:
+  VerifierDepsTest() {
+    this->use_boot_image_ = true;  // Make the Runtime creation cheaper.
+  }
+
   void SetUpRuntimeOptions(RuntimeOptions* options) override {
     CommonCompilerTest::SetUpRuntimeOptions(options);
     callbacks_.reset(new VerifierDepsCompilerCallbacks());
diff --git a/libartbase/base/flags_test.cc b/libartbase/base/flags_test.cc
index 7cc2890..abc8f22 100644
--- a/libartbase/base/flags_test.cc
+++ b/libartbase/base/flags_test.cc
@@ -98,6 +98,10 @@
 
 class FlagsTests : public CommonRuntimeTest {
  protected:
+  FlagsTests() {
+    this->use_boot_image_ = true;  // Make the Runtime creation cheaper.
+  }
+
   // We need to initialize the flag after the ScratchDir is created
   // but before we configure the runtime options (so that we can get
   // the right name for the config).
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index 4eb3408..3f643e8 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -71,7 +71,11 @@
 static bool unstarted_initialized_ = false;
 
 CommonRuntimeTestImpl::CommonRuntimeTestImpl()
-    : class_linker_(nullptr), java_lang_dex_file_(nullptr) {
+    : class_linker_(nullptr),
+      java_lang_dex_file_(nullptr),
+      boot_class_path_(),
+      callbacks_(),
+      use_boot_image_(false) {
 }
 
 CommonRuntimeTestImpl::~CommonRuntimeTestImpl() {
@@ -94,6 +98,9 @@
 
   options.push_back(std::make_pair(boot_class_path_string, nullptr));
   options.push_back(std::make_pair(boot_class_path_locations_string, nullptr));
+  if (use_boot_image_) {
+    options.emplace_back("-Ximage:" + GetImageLocation(), nullptr);
+  }
   options.push_back(std::make_pair("-Xcheck:jni", nullptr));
   options.push_back(std::make_pair(min_heap_string, nullptr));
   options.push_back(std::make_pair(max_heap_string, nullptr));
@@ -107,7 +114,7 @@
 
   SetUpRuntimeOptions(&options);
 
-  // Install compiler-callbacks if SetupRuntimeOptions hasn't deleted them.
+  // Install compiler-callbacks if SetUpRuntimeOptions hasn't deleted them.
   if (callbacks_.get() != nullptr) {
     options.push_back(std::make_pair("compilercallbacks", callbacks_.get()));
   }
diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h
index 7c11fd8..9fa9c5d 100644
--- a/runtime/common_runtime_test.h
+++ b/runtime/common_runtime_test.h
@@ -207,6 +207,8 @@
 
   std::unique_ptr<CompilerCallbacks> callbacks_;
 
+  bool use_boot_image_;
+
   virtual void SetUp();
 
   virtual void TearDown();
diff --git a/runtime/jni/java_vm_ext_test.cc b/runtime/jni/java_vm_ext_test.cc
index 0363cdb..cae33b5 100644
--- a/runtime/jni/java_vm_ext_test.cc
+++ b/runtime/jni/java_vm_ext_test.cc
@@ -27,6 +27,10 @@
 
 class JavaVmExtTest : public CommonRuntimeTest {
  protected:
+  JavaVmExtTest() {
+    this->use_boot_image_ = true;  // Make the Runtime creation cheaper.
+  }
+
   void SetUp() override {
     CommonRuntimeTest::SetUp();
 
diff --git a/runtime/mirror/dex_cache_test.cc b/runtime/mirror/dex_cache_test.cc
index b89b20d..a0e8fda 100644
--- a/runtime/mirror/dex_cache_test.cc
+++ b/runtime/mirror/dex_cache_test.cc
@@ -30,7 +30,12 @@
 namespace art {
 namespace mirror {
 
-class DexCacheTest : public CommonRuntimeTest {};
+class DexCacheTest : public CommonRuntimeTest {
+ protected:
+  DexCacheTest() {
+    this->use_boot_image_ = true;  // Make the Runtime creation cheaper.
+  }
+};
 
 class DexCacheMethodHandlesTest : public DexCacheTest {
  protected:
diff --git a/runtime/transaction_test.cc b/runtime/transaction_test.cc
index 88e3f4f..04aa7cd 100644
--- a/runtime/transaction_test.cc
+++ b/runtime/transaction_test.cc
@@ -29,9 +29,8 @@
 
 class TransactionTest : public CommonRuntimeTest {
  protected:
-  void SetUpRuntimeOptions(/*out*/RuntimeOptions* options) override {
-    // Set up the image location.
-    options->emplace_back("-Ximage:" + GetImageLocation(), nullptr);
+  TransactionTest() {
+    this->use_boot_image_ = true;  // We need the boot image for this test.
   }
 
   // Tests failing class initialization due to native call with transaction rollback.
diff --git a/runtime/verifier/reg_type_test.cc b/runtime/verifier/reg_type_test.cc
index 207bb5d..a157464 100644
--- a/runtime/verifier/reg_type_test.cc
+++ b/runtime/verifier/reg_type_test.cc
@@ -31,7 +31,12 @@
 namespace art {
 namespace verifier {
 
-class RegTypeTest : public CommonRuntimeTest {};
+class RegTypeTest : public CommonRuntimeTest {
+ public:
+  RegTypeTest() {
+    use_boot_image_ = true;  // Make the Runtime creation cheaper.
+  }
+};
 
 TEST_F(RegTypeTest, ConstLoHi) {
   // Tests creating primitive types types.