diff options
author | 2023-03-16 15:15:53 +0000 | |
---|---|---|
committer | 2023-03-17 17:13:28 +0000 | |
commit | 240c51b114bedf1ec03f40fb87d6301fd1ea2ab9 (patch) | |
tree | a09721645415773b519da8c4898a1ed72eb2ba2e | |
parent | 1abfc59b5764ca8fec77f377209de41daabbe137 (diff) |
Deprecate the extract compiler filter.
For now make it an alias to verify.
Test: test.py
Bug: 237380287
Change-Id: Ib6cb2037d24bb895b77a870e8aebe76764b53e3d
-rw-r--r-- | compiler/driver/compiler_options.h | 4 | ||||
-rw-r--r-- | dex2oat/dex2oat.cc | 6 | ||||
-rw-r--r-- | dex2oat/dex2oat_test.cc | 9 | ||||
-rw-r--r-- | dexoptanalyzer/dexoptanalyzer_test.cc | 38 | ||||
-rw-r--r-- | libartbase/base/compiler_filter.cc | 28 | ||||
-rw-r--r-- | libartbase/base/compiler_filter.h | 1 | ||||
-rw-r--r-- | libartbase/base/compiler_filter_test.cc | 2 | ||||
-rw-r--r-- | runtime/oat_file_assistant_test.cc | 159 |
8 files changed, 16 insertions, 231 deletions
diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h index 1cc9f2d7e2..74d081d29e 100644 --- a/compiler/driver/compiler_options.h +++ b/compiler/driver/compiler_options.h @@ -114,10 +114,6 @@ class CompilerOptions final { return compiler_filter_ == CompilerFilter::kAssumeVerified; } - bool VerifyAtRuntime() const { - return compiler_filter_ == CompilerFilter::kExtract; - } - bool IsAnyCompilationEnabled() const { return CompilerFilter::IsAnyCompilationEnabled(compiler_filter_); } diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 51a36895fd..a0b860f465 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -1840,7 +1840,7 @@ class Dex2Oat final { // 2. not verifying a vdex file, and // 3. using multidex, and // 4. not doing any AOT compilation. - // This means extract, no-vdex verify, and quicken, will use the individual compilation + // This means no-vdex verify will use the individual compilation // mode (to reduce RAM used by the compiler). return compile_individually_ && (!IsImage() && !use_existing_vdex_ && @@ -1934,9 +1934,7 @@ class Dex2Oat final { const bool compile_individually = ShouldCompileDexFilesIndividually(); if (compile_individually) { - // Set the compiler driver in the callbacks so that we can avoid re-verification. This not - // only helps performance but also prevents reverifying quickened bytecodes. Attempting - // verify quickened bytecode causes verification failures. + // Set the compiler driver in the callbacks so that we can avoid re-verification. // Only set the compiler filter if we are doing separate compilation since there is a bit // of overhead when checking if a class was previously verified. callbacks_->SetDoesClassUnloading(true, driver_.get()); diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc index fd321e4d95..e444071e9c 100644 --- a/dex2oat/dex2oat_test.cc +++ b/dex2oat/dex2oat_test.cc @@ -479,7 +479,6 @@ class Dex2oatVeryLargeTest : public Dex2oatTest { CheckResult(dex_location, odex_location, app_image_file, - filter, expected_filter, expect_large, expect_downgrade); @@ -488,7 +487,6 @@ class Dex2oatVeryLargeTest : public Dex2oatTest { void CheckResult(const std::string& dex_location, const std::string& odex_location, const std::string& app_image_file, - CompilerFilter::Filter filter, CompilerFilter::Filter expected_filter, bool expect_large, bool expect_downgrade) { @@ -526,9 +524,7 @@ class Dex2oatVeryLargeTest : public Dex2oatTest { } // If the input filter was "below," it should have been used. - if (!CompilerFilter::IsAsGoodAs(CompilerFilter::kExtract, filter)) { - EXPECT_EQ(odex_file->GetCompilerFilter(), expected_filter); - } + EXPECT_EQ(odex_file->GetCompilerFilter(), expected_filter); // If expect large, make sure the app image isn't generated or is empty. if (file != nullptr) { @@ -583,17 +579,14 @@ class Dex2oatVeryLargeTest : public Dex2oatTest { TEST_F(Dex2oatVeryLargeTest, DontUseVeryLarge) { RunTest(CompilerFilter::kAssumeVerified, false, false); - RunTest(CompilerFilter::kExtract, false, false); RunTest(CompilerFilter::kSpeed, false, false); RunTest(CompilerFilter::kAssumeVerified, false, false, { "--very-large-app-threshold=10000000" }); - RunTest(CompilerFilter::kExtract, false, false, { "--very-large-app-threshold=10000000" }); RunTest(CompilerFilter::kSpeed, false, false, { "--very-large-app-threshold=10000000" }); } TEST_F(Dex2oatVeryLargeTest, UseVeryLarge) { RunTest(CompilerFilter::kAssumeVerified, true, false, { "--very-large-app-threshold=100" }); - RunTest(CompilerFilter::kExtract, true, false, { "--very-large-app-threshold=100" }); RunTest(CompilerFilter::kSpeed, true, true, { "--very-large-app-threshold=100" }); } diff --git a/dexoptanalyzer/dexoptanalyzer_test.cc b/dexoptanalyzer/dexoptanalyzer_test.cc index 7abd4baff2..b6b26dbdda 100644 --- a/dexoptanalyzer/dexoptanalyzer_test.cc +++ b/dexoptanalyzer/dexoptanalyzer_test.cc @@ -118,7 +118,6 @@ TEST_F(DexoptAnalyzerTest, DexNoOat) { Copy(GetDexSrc1(), dex_location); Verify(dex_location, CompilerFilter::kSpeed); - Verify(dex_location, CompilerFilter::kExtract); Verify(dex_location, CompilerFilter::kVerify); Verify(dex_location, CompilerFilter::kSpeedProfile); Verify(dex_location, CompilerFilter::kSpeed, @@ -134,7 +133,6 @@ TEST_F(DexoptAnalyzerTest, OatUpToDate) { Verify(dex_location, CompilerFilter::kSpeed); Verify(dex_location, CompilerFilter::kVerify); - Verify(dex_location, CompilerFilter::kExtract); Verify(dex_location, CompilerFilter::kEverything); Verify(dex_location, CompilerFilter::kSpeed, ProfileAnalysisResult::kDontOptimizeSmallDelta, false, nullptr); @@ -194,8 +192,6 @@ TEST_F(DexoptAnalyzerTest, Downgrade) { ProfileAnalysisResult::kDontOptimizeSmallDelta, true); Verify(dex_location, CompilerFilter::kVerify, ProfileAnalysisResult::kDontOptimizeSmallDelta, true); - Verify(dex_location, CompilerFilter::kExtract, - ProfileAnalysisResult::kDontOptimizeSmallDelta, true); } // Case: We have a MultiDEX file and up-to-date ODEX file for it. @@ -237,7 +233,6 @@ TEST_F(DexoptAnalyzerTest, OatDexOutOfDate) { GenerateOdexForTest(dex_location.c_str(), odex_location.c_str(), CompilerFilter::kSpeed); Copy(GetDexSrc2(), dex_location); - Verify(dex_location, CompilerFilter::kExtract); Verify(dex_location, CompilerFilter::kSpeed); } @@ -253,29 +248,10 @@ TEST_F(DexoptAnalyzerTest, OatImageOutOfDate) { CompilerFilter::kSpeed, /*with_alternate_image=*/true); - Verify(dex_location, CompilerFilter::kExtract); Verify(dex_location, CompilerFilter::kVerify); Verify(dex_location, CompilerFilter::kSpeed); } -// Case: We have a DEX file and a verify-at-runtime OAT file out of date with -// respect to the boot image. -// It shouldn't matter that the OAT file is out of date, because it is -// verify-at-runtime. -TEST_F(DexoptAnalyzerTest, OatVerifyAtRuntimeImageOutOfDate) { - std::string dex_location = GetScratchDir() + "/OatVerifyAtRuntimeImageOutOfDate.jar"; - std::string odex_location = GetOdexDir() + "/OatVerifyAtRuntimeImageOutOfDate.odex"; - - Copy(GetDexSrc1(), dex_location); - GenerateOatForTest(dex_location.c_str(), - odex_location.c_str(), - CompilerFilter::kExtract, - /*with_alternate_image=*/true); - - Verify(dex_location, CompilerFilter::kExtract); - Verify(dex_location, CompilerFilter::kVerify); -} - // Case: We have a DEX file and an ODEX file, but no OAT file. TEST_F(DexoptAnalyzerTest, DexOdexNoOat) { std::string dex_location = GetScratchDir() + "/DexOdexNoOat.jar"; @@ -284,7 +260,6 @@ TEST_F(DexoptAnalyzerTest, DexOdexNoOat) { Copy(GetDexSrc1(), dex_location); GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed); - Verify(dex_location, CompilerFilter::kExtract); Verify(dex_location, CompilerFilter::kSpeed); Verify(dex_location, CompilerFilter::kEverything); } @@ -297,7 +272,6 @@ TEST_F(DexoptAnalyzerTest, ResourceOnlyDex) { Copy(GetResourceOnlySrc1(), dex_location); Verify(dex_location, CompilerFilter::kSpeed); - Verify(dex_location, CompilerFilter::kExtract); Verify(dex_location, CompilerFilter::kVerify); } @@ -317,18 +291,6 @@ TEST_F(DexoptAnalyzerTest, OdexOatOverlap) { Verify(dex_location, CompilerFilter::kSpeed); } -// Case: We have a DEX file and a VerifyAtRuntime ODEX file, but no OAT file.. -TEST_F(DexoptAnalyzerTest, DexVerifyAtRuntimeOdexNoOat) { - std::string dex_location = GetScratchDir() + "/DexVerifyAtRuntimeOdexNoOat.jar"; - std::string odex_location = GetOdexDir() + "/DexVerifyAtRuntimeOdexNoOat.odex"; - - Copy(GetDexSrc1(), dex_location); - GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kExtract); - - Verify(dex_location, CompilerFilter::kExtract); - Verify(dex_location, CompilerFilter::kSpeed); -} - // Case: Non-standard extension for dex file. TEST_F(DexoptAnalyzerTest, LongDexExtension) { std::string dex_location = GetScratchDir() + "/LongDexExtension.jarx"; diff --git a/libartbase/base/compiler_filter.cc b/libartbase/base/compiler_filter.cc index a6d1c80afa..b4f924d39f 100644 --- a/libartbase/base/compiler_filter.cc +++ b/libartbase/base/compiler_filter.cc @@ -25,7 +25,6 @@ namespace art { bool CompilerFilter::IsAotCompilationEnabled(Filter filter) { switch (filter) { case CompilerFilter::kAssumeVerified: - case CompilerFilter::kExtract: case CompilerFilter::kVerify: return false; case CompilerFilter::kSpaceProfile: @@ -41,7 +40,6 @@ bool CompilerFilter::IsAotCompilationEnabled(Filter filter) { bool CompilerFilter::IsJniCompilationEnabled(Filter filter) { switch (filter) { case CompilerFilter::kAssumeVerified: - case CompilerFilter::kExtract: case CompilerFilter::kVerify: return false; case CompilerFilter::kSpaceProfile: @@ -60,8 +58,7 @@ bool CompilerFilter::IsAnyCompilationEnabled(Filter filter) { bool CompilerFilter::IsVerificationEnabled(Filter filter) { switch (filter) { - case CompilerFilter::kAssumeVerified: - case CompilerFilter::kExtract: return false; + case CompilerFilter::kAssumeVerified: return false; case CompilerFilter::kVerify: case CompilerFilter::kSpaceProfile: @@ -83,7 +80,6 @@ bool CompilerFilter::DependsOnImageChecksum(Filter filter) { bool CompilerFilter::DependsOnProfile(Filter filter) { switch (filter) { case CompilerFilter::kAssumeVerified: - case CompilerFilter::kExtract: case CompilerFilter::kVerify: case CompilerFilter::kSpace: case CompilerFilter::kSpeed: @@ -99,7 +95,6 @@ bool CompilerFilter::DependsOnProfile(Filter filter) { CompilerFilter::Filter CompilerFilter::GetNonProfileDependentFilterFrom(Filter filter) { switch (filter) { case CompilerFilter::kAssumeVerified: - case CompilerFilter::kExtract: case CompilerFilter::kVerify: case CompilerFilter::kSpace: case CompilerFilter::kSpeed: @@ -123,7 +118,6 @@ CompilerFilter::Filter CompilerFilter::GetSafeModeFilterFrom(Filter filter) { // code. switch (filter) { case CompilerFilter::kAssumeVerified: - case CompilerFilter::kExtract: case CompilerFilter::kVerify: return filter; @@ -149,7 +143,6 @@ bool CompilerFilter::IsBetter(Filter current, Filter target) { std::string CompilerFilter::NameOfFilter(Filter filter) { switch (filter) { case CompilerFilter::kAssumeVerified: return "assume-verified"; - case CompilerFilter::kExtract: return "extract"; case CompilerFilter::kVerify: return "verify"; case CompilerFilter::kSpaceProfile: return "space-profile"; case CompilerFilter::kSpace: return "space"; @@ -178,8 +171,8 @@ bool CompilerFilter::ParseCompilerFilter(const char* option, Filter* filter) { *filter = kVerify; } else if (strcmp(option, "verify-at-runtime") == 0) { LOG(WARNING) << "'verify-at-runtime' is an obsolete compiler filter name that will be " - << "removed in future releases, please use 'extract' instead."; - *filter = kExtract; + << "removed in future releases, please use 'verify' instead."; + *filter = kVerify; } else if (strcmp(option, "balanced") == 0) { LOG(WARNING) << "'balanced' is an obsolete compiler filter name that will be " << "removed in future releases, please use 'speed' instead."; @@ -188,14 +181,17 @@ bool CompilerFilter::ParseCompilerFilter(const char* option, Filter* filter) { LOG(WARNING) << "'time' is an obsolete compiler filter name that will be " << "removed in future releases, please use 'space' instead."; *filter = kSpace; - } else if (strcmp(option, "assume-verified") == 0) { - *filter = kAssumeVerified; } else if (strcmp(option, "extract") == 0) { - *filter = kExtract; - } else if (strcmp(option, "verify") == 0) { + LOG(WARNING) << "'extract' is an obsolete compiler filter name that will be " + << "removed in future releases, please use 'verify' instead."; *filter = kVerify; } else if (strcmp(option, "quicken") == 0) { - // b/170086509 'quicken' becomes an alias to 'verify. + LOG(WARNING) << "'quicken' is an obsolete compiler filter name that will be " + << "removed in future releases, please use 'verify' instead."; + *filter = kVerify; + } else if (strcmp(option, "assume-verified") == 0) { + *filter = kAssumeVerified; + } else if (strcmp(option, "verify") == 0) { *filter = kVerify; } else if (strcmp(option, "space") == 0) { *filter = kSpace; @@ -216,7 +212,7 @@ bool CompilerFilter::ParseCompilerFilter(const char* option, Filter* filter) { } const char* CompilerFilter::DescribeOptions() { - return "assume-verified|extract|verify|quicken|space{,-profile}|speed{,-profile}|" + return "assume-verified|verify|space{,-profile}|speed{,-profile}|" "everything{,-profile}"; } diff --git a/libartbase/base/compiler_filter.h b/libartbase/base/compiler_filter.h index 4ca3c761a6..7e6aae8ebd 100644 --- a/libartbase/base/compiler_filter.h +++ b/libartbase/base/compiler_filter.h @@ -31,7 +31,6 @@ class CompilerFilter final { // as" earlier filter choices. enum Filter { kAssumeVerified, // Skip verification but mark all classes as verified anyway. - kExtract, // Delay verication to runtime, do not compile anything. kVerify, // Only verify classes. kSpaceProfile, // Maximize space savings based on profile. kSpace, // Maximize space savings. diff --git a/libartbase/base/compiler_filter_test.cc b/libartbase/base/compiler_filter_test.cc index df7c8e74a8..3677afa534 100644 --- a/libartbase/base/compiler_filter_test.cc +++ b/libartbase/base/compiler_filter_test.cc @@ -41,7 +41,6 @@ TEST(CompilerFilterTest, ParseCompilerFilter) { CompilerFilter::Filter filter; TestCompilerFilterName(CompilerFilter::kAssumeVerified, "assume-verified"); - TestCompilerFilterName(CompilerFilter::kExtract, "extract"); TestCompilerFilterName(CompilerFilter::kVerify, "verify"); TestCompilerFilterName(CompilerFilter::kSpaceProfile, "space-profile"); TestCompilerFilterName(CompilerFilter::kSpace, "space"); @@ -55,7 +54,6 @@ TEST(CompilerFilterTest, ParseCompilerFilter) { TEST(CompilerFilterTest, SafeModeFilter) { TestSafeModeFilter(CompilerFilter::kAssumeVerified, "assume-verified"); - TestSafeModeFilter(CompilerFilter::kExtract, "extract"); TestSafeModeFilter(CompilerFilter::kVerify, "verify"); TestSafeModeFilter(CompilerFilter::kVerify, "space-profile"); TestSafeModeFilter(CompilerFilter::kVerify, "space"); diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc index baa3094f29..d34e6a7555 100644 --- a/runtime/oat_file_assistant_test.cc +++ b/runtime/oat_file_assistant_test.cc @@ -380,12 +380,6 @@ TEST_P(OatFileAssistantTest, DexNoOat) { OatFileAssistant oat_file_assistant = CreateOatFileAssistant(dex_location.c_str()); VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, - /*expected_dexopt_needed=*/true, - /*expected_is_vdex_usable=*/false, - /*expected_location=*/OatFileAssistant::kLocationNoneOrError, - /*expected_legacy_result=*/OatFileAssistant::kDex2OatFromScratch); - VerifyGetDexOptNeededDefault(&oat_file_assistant, CompilerFilter::kVerify, /*expected_dexopt_needed=*/true, /*expected_is_vdex_usable=*/false, @@ -462,12 +456,6 @@ TEST_P(OatFileAssistantTest, OdexUpToDate) { /*expected_location=*/OatFileAssistant::kLocationOdex, /*expected_legacy_result=*/-OatFileAssistant::kNoDexOptNeeded); VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, - /*expected_dexopt_needed=*/false, - /*expected_is_vdex_usable=*/true, - /*expected_location=*/OatFileAssistant::kLocationOdex, - /*expected_legacy_result=*/-OatFileAssistant::kNoDexOptNeeded); - VerifyGetDexOptNeededDefault(&oat_file_assistant, CompilerFilter::kEverything, /*expected_dexopt_needed=*/true, /*expected_is_vdex_usable=*/true, @@ -513,12 +501,6 @@ TEST_P(OatFileAssistantTest, OdexUpToDatePartialBootImage) { /*expected_location=*/OatFileAssistant::kLocationOdex, /*expected_legacy_result=*/-OatFileAssistant::kNoDexOptNeeded); VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, - /*expected_dexopt_needed=*/false, - /*expected_is_vdex_usable=*/true, - /*expected_location=*/OatFileAssistant::kLocationOdex, - /*expected_legacy_result=*/-OatFileAssistant::kNoDexOptNeeded); - VerifyGetDexOptNeededDefault(&oat_file_assistant, CompilerFilter::kEverything, /*expected_dexopt_needed=*/true, /*expected_is_vdex_usable=*/true, @@ -567,12 +549,6 @@ TEST_P(OatFileAssistantTest, OdexUpToDateSymLink) { /*expected_location=*/OatFileAssistant::kLocationOdex, /*expected_legacy_result=*/-OatFileAssistant::kNoDexOptNeeded); VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, - /*expected_dexopt_needed=*/false, - /*expected_is_vdex_usable=*/true, - /*expected_location=*/OatFileAssistant::kLocationOdex, - /*expected_legacy_result=*/-OatFileAssistant::kNoDexOptNeeded); - VerifyGetDexOptNeededDefault(&oat_file_assistant, CompilerFilter::kEverything, /*expected_dexopt_needed=*/true, /*expected_is_vdex_usable=*/true, @@ -619,12 +595,6 @@ TEST_P(OatFileAssistantTest, OatUpToDate) { /*expected_location=*/OatFileAssistant::kLocationOat, /*expected_legacy_result=*/OatFileAssistant::kNoDexOptNeeded); VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, - /*expected_dexopt_needed=*/false, - /*expected_is_vdex_usable=*/true, - /*expected_location=*/OatFileAssistant::kLocationOat, - /*expected_legacy_result=*/OatFileAssistant::kNoDexOptNeeded); - VerifyGetDexOptNeededDefault(&oat_file_assistant, CompilerFilter::kEverything, /*expected_dexopt_needed=*/true, /*expected_is_vdex_usable=*/true, @@ -678,12 +648,6 @@ TEST_P(OatFileAssistantTest, GetDexOptNeededWithFd) { /*expected_location=*/OatFileAssistant::kLocationOdex, /*expected_legacy_result=*/OatFileAssistant::kNoDexOptNeeded); VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, - /*expected_dexopt_needed=*/false, - /*expected_is_vdex_usable=*/true, - /*expected_location=*/OatFileAssistant::kLocationOdex, - /*expected_legacy_result=*/OatFileAssistant::kNoDexOptNeeded); - VerifyGetDexOptNeededDefault(&oat_file_assistant, CompilerFilter::kEverything, /*expected_dexopt_needed=*/true, /*expected_is_vdex_usable=*/true, @@ -1069,12 +1033,6 @@ TEST_P(OatFileAssistantTest, OatDexOutOfDate) { OatFileAssistant oat_file_assistant = CreateOatFileAssistant(dex_location.c_str()); VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, - /*expected_dexopt_needed=*/true, - /*expected_is_vdex_usable=*/false, - /*expected_location=*/OatFileAssistant::kLocationNoneOrError, - /*expected_legacy_result=*/OatFileAssistant::kDex2OatFromScratch); - VerifyGetDexOptNeededDefault(&oat_file_assistant, CompilerFilter::kSpeed, /*expected_dexopt_needed=*/true, /*expected_is_vdex_usable=*/false, @@ -1159,12 +1117,6 @@ TEST_P(OatFileAssistantTest, OatImageOutOfDate) { OatFileAssistant oat_file_assistant = CreateOatFileAssistant(dex_location.c_str()); VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, - /*expected_dexopt_needed=*/false, - /*expected_is_vdex_usable=*/true, - /*expected_location=*/OatFileAssistant::kLocationOat, - /*expected_legacy_result=*/OatFileAssistant::kNoDexOptNeeded); - VerifyGetDexOptNeededDefault(&oat_file_assistant, CompilerFilter::kVerify, /*expected_dexopt_needed=*/false, /*expected_is_vdex_usable=*/true, @@ -1214,49 +1166,6 @@ TEST_P(OatFileAssistantTest, OatContextOutOfDate) { dex_location.c_str(), context.get(), "verify", "vdex", "up-to-date", /*check_context=*/true); } -// Case: We have a DEX file and a verify-at-runtime OAT file out of date with -// respect to the boot image. -// It shouldn't matter that the OAT file is out of date, because it is -// verify-at-runtime. -TEST_P(OatFileAssistantTest, OatVerifyAtRuntimeImageOutOfDate) { - if (IsExecutedAsRoot()) { - // We cannot simulate non writable locations when executed as root: b/38000545. - LOG(ERROR) << "Test skipped because it's running as root"; - return; - } - - std::string dex_location = GetScratchDir() + "/OatVerifyAtRuntimeImageOutOfDate.jar"; - - Copy(GetDexSrc1(), dex_location); - GenerateOatForTest(dex_location.c_str(), - CompilerFilter::kExtract, - /* with_alternate_image= */ true); - - ScopedNonWritable scoped_non_writable(dex_location); - ASSERT_TRUE(scoped_non_writable.IsSuccessful()); - - auto scoped_maybe_without_runtime = ScopedMaybeWithoutRuntime(); - - OatFileAssistant oat_file_assistant = CreateOatFileAssistant(dex_location.c_str()); - VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, - /*expected_dexopt_needed=*/false, - /*expected_is_vdex_usable=*/true, - /*expected_location=*/OatFileAssistant::kLocationOat, - /*expected_legacy_result=*/OatFileAssistant::kNoDexOptNeeded); - VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kVerify, - /*expected_dexopt_needed=*/true, - /*expected_is_vdex_usable=*/true, - /*expected_location=*/OatFileAssistant::kLocationOat, - /*expected_legacy_result=*/OatFileAssistant::kDex2OatForFilter); - - EXPECT_FALSE(oat_file_assistant.IsInBootClassPath()); - EXPECT_EQ(OatFileAssistant::kOatCannotOpen, oat_file_assistant.OdexFileStatus()); - EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OatFileStatus()); - ExpectHasDexFiles(&oat_file_assistant, true); -} - // Case: We have a DEX file and an ODEX file, but no OAT file. TEST_P(OatFileAssistantTest, DexOdexNoOat) { std::string dex_location = GetScratchDir() + "/DexOdexNoOat.jar"; @@ -1272,12 +1181,6 @@ TEST_P(OatFileAssistantTest, DexOdexNoOat) { OatFileAssistant oat_file_assistant = CreateOatFileAssistant(dex_location.c_str()); VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, - /*expected_dexopt_needed=*/false, - /*expected_is_vdex_usable=*/true, - /*expected_location=*/OatFileAssistant::kLocationOdex, - /*expected_legacy_result=*/OatFileAssistant::kNoDexOptNeeded); - VerifyGetDexOptNeededDefault(&oat_file_assistant, CompilerFilter::kSpeed, /*expected_dexopt_needed=*/false, /*expected_is_vdex_usable=*/true, @@ -1313,12 +1216,6 @@ TEST_P(OatFileAssistantTest, ResourceOnlyDex) { /*expected_location=*/OatFileAssistant::kLocationNoneOrError, /*expected_legacy_result=*/OatFileAssistant::kNoDexOptNeeded); VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, - /*expected_dexopt_needed=*/false, - /*expected_is_vdex_usable=*/false, - /*expected_location=*/OatFileAssistant::kLocationNoneOrError, - /*expected_legacy_result=*/OatFileAssistant::kNoDexOptNeeded); - VerifyGetDexOptNeededDefault(&oat_file_assistant, CompilerFilter::kVerify, /*expected_dexopt_needed=*/false, /*expected_is_vdex_usable=*/false, @@ -1384,40 +1281,6 @@ TEST_P(OatFileAssistantTest, OdexOatOverlap) { EXPECT_EQ(1u, dex_files.size()); } -// Case: We have a DEX file and a VerifyAtRuntime ODEX file, but no OAT file. -// Expect: The status is kNoDexOptNeeded, because VerifyAtRuntime contains no code. -TEST_P(OatFileAssistantTest, DexVerifyAtRuntimeOdexNoOat) { - std::string dex_location = GetScratchDir() + "/DexVerifyAtRuntimeOdexNoOat.jar"; - std::string odex_location = GetOdexDir() + "/DexVerifyAtRuntimeOdexNoOat.odex"; - - // Create the dex and odex files - Copy(GetDexSrc1(), dex_location); - GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kExtract); - - auto scoped_maybe_without_runtime = ScopedMaybeWithoutRuntime(); - - // Verify the status. - OatFileAssistant oat_file_assistant = CreateOatFileAssistant(dex_location.c_str()); - - VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, - /*expected_dexopt_needed=*/false, - /*expected_is_vdex_usable=*/true, - /*expected_location=*/OatFileAssistant::kLocationOdex, - /*expected_legacy_result=*/OatFileAssistant::kNoDexOptNeeded); - VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kSpeed, - /*expected_dexopt_needed=*/true, - /*expected_is_vdex_usable=*/true, - /*expected_location=*/OatFileAssistant::kLocationOdex, - /*expected_legacy_result=*/-OatFileAssistant::kDex2OatForFilter); - - EXPECT_FALSE(oat_file_assistant.IsInBootClassPath()); - EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OdexFileStatus()); - EXPECT_EQ(OatFileAssistant::kOatCannotOpen, oat_file_assistant.OatFileStatus()); - ExpectHasDexFiles(&oat_file_assistant, true); -} - // Case: We have a DEX file and up-to-date OAT file for it. // Expect: We should load an executable dex file. TEST_P(OatFileAssistantTest, LoadOatUpToDate) { @@ -1861,26 +1724,6 @@ TEST_P(OatFileAssistantTest, GetDexOptNeededWithOutOfDateContext) { ASSERT_TRUE(updated_context != nullptr); std::vector<int> context_fds; ASSERT_TRUE(updated_context->OpenDexFiles("", context_fds, /*only_read_checksums*/ true)); - args.push_back("--compiler-filter=extract"); - ASSERT_TRUE(Dex2Oat(args, &error_msg)) << error_msg; - - auto scoped_maybe_without_runtime = ScopedMaybeWithoutRuntime(); - - OatFileAssistant oat_file_assistant = - CreateOatFileAssistant(dex_location.c_str(), updated_context.get()); - // Now check that DexOptNeeded does not advise compilation if we only extracted the file. - VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, - /*expected_dexopt_needed=*/false, - /*expected_is_vdex_usable=*/true, - /*expected_location=*/OatFileAssistant::kLocationOdex, - /*expected_legacy_result=*/OatFileAssistant::kNoDexOptNeeded); - } - { - std::unique_ptr<ClassLoaderContext> updated_context = ClassLoaderContext::Create(context_str); - ASSERT_TRUE(updated_context != nullptr); - std::vector<int> context_fds; - ASSERT_TRUE(updated_context->OpenDexFiles("", context_fds, /*only_read_checksums*/ true)); args.push_back("--compiler-filter=verify"); ASSERT_TRUE(Dex2Oat(args, &error_msg)) << error_msg; @@ -1890,7 +1733,7 @@ TEST_P(OatFileAssistantTest, GetDexOptNeededWithOutOfDateContext) { CreateOatFileAssistant(dex_location.c_str(), updated_context.get()); // Now check that DexOptNeeded does not advise compilation if we only verify the file. VerifyGetDexOptNeededDefault(&oat_file_assistant, - CompilerFilter::kExtract, + CompilerFilter::kVerify, /*expected_dexopt_needed=*/false, /*expected_is_vdex_usable=*/true, /*expected_location=*/OatFileAssistant::kLocationOdex, |