Remove superfluous verification from dex2oat

All input dex files are verified in WriteDexFiles before we copy them.

We need to re-open the DexFiles from the copy in vdex,
but we don't need to verify them again.

Bug: 282589477
Test: ./art/test.py -b --host
Change-Id: I92ed2a572613d9d8f6e2014fbaa1c51071a86b42
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index 413d71f..b290c34 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -472,6 +472,10 @@
     return false;
   }
   for (auto& dex_file : dex_files) {
+    if (dex_file->IsCompactDexFile()) {
+      LOG(ERROR) << "Compact dex is only supported from vdex: " << location;
+      return false;
+    }
     oat_dex_files_.emplace_back(std::move(dex_file));
   }
   return true;
@@ -568,7 +572,7 @@
   std::vector<MemMap> dex_files_map;
   std::vector<std::unique_ptr<const DexFile>> dex_files;
   if (!WriteDexFiles(vdex_file, verify, use_existing_vdex, copy_dex_files, &dex_files_map) ||
-      !OpenDexFiles(vdex_file, verify, &dex_files_map, &dex_files)) {
+      !OpenDexFiles(vdex_file, &dex_files_map, &dex_files)) {
     return false;
   }
 
@@ -3198,6 +3202,9 @@
     TimingLogger::ScopedTiming split2("Verify input Dex files", timings_);
     for (OatDexFile& oat_dex_file : oat_dex_files_) {
       const DexFile* dex_file = oat_dex_file.GetDexFile();
+      if (dex_file->IsCompactDexFile()) {
+        continue;  // Compact dex files can not be verified.
+      }
       std::string error_msg;
       if (!dex::Verify(dex_file,
                        dex_file->GetLocation().c_str(),
@@ -3433,7 +3440,6 @@
 
 bool OatWriter::OpenDexFiles(
     File* file,
-    bool verify,
     /*inout*/ std::vector<MemMap>* opened_dex_files_map,
     /*out*/ std::vector<std::unique_ptr<const DexFile>>* opened_dex_files) {
   TimingLogger::ScopedTiming split("OpenDexFiles", timings_);
@@ -3484,10 +3490,11 @@
     std::string error_msg;
     ArtDexFileLoader dex_file_loader(
         raw_dex_file, oat_dex_file.dex_file_size_, oat_dex_file.GetLocation());
+    // All dex files have been already verified in WriteDexFiles before we copied them.
     dex_files.emplace_back(dex_file_loader.Open(oat_dex_file.dex_file_location_checksum_,
-                                                /* oat_dex_file */ nullptr,
-                                                verify,
-                                                verify,
+                                                /*oat_dex_file=*/nullptr,
+                                                /*verify=*/false,
+                                                /*verify_checksum=*/false,
                                                 &error_msg));
     if (dex_files.back() == nullptr) {
       LOG(ERROR) << "Failed to open dex file from oat file. File: " << oat_dex_file.GetLocation()
diff --git a/dex2oat/linker/oat_writer.h b/dex2oat/linker/oat_writer.h
index 0e872e9..79ec47e 100644
--- a/dex2oat/linker/oat_writer.h
+++ b/dex2oat/linker/oat_writer.h
@@ -284,7 +284,6 @@
                      /*out*/ std::vector<MemMap>* opened_dex_files_map);
   bool LayoutDexFile(OatDexFile* oat_dex_file);
   bool OpenDexFiles(File* file,
-                    bool verify,
                     /*inout*/ std::vector<MemMap>* opened_dex_files_map,
                     /*out*/ std::vector<std::unique_ptr<const DexFile>>* opened_dex_files);
   void WriteQuickeningInfo(/*out*/std::vector<uint8_t>* buffer);