Improve dex location canonicalization-related performance.
Eagerly add canonical dex file locations to the OatFile's
primary lookup map in Setup(). This moves the boot.oat work
from every app startup to the zygote initialization. Since
we always ended up initializing the canonical location map
anyway due to the way that we're loading dex files, the lazy
initialization didn't save anything.
Clean up dex file name canonicalization to make sure we
free() the memory returned by realpath() rather than using
std::unique_ptr<> with the default deleter.
Avoid some unnecessary duplicate OatDexFile lookups.
Bug: 16828525
Bug: 17346103
Change-Id: Id8fbc8992f62996138eb2006a0046c6529747c09
diff --git a/compiler/elf_patcher.cc b/compiler/elf_patcher.cc
index 72bf7d3..f192227 100644
--- a/compiler/elf_patcher.cc
+++ b/compiler/elf_patcher.cc
@@ -200,7 +200,8 @@
mirror::ArtMethod* target = GetTargetMethod(patch);
uintptr_t quick_code = reinterpret_cast<uintptr_t>(class_linker->GetQuickOatCodeFor(target));
DCHECK_NE(quick_code, 0U) << PrettyMethod(target);
- const OatFile* target_oat = class_linker->FindOpenedOatFileForDexFile(*patch->GetTargetDexFile());
+ const OatFile* target_oat =
+ class_linker->FindOpenedOatDexFileForDexFile(*patch->GetTargetDexFile())->GetOatFile();
// Get where the data actually starts. if target is this oat_file_ it is oat_data_start_,
// otherwise it is wherever target_oat is loaded.
uintptr_t oat_data_addr = GetBaseAddressFor(target_oat);