Reland "Remove old unquickening of vdex logic."

This reverts commit dcf9570d756aa74a2330406c13330c18c34e0db2.

Bug: 170086509

Reason for revert: Fix handling of input-vdex file.

Change-Id: Idbd59d4fe2be672858f33668a8564933518c28df
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 123165d..48b2c93 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1237,7 +1237,6 @@
           input_vdex_file_ = VdexFile::Open(input_vdex_,
                                             /* writable */ false,
                                             /* low_4gb */ false,
-                                            DoEagerUnquickeningOfVdex(),
                                             &error_msg);
         }
 
@@ -1246,8 +1245,8 @@
             ? ReplaceFileExtension(oat_filename, "vdex")
             : output_vdex_;
         if (vdex_filename == input_vdex_ && output_vdex_.empty()) {
-          update_input_vdex_ = true;
-          std::unique_ptr<File> vdex_file(OS::OpenFileReadWrite(vdex_filename.c_str()));
+          use_existing_vdex_ = true;
+          std::unique_ptr<File> vdex_file(OS::OpenFileForReading(vdex_filename.c_str()));
           vdex_files_.push_back(std::move(vdex_file));
         } else {
           std::unique_ptr<File> vdex_file(OS::CreateEmptyFile(vdex_filename.c_str()));
@@ -1289,7 +1288,6 @@
                                             "vdex",
                                             /* writable */ false,
                                             /* low_4gb */ false,
-                                            DoEagerUnquickeningOfVdex(),
                                             &error_msg);
           // If there's any problem with the passed vdex, just warn and proceed
           // without it.
@@ -1301,15 +1299,20 @@
 
       DCHECK_NE(output_vdex_fd_, -1);
       std::string vdex_location = ReplaceFileExtension(oat_location_, "vdex");
-      std::unique_ptr<File> vdex_file(new File(
-          DupCloexec(output_vdex_fd_), vdex_location, /* check_usage */ true));
+      if (input_vdex_file_ != nullptr && output_vdex_fd_ == input_vdex_fd_) {
+        use_existing_vdex_ = true;
+      }
+
+      std::unique_ptr<File> vdex_file(new File(DupCloexec(output_vdex_fd_),
+                                               vdex_location,
+                                               /* check_usage= */ true,
+                                               /* read_only_mode= */ use_existing_vdex_));
       if (!vdex_file->IsOpened()) {
         PLOG(ERROR) << "Failed to create vdex file: " << vdex_location;
         return false;
       }
