Skip profiling if the dex file is fully compiled
The OatFile does not store the original dex location that was used to
compile the file. So in order to get the oat file for a given code path
we need to iterate over the inner oat dex files and check against them.
Also, we used to pass the unfiltered code_paths set to the saver which
would make the filtering useless. This fixes the parameter passing as
well.
Bug: 27893309
(cherry picked from commit 7506423b2b9ea13fc5fa9711ab0106977876a5a2)
Change-Id: I99388dee40f2d0e70f970b3f5c6a4171a7e97c0e
diff --git a/runtime/jit/profile_saver.cc b/runtime/jit/profile_saver.cc
index 6599df2..a224ebb 100644
--- a/runtime/jit/profile_saver.cc
+++ b/runtime/jit/profile_saver.cc
@@ -265,16 +265,20 @@
}
static bool ShouldProfileLocation(const std::string& location) {
- const OatFileManager& oat_manager = Runtime::Current()->GetOatFileManager();
- const OatFile* oat_file = oat_manager.FindOpenedOatFileFromOatLocation(location);
+ OatFileManager& oat_manager = Runtime::Current()->GetOatFileManager();
+ const OatFile* oat_file = oat_manager.FindOpenedOatFileFromDexLocation(location);
if (oat_file == nullptr) {
// This can happen if we fallback to run code directly from the APK.
// Profile it with the hope that the background dexopt will get us back into
// a good state.
+ VLOG(profiler) << "Asked to profile a location without an oat file:" << location;
return true;
}
CompilerFilter::Filter filter = oat_file->GetCompilerFilter();
if (filter == CompilerFilter::kSpeed || CompilerFilter::kEverything) {
+ VLOG(profiler)
+ << "Skip profiling oat file because it's already speed|everything compiled:"
+ << location;
return false;
}
return true;
@@ -294,13 +298,10 @@
for (const std::string& location : code_paths) {
if (ShouldProfileLocation(location)) {
code_paths_to_profile.push_back(location);
- } else {
- VLOG(profiler)
- << "Skip profiling oat file because it's already speed|everything compiled:"
- << location;
}
}
if (code_paths_to_profile.empty()) {
+ VLOG(profiler) << "No code paths should be profiled.";
return;
}
@@ -316,11 +317,11 @@
}
VLOG(profiler) << "Starting profile saver using output file: " << output_filename
- << ". Tracking: " << Join(code_paths, ':');
+ << ". Tracking: " << Join(code_paths_to_profile, ':');
instance_ = new ProfileSaver(output_filename,
jit_code_cache,
- code_paths,
+ code_paths_to_profile,
foreign_dex_profile_path,
app_data_dir);