summaryrefslogtreecommitdiffstats
path: root/dex2oat/dex2oat.cc
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2016-02-18 18:47:37 +0000
committerCalin Juravle <calin@google.com>2016-03-08 15:53:30 +0000
commitb077e15d2d11b7c81aacbcd4a46c2b1e9c9ba20d (patch)
tree148a47a1aace48313cdfdeede48902563d89c7ee /dex2oat/dex2oat.cc
parentc90bc92bc577020ff4d3caced4cee1cdf41fa5de (diff)
downloadandroid_art-b077e15d2d11b7c81aacbcd4a46c2b1e9c9ba20d.tar.gz
android_art-b077e15d2d11b7c81aacbcd4a46c2b1e9c9ba20d.tar.bz2
android_art-b077e15d2d11b7c81aacbcd4a46c2b1e9c9ba20d.zip
Update GetDexOptNeeded to handle different levels of compilation
extract-only or profile-guide oat files are considered up to date from runtime perspective as they don't necessary need (re)compilation or relocation. However, it is useful to return a more refined code to the caller so that they can decide whether or not that's good enough. For example, the package manager might decide to still compile a previous extract-only and during profile guide compilation we should always recompile even if we have an oat file. Note that dex files compiled via ClassLoaders will still be fully compiled. This change introduces: - a new key in the oat header kCompilationType to capture what type of compilation has been made. Note tha the key might be missing. The distinction is needed in order to avoid recompilation of a previous fully compiled file during profile guide compilation analysis. - a new argument to GetDexOptNeeded which tells the runtime to cast its opinion whether or not the oat file is up to date relative to the desired target type of compilation. Bug: 27189430 (cherry picked from commit d91b8a2464b99625efe03caf7d30c8372bc378ed) Change-Id: I6ce450350f388451f7bab7d285c1846d539a4b13
Diffstat (limited to 'dex2oat/dex2oat.cc')
-rw-r--r--dex2oat/dex2oat.cc26
1 files changed, 8 insertions, 18 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index d9a2f300d9..cbce0f6e91 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1031,9 +1031,11 @@ class Dex2Oat FINAL {
key_value_store_->Put(
OatHeader::kDebuggableKey,
compiler_options_->debuggable_ ? OatHeader::kTrueValue : OatHeader::kFalseValue);
- key_value_store_->Put(
- OatHeader::kExtractOnlyKey,
- compiler_options_->IsExtractOnly() ? OatHeader::kTrueValue : OatHeader::kFalseValue);
+ if (compiler_options_->IsExtractOnly()) {
+ key_value_store_->Put(OatHeader::kCompilationType, OatHeader::kExtractOnlyValue);
+ } else if (UseProfileGuidedCompilation()) {
+ key_value_store_->Put(OatHeader::kCompilationType, OatHeader::kProfileGuideCompiledValue);
+ }
}
// Parse the arguments from the command line. In case of an unrecognized option or impossible
@@ -1888,13 +1890,6 @@ class Dex2Oat FINAL {
return success;
}
- bool ShouldCompileBasedOnProfiles() const {
- DCHECK(UseProfileGuidedCompilation());
- // If we are given a profile, compile only if we have some data in it.
- return (profile_compilation_info_ != nullptr) &&
- (profile_compilation_info_->GetNumberOfMethods() != 0);
- }
-
private:
template <typename T>
static std::vector<T*> MakeNonOwningPointerVector(const std::vector<std::unique_ptr<T>>& src) {
@@ -2590,16 +2585,11 @@ static int dex2oat(int argc, char** argv) {
// Parse arguments. Argument mistakes will lead to exit(EXIT_FAILURE) in UsageError.
dex2oat->ParseArgs(argc, argv);
- // Process profile information and assess if we need to do a profile guided compilation.
+ // If needed, process profile information for profile guided compilation.
// This operation involves I/O.
if (dex2oat->UseProfileGuidedCompilation()) {
- if (dex2oat->LoadProfile()) {
- if (!dex2oat->ShouldCompileBasedOnProfiles()) {
- LOG(INFO) << "Skipped compilation because of insignificant profile delta";
- return EXIT_SUCCESS;
- }
- } else {
- LOG(WARNING) << "Failed to process profile files";
+ if (!dex2oat->LoadProfile()) {
+ LOG(ERROR) << "Failed to process profile file";
return EXIT_FAILURE;
}
}