summaryrefslogtreecommitdiffstats
path: root/dex2oat/dex2oat.cc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2016-05-25 15:05:59 -0700
committerMathieu Chartier <mathieuc@google.com>2016-05-25 15:36:51 -0700
commit8d26c5967674d2eab21f65eeac9f1adcf88fce38 (patch)
tree90b9778eccdeca2bbd5d4e492947c74347738ec9 /dex2oat/dex2oat.cc
parent26da99595fd9b4298af68937c1c6302faec4e4da (diff)
downloadandroid_art-8d26c5967674d2eab21f65eeac9f1adcf88fce38.tar.gz
android_art-8d26c5967674d2eab21f65eeac9f1adcf88fce38.tar.bz2
android_art-8d26c5967674d2eab21f65eeac9f1adcf88fce38.zip
Prune class path classes from profile
Fixes a theoretical case where classes not in the app, but in the in the class path could have been included in the image. The dex caches for these classes are not properly handled and need to be pruned. Not including the classes in the image classes makes sure the that class linker automatically prunes them and frees the dex cache with the explicit garbage collection. Bug: 28452385 Change-Id: Ia44813863b5f1c79367049838021a64cc3842fc9
Diffstat (limited to 'dex2oat/dex2oat.cc')
-rw-r--r--dex2oat/dex2oat.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 9f6f4530c7..cce83f32b5 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1269,6 +1269,21 @@ class Dex2Oat FINAL {
CHECK(runtime != nullptr);
std::set<DexCacheResolvedClasses> resolved_classes(
profile_compilation_info_->GetResolvedClasses());
+
+ // Filter out class path classes since we don't want to include these in the image.
+ std::unordered_set<std::string> dex_files_locations;
+ for (const DexFile* dex_file : dex_files_) {
+ dex_files_locations.insert(dex_file->GetLocation());
+ }
+ for (auto it = resolved_classes.begin(); it != resolved_classes.end(); ) {
+ if (dex_files_locations.find(it->GetDexLocation()) == dex_files_locations.end()) {
+ VLOG(compiler) << "Removed profile samples for non-app dex file " << it->GetDexLocation();
+ it = resolved_classes.erase(it);
+ } else {
+ ++it;
+ }
+ }
+
image_classes_.reset(new std::unordered_set<std::string>(
runtime->GetClassLinker()->GetClassDescriptorsForProfileKeys(resolved_classes)));
VLOG(compiler) << "Loaded " << image_classes_->size()
@@ -2443,6 +2458,7 @@ class Dex2Oat FINAL {
bool multi_image_;
bool is_host_;
std::string android_root_;
+ // Dex files we are compiling, does not include the class path dex files.
std::vector<const DexFile*> dex_files_;
std::string no_inline_from_string_;
std::vector<jobject> dex_caches_;