Code cleanup around vdex.
1) Handle the vdex in dex2oat instead of compiler_driver
2) CHECK instead of DCHECK that we don't dexlayout with vdex.
Test: test.py
Change-Id: Idf7be59bb25708181e391d17128480659ac697e5
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index b88fe09..d5d927c 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1292,8 +1292,6 @@
}
// OAT and VDEX file handling
- bool eagerly_unquicken_vdex = DoDexLayoutOptimizations();
-
if (oat_fd_ == -1) {
DCHECK(!oat_filenames_.empty());
for (const char* oat_filename : oat_filenames_) {
@@ -1314,7 +1312,7 @@
input_vdex_file_ = VdexFile::Open(input_vdex_,
/* writable */ false,
/* low_4gb */ false,
- eagerly_unquicken_vdex,
+ DoEagerUnquickeningOfVdex(),
&error_msg);
}
@@ -1364,7 +1362,7 @@
"vdex",
/* writable */ false,
/* low_4gb */ false,
- eagerly_unquicken_vdex,
+ DoEagerUnquickeningOfVdex(),
&error_msg);
// If there's any problem with the passed vdex, just warn and proceed
// without it.
@@ -1770,7 +1768,19 @@
swap_fd_,
profile_compilation_info_.get()));
driver_->SetDexFilesForOatFile(dex_files_);
- driver_->CompileAll(class_loader_, dex_files_, input_vdex_file_.get(), timings_);
+
+ // Setup vdex for compilation.
+ if (!DoEagerUnquickeningOfVdex() && input_vdex_file_ != nullptr) {
+ callbacks_->SetVerifierDeps(
+ new verifier::VerifierDeps(dex_files_, input_vdex_file_->GetVerifierDepsData()));
+
+ // TODO: we unquicken unconditionally, as we don't know
+ // if the boot image has changed. How exactly we'll know is under
+ // experimentation.
+ TimingLogger::ScopedTiming time_unquicken("Unquicken", timings_);
+ VdexFile::Unquicken(dex_files_, input_vdex_file_->GetQuickeningInfo());
+ }
+ driver_->CompileAll(class_loader_, dex_files_, timings_);
}
// Notes on the interleaving of creating the images and oat files to
@@ -2146,6 +2156,12 @@
return DoProfileGuidedOptimizations();
}
+ bool DoEagerUnquickeningOfVdex() const {
+ // DexLayout can invalidate the vdex metadata, so we need to unquicken
+ // the vdex file eagerly, before passing it to dexlayout.
+ return DoDexLayoutOptimizations();
+ }
+
bool LoadProfile() {
DCHECK(UseProfile());
// TODO(calin): We should be using the runtime arena pool (instead of the