Add dex2oat support for profile based image creation
Allow creating a boot image with only a profile without requiring
any of --compiled-classes, --compiled-methods, or --image-classes.
To do so, you need to pass --profile-file and
--compiler-filter=speed-profile.
Added a test dex2oat_image_test to verify behavior. This test covers:
--compiled-classes
--compiled-methods
--image-classes
--profile-file
Test: test-art-host-gtest-dex2oat_image_test
Bug: 37966211
Change-Id: I36d41b1c6e6560e6b3494b1df7024a4450ed0c0e
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index f9267e2..c0ab21d 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -867,6 +867,15 @@
Usage("Profile file should not be specified with both --profile-file-fd and --profile-file");
}
+ if (have_profile_file || have_profile_fd) {
+ if (compiled_classes_filename_ != nullptr ||
+ compiled_classes_zip_filename_ != nullptr ||
+ image_classes_filename_ != nullptr ||
+ image_classes_zip_filename_ != nullptr) {
+ Usage("Profile based image creation is not supported with image or compiled classes");
+ }
+ }
+
if (!parser_options->oat_symbols.empty()) {
oat_unstripped_ = std::move(parser_options->oat_symbols);
}
@@ -1456,7 +1465,7 @@
}
void LoadClassProfileDescriptors() {
- if (profile_compilation_info_ != nullptr && IsAppImage()) {
+ if (profile_compilation_info_ != nullptr && IsImage()) {
Runtime* runtime = Runtime::Current();
CHECK(runtime != nullptr);
// Filter out class path classes since we don't want to include these in the image.