Only soft-pin hierarchy of proxied interfaces during initial shaking
This also adds `-dontwarn android.content.pm.IPackageManager` to chrome 180917.
Bug: 204421595
Change-Id: I6a73743e8b6acdb86d0cbe139dbe5a81ed255926
diff --git a/src/main/java/com/android/tools/r8/shaking/Enqueuer.java b/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
index 494cf92..fb814c6 100644
--- a/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
+++ b/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
@@ -4626,38 +4626,38 @@
}
DexProgramClass clazz = asProgramClassOrNull(definitionFor(type, method));
- if (clazz != null) {
+ if (clazz != null && clazz.isInterface()) {
+ KeepReason reason = KeepReason.reflectiveUseIn(method);
+ markInterfaceAsInstantiated(clazz, graphReporter.registerClass(clazz, reason));
worklist.addIfNotSeen(clazz);
}
}
while (worklist.hasNext()) {
DexProgramClass clazz = worklist.next();
- if (!clazz.isInterface()) {
- continue;
- }
+ assert clazz.isInterface();
- // Add this interface to the set of pinned items to ensure that we do not merge the
- // interface into its unique subtype, if any.
- // TODO(b/145344105): This should be superseded by the unknown interface hierarchy.
+ // Keep this interface to ensure that we do not merge the interface into its unique subtype,
+ // or merge other interfaces into it horizontally.
keepInfo.joinClass(clazz, joiner -> joiner.disallowOptimization().disallowShrinking());
- KeepReason reason = KeepReason.reflectiveUseIn(method);
- markInterfaceAsInstantiated(clazz, graphReporter.registerClass(clazz, reason));
- // Also pin all of its virtual methods to ensure that the devirtualizer does not perform
+ // Also keep all of its virtual methods to ensure that the devirtualizer does not perform
// illegal rewritings of invoke-interface instructions into invoke-virtual instructions.
- clazz.forEachProgramVirtualMethod(
- virtualMethod -> {
- keepInfo.joinMethod(
- virtualMethod, joiner -> joiner.disallowOptimization().disallowShrinking());
- markVirtualMethodAsReachable(virtualMethod.getReference(), true, method, reason);
- });
+ if (mode.isInitialTreeShaking()) {
+ KeepReason reason = KeepReason.reflectiveUseIn(method);
+ clazz.forEachProgramVirtualMethod(
+ virtualMethod -> {
+ keepInfo.joinMethod(
+ virtualMethod, joiner -> joiner.disallowOptimization().disallowShrinking());
+ markVirtualMethodAsReachable(virtualMethod.getReference(), true, method, reason);
+ });
+ }
// Repeat for all super interfaces.
for (DexType implementedType : clazz.getInterfaces()) {
DexProgramClass implementedClass =
asProgramClassOrNull(definitionFor(implementedType, clazz));
- if (implementedClass != null) {
+ if (implementedClass != null && implementedClass.isInterface()) {
worklist.addIfNotSeen(implementedClass);
}
}
diff --git a/third_party/chrome/chrome_180917_ffbaa8.tar.gz.sha1 b/third_party/chrome/chrome_180917_ffbaa8.tar.gz.sha1
index 104ad9d..3ac92ca 100644
--- a/third_party/chrome/chrome_180917_ffbaa8.tar.gz.sha1
+++ b/third_party/chrome/chrome_180917_ffbaa8.tar.gz.sha1
@@ -1 +1 @@
-e35ecc90931db82165b96f7b5f0e1c251ebe7347
\ No newline at end of file
+c32dc7f70022946c04bfe9316e35e60e8d2ee0cb
\ No newline at end of file