OSDN Git Service

Prune uses library classes even without profile DO NOT MERGE
authorMathieu Chartier <mathieuc@google.com>
Fri, 5 Aug 2016 23:09:09 +0000 (16:09 -0700)
committerGriff Hazen <griff@google.com>
Wed, 14 Dec 2016 22:31:08 +0000 (22:31 +0000)
The previous pruning relied on the classes being pruned from the
profile, and then using the profile to prune classes. If there was
no profile, the uses library classes were incorrectly left unpruned.

Leaving these classes unpruned caused aborts during compilation.

Cherry picked from https://android-review.googlesource.com/#/c/312750/

Bug: 30688277
Bug: 31427727

Test: adb shell dex2oat --runtime-arg -classpath --runtime-arg /system/framework/com.google.android.maps.jar --dex-file=/data/app/comb.BBClient-1/base.apk --dex-location=/data/app/comb.BBClient-1/base.apk --oat-file=/data/app/comb.BBClient-1/oat/arm/base.odex  --app-image-file=/data/app/comb.BBClient-1/oat/arm/base.art --image-format=lz4 --compiler-filter=speed

Change-Id: I261b8894847b5b0a4f7330f49666e823a1b38bb0

compiler/image_writer.cc

index 61cf009..2d6c4da 100644 (file)
@@ -789,6 +789,13 @@ bool ImageWriter::PruneAppImageClassInternal(
   result = result || PruneAppImageClassInternal(klass->GetSuperClass(),
                                                 &my_early_exit,
                                                 visited);
+  // Remove the class if the dex file is not in the set of dex files. This happens for classes that
+  // are from uses library if there is no profile. b/30688277
+  mirror::DexCache* dex_cache = klass->GetDexCache();
+  if (dex_cache != nullptr) {
+    result = result ||
+        dex_file_oat_index_map_.find(dex_cache->GetDexFile()) == dex_file_oat_index_map_.end();
+  }
   // Erase the element we stored earlier since we are exiting the function.
   auto it = visited->find(klass);
   DCHECK(it != visited->end());