diff options
| -rw-r--r-- | compiler/dex/dex_to_dex_decompiler.cc | 2 | ||||
| -rw-r--r-- | compiler/driver/compiler_driver.cc | 4 | ||||
| -rw-r--r-- | compiler/oat_writer.cc | 23 | ||||
| -rw-r--r-- | dex2oat/dex2oat.cc | 11 | ||||
| -rw-r--r-- | dex2oat/dex2oat_test.cc | 14 | ||||
| -rw-r--r-- | runtime/vdex_file.h | 2 |
6 files changed, 27 insertions, 29 deletions
diff --git a/compiler/dex/dex_to_dex_decompiler.cc b/compiler/dex/dex_to_dex_decompiler.cc index 53601033da..85d5784c7a 100644 --- a/compiler/dex/dex_to_dex_decompiler.cc +++ b/compiler/dex/dex_to_dex_decompiler.cc @@ -185,7 +185,7 @@ bool DexDecompiler::Decompile() { } if (quickened_info_ptr_ != quickened_info_end_) { - LOG(ERROR) << "Failed to use all values in quickening info." + LOG(FATAL) << "Failed to use all values in quickening info." << " Actual: " << std::hex << quickened_info_ptr_ << " Expected: " << quickened_info_end_; return false; diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 057e3c9960..995098799c 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -480,7 +480,9 @@ static void Unquicken(const std::vector<const DexFile*>& dex_files, DCHECK(!it.HasNext()); } } - DCHECK_EQ(quickening_info_ptr, quickening_info_end) << "Failed to use all quickening info"; + if (quickening_info_ptr != quickening_info_end) { + LOG(FATAL) << "Failed to use all quickening info"; + } } void CompilerDriver::CompileAll(jobject class_loader, diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc index 43f606af65..afcdf5ea17 100644 --- a/compiler/oat_writer.cc +++ b/compiler/oat_writer.cc @@ -2270,28 +2270,11 @@ bool OatWriter::LayoutAndWriteDexFile(OutputStream* out, OatDexFile* oat_dex_fil /* verify */ true, /* verify_checksum */ true, &error_msg); - } else if (oat_dex_file->source_.IsRawFile()) { - File* raw_file = oat_dex_file->source_.GetRawFile(); - dex_file = DexFile::OpenDex(raw_file->Fd(), location, /* verify_checksum */ true, &error_msg); } else { - // The source data is a vdex file. - CHECK(oat_dex_file->source_.IsRawData()) + CHECK(oat_dex_file->source_.IsRawFile()) << static_cast<size_t>(oat_dex_file->source_.GetType()); - const uint8_t* raw_dex_file = oat_dex_file->source_.GetRawData(); - // 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(raw_dex_file != nullptr); - DCHECK(ValidateDexFileHeader(raw_dex_file, oat_dex_file->GetLocation())); - const UnalignedDexFileHeader* header = AsUnalignedDexFileHeader(raw_dex_file); - // Since the source may have had its layout changed, don't verify the checksum. - dex_file = DexFile::Open(raw_dex_file, - header->file_size_, - location, - oat_dex_file->dex_file_location_checksum_, - nullptr, - /* verify */ true, - /* verify_checksum */ false, - &error_msg); + File* raw_file = oat_dex_file->source_.GetRawFile(); + dex_file = DexFile::OpenDex(raw_file->Fd(), location, /* verify_checksum */ true, &error_msg); } if (dex_file == nullptr) { LOG(ERROR) << "Failed to open dex file for layout: " << error_msg; diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 2684f3d8e2..3fa30fafb1 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -2100,6 +2100,10 @@ class Dex2Oat FINAL { return DoProfileGuidedOptimizations(); } + bool HasInputVdexFile() const { + return input_vdex_file_ != nullptr || input_vdex_fd_ != -1 || !input_vdex_.empty(); + } + bool LoadProfile() { DCHECK(UseProfile()); @@ -2885,6 +2889,13 @@ static int dex2oat(int argc, char** argv) { } } + if (dex2oat->DoDexLayoutOptimizations()) { + if (dex2oat->HasInputVdexFile()) { + LOG(ERROR) << "Dexlayout is incompatible with an input VDEX"; + return EXIT_FAILURE; + } + } + art::MemMap::Init(); // For ZipEntry::ExtractToMemMap, and vdex. // Check early that the result of compilation can be written diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc index e7277bceae..289b8ab50a 100644 --- a/dex2oat/dex2oat_test.cc +++ b/dex2oat/dex2oat_test.cc @@ -604,7 +604,8 @@ class Dex2oatLayoutTest : public Dex2oatTest { const std::string& app_image_file_name, bool use_fd, size_t num_profile_classes, - const std::vector<std::string>& extra_args = {}) { + const std::vector<std::string>& extra_args = {}, + bool expect_success = true) { const std::string profile_location = GetScratchDir() + "/primary.prof"; const char* location = dex_location.c_str(); std::string error_msg; @@ -631,7 +632,7 @@ class Dex2oatLayoutTest : public Dex2oatTest { odex_location, CompilerFilter::kSpeedProfile, copy, - /* expect_success */ true, + expect_success, use_fd); if (app_image_file != nullptr) { ASSERT_EQ(app_image_file->FlushCloseOrErase(), 0) << "Could not flush and close art file"; @@ -709,6 +710,7 @@ class Dex2oatLayoutTest : public Dex2oatTest { EXPECT_GT(vdex_file1->GetLength(), 0u); } { + // Test that vdex and dexlayout fail gracefully. std::string input_vdex = StringPrintf("--input-vdex-fd=%d", vdex_file1->Fd()); std::string output_vdex = StringPrintf("--output-vdex-fd=%d", vdex_file2.GetFd()); CompileProfileOdex(dex_location, @@ -716,13 +718,13 @@ class Dex2oatLayoutTest : public Dex2oatTest { app_image_file_name, /* use_fd */ true, /* num_profile_classes */ 1, - { input_vdex, output_vdex }); - EXPECT_GT(vdex_file2.GetFile()->GetLength(), 0u); + { input_vdex, output_vdex }, + /* expect_success */ false); + EXPECT_EQ(vdex_file2.GetFile()->GetLength(), 0u); } ASSERT_EQ(vdex_file1->FlushCloseOrErase(), 0) << "Could not flush and close vdex file"; CheckValidity(); - ASSERT_TRUE(success_); - CheckResult(dex_location, odex_location, app_image_file_name); + ASSERT_FALSE(success_); } void CheckResult(const std::string& dex_location, diff --git a/runtime/vdex_file.h b/runtime/vdex_file.h index 7daf2f8d7b..5048bad121 100644 --- a/runtime/vdex_file.h +++ b/runtime/vdex_file.h @@ -61,7 +61,7 @@ class VdexFile { private: static constexpr uint8_t kVdexMagic[] = { 'v', 'd', 'e', 'x' }; - static constexpr uint8_t kVdexVersion[] = { '0', '0', '3', '\0' }; // Remove verify-profile + static constexpr uint8_t kVdexVersion[] = { '0', '0', '4', '\0' }; // dexlayout incompatibility uint8_t magic_[4]; uint8_t version_[4]; |