summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dex2oat/dex2oat.cc3
-rw-r--r--runtime/oat.cc4
-rw-r--r--runtime/oat.h4
-rw-r--r--runtime/oat_file.cc4
-rw-r--r--runtime/oat_file.h2
-rw-r--r--runtime/oat_file_assistant.cc67
-rw-r--r--runtime/oat_file_assistant.h21
-rw-r--r--runtime/oat_file_assistant_test.cc166
8 files changed, 14 insertions, 257 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index ece81e3919..21b03eb8ba 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1095,9 +1095,6 @@ class Dex2Oat FINAL {
compiler_options_->GetNativeDebuggable() ? OatHeader::kTrueValue : OatHeader::kFalseValue);
key_value_store_->Put(OatHeader::kCompilerFilter,
CompilerFilter::NameOfFilter(compiler_options_->GetCompilerFilter()));
- key_value_store_->Put(OatHeader::kHasPatchInfoKey,
- compiler_options_->GetIncludePatchInformation() ? OatHeader::kTrueValue
- : OatHeader::kFalseValue);
}
// Parse the arguments from the command line. In case of an unrecognized option or impossible
diff --git a/runtime/oat.cc b/runtime/oat.cc
index cebe765369..1a07cdc7f3 100644
--- a/runtime/oat.cc
+++ b/runtime/oat.cc
@@ -469,10 +469,6 @@ bool OatHeader::IsPic() const {
return IsKeyEnabled(OatHeader::kPicKey);
}
-bool OatHeader::HasPatchInfo() const {
- return IsKeyEnabled(OatHeader::kHasPatchInfoKey);
-}
-
bool OatHeader::IsDebuggable() const {
return IsKeyEnabled(OatHeader::kDebuggableKey);
}
diff --git a/runtime/oat.h b/runtime/oat.h
index 0f4cbbb767..1fd906dc1b 100644
--- a/runtime/oat.h
+++ b/runtime/oat.h
@@ -32,13 +32,12 @@ class InstructionSetFeatures;
class PACKED(4) OatHeader {
public:
static constexpr uint8_t kOatMagic[] = { 'o', 'a', 't', '\n' };
- static constexpr uint8_t kOatVersion[] = { '0', '9', '3', '\0' };
+ static constexpr uint8_t kOatVersion[] = { '0', '9', '4', '\0' };
static constexpr const char* kImageLocationKey = "image-location";
static constexpr const char* kDex2OatCmdLineKey = "dex2oat-cmdline";
static constexpr const char* kDex2OatHostKey = "dex2oat-host";
static constexpr const char* kPicKey = "pic";
- static constexpr const char* kHasPatchInfoKey = "has-patch-info";
static constexpr const char* kDebuggableKey = "debuggable";
static constexpr const char* kNativeDebuggableKey = "native-debuggable";
static constexpr const char* kCompilerFilter = "compiler-filter";
@@ -110,7 +109,6 @@ class PACKED(4) OatHeader {
size_t GetHeaderSize() const;
bool IsPic() const;
- bool HasPatchInfo() const;
bool IsDebuggable() const;
bool IsNativeDebuggable() const;
CompilerFilter::Filter GetCompilerFilter() const;
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 2e4211133c..38df427ed1 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -1438,10 +1438,6 @@ void OatFile::OatMethod::LinkMethod(ArtMethod* method) const {
method->SetEntryPointFromQuickCompiledCode(GetQuickCode());
}
-bool OatFile::HasPatchInfo() const {
- return GetOatHeader().HasPatchInfo();
-}
-
bool OatFile::IsPic() const {
return GetOatHeader().IsPic();
// TODO: Check against oat_patches. b/18144996
diff --git a/runtime/oat_file.h b/runtime/oat_file.h
index 29add5b2b2..62d99fb51c 100644
--- a/runtime/oat_file.h
+++ b/runtime/oat_file.h
@@ -104,8 +104,6 @@ class OatFile {
return is_executable_;
}
- bool HasPatchInfo() const;
-
bool IsPic() const;
// Indicates whether the oat file was compiled with full debugging capability.
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index ee7cf9deef..f12a5e7742 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -203,10 +203,6 @@ OatFileAssistant::MakeUpToDate(bool profile_changed, std::string* error_msg) {
case kDex2OatForRelocation:
case kDex2OatForFilter:
return GenerateOatFile(error_msg);
-
- case kPatchoatForRelocation: {
- return RelocateOatFile(info.Filename(), error_msg);
- }
}
UNREACHABLE();
}
@@ -420,58 +416,6 @@ OatFileAssistant::OatStatus OatFileAssistant::GivenOatFileStatus(const OatFile&
}
OatFileAssistant::ResultOfAttemptToUpdate
-OatFileAssistant::RelocateOatFile(const std::string* input_file, std::string* error_msg) {
- CHECK(error_msg != nullptr);
-
- if (input_file == nullptr) {
- *error_msg = "Patching of oat file for dex location " + dex_location_
- + " not attempted because the input file name could not be determined.";
- return kUpdateNotAttempted;
- }
- const std::string& input_file_name = *input_file;
-
- if (oat_.Filename() == nullptr) {
- *error_msg = "Patching of oat file for dex location " + dex_location_
- + " not attempted because the oat file name could not be determined.";
- return kUpdateNotAttempted;
- }
- const std::string& oat_file_name = *oat_.Filename();
-
- const ImageInfo* image_info = GetImageInfo();
- Runtime* runtime = Runtime::Current();
- if (image_info == nullptr) {
- *error_msg = "Patching of oat file " + oat_file_name
- + " not attempted because no image location was found.";
- return kUpdateNotAttempted;
- }
-
- if (!runtime->IsDex2OatEnabled()) {
- *error_msg = "Patching of oat file " + oat_file_name
- + " not attempted because dex2oat is disabled";
- return kUpdateNotAttempted;
- }
-
- std::vector<std::string> argv;
- argv.push_back(runtime->GetPatchoatExecutable());
- argv.push_back("--instruction-set=" + std::string(GetInstructionSetString(isa_)));
- argv.push_back("--input-oat-file=" + input_file_name);
- argv.push_back("--output-oat-file=" + oat_file_name);
- argv.push_back("--patched-image-location=" + image_info->location);
-
- std::string command_line(android::base::Join(argv, ' '));
- if (!Exec(argv, error_msg)) {
- // Manually delete the file. This ensures there is no garbage left over if
- // the process unexpectedly died.
- unlink(oat_file_name.c_str());
- return kUpdateFailed;
- }
-
- // Mark that the oat file has changed and we should try to reload.
- oat_.Reset();
- return kUpdateSucceeded;
-}
-
-OatFileAssistant::ResultOfAttemptToUpdate
OatFileAssistant::GenerateOatFile(std::string* error_msg) {
CHECK(error_msg != nullptr);
@@ -852,13 +796,7 @@ OatFileAssistant::DexOptNeeded OatFileAssistant::OatFileInfo::GetDexOptNeeded(
return kNoDexOptNeeded;
}
- if (filter_okay && Status() == kOatRelocationOutOfDate && HasPatchInfo()) {
- return kPatchoatForRelocation;
- }
-
if (oat_file_assistant_->HasOriginalDexFiles()) {
- // Run dex2oat for relocation if we didn't have the patch info necessary
- // to use patchoat.
if (filter_okay && Status() == kOatRelocationOutOfDate) {
return kDex2OatForRelocation;
}
@@ -921,11 +859,6 @@ bool OatFileAssistant::OatFileInfo::IsExecutable() {
return (file != nullptr && file->IsExecutable());
}
-bool OatFileAssistant::OatFileInfo::HasPatchInfo() {
- const OatFile* file = GetFile();
- return (file != nullptr && file->HasPatchInfo());
-}
-
void OatFileAssistant::OatFileInfo::Reset() {
load_attempted_ = false;
file_.reset();
diff --git a/runtime/oat_file_assistant.h b/runtime/oat_file_assistant.h
index bed1edc6c8..588a698be7 100644
--- a/runtime/oat_file_assistant.h
+++ b/runtime/oat_file_assistant.h
@@ -67,14 +67,9 @@ class OatFileAssistant {
kDex2OatForFilter = 3,
// dex2oat should be run to update the apk/jar because the existing code
- // is not relocated to match the boot image and does not have the
- // necessary patch information to use patchoat.
+ // is not relocated to match the boot image.
// Matches Java: dalvik.system.DexFile.DEX2OAT_FOR_RELOCATION
kDex2OatForRelocation = 4,
-
- // patchoat should be run to update the apk/jar.
- // Matches Java: dalvik.system.DexFile.PATCHOAT_FOR_RELOCATION
- kPatchoatForRelocation = 5,
};
enum OatStatus {
@@ -237,15 +232,6 @@ class OatFileAssistant {
// Returns the status of the oat file for the dex location.
OatStatus OatFileStatus();
- // Generates the oat file by relocation from the named input file.
- // This does not check the current status before attempting to relocate 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 RelocateOatFile(const std::string* input_file, std::string* error_msg);
-
// Generate the oat file from the dex file using the current runtime
// compiler options.
// This does not check the current status before attempting to generate the
@@ -328,8 +314,6 @@ class OatFileAssistant {
// given target_compilation_filter.
// profile_changed should be true to indicate the profile has recently
// changed for this dex location.
- // If patchoat is needed, this function will return the kPatchOatNeeded
- // status, not the kSelfPatchOatNeeded status.
DexOptNeeded GetDexOptNeeded(CompilerFilter::Filter target_compiler_filter,
bool profile_changed);
@@ -341,9 +325,6 @@ class OatFileAssistant {
// Returns true if the file is opened executable.
bool IsExecutable();
- // Returns true if the file has patch info required to run patchoat.
- bool HasPatchInfo();
-
// Clear any cached information about the file that depends on the
// contents of the file. This does not reset the provided filename.
void Reset();
diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc
index 26dbaab367..afa804c08c 100644
--- a/runtime/oat_file_assistant_test.cc
+++ b/runtime/oat_file_assistant_test.cc
@@ -85,7 +85,6 @@ class OatFileAssistantTest : public Dex2oatEnvironmentTest {
CompilerFilter::Filter filter,
bool relocate,
bool pic,
- bool with_patch_info,
bool with_alternate_image) {
std::string dalvik_cache = GetDalvikCache(GetInstructionSetString(kRuntimeISA));
std::string dalvik_cache_tmp = dalvik_cache + ".redirected";
@@ -111,10 +110,6 @@ class OatFileAssistantTest : public Dex2oatEnvironmentTest {
args.push_back("--compile-pic");
}
- if (with_patch_info) {
- args.push_back("--include-patch-information");
- }
-
std::string image_location = GetImageLocation();
if (with_alternate_image) {
args.push_back("--boot-image=" + GetImageLocation2());
@@ -139,7 +134,6 @@ class OatFileAssistantTest : public Dex2oatEnvironmentTest {
&error_msg));
ASSERT_TRUE(odex_file.get() != nullptr) << error_msg;
EXPECT_EQ(pic, odex_file->IsPic());
- EXPECT_EQ(with_patch_info, odex_file->HasPatchInfo());
EXPECT_EQ(filter, odex_file->GetCompilerFilter());
std::unique_ptr<ImageHeader> image_header(
@@ -181,7 +175,6 @@ class OatFileAssistantTest : public Dex2oatEnvironmentTest {
filter,
/*relocate*/false,
/*pic*/false,
- /*with_patch_info*/true,
/*with_alternate_image*/false);
}
@@ -193,21 +186,6 @@ class OatFileAssistantTest : public Dex2oatEnvironmentTest {
filter,
/*relocate*/false,
/*pic*/true,
- /*with_patch_info*/false,
- /*with_alternate_image*/false);
- }
-
- // Generate a non-PIC odex file without patch information for the purposes
- // of test. The generated odex file will be un-relocated.
- void GenerateNoPatchOdexForTest(const std::string& dex_location,
- const std::string& odex_location,
- CompilerFilter::Filter filter) {
- GenerateOatForTest(dex_location,
- odex_location,
- filter,
- /*relocate*/false,
- /*pic*/false,
- /*with_patch_info*/false,
/*with_alternate_image*/false);
}
@@ -216,7 +194,6 @@ class OatFileAssistantTest : public Dex2oatEnvironmentTest {
CompilerFilter::Filter filter,
bool relocate,
bool pic,
- bool with_patch_info,
bool with_alternate_image) {
std::string oat_location;
std::string error_msg;
@@ -227,7 +204,6 @@ class OatFileAssistantTest : public Dex2oatEnvironmentTest {
filter,
relocate,
pic,
- with_patch_info,
with_alternate_image);
}
@@ -237,7 +213,6 @@ class OatFileAssistantTest : public Dex2oatEnvironmentTest {
filter,
/*relocate*/true,
/*pic*/false,
- /*with_patch_info*/false,
/*with_alternate_image*/false);
}
@@ -519,7 +494,6 @@ TEST_F(OatFileAssistantTest, OatImageOutOfDate) {
CompilerFilter::kSpeed,
/*relocate*/true,
/*pic*/false,
- /*with_patch_info*/false,
/*with_alternate_image*/true);
OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false);
@@ -548,7 +522,6 @@ TEST_F(OatFileAssistantTest, OatVerifyAtRuntimeImageOutOfDate) {
CompilerFilter::kVerifyAtRuntime,
/*relocate*/true,
/*pic*/false,
- /*with_patch_info*/false,
/*with_alternate_image*/true);
OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false);
@@ -564,7 +537,6 @@ TEST_F(OatFileAssistantTest, OatVerifyAtRuntimeImageOutOfDate) {
}
// Case: We have a DEX file and an ODEX file, but no OAT file.
-// Expect: The status is kPatchOatNeeded.
TEST_F(OatFileAssistantTest, DexOdexNoOat) {
std::string dex_location = GetScratchDir() + "/DexOdexNoOat.jar";
std::string odex_location = GetOdexDir() + "/DexOdexNoOat.odex";
@@ -578,7 +550,7 @@ TEST_F(OatFileAssistantTest, DexOdexNoOat) {
EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
oat_file_assistant.GetDexOptNeeded(CompilerFilter::kVerifyAtRuntime));
- EXPECT_EQ(-OatFileAssistant::kPatchoatForRelocation,
+ EXPECT_EQ(-OatFileAssistant::kDex2OatForRelocation,
oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
@@ -591,15 +563,14 @@ TEST_F(OatFileAssistantTest, DexOdexNoOat) {
ASSERT_TRUE(oat_file.get() != nullptr);
}
-// Case: We have a stripped DEX file and an ODEX file, but no OAT file.
-// Expect: The status is kPatchOatNeeded
+// Case: We have a stripped DEX file and a PIC ODEX file, but no OAT file.
TEST_F(OatFileAssistantTest, StrippedDexOdexNoOat) {
std::string dex_location = GetScratchDir() + "/StrippedDexOdexNoOat.jar";
std::string odex_location = GetOdexDir() + "/StrippedDexOdexNoOat.odex";
// Create the dex and odex files
Copy(GetDexSrc1(), dex_location);
- GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
+ GeneratePicOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
// Strip the dex file
Copy(GetStrippedDexSrc1(), dex_location);
@@ -607,28 +578,14 @@ TEST_F(OatFileAssistantTest, StrippedDexOdexNoOat) {
// Verify the status.
OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
- EXPECT_EQ(-OatFileAssistant::kPatchoatForRelocation,
+ EXPECT_EQ(-OatFileAssistant::kNoDexOptNeeded,
oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
- EXPECT_EQ(OatFileAssistant::kOatRelocationOutOfDate, oat_file_assistant.OdexFileStatus());
+ EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OdexFileStatus());
EXPECT_EQ(OatFileAssistant::kOatCannotOpen, oat_file_assistant.OatFileStatus());
EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
- // Make the oat file up to date.
- std::string error_msg;
- Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
- ASSERT_EQ(OatFileAssistant::kUpdateSucceeded,
- oat_file_assistant.MakeUpToDate(false, &error_msg)) << error_msg;
-
- EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
-
- EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
- EXPECT_EQ(OatFileAssistant::kOatRelocationOutOfDate, oat_file_assistant.OdexFileStatus());
- EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OatFileStatus());
- EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
-
// Verify we can load the dex files from it.
std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
ASSERT_TRUE(oat_file.get() != nullptr);
@@ -638,8 +595,7 @@ TEST_F(OatFileAssistantTest, StrippedDexOdexNoOat) {
EXPECT_EQ(1u, dex_files.size());
}
-// Case: We have a stripped DEX file, an ODEX file, and an out-of-date OAT file.
-// Expect: The status is kPatchOatNeeded.
+// Case: We have a stripped DEX file, a PIC ODEX file, and an out-of-date OAT file.
TEST_F(OatFileAssistantTest, StrippedDexOdexOat) {
std::string dex_location = GetScratchDir() + "/StrippedDexOdexOat.jar";
std::string odex_location = GetOdexDir() + "/StrippedDexOdexOat.odex";
@@ -650,7 +606,7 @@ TEST_F(OatFileAssistantTest, StrippedDexOdexOat) {
// Create the odex file
Copy(GetDexSrc1(), dex_location);
- GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
+ GeneratePicOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
// Strip the dex file.
Copy(GetStrippedDexSrc1(), dex_location);
@@ -660,30 +616,14 @@ TEST_F(OatFileAssistantTest, StrippedDexOdexOat) {
EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
oat_file_assistant.GetDexOptNeeded(CompilerFilter::kVerifyAtRuntime));
- EXPECT_EQ(-OatFileAssistant::kPatchoatForRelocation,
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
- EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, // Can't run dex2oat because dex file is stripped.
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kEverything));
-
- EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
- EXPECT_EQ(OatFileAssistant::kOatRelocationOutOfDate, oat_file_assistant.OdexFileStatus());
- EXPECT_EQ(OatFileAssistant::kOatDexOutOfDate, oat_file_assistant.OatFileStatus());
- EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
-
- // Make the oat file up to date.
- std::string error_msg;
- Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
- ASSERT_EQ(OatFileAssistant::kUpdateSucceeded,
- oat_file_assistant.MakeUpToDate(false, &error_msg)) << error_msg;
-
EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, // Can't run dex2oat because dex file is stripped.
oat_file_assistant.GetDexOptNeeded(CompilerFilter::kEverything));
EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
- EXPECT_EQ(OatFileAssistant::kOatRelocationOutOfDate, oat_file_assistant.OdexFileStatus());
- EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OatFileStatus());
+ EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OdexFileStatus());
+ EXPECT_EQ(OatFileAssistant::kOatDexOutOfDate, oat_file_assistant.OatFileStatus());
EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
// Verify we can load the dex files from it.
@@ -732,90 +672,9 @@ TEST_F(OatFileAssistantTest, ResourceOnlyDex) {
EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
}
-// Case: We have a DEX file, no ODEX file and an OAT file that needs
-// relocation.
-// Expect: The status is kSelfPatchOatNeeded.
-TEST_F(OatFileAssistantTest, SelfRelocation) {
- std::string dex_location = GetScratchDir() + "/SelfRelocation.jar";
- std::string oat_location = GetOdexDir() + "/SelfRelocation.oat";
-
- // Create the dex and odex files
- Copy(GetDexSrc1(), dex_location);
- GenerateOdexForTest(dex_location, oat_location, CompilerFilter::kSpeed);
-
- OatFileAssistant oat_file_assistant(dex_location.c_str(),
- oat_location.c_str(), kRuntimeISA, true);
-
- EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kInterpretOnly));
- EXPECT_EQ(OatFileAssistant::kPatchoatForRelocation,
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
- EXPECT_EQ(OatFileAssistant::kDex2OatForFilter,
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kEverything));
-
- EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
- EXPECT_EQ(OatFileAssistant::kOatCannotOpen, oat_file_assistant.OdexFileStatus());
- EXPECT_EQ(OatFileAssistant::kOatRelocationOutOfDate, oat_file_assistant.OatFileStatus());
- EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
-
- // Make the oat file up to date.
- std::string error_msg;
- Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
- ASSERT_EQ(OatFileAssistant::kUpdateSucceeded,
- oat_file_assistant.MakeUpToDate(false, &error_msg)) << error_msg;
-
- EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
-
- EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
- EXPECT_EQ(OatFileAssistant::kOatCannotOpen, oat_file_assistant.OdexFileStatus());
- EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OatFileStatus());
- EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
-
- std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
- ASSERT_TRUE(oat_file.get() != nullptr);
- EXPECT_TRUE(oat_file->IsExecutable());
- std::vector<std::unique_ptr<const DexFile>> dex_files;
- dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
- EXPECT_EQ(1u, dex_files.size());
-}
-
-// Case: We have a DEX file, no ODEX file and an OAT file that needs
-// relocation but doesn't have patch info.
-// Expect: The status is kDex2OatNeeded, because we can't run patchoat.
-TEST_F(OatFileAssistantTest, NoSelfRelocation) {
- std::string dex_location = GetScratchDir() + "/NoSelfRelocation.jar";
- std::string oat_location = GetOdexDir() + "/NoSelfRelocation.oat";
-
- // Create the dex and odex files
- Copy(GetDexSrc1(), dex_location);
- GenerateNoPatchOdexForTest(dex_location, oat_location, CompilerFilter::kSpeed);
-
- OatFileAssistant oat_file_assistant(dex_location.c_str(),
- oat_location.c_str(), kRuntimeISA, true);
-
- EXPECT_EQ(OatFileAssistant::kDex2OatForRelocation,
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
-
- // Make the oat file up to date.
- std::string error_msg;
- Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
- ASSERT_EQ(OatFileAssistant::kUpdateSucceeded,
- oat_file_assistant.MakeUpToDate(false, &error_msg)) << error_msg;
- EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
-
- std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
- ASSERT_TRUE(oat_file.get() != nullptr);
- EXPECT_TRUE(oat_file->IsExecutable());
- std::vector<std::unique_ptr<const DexFile>> dex_files;
- dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
- EXPECT_EQ(1u, dex_files.size());
-}
-
// Case: We have a DEX file, an ODEX file and an OAT file, where the ODEX and
// OAT files both have patch delta of 0.
-// Expect: It shouldn't crash, and status is kSelfPatchOatNeeded.
+// Expect: It shouldn't crash.
TEST_F(OatFileAssistantTest, OdexOatOverlap) {
std::string dex_location = GetScratchDir() + "/OdexOatOverlap.jar";
std::string odex_location = GetOdexDir() + "/OdexOatOverlap.odex";
@@ -833,10 +692,10 @@ TEST_F(OatFileAssistantTest, OdexOatOverlap) {
OatFileAssistant oat_file_assistant(dex_location.c_str(),
oat_location.c_str(), kRuntimeISA, true);
- // kPatchoatForRelocation is expected rather than -kPatchoatForRelocation
+ // kDex2OatForRelocation is expected rather than -kDex2OatForRelocation
// based on the assumption that the oat location is more up-to-date than the odex
// location, even if they both need relocation.
- EXPECT_EQ(OatFileAssistant::kPatchoatForRelocation,
+ EXPECT_EQ(OatFileAssistant::kDex2OatForRelocation,
oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
@@ -1285,7 +1144,6 @@ TEST_F(OatFileAssistantTest, DexOptStatusValues) {
{OatFileAssistant::kDex2OatForBootImage, "DEX2OAT_FOR_BOOT_IMAGE"},
{OatFileAssistant::kDex2OatForFilter, "DEX2OAT_FOR_FILTER"},
{OatFileAssistant::kDex2OatForRelocation, "DEX2OAT_FOR_RELOCATION"},
- {OatFileAssistant::kPatchoatForRelocation, "PATCHOAT_FOR_RELOCATION"}
};
ScopedObjectAccess soa(Thread::Current());