diff options
| author | 2021-04-01 14:22:40 +0100 | |
|---|---|---|
| committer | 2021-04-15 12:30:01 +0000 | |
| commit | c8fe6517faf91b45683cddff3c15e08e489e12e9 (patch) | |
| tree | 10bf664496e680bbae0d22ff7da32dbbb923613f /dexoptanalyzer/dexoptanalyzer_test.cc | |
| parent | 0c39de679bc4b647cfeb1c5c94c86d879848aa55 (diff) | |
Integrate ClassLoaderContext check in OatFileAssistant::GetBestOatFile.
This reduces some code duplication between
OatFileManager::OpenDexFilesFromOat and GetDexoptNeeded.
It also gives the chance for OatFileAssistant and GetDexoptNeeded to
find the real best oat file.
Test: test.py
Bug: 176960283
Change-Id: Id366aef7a9e91833d8edaea965abda4cfdcd8455
Diffstat (limited to 'dexoptanalyzer/dexoptanalyzer_test.cc')
| -rw-r--r-- | dexoptanalyzer/dexoptanalyzer_test.cc | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/dexoptanalyzer/dexoptanalyzer_test.cc b/dexoptanalyzer/dexoptanalyzer_test.cc index 42be4735a2..ef6282aa1f 100644 --- a/dexoptanalyzer/dexoptanalyzer_test.cc +++ b/dexoptanalyzer/dexoptanalyzer_test.cc @@ -79,18 +79,23 @@ class DexoptAnalyzerTest : public DexoptTest { bool assume_profile_changed = false, bool downgrade = false, const char* class_loader_context = "PCL[]") { - int dexoptanalyzerResult = Analyze( - dex_file, compiler_filter, assume_profile_changed, class_loader_context); - dexoptanalyzerResult = DexoptanalyzerToOatFileAssistant(dexoptanalyzerResult); - OatFileAssistant oat_file_assistant(dex_file.c_str(), kRuntimeISA, /*load_executable=*/ false); - std::vector<int> context_fds; - std::unique_ptr<ClassLoaderContext> context = class_loader_context == nullptr ? nullptr : ClassLoaderContext::Create(class_loader_context); + if (context != nullptr) { + std::vector<int> context_fds; + ASSERT_TRUE(context->OpenDexFiles("", context_fds, /*only_read_checksums*/ true)); + } + int dexoptanalyzerResult = Analyze( + dex_file, compiler_filter, assume_profile_changed, class_loader_context); + dexoptanalyzerResult = DexoptanalyzerToOatFileAssistant(dexoptanalyzerResult); + OatFileAssistant oat_file_assistant(dex_file.c_str(), + kRuntimeISA, + context.get(), + /*load_executable=*/ false); int assistantResult = oat_file_assistant.GetDexOptNeeded( - compiler_filter, context.get(), context_fds, assume_profile_changed, downgrade); + compiler_filter, assume_profile_changed, downgrade); EXPECT_EQ(assistantResult, dexoptanalyzerResult); } }; |