ART: Use optimizing compiler in image_test

Expose some compiler options so we can run the image test with
the optimizing compiler without running into a stack overflow.

Also allow a variable amount of threads in CreateCompilerDriver.
Use 16 as a middle ground on the host to speed up the otherwise
now slowed-down test.

Bug: 27240085
Bug: 27552475
Change-Id: I8db5055d32ae722c8f430903244faa9166cc4886
diff --git a/compiler/image_test.cc b/compiler/image_test.cc
index 3b622b5..91579e9 100644
--- a/compiler/image_test.cc
+++ b/compiler/image_test.cc
@@ -24,6 +24,7 @@
 #include "class_linker-inl.h"
 #include "common_compiler_test.h"
 #include "debug/method_debug_info.h"
+#include "driver/compiler_options.h"
 #include "elf_writer.h"
 #include "elf_writer_quick.h"
 #include "gc/space/image_space.h"
@@ -48,8 +49,12 @@
 };
 
 void ImageTest::TestWriteRead(ImageHeader::StorageMode storage_mode) {
-  // TODO: Test does not currently work with optimizing.
-  CreateCompilerDriver(Compiler::kQuick, kRuntimeISA);
+  CreateCompilerDriver(Compiler::kOptimizing, kRuntimeISA, kIsTargetBuild ? 2U : 16U);
+
+  // Set inline filter values.
+  compiler_options_->SetInlineDepthLimit(CompilerOptions::kDefaultInlineDepthLimit);
+  compiler_options_->SetInlineMaxCodeUnits(CompilerOptions::kDefaultInlineMaxCodeUnits);
+
   ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
   // Enable write for dex2dex.
   for (const DexFile* dex_file : class_linker->GetBootClassPath()) {