Revert "Revert "Use OatFileAssistant default filter instead of the dex2oat one""

Disable checker when testing no-prebuilds. By default, the compiler will
only quicken (in no prebuild mode) and will not generate a cfg file.

The checker test are already covered by other modes like:
art-preopt (pic) or art-optimizing (npic).

Test: testrunner.py --host --no-prebuild

This reverts commit df663fb4f871ae2e49aad7b58e31952ff647b061.

Bug: 38442248
Change-Id: Ifc43715d610787a33a97f13620a80ba3c9f217db
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index dcdf3bc..331a6f2 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -113,13 +113,18 @@
 static std::string StrippedCommandLine() {
   std::vector<std::string> command;
 
-  // Do a pre-pass to look for zip-fd.
+  // Do a pre-pass to look for zip-fd and the compiler filter.
   bool saw_zip_fd = false;
+  bool saw_compiler_filter = false;
   for (int i = 0; i < original_argc; ++i) {
     if (android::base::StartsWith(original_argv[i], "--zip-fd=")) {
       saw_zip_fd = true;
       break;
     }
+    if (android::base::StartsWith(original_argv[i], "--compiler-filter=")) {
+      saw_compiler_filter = true;
+      break;
+    }
   }
 
   // Now filter out things.
@@ -162,6 +167,11 @@
     command.push_back(original_argv[i]);
   }
 
+  if (!saw_compiler_filter) {
+    command.push_back("--compiler-filter=" +
+        CompilerFilter::NameOfFilter(CompilerFilter::kDefaultCompilerFilter));
+  }
+
   // Construct the final output.
   if (command.size() <= 1U) {
     // It seems only "/system/bin/dex2oat" is left, or not even that. Use a pretty line.
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index 9e08b34..f0912cf 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -239,7 +239,7 @@
     case kDex2OatForBootImage:
     case kDex2OatForRelocation:
     case kDex2OatForFilter:
-      return GenerateOatFileNoChecks(info, error_msg);
+      return GenerateOatFileNoChecks(info, target, error_msg);
   }
   UNREACHABLE();
 }
@@ -614,7 +614,7 @@
 }
 
 OatFileAssistant::ResultOfAttemptToUpdate OatFileAssistant::GenerateOatFileNoChecks(
-      OatFileAssistant::OatFileInfo& info, std::string* error_msg) {
+      OatFileAssistant::OatFileInfo& info, CompilerFilter::Filter filter, std::string* error_msg) {
   CHECK(error_msg != nullptr);
 
   Runtime* runtime = Runtime::Current();
@@ -689,6 +689,7 @@
   args.push_back("--output-vdex-fd=" + std::to_string(vdex_file->Fd()));
   args.push_back("--oat-fd=" + std::to_string(oat_file->Fd()));
   args.push_back("--oat-location=" + oat_file_name);
+  args.push_back("--compiler-filter=" + CompilerFilter::NameOfFilter(filter));
 
   if (!Dex2Oat(args, error_msg)) {
     // Manually delete the oat and vdex files. This ensures there is no garbage
diff --git a/runtime/oat_file_assistant.h b/runtime/oat_file_assistant.h
index 7e2385e..03d9ca3 100644
--- a/runtime/oat_file_assistant.h
+++ b/runtime/oat_file_assistant.h
@@ -366,14 +366,16 @@
   };
 
   // Generate the oat file for the given info from the dex file using the
-  // current runtime compiler options.
+  // current runtime compiler options and the specified filter.
   // This does not check the current status before attempting to generate the
   // oat file.
   //
   // If the result is not kUpdateSucceeded, the value of error_msg will be set
   // to a string describing why there was a failure or the update was not
   // attempted. error_msg must not be null.
-  ResultOfAttemptToUpdate GenerateOatFileNoChecks(OatFileInfo& info, std::string* error_msg);
+  ResultOfAttemptToUpdate GenerateOatFileNoChecks(OatFileInfo& info,
+                                                  CompilerFilter::Filter target,
+                                                  std::string* error_msg);
 
   // Return info for the best oat file.
   OatFileInfo& GetBestInfo();
diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc
index c202916..3619129 100644
--- a/runtime/oat_file_assistant_test.cc
+++ b/runtime/oat_file_assistant_test.cc
@@ -1232,6 +1232,25 @@
   }
 }
 
+// Verify that when no compiler filter is passed the default one from OatFileAssistant is used.
+TEST_F(OatFileAssistantTest, DefaultMakeUpToDateFilter) {
+  std::string dex_location = GetScratchDir() + "/TestDex.jar";
+  Copy(GetDexSrc1(), dex_location);
+
+  OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false);
+
+  const CompilerFilter::Filter default_filter =
+      OatFileAssistant::kDefaultCompilerFilterForDexLoading;
+  std::string error_msg;
+  EXPECT_EQ(OatFileAssistant::kUpdateSucceeded,
+      oat_file_assistant.MakeUpToDate(false, &error_msg)) << error_msg;
+  EXPECT_EQ(-OatFileAssistant::kNoDexOptNeeded,
+            oat_file_assistant.GetDexOptNeeded(default_filter));
+  std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
+  EXPECT_NE(nullptr, oat_file.get());
+  EXPECT_EQ(default_filter, oat_file->GetCompilerFilter());
+}
+
 // TODO: More Tests:
 //  * Test class linker falls back to unquickened dex for DexNoOat
 //  * Test class linker falls back to unquickened dex for MultiDexNoOat
diff --git a/test/run-test b/test/run-test
index 933a7fe..7db37a4 100755
--- a/test/run-test
+++ b/test/run-test
@@ -728,10 +728,8 @@
 # Checker when compiled with Optimizing on host.
 if [[ "$TEST_NAME" =~ ^[0-9]+-checker- ]]; then
   if [ "$runtime" = "art" -a "$image_suffix" = "" -a "$USE_JACK" = "true" ]; then
-    # In no-prebuild mode, the compiler is only invoked if both dex2oat and
-    # patchoat are available. Disable Checker otherwise (b/22552692).
-    if [ "$prebuild_mode" = "yes" ] \
-         || [ "$have_patchoat" = "yes" -a "$have_dex2oat" = "yes" ]; then
+    # In no-prebuild mode, the compiler only quickens so disable the checker.
+    if [ "$prebuild_mode" = "yes" ]; then
       run_checker="yes"
 
       if [ "$target_mode" = "no" ]; then