-      if (input_vdex_file_ != nullptr && output_vdex_fd_ == input_vdex_fd_) {
-        update_input_vdex_ = true;
-      } else {
+
+      if (!use_existing_vdex_) {
         if (vdex_file->SetLength(0) != 0) {
           PLOG(ERROR) << "Truncating vdex file " << vdex_location << " failed.";
           vdex_file->Erase();
@@ -1321,26 +1324,6 @@
       oat_filenames_.push_back(oat_location_);
     }
 
-    // If we're updating in place a vdex file, be defensive and put an invalid vdex magic in case
-    // dex2oat gets killed.
-    // Note: we're only invalidating the magic data in the file, as dex2oat needs the rest of
-    // the information to remain valid.
-    if (update_input_vdex_) {
-      File* vdex_file = vdex_files_.back().get();
-      if (!vdex_file->PwriteFully(&VdexFile::VdexFileHeader::kVdexInvalidMagic,
-                                  arraysize(VdexFile::VdexFileHeader::kVdexInvalidMagic),
-                                  /*offset=*/ 0u)) {
-        PLOG(ERROR) << "Failed to invalidate vdex header. File: " << vdex_file->GetPath();
-        return false;
-      }
-
-      if (vdex_file->Flush() != 0) {
-        PLOG(ERROR) << "Failed to flush stream after invalidating header of vdex file."
-                    << " File: " << vdex_file->GetPath();
-        return false;
-      }
-    }
-
     if (dm_fd_ != -1 || !dm_file_location_.empty()) {
       std::string error_msg;
       if (dm_fd_ != -1) {
@@ -1389,9 +1372,12 @@
   void EraseOutputFiles() {
     for (auto& files : { &vdex_files_, &oat_files_ }) {
       for (size_t i = 0; i < files->size(); ++i) {
-        if ((*files)[i].get() != nullptr) {
-          (*files)[i]->Erase();
-          (*files)[i].reset();
+        auto& file = (*files)[i];
+        if (file != nullptr) {
+          if (!file->ReadOnlyMode()) {
+            file->Erase();
+          }
+          file.reset();
         }
       }
     }
@@ -1455,7 +1441,7 @@
         if (!oat_writers_[i]->WriteAndOpenDexFiles(
             vdex_files_[i].get(),
             verify,
-            update_input_vdex_,
+            use_existing_vdex_,
             copy_dex_files_,
             &opened_dex_files_map,
             &opened_dex_files)) {
@@ -1695,21 +1681,16 @@
       }
     }
 
-    // Ensure opened dex files are writable for dex-to-dex transformations.
-    for (MemMap& map : opened_dex_files_maps_) {
-      if (!map.Protect(PROT_READ | PROT_WRITE)) {
-        PLOG(ERROR) << "Failed to make .dex files writeable.";
-        return dex2oat::ReturnCode::kOther;
-      }
-    }
-
     // Setup VerifierDeps for compilation and report if we fail to parse the data.
-    if (!DoEagerUnquickeningOfVdex() && input_vdex_file_ != nullptr) {
+    // When we do profile guided optimizations, the compiler currently needs to run
+    // full verification.
+    if (!DoProfileGuidedOptimizations() && input_vdex_file_ != nullptr) {
       std::unique_ptr<verifier::VerifierDeps> verifier_deps(
           new verifier::VerifierDeps(dex_files, /*output_only=*/ false));
       if (!verifier_deps->ParseStoredData(dex_files, input_vdex_file_->GetVerifierDepsData())) {
         return dex2oat::ReturnCode::kOther;
       }
+      // We can do fast verification.
       callbacks_->SetVerifierDeps(verifier_deps.release());
     } else {
       // Create the main VerifierDeps, here instead of in the compiler since we want to aggregate
@@ -1792,7 +1773,7 @@
     // This means extract, no-vdex verify, and quicken, will use the individual compilation
     // mode (to reduce RAM used by the compiler).
     return compile_individually_ &&
-           (!IsImage() && !update_input_vdex_ &&
+           (!IsImage() && !use_existing_vdex_ &&
             compiler_options_->dex_files_for_oat_file_.size() > 1 &&
             !CompilerFilter::IsAotCompilationEnabled(compiler_options_->GetCompilerFilter()));
   }
@@ -2069,7 +2050,7 @@
       oat_writer->Initialize(driver_.get(), image_writer_.get(), dex_files);
     }
 
-    {
+    if (!use_existing_vdex_) {
       TimingLogger::ScopedTiming t2("dex2oat Write VDEX", timings_);
       DCHECK(IsBootImage() || IsBootImageExtension() || oat_files_.size() == 1u);
       verifier::VerifierDeps* verifier_deps = callbacks_->GetVerifierDeps();
@@ -2235,7 +2216,7 @@
   }
 
   bool FlushOutputFile(std::unique_ptr<File>* file) {
-    if (file->get() != nullptr) {
+    if ((file->get() != nullptr) && !file->get()->ReadOnlyMode()) {
       if (file->get()->Flush() != 0) {
         PLOG(ERROR) << "Failed to flush output file: " << file->get()->GetPath();
         return false;
@@ -2245,7 +2226,7 @@
   }
 
   bool FlushCloseOutputFile(File* file) {
-    if (file != nullptr) {
+    if ((file != nullptr) && !file->ReadOnlyMode()) {
       if (file->FlushCloseOrErase() != 0) {
         PLOG(ERROR) << "Failed to flush and close output file: " << file->GetPath();
         return false;
@@ -2325,16 +2306,6 @@
     return DoProfileGuidedOptimizations();
   }
 
-  bool MayInvalidateVdexMetadata() const {
-    // DexLayout can invalidate the vdex metadata if changing the class def order is enabled, so
-    // we need to unquicken the vdex file eagerly, before passing it to dexlayout.
-    return DoDexLayoutOptimizations();
-  }
-
-  bool DoEagerUnquickeningOfVdex() const {
-    return MayInvalidateVdexMetadata() && dm_file_ == nullptr;
-  }
-
   bool LoadProfile() {
     DCHECK(HasProfileInput());
     profile_load_attempted_ = true;
@@ -2948,7 +2919,7 @@
   std::string classpath_dir_;
 
   // Whether the given input vdex is also the output.
-  bool update_input_vdex_ = false;
+  bool use_existing_vdex_ = false;
 
   // By default, copy the dex to the vdex file only if dex files are
   // compressed in APK.
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index 557675d..b340c80 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -1812,7 +1812,6 @@
     std::unique_ptr<VdexFile> vdex(VdexFile::Open(vdex_location.c_str(),
                                                   /*writable=*/ false,
                                                   /*low_4gb=*/ false,
-                                                  /*unquicken=*/ false,
                                                   &error_msg));
     ASSERT_TRUE(vdex != nullptr);
     EXPECT_FALSE(vdex->HasDexSection()) << output_;
diff --git a/dex2oat/dex2oat_vdex_test.cc b/dex2oat/dex2oat_vdex_test.cc
index 1f486e6..895e9c2 100644
--- a/dex2oat/dex2oat_vdex_test.cc
+++ b/dex2oat/dex2oat_vdex_test.cc
@@ -73,7 +73,6 @@
     std::unique_ptr<VdexFile> vdex(VdexFile::Open(vdex_location.c_str(),
                                                   /*writable=*/ false,
                                                   /*low_4gb=*/ false,
-                                                  /*unquicken=*/ false,
                                                   &error_msg_));
     // Check the vdex doesn't have dex.
     if (vdex->HasDexSection()) {
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index 5ac2bbf..70260bc 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -683,21 +683,22 @@
 bool OatWriter::WriteAndOpenDexFiles(
     File* vdex_file,
     bool verify,
-    bool update_input_vdex,
+    bool use_existing_vdex,
     CopyOption copy_dex_files,
     /*out*/ std::vector<MemMap>* opened_dex_files_map,
     /*out*/ std::vector<std::unique_ptr<const DexFile>>* opened_dex_files) {
   CHECK(write_state_ == WriteState::kAddingDexFileSources);
 
+  // Reserve space for Vdex header, sections, and checksums.
   size_vdex_header_ = sizeof(VdexFile::VdexFileHeader) +
       VdexSection::kNumberOfSections * sizeof(VdexFile::VdexSectionHeader);
-  // Reserve space for Vdex header, sections, and checksums.
-  vdex_size_ = size_vdex_header_ + oat_dex_files_.size() * sizeof(VdexFile::VdexChecksum);
+  size_vdex_checksums_ = oat_dex_files_.size() * sizeof(VdexFile::VdexChecksum);
+  vdex_size_ = size_vdex_header_ + size_vdex_checksums_;
 
   // Write DEX files into VDEX, mmap and open them.
   std::vector<MemMap> dex_files_map;
   std::vector<std::unique_ptr<const DexFile>> dex_files;
-  if (!WriteDexFiles(vdex_file, update_input_vdex, copy_dex_files, &dex_files_map) ||
+  if (!WriteDexFiles(vdex_file, use_existing_vdex, copy_dex_files, &dex_files_map) ||
       !OpenDexFiles(vdex_file, verify, &dex_files_map, &dex_files)) {
     return false;
   }
@@ -3103,7 +3104,7 @@
 }
 
 bool OatWriter::WriteDexFiles(File* file,
-                              bool update_input_vdex,
+                              bool use_existing_vdex,
                               CopyOption copy_dex_files,
                               /*out*/ std::vector<MemMap>* opened_dex_files_map) {
   TimingLogger::ScopedTiming split("Write Dex files", timings_);
@@ -3136,8 +3137,8 @@
     if (profile_compilation_info_ != nullptr ||
         compact_dex_level_ != CompactDexLevel::kCompactDexLevelNone) {
       for (OatDexFile& oat_dex_file : oat_dex_files_) {
-        // update_input_vdex disables compact dex and layout.
-        CHECK(!update_input_vdex)
+        // use_existing_vdex should not be used with compact dex and layout.
+        CHECK(!use_existing_vdex)
             << "We should never update the input vdex when doing dexlayout or compact dex";
         if (!LayoutDexFile(&oat_dex_file)) {
           return false;
@@ -3202,7 +3203,7 @@
     // Extend the file and include the full page at the end as we need to write
     // additional data there and do not want to mmap that page twice.
     size_t page_aligned_size = RoundUp(vdex_size_with_dex_files, kPageSize);
-    if (!update_input_vdex) {
+    if (!use_existing_vdex) {
       if (file->SetLength(page_aligned_size) != 0) {
         PLOG(ERROR) << "Failed to resize vdex file " << file->GetPath();
         return false;
@@ -3212,7 +3213,7 @@
     std::string error_msg;
     MemMap dex_files_map = MemMap::MapFile(
         page_aligned_size,
-        PROT_READ | PROT_WRITE,
+        use_existing_vdex ? PROT_READ : PROT_READ | PROT_WRITE,
         MAP_SHARED,
         file->Fd(),
         /*start=*/ 0u,
@@ -3233,7 +3234,7 @@
       vdex_size_ = RoundUp(vdex_size_, 4u);
       size_dex_file_alignment_ += vdex_size_ - old_vdex_size;
       // Write the actual dex file.
-      if (!WriteDexFile(file, &oat_dex_file, update_input_vdex)) {
+      if (!WriteDexFile(file, &oat_dex_file, use_existing_vdex)) {
         return false;
       }
     }
@@ -3241,27 +3242,25 @@
     // Write shared dex file data section and fix up the dex file headers.
     if (shared_data_size != 0u) {
       DCHECK_EQ(RoundUp(vdex_size_, 4u), vdex_dex_shared_data_offset_);
-      if (!update_input_vdex) {
-        memset(vdex_begin_ + vdex_size_, 0, vdex_dex_shared_data_offset_ - vdex_size_);
-      }
+      DCHECK(!use_existing_vdex);
+      memset(vdex_begin_ + vdex_size_, 0, vdex_dex_shared_data_offset_ - vdex_size_);
       size_dex_file_alignment_ += vdex_dex_shared_data_offset_ - vdex_size_;
       vdex_size_ = vdex_dex_shared_data_offset_;
 
       if (dex_container_ != nullptr) {
-        CHECK(!update_input_vdex) << "Update input vdex should have empty dex container";
+        CHECK(!use_existing_vdex) << "Use existing vdex should have empty dex container";
         CHECK(compact_dex_level_ != CompactDexLevel::kCompactDexLevelNone);
         DexContainer::Section* const section = dex_container_->GetDataSection();
         DCHECK_EQ(shared_data_size, section->Size());
         memcpy(vdex_begin_ + vdex_size_, section->Begin(), shared_data_size);
         section->Clear();
         dex_container_.reset();
-      } else if (!update_input_vdex) {
-        // If we are not updating the input vdex, write out the shared data section.
+      } else {
         memcpy(vdex_begin_ + vdex_size_, raw_dex_file_shared_data_begin, shared_data_size);
       }
       vdex_size_ += shared_data_size;
       size_dex_file_ += shared_data_size;
-      if (!update_input_vdex) {
+      if (!use_existing_vdex) {
         // Fix up the dex headers to have correct offsets to the data section.
         for (OatDexFile& oat_dex_file : oat_dex_files_) {
           DexFile::Header* header =
@@ -3283,6 +3282,14 @@
     vdex_dex_shared_data_offset_ = vdex_size_;
   }
 
+  if (use_existing_vdex) {
+    // If we re-use an existing vdex, artificially set the verifier deps size,
+    // so the compiler has a correct computation of the vdex size.
+    size_t actual_size = file->GetLength();
+    size_verifier_deps_ = actual_size - vdex_size_;
+    vdex_size_ = actual_size;
+  }
+
   return true;
 }
 
@@ -3297,22 +3304,22 @@
 
 bool OatWriter::WriteDexFile(File* file,
                              OatDexFile* oat_dex_file,
-                             bool update_input_vdex) {
+                             bool use_existing_vdex) {
   DCHECK_EQ(vdex_size_, oat_dex_file->dex_file_offset_);
   if (oat_dex_file->source_.IsZipEntry()) {
-    DCHECK(!update_input_vdex);
+    DCHECK(!use_existing_vdex);
     if (!WriteDexFile(file, oat_dex_file, oat_dex_file->source_.GetZipEntry())) {
       return false;
     }
   } else if (oat_dex_file->source_.IsRawFile()) {
-    DCHECK(!update_input_vdex);
+    DCHECK(!use_existing_vdex);
     if (!WriteDexFile(file, oat_dex_file, oat_dex_file->source_.GetRawFile())) {
       return false;
     }
   } else {
     DCHECK(oat_dex_file->source_.IsRawData());
     const uint8_t* raw_data = oat_dex_file->source_.GetRawData();
-    if (!WriteDexFile(oat_dex_file, raw_data, update_input_vdex)) {
+    if (!WriteDexFile(oat_dex_file, raw_data, use_existing_vdex)) {
       return false;
     }
   }
@@ -3447,14 +3454,14 @@
 
 bool OatWriter::WriteDexFile(OatDexFile* oat_dex_file,
                              const uint8_t* dex_file,
-                             bool update_input_vdex) {
+                             bool use_existing_vdex) {
   // Note: The raw data has already been checked to contain the header
   // and all the data that the header specifies as the file size.
   DCHECK(dex_file != nullptr);
   DCHECK(ValidateDexFileHeader(dex_file, oat_dex_file->GetLocation()));
   DCHECK_EQ(oat_dex_file->dex_file_size_, AsUnalignedDexFileHeader(dex_file)->file_size_);
 
-  if (update_input_vdex) {
+  if (use_existing_vdex) {
     // The vdex already contains the dex code, no need to write it again.
   } else {
     uint8_t* raw_output = vdex_begin_ + oat_dex_file->dex_file_offset_;
@@ -3763,7 +3770,6 @@
   for (size_t i = 0, size = oat_dex_files_.size(); i != size; ++i) {
     OatDexFile* oat_dex_file = &oat_dex_files_[i];
     checksums_data[i] = oat_dex_file->dex_file_location_checksum_;
-    size_vdex_checksums_ += sizeof(VdexFile::VdexChecksum);
   }
 
   // Write sections.
diff --git a/dex2oat/linker/oat_writer.h b/dex2oat/linker/oat_writer.h
index 87174eb..ad14d60 100644
--- a/dex2oat/linker/oat_writer.h
+++ b/dex2oat/linker/oat_writer.h
@@ -157,11 +157,11 @@
   // Write raw dex files to the vdex file, mmap the file and open the dex files from it.
   // The `verify` setting dictates whether the dex file verifier should check the dex files.
   // This is generally the case, and should only be false for tests.
-  // If `update_input_vdex` is true, then this method won't actually write the dex files,
+  // If `use_existing_vdex` is true, then this method won't actually write the dex files,
   // and the compiler will just re-use the existing vdex file.
   bool WriteAndOpenDexFiles(File* vdex_file,
                             bool verify,
-                            bool update_input_vdex,
+                            bool use_existing_vdex,
                             CopyOption copy_dex_files,
                             /*out*/ std::vector<MemMap>* opened_dex_files_map,
                             /*out*/ std::vector<std::unique_ptr<const DexFile>>* opened_dex_files);
@@ -276,12 +276,12 @@
   // If `update_input_vdex` is true, then this method won't actually write the dex files,
   // and the compiler will just re-use the existing vdex file.
   bool WriteDexFiles(File* file,
-                     bool update_input_vdex,
+                     bool use_existing_vdex,
                      CopyOption copy_dex_files,
                      /*out*/ std::vector<MemMap>* opened_dex_files_map);
   bool WriteDexFile(File* file,
                     OatDexFile* oat_dex_file,
-                    bool update_input_vdex);
+                    bool use_existing_vdex);
   bool LayoutDexFile(OatDexFile* oat_dex_file);
   bool WriteDexFile(File* file,
                     OatDexFile* oat_dex_file,
@@ -291,7 +291,7 @@
                     File* dex_file);
   bool WriteDexFile(OatDexFile* oat_dex_file,
                     const uint8_t* dex_file,
-                    bool update_input_vdex);
+                    bool use_existing_vdex);
   bool OpenDexFiles(File* file,
                     bool verify,
                     /*inout*/ std::vector<MemMap>* opened_dex_files_map,
diff --git a/dexlayout/dexdiag.cc b/dexlayout/dexdiag.cc
index a9ea27d..9aa0353 100644
--- a/dexlayout/dexdiag.cc
+++ b/dexlayout/dexdiag.cc
@@ -330,7 +330,6 @@
   std::unique_ptr<VdexFile> vdex(VdexFile::Open(vdex_name,
                                                 /*writable=*/ false,
                                                 /*low_4gb=*/ false,
-                                                /*unquicken= */ false,
                                                 &error_msg /*out*/));
   if (vdex == nullptr) {
     std::cerr << "Could not open vdex file "
diff --git a/dexlayout/dexlayout.h b/dexlayout/dexlayout.h
index 9bb7b8b..bdc7863 100644
--- a/dexlayout/dexlayout.h
+++ b/dexlayout/dexlayout.h
@@ -99,7 +99,10 @@
 
   // Setting this to false disables class def layout entirely, which is stronger than strictly
   // necessary to ensure the partial order w.r.t. class derivation. TODO: Re-enable (b/68317550).
+  // This should never be set for a device build, as changing class defs ids
+  // conflict with profiles and verification passed by Play.
   static constexpr bool kChangeClassDefOrder = false;
+  static_assert(!(kIsTargetBuild && kChangeClassDefOrder), "Never set class reordering on target");
 
   DexLayout(Options& options,
             ProfileCompilationInfo* info,
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 54e3712..c80feaf 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -190,10 +190,6 @@
   }
 
  private:
-  // Returns true if we want to remove quickened opcodes before loading the VDEX file, false
-  // otherwise.
-  bool ShouldUnquickenVDex() const;
-
   DISALLOW_COPY_AND_ASSIGN(OatFileBase);
 };
 
@@ -280,23 +276,6 @@
   return ret.release();
 }
 
-bool OatFileBase::ShouldUnquickenVDex() const {
-  // We sometimes load oat files without a runtime (eg oatdump) and don't want to do anything in
-  // that case. If we are debuggable there are no -quick opcodes to unquicken. If the runtime is not
-  // debuggable we don't care whether there are -quick opcodes or not so no need to do anything.
-  Runtime* runtime = Runtime::Current();
-  return (runtime != nullptr && runtime->IsJavaDebuggable()) &&
-         // Note: This is called before `OatFileBase::Setup()` where we validate the
-         // oat file contents. Check that we have at least a valid header, including
-         // oat file version, to avoid parsing the key-value store for a different
-         // version (out-of-date oat file) which can lead to crashes. b/179221298.
-         // TODO: While this is a poor workaround and the correct solution would be
-         // to postpone the unquickening check until after `OatFileBase::Setup()`,
-         // we prefer to avoid larger rewrites because quickening is deprecated and
-         // should be removed completely anyway. b/170086509
-         (GetOatHeader().IsValid() && !IsDebuggable());
-}
-
 bool OatFileBase::LoadVdex(const std::string& vdex_filename,
                            bool writable,
                            bool low_4gb,
@@ -307,7 +286,6 @@
                                   vdex_filename,
                                   writable,
                                   low_4gb,
-                                  ShouldUnquickenVDex(),
                                   error_msg);
   if (vdex_.get() == nullptr) {
     *error_msg = StringPrintf("Failed to load vdex file '%s' %s",
@@ -338,7 +316,6 @@
           vdex_filename,
           writable,
           low_4gb,
-          ShouldUnquickenVDex(),
           error_msg);
       if (vdex_.get() == nullptr) {
         *error_msg = "Failed opening vdex file.";
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index 414b24e..c303a7b 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -877,7 +877,6 @@
                                 filename_,
                                 /*writable=*/ false,
                                 /*low_4gb=*/ false,
-                                /*unquicken=*/ false,
                                 &error_msg);
         }
       }
@@ -885,7 +884,6 @@
       vdex = VdexFile::Open(filename_,
                             /*writable=*/ false,
                             /*low_4gb=*/ false,
-                            /*unquicken=*/ false,
                             &error_msg);
     }
     if (vdex == nullptr) {
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index f172ee0..aaa6600 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -497,7 +497,6 @@
     vdex_file = VdexFile::Open(vdex_path,
                                /* writable= */ false,
                                /* low_4gb= */ false,
-                               /* unquicken= */ false,
                                &error_msg);
     if (vdex_file == nullptr) {
       LOG(WARNING) << "Failed to open vdex " << vdex_path << ": " << error_msg;
diff --git a/runtime/vdex_file.cc b/runtime/vdex_file.cc
index 1bf6493..77647fb 100644
--- a/runtime/vdex_file.cc
+++ b/runtime/vdex_file.cc
@@ -75,7 +75,6 @@
                                                   const std::string& vdex_filename,
                                                   bool writable,
                                                   bool low_4gb,
-                                                  bool unquicken,
                                                   std::string* error_msg) {
   ScopedTrace trace(("VdexFile::OpenAtAddress " + vdex_filename).c_str());
   if (!OS::FileExists(vdex_filename.c_str())) {
@@ -109,7 +108,6 @@
                        vdex_filename,
                        writable,
                        low_4gb,
-                       unquicken,
                        error_msg);
 }
 
@@ -121,7 +119,6 @@
                                                   const std::string& vdex_filename,
                                                   bool writable,
                                                   bool low_4gb,
-                                                  bool unquicken,
                                                   std::string* error_msg) {
   if (mmap_addr != nullptr && mmap_size < vdex_length) {
     *error_msg = StringPrintf("Insufficient pre-allocated space to mmap vdex: %zu and %zu",
@@ -130,7 +127,6 @@
     return nullptr;
   }
   CHECK(!mmap_reuse || mmap_addr != nullptr);
-  CHECK(!(writable && unquicken)) << "We don't want to be writing unquickened files out to disk!";
   // Start as PROT_WRITE so we can mprotect back to it if we want to.
   MemMap mmap = MemMap::MapFileAtAddress(
       mmap_addr,
diff --git a/runtime/vdex_file.h b/runtime/vdex_file.h
index 35be4fb..3ccbfa5 100644
--- a/runtime/vdex_file.h
+++ b/runtime/vdex_file.h
@@ -194,7 +194,6 @@
                                                  const std::string& vdex_filename,
                                                  bool writable,
                                                  bool low_4gb,
-                                                 bool unquicken,
                                                  std::string* error_msg);
 
   // Returns nullptr if the vdex file cannot be opened or is not valid.
@@ -207,14 +206,12 @@
                                                  const std::string& vdex_filename,
                                                  bool writable,
                                                  bool low_4gb,
-                                                 bool unquicken,
                                                  std::string* error_msg);
 
   // Returns nullptr if the vdex file cannot be opened or is not valid.
   static std::unique_ptr<VdexFile> Open(const std::string& vdex_filename,
                                         bool writable,
                                         bool low_4gb,
-                                        bool unquicken,
                                         std::string* error_msg) {
     return OpenAtAddress(nullptr,
                          0,
@@ -222,7 +219,6 @@
                          vdex_filename,
                          writable,
                          low_4gb,
-                         unquicken,
                          error_msg);
   }
 
@@ -232,7 +228,6 @@
                                         const std::string& vdex_filename,
                                         bool writable,
                                         bool low_4gb,
-                                        bool unquicken,
                                         std::string* error_msg) {
     return OpenAtAddress(nullptr,
                          0,
@@ -242,7 +237,6 @@
                          vdex_filename,
                          writable,
                          low_4gb,
-                         unquicken,
                          error_msg);
   }
 
diff --git a/runtime/vdex_file_test.cc b/runtime/vdex_file_test.cc
index 9d92b42..565487e 100644
--- a/runtime/vdex_file_test.cc
+++ b/runtime/vdex_file_test.cc
@@ -36,12 +36,11 @@
                                                   tmp.GetFilename(),
                                                   /*writable=*/false,
                                                   /*low_4gb=*/false,
-                                                  /*unquicken=*/false,
                                                   &error_msg);
   EXPECT_TRUE(vdex == nullptr);
 
   vdex = VdexFile::Open(
-      tmp.GetFilename(), /*writable=*/false, /*low_4gb=*/false, /*unquicken=*/ false, &error_msg);
+      tmp.GetFilename(), /*writable=*/false, /*low_4gb=*/false, &error_msg);
   EXPECT_TRUE(vdex == nullptr);
 }