Make compiling an apex image explicit.
And when compiling an apex image, discard dex files not present
in an apex.
Test: m
Bug: 119800099
Change-Id: Ie91c5b8d271783f04e4c1501f315a3ec59137475
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index b44dc3f..278523e 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -765,7 +765,11 @@
compiler_options_->compile_pic_ = true; // All AOT compilation is PIC.
DCHECK(compiler_options_->image_type_ == CompilerOptions::ImageType::kNone);
if (!image_filenames_.empty()) {
- compiler_options_->image_type_ = CompilerOptions::ImageType::kBootImage;
+ if (android::base::EndsWith(image_filenames_[0], "apex.art")) {
+ compiler_options_->image_type_ = CompilerOptions::ImageType::kApexBootImage;
+ } else {
+ compiler_options_->image_type_ = CompilerOptions::ImageType::kBootImage;
+ }
}
if (app_image_fd_ != -1 || !app_image_file_name_.empty()) {
if (compiler_options_->IsBootImage()) {
diff --git a/dex2oat/driver/compiler_driver.cc b/dex2oat/driver/compiler_driver.cc
index 5373435..540b8a6 100644
--- a/dex2oat/driver/compiler_driver.cc
+++ b/dex2oat/driver/compiler_driver.cc
@@ -930,6 +930,14 @@
}
bool CompilerDriver::ShouldCompileBasedOnProfile(const MethodReference& method_ref) const {
+ // If compiling the apex image, filter out methods not in an apex file (the profile used
+ // for boot classpath is the same between the apex image and the boot image, so it includes
+ /// framewkro methods).
+ if (compiler_options_->IsApexBootImage() &&
+ !android::base::StartsWith(method_ref.dex_file->GetLocation(), "/apex")) {
+ return false;
+ }
+
// Profile compilation info may be null if no profile is passed.
if (!CompilerFilter::DependsOnProfile(compiler_options_->GetCompilerFilter())) {
// Use the compiler filter instead of the presence of profile_compilation_info_ since
@@ -950,6 +958,7 @@
LOG(INFO) << "[ProfileGuidedCompilation] "
<< (result ? "Compiled" : "Skipped") << " method:" << method_ref.PrettyMethod(true);
}
+
return result;
}