summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/Android.oat.mk2
-rw-r--r--build/apex/art_preinstall_hook_boot.sh2
-rw-r--r--dex2oat/dex2oat.cc82
-rw-r--r--dex2oat/dex2oat_image_test.cc105
-rw-r--r--dex2oat/dex2oat_options.cc6
-rw-r--r--dex2oat/dex2oat_options.def2
6 files changed, 37 insertions, 162 deletions
diff --git a/build/Android.oat.mk b/build/Android.oat.mk
index 2ad11432d7..c29cd299ea 100644
--- a/build/Android.oat.mk
+++ b/build/Android.oat.mk
@@ -83,7 +83,6 @@ $$(core_image_name): $$(HOST_CORE_IMG_DEX_LOCATIONS) $$(core_dex2oat_dependency)
@mkdir -p $$(dir $$@)
$$(hide) ANDROID_LOG_TAGS="*:e" $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
--runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
- --image-classes=$$(PRELOADED_CLASSES) \
$$(addprefix --dex-file=,$$(HOST_CORE_IMG_DEX_FILES)) \
$$(addprefix --dex-location=,$$(HOST_CORE_IMG_DEX_LOCATIONS)) \
--oat-file=$$(PRIVATE_CORE_OAT_NAME) \
@@ -174,7 +173,6 @@ $$(core_image_name): $$(TARGET_CORE_IMG_DEX_FILES) $$(core_dex2oat_dependency)
@mkdir -p $$(dir $$@)
$$(hide) $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
--runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
- --image-classes=$$(PRELOADED_CLASSES) \
$$(addprefix --dex-file=,$$(TARGET_CORE_IMG_DEX_FILES)) \
$$(addprefix --dex-location=,$$(TARGET_CORE_IMG_DEX_LOCATIONS)) \
--oat-file=$$(PRIVATE_CORE_OAT_NAME) \
diff --git a/build/apex/art_preinstall_hook_boot.sh b/build/apex/art_preinstall_hook_boot.sh
index cdad144c91..0985befb9d 100644
--- a/build/apex/art_preinstall_hook_boot.sh
+++ b/build/apex/art_preinstall_hook_boot.sh
@@ -40,8 +40,6 @@ done
PROFILING=
if [ -f "/system/etc/boot-image.prof" ] ; then
PROFILING="--compiler-filter=speed-profile --profile-file=/system/etc/boot-image.prof"
-elif [ -f "/system/etc/preloaded-classes" ]; then
- PROFILING="--image-classes=/system/etc/preloaded-classes"
fi
if [ -f "/system/etc/dirty-image-objects" ] ; then
PROFILING="$PROFILING --dirty-image-objects=/system/etc/dirty-image-objects"
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index c576f2c936..c1504cc535 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -273,9 +273,6 @@ NO_RETURN static void Usage(const char* fmt, ...) {
UsageError(" Example: --image-format=lz4");
UsageError(" Default: uncompressed");
UsageError("");
- UsageError(" --image-classes=<classname-file>: specifies classes to include in an image.");
- UsageError(" Example: --image=frameworks/base/preloaded-classes");
- UsageError("");
UsageError(" --base=<hex-address>: specifies the base address when creating a boot image.");
UsageError(" Example: --base=0x50000000");
UsageError("");
@@ -672,8 +669,6 @@ class Dex2Oat final {
dm_fd_(-1),
zip_fd_(-1),
image_base_(0U),
- image_classes_zip_filename_(nullptr),
- image_classes_filename_(nullptr),
image_storage_mode_(ImageHeader::kStorageModeUncompressed),
passes_to_run_filename_(nullptr),
dirty_image_objects_filename_(nullptr),
@@ -848,18 +843,6 @@ class Dex2Oat final {
boot_image_filename_ = parser_options->boot_image_filename;
}
- if (image_classes_filename_ != nullptr && !IsBootImage()) {
- Usage("--image-classes should only be used with --image");
- }
-
- if (image_classes_filename_ != nullptr && !boot_image_filename_.empty()) {
- Usage("--image-classes should not be used with --boot-image");
- }
-
- if (image_classes_zip_filename_ != nullptr && image_classes_filename_ == nullptr) {
- Usage("--image-classes-zip should be used with --image-classes");
- }
-
if (dex_filenames_.empty() && zip_fd_ == -1) {
Usage("Input must be supplied with either --dex-file or --zip-fd");
}
@@ -900,13 +883,6 @@ class Dex2Oat final {
Usage("Profile file should not be specified with both --profile-file-fd and --profile-file");
}
- if (have_profile_file || have_profile_fd) {
- if (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);
}
@@ -1138,8 +1114,6 @@ class Dex2Oat final {
AssignIfExists(args, M::Watchdog, &parser_options->watch_dog_enabled);
AssignIfExists(args, M::WatchdogTimeout, &parser_options->watch_dog_timeout_in_ms);
AssignIfExists(args, M::Threads, &thread_count_);
- AssignIfExists(args, M::ImageClasses, &image_classes_filename_);
- AssignIfExists(args, M::ImageClassesZip, &image_classes_zip_filename_);
AssignIfExists(args, M::Passes, &passes_to_run_filename_);
AssignIfExists(args, M::BootImage, &parser_options->boot_image_filename);
AssignIfExists(args, M::AndroidRoot, &android_root_);
@@ -1466,8 +1440,6 @@ class Dex2Oat final {
LOG(INFO) << "Image class " << s;
}
}
- // Note: If we have a profile, classes previously loaded for the --image-classes
- // option are overwritten here.
compiler_options_->image_classes_.swap(image_classes);
}
}
@@ -1477,7 +1449,7 @@ class Dex2Oat final {
dex2oat::ReturnCode Setup() {
TimingLogger::ScopedTiming t("dex2oat Setup", timings_);
- if (!PrepareImageClasses() || !PrepareDirtyObjects()) {
+ if (!PrepareDirtyObjects()) {
return dex2oat::ReturnCode::kOther;
}
@@ -2329,37 +2301,6 @@ class Dex2Oat final {
return dex_files_size >= very_large_threshold_;
}
- bool PrepareImageClasses() {
- // If --image-classes was specified, calculate the full list of classes to include in the image.
- DCHECK(compiler_options_->image_classes_.empty());
- if (image_classes_filename_ != nullptr) {
- std::unique_ptr<HashSet<std::string>> image_classes =
- ReadClasses(image_classes_zip_filename_, image_classes_filename_, "image");
- if (image_classes == nullptr) {
- return false;
- }
- compiler_options_->image_classes_.swap(*image_classes);
- }
- return true;
- }
-
- static std::unique_ptr<HashSet<std::string>> ReadClasses(const char* zip_filename,
- const char* classes_filename,
- const char* tag) {
- std::unique_ptr<HashSet<std::string>> classes;
- std::string error_msg;
- if (zip_filename != nullptr) {
- classes = ReadImageClassesFromZip(zip_filename, classes_filename, &error_msg);
- } else {
- classes = ReadImageClassesFromFile(classes_filename);
- }
- if (classes == nullptr) {
- LOG(ERROR) << "Failed to create list of " << tag << " classes from '"
- << classes_filename << "': " << error_msg;
- }
- return classes;
- }
-
bool PrepareDirtyObjects() {
if (dirty_image_objects_filename_ != nullptr) {
dirty_image_objects_ = ReadCommentedInputFromFile<HashSet<std::string>>(
@@ -2607,25 +2548,6 @@ class Dex2Oat final {
return true;
}
- // Reads the class names (java.lang.Object) and returns a set of descriptors (Ljava/lang/Object;)
- static std::unique_ptr<HashSet<std::string>> ReadImageClassesFromFile(
- const char* image_classes_filename) {
- std::function<std::string(const char*)> process = DotToDescriptor;
- return ReadCommentedInputFromFile<HashSet<std::string>>(image_classes_filename, &process);
- }
-
- // Reads the class names (java.lang.Object) and returns a set of descriptors (Ljava/lang/Object;)
- static std::unique_ptr<HashSet<std::string>> ReadImageClassesFromZip(
- const char* zip_filename,
- const char* image_classes_filename,
- std::string* error_msg) {
- std::function<std::string(const char*)> process = DotToDescriptor;
- return ReadCommentedInputFromZip<HashSet<std::string>>(zip_filename,
- image_classes_filename,
- &process,
- error_msg);
- }
-
// Read lines from the given file, dropping comments and empty lines. Post-process each line with
// the given function.
template <typename T>
@@ -2773,8 +2695,6 @@ class Dex2Oat final {
std::vector<const char*> runtime_args_;
std::vector<std::string> image_filenames_;
uintptr_t image_base_;
- const char* image_classes_zip_filename_;
- const char* image_classes_filename_;
ImageHeader::StorageMode image_storage_mode_;
const char* passes_to_run_filename_;
const char* dirty_image_objects_filename_;
diff --git a/dex2oat/dex2oat_image_test.cc b/dex2oat/dex2oat_image_test.cc
index e047b4f925..336c5c9351 100644
--- a/dex2oat/dex2oat_image_test.cc
+++ b/dex2oat/dex2oat_image_test.cc
@@ -94,11 +94,19 @@ class Dex2oatImageTest : public CommonRuntimeTest {
EXPECT_TRUE(file->WriteFully(&line[0], line.length()));
}
- void GenerateClasses(File* out_file, size_t frequency = 1) {
- VisitLibcoreDexes(VoidFunctor(),
- [out_file](TypeReference ref) {
- WriteLine(out_file, ref.dex_file->PrettyType(ref.TypeIndex()));
- }, frequency, frequency);
+ void GenerateProfile(File* out_file, size_t method_frequency, size_t type_frequency) {
+ ProfileCompilationInfo profile;
+ VisitLibcoreDexes([&profile](MethodReference ref) {
+ uint32_t flags = ProfileCompilationInfo::MethodHotness::kFlagHot |
+ ProfileCompilationInfo::MethodHotness::kFlagStartup;
+ EXPECT_TRUE(profile.AddMethodIndex(
+ static_cast<ProfileCompilationInfo::MethodHotness::Flag>(flags),
+ ref));
+ }, [&profile](TypeReference ref) {
+ EXPECT_TRUE(profile.AddClassForDex(ref));
+ }, method_frequency, type_frequency);
+ ScratchFile profile_file;
+ profile.Save(out_file->Fd());
EXPECT_EQ(out_file->Flush(), 0);
}
@@ -209,87 +217,46 @@ TEST_F(Dex2oatImageTest, TestModesAndFilters) {
return;
}
ImageSizes base_sizes = CompileImageAndGetSizes({});
- ImageSizes image_classes_sizes;
- ImageSizes compiled_classes_sizes;
- ImageSizes compiled_methods_sizes;
- ImageSizes profile_sizes;
+ ImageSizes everything_sizes;
+ ImageSizes filter_sizes;
std::cout << "Base compile sizes " << base_sizes << std::endl;
- // Test image classes
+ // Compile all methods and classes
{
- ScratchFile classes;
- GenerateClasses(classes.GetFile(), /*frequency*/ 1u);
- image_classes_sizes = CompileImageAndGetSizes(
- {"--image-classes=" + classes.GetFilename()});
- classes.Close();
- std::cout << "Image classes sizes " << image_classes_sizes << std::endl;
+ ScratchFile profile_file;
+ GenerateProfile(profile_file.GetFile(), /*method_frequency=*/ 1u, /*type_frequency=*/ 1u);
+ everything_sizes = CompileImageAndGetSizes(
+ {"--profile-file=" + profile_file.GetFilename(),
+ "--compiler-filter=speed-profile"});
+ profile_file.Close();
+ std::cout << "All methods and classes sizes " << everything_sizes << std::endl;
// Putting all classes as image classes should increase art size
- EXPECT_GE(image_classes_sizes.art_size, base_sizes.art_size);
+ EXPECT_GE(everything_sizes.art_size, base_sizes.art_size);
// Sanity check that dex is the same size.
- EXPECT_EQ(image_classes_sizes.vdex_size, base_sizes.vdex_size);
- }
- // Test compiled classes.
- {
- ScratchFile classes;
- // Only compile every even class.
- GenerateClasses(classes.GetFile(), /*frequency*/ 2u);
- compiled_classes_sizes = CompileImageAndGetSizes(
- {"--image-classes=" + classes.GetFilename()});
- classes.Close();
- std::cout << "Compiled classes sizes " << compiled_classes_sizes << std::endl;
- // Art file should be smaller than image classes version since we included fewer classes in the
- // list.
- EXPECT_LT(compiled_classes_sizes.art_size, image_classes_sizes.art_size);
+ EXPECT_EQ(everything_sizes.vdex_size, base_sizes.vdex_size);
}
static size_t kMethodFrequency = 3;
static size_t kTypeFrequency = 4;
// Test compiling fewer methods and classes.
{
- ScratchFile classes;
- // Only compile every even class.
- GenerateClasses(classes.GetFile(), kTypeFrequency);
- compiled_methods_sizes = CompileImageAndGetSizes(
- {"--image-classes=" + classes.GetFilename()});
- classes.Close();
- std::cout << "Compiled fewer methods sizes " << compiled_methods_sizes << std::endl;
- }
- // Cross verify profile based image against image-classes and compiled-methods to make sure it
- // matches.
- {
- ProfileCompilationInfo profile;
- VisitLibcoreDexes([&profile](MethodReference ref) {
- uint32_t flags = ProfileCompilationInfo::MethodHotness::kFlagHot |
- ProfileCompilationInfo::MethodHotness::kFlagStartup;
- EXPECT_TRUE(profile.AddMethodIndex(
- static_cast<ProfileCompilationInfo::MethodHotness::Flag>(flags),
- ref));
- }, [&profile](TypeReference ref) {
- EXPECT_TRUE(profile.AddClassForDex(ref));
- }, kMethodFrequency, kTypeFrequency);
ScratchFile profile_file;
- profile.Save(profile_file.GetFile()->Fd());
- EXPECT_EQ(profile_file.GetFile()->Flush(), 0);
- profile_sizes = CompileImageAndGetSizes(
+ GenerateProfile(profile_file.GetFile(), kMethodFrequency, kTypeFrequency);
+ filter_sizes = CompileImageAndGetSizes(
{"--profile-file=" + profile_file.GetFilename(),
"--compiler-filter=speed-profile"});
profile_file.Close();
- std::cout << "Profile sizes " << profile_sizes << std::endl;
- // Since there is some difference between profile vs image + methods due to layout, check that
- // the range is within expected margins (+-10%).
- const double kRatio = 0.90;
- EXPECT_LE(profile_sizes.art_size * kRatio, compiled_methods_sizes.art_size);
- // TODO(mathieuc): Find a reliable way to check compiled code. b/63746626
- // EXPECT_LE(profile_sizes.oat_size * kRatio, compiled_methods_sizes.oat_size);
- EXPECT_LE(profile_sizes.vdex_size * kRatio, compiled_methods_sizes.vdex_size);
- EXPECT_GE(profile_sizes.art_size / kRatio, compiled_methods_sizes.art_size);
- // TODO(mathieuc): Find a reliable way to check compiled code. b/63746626
- // EXPECT_GE(profile_sizes.oat_size / kRatio, compiled_methods_sizes.oat_size);
- EXPECT_GE(profile_sizes.vdex_size / kRatio, compiled_methods_sizes.vdex_size);
+ std::cout << "Fewer methods and classes sizes " << filter_sizes << std::endl;
+ EXPECT_LE(filter_sizes.art_size, everything_sizes.art_size);
+ EXPECT_LE(filter_sizes.oat_size, everything_sizes.oat_size);
+ EXPECT_LE(filter_sizes.vdex_size, everything_sizes.vdex_size);
}
// Test dirty image objects.
{
ScratchFile classes;
- GenerateClasses(classes.GetFile(), /*frequency*/ 1u);
- image_classes_sizes = CompileImageAndGetSizes(
+ VisitLibcoreDexes(VoidFunctor(),
+ [&](TypeReference ref) {
+ WriteLine(classes.GetFile(), ref.dex_file->PrettyType(ref.TypeIndex()));
+ }, /*method_frequency=*/ 1u, /*class_frequency=*/ 1u);
+ ImageSizes image_classes_sizes = CompileImageAndGetSizes(
{"--dirty-image-objects=" + classes.GetFilename()});
classes.Close();
std::cout << "Dirty image object sizes " << image_classes_sizes << std::endl;
diff --git a/dex2oat/dex2oat_options.cc b/dex2oat/dex2oat_options.cc
index 4a19fb1304..cb03fc6cec 100644
--- a/dex2oat/dex2oat_options.cc
+++ b/dex2oat/dex2oat_options.cc
@@ -113,12 +113,6 @@ static void AddImageMappings(Builder& builder) {
Define("--image=_")
.WithType<std::vector<std::string>>().AppendValues()
.IntoKey(M::ImageFilenames)
- .Define("--image-classes=_")
- .WithType<std::string>()
- .IntoKey(M::ImageClasses)
- .Define("--image-classes-zip=_")
- .WithType<std::string>()
- .IntoKey(M::ImageClassesZip)
.Define("--base=_")
.WithType<std::string>()
.IntoKey(M::Base)
diff --git a/dex2oat/dex2oat_options.def b/dex2oat/dex2oat_options.def
index 0717e1af18..9e11103edc 100644
--- a/dex2oat/dex2oat_options.def
+++ b/dex2oat/dex2oat_options.def
@@ -54,8 +54,6 @@ DEX2OAT_OPTIONS_KEY (bool, Watchdog)
DEX2OAT_OPTIONS_KEY (int, WatchdogTimeout)
DEX2OAT_OPTIONS_KEY (unsigned int, Threads)
DEX2OAT_OPTIONS_KEY (std::vector<std::string>, ImageFilenames)
-DEX2OAT_OPTIONS_KEY (std::string, ImageClasses)
-DEX2OAT_OPTIONS_KEY (std::string, ImageClassesZip)
DEX2OAT_OPTIONS_KEY (ImageHeader::StorageMode, ImageFormat)
DEX2OAT_OPTIONS_KEY (std::string, Passes)
DEX2OAT_OPTIONS_KEY (std::string, Base) // TODO: Hex string parsing.