Revert "Share subtyping computation where possible."
This reverts commit 1ba6a0cb94d6b2c994efbdb4b906e788a888f3e5.
Reason for revert: Increase the bot running time with >30 minutes causing the linux builder to fail.
Change-Id: I3c21e31d9d68b1f3d6c2c324587f6ee534a14c39
diff --git a/src/main/java/com/android/tools/r8/GenerateMainDexList.java b/src/main/java/com/android/tools/r8/GenerateMainDexList.java
index 42290d2..0bb17c7 100644
--- a/src/main/java/com/android/tools/r8/GenerateMainDexList.java
+++ b/src/main/java/com/android/tools/r8/GenerateMainDexList.java
@@ -13,7 +13,6 @@
import com.android.tools.r8.graph.DexClass;
import com.android.tools.r8.graph.DexProgramClass;
import com.android.tools.r8.graph.DirectMappedDexApplication;
-import com.android.tools.r8.graph.SubtypingInfo;
import com.android.tools.r8.shaking.Enqueuer;
import com.android.tools.r8.shaking.EnqueuerFactory;
import com.android.tools.r8.shaking.MainDexClasses;
@@ -55,10 +54,8 @@
MainDexListBuilder.checkForAssumedLibraryTypes(appView.appInfo());
- SubtypingInfo subtypingInfo = new SubtypingInfo(application.allClasses(), application);
-
RootSet mainDexRootSet =
- new RootSetBuilder(appView, subtypingInfo, options.mainDexKeepRules).run(executor);
+ new RootSetBuilder(appView, application, options.mainDexKeepRules).run(executor);
GraphConsumer graphConsumer = options.mainDexKeptGraphConsumer;
WhyAreYouKeepingConsumer whyAreYouKeepingConsumer = null;
@@ -67,8 +64,7 @@
graphConsumer = whyAreYouKeepingConsumer;
}
- Enqueuer enqueuer =
- EnqueuerFactory.createForMainDexTracing(appView, subtypingInfo, graphConsumer);
+ Enqueuer enqueuer = EnqueuerFactory.createForMainDexTracing(appView, graphConsumer);
Set<DexProgramClass> liveTypes = enqueuer.traceMainDex(mainDexRootSet, executor, timing);
// LiveTypes is the result.
MainDexClasses mainDexClasses = new MainDexListBuilder(liveTypes, application).run();
diff --git a/src/main/java/com/android/tools/r8/PrintSeeds.java b/src/main/java/com/android/tools/r8/PrintSeeds.java
index 7c2302a..fb4edb5 100644
--- a/src/main/java/com/android/tools/r8/PrintSeeds.java
+++ b/src/main/java/com/android/tools/r8/PrintSeeds.java
@@ -10,7 +10,6 @@
import com.android.tools.r8.graph.AppServices;
import com.android.tools.r8.graph.AppView;
import com.android.tools.r8.graph.DirectMappedDexApplication;
-import com.android.tools.r8.graph.SubtypingInfo;
import com.android.tools.r8.shaking.AppInfoWithLiveness;
import com.android.tools.r8.shaking.Enqueuer;
import com.android.tools.r8.shaking.EnqueuerFactory;
@@ -90,11 +89,10 @@
AppView<? extends AppInfoWithClassHierarchy> appView =
AppView.createForR8(new AppInfoWithClassHierarchy(application), options);
appView.setAppServices(AppServices.builder(appView).build());
- SubtypingInfo subtypingInfo = new SubtypingInfo(application.allClasses(), application);
RootSet rootSet =
- new RootSetBuilder(appView, subtypingInfo, options.getProguardConfiguration().getRules())
+ new RootSetBuilder(appView, application, options.getProguardConfiguration().getRules())
.run(executor);
- Enqueuer enqueuer = EnqueuerFactory.createForInitialTreeShaking(appView, subtypingInfo);
+ Enqueuer enqueuer = EnqueuerFactory.createForInitialTreeShaking(appView);
AppInfoWithLiveness appInfo =
enqueuer.traceApplication(
rootSet, options.getProguardConfiguration().getDontWarnPatterns(), executor, timing);
diff --git a/src/main/java/com/android/tools/r8/R8.java b/src/main/java/com/android/tools/r8/R8.java
index 30201ce..e82c7eb 100644
--- a/src/main/java/com/android/tools/r8/R8.java
+++ b/src/main/java/com/android/tools/r8/R8.java
@@ -334,11 +334,11 @@
options.itemFactory, AndroidApiLevel.getAndroidApiLevel(options.minApiLevel)));
}
}
- SubtypingInfo subtypingInfo = new SubtypingInfo(application.allClasses(), application);
+
appView.setRootSet(
new RootSetBuilder(
appView,
- subtypingInfo,
+ application,
Iterables.concat(
options.getProguardConfiguration().getRules(), synthesizedProguardRules))
.run(executorService));
@@ -346,7 +346,7 @@
AnnotationRemover.Builder annotationRemoverBuilder =
options.isShrinking() ? AnnotationRemover.builder() : null;
AppView<AppInfoWithLiveness> appViewWithLiveness =
- runEnqueuer(annotationRemoverBuilder, executorService, appView, subtypingInfo);
+ runEnqueuer(annotationRemoverBuilder, executorService, appView);
application = appViewWithLiveness.appInfo().app().asDirect();
assert appView.rootSet().verifyKeptFieldsAreAccessedAndLive(appViewWithLiveness.appInfo());
assert appView.rootSet().verifyKeptMethodsAreTargetedAndLive(appViewWithLiveness.appInfo());
@@ -414,14 +414,11 @@
if (!options.mainDexKeepRules.isEmpty()) {
assert appView.graphLense().isIdentityLense();
// Find classes which may have code executed before secondary dex files installation.
- SubtypingInfo subtypingInfo =
- new SubtypingInfo(appView.appInfo().app().asDirect().allClasses(), appView);
mainDexRootSet =
- new RootSetBuilder(appView, subtypingInfo, options.mainDexKeepRules)
- .run(executorService);
+ new RootSetBuilder(appView, application, options.mainDexKeepRules).run(executorService);
// Live types is the tracing result.
Set<DexProgramClass> mainDexBaseClasses =
- EnqueuerFactory.createForMainDexTracing(appView, subtypingInfo)
+ EnqueuerFactory.createForMainDexTracing(appView)
.traceMainDex(mainDexRootSet, executorService, timing);
// Calculate the automatic main dex list according to legacy multidex constraints.
mainDexClasses = new MainDexListBuilder(mainDexBaseClasses, application).run();
@@ -611,10 +608,7 @@
}
Enqueuer enqueuer =
- EnqueuerFactory.createForMainDexTracing(
- appView,
- new SubtypingInfo(application.allClasses(), application),
- mainDexKeptGraphConsumer);
+ EnqueuerFactory.createForMainDexTracing(appView, mainDexKeptGraphConsumer);
// Find classes which may have code executed before secondary dex files installation.
// Live types is the tracing result.
Set<DexProgramClass> mainDexBaseClasses =
@@ -663,11 +657,7 @@
}
Enqueuer enqueuer =
- EnqueuerFactory.createForFinalTreeShaking(
- appView,
- new SubtypingInfo(application.allClasses(), application),
- keptGraphConsumer,
- missingClasses);
+ EnqueuerFactory.createForFinalTreeShaking(appView, keptGraphConsumer, missingClasses);
appView.setAppInfo(
enqueuer
.traceApplication(
@@ -873,10 +863,9 @@
private AppView<AppInfoWithLiveness> runEnqueuer(
AnnotationRemover.Builder annotationRemoverBuilder,
ExecutorService executorService,
- AppView<AppInfoWithClassHierarchy> appView,
- SubtypingInfo subtypingInfo)
+ AppView<AppInfoWithClassHierarchy> appView)
throws ExecutionException {
- Enqueuer enqueuer = EnqueuerFactory.createForInitialTreeShaking(appView, subtypingInfo);
+ Enqueuer enqueuer = EnqueuerFactory.createForInitialTreeShaking(appView);
enqueuer.setAnnotationRemoverBuilder(annotationRemoverBuilder);
if (appView.options().enableInitializedClassesInInstanceMethodsAnalysis) {
enqueuer.registerAnalysis(new InitializedClassesInInstanceMethodsAnalysis(appView));
@@ -932,17 +921,11 @@
// If there is no kept-graph info, re-run the enqueueing to compute it.
if (whyAreYouKeepingConsumer == null) {
whyAreYouKeepingConsumer = new WhyAreYouKeepingConsumer(null);
- SubtypingInfo subtypingInfo =
- new SubtypingInfo(appView.appInfo().app().asDirect().allClasses(), appView);
if (forMainDex) {
- enqueuer =
- EnqueuerFactory.createForMainDexTracing(
- appView, subtypingInfo, whyAreYouKeepingConsumer);
+ enqueuer = EnqueuerFactory.createForMainDexTracing(appView, whyAreYouKeepingConsumer);
enqueuer.traceMainDex(rootSet, executorService, timing);
} else {
- enqueuer =
- EnqueuerFactory.createForWhyAreYouKeeping(
- appView, subtypingInfo, whyAreYouKeepingConsumer);
+ enqueuer = EnqueuerFactory.createForWhyAreYouKeeping(appView, whyAreYouKeepingConsumer);
enqueuer.traceApplication(
rootSet,
options.getProguardConfiguration().getDontWarnPatterns(),
diff --git a/src/main/java/com/android/tools/r8/graph/SubtypingInfo.java b/src/main/java/com/android/tools/r8/graph/SubtypingInfo.java
index 662ccb0..6c6e3ba 100644
--- a/src/main/java/com/android/tools/r8/graph/SubtypingInfo.java
+++ b/src/main/java/com/android/tools/r8/graph/SubtypingInfo.java
@@ -14,7 +14,6 @@
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Map;
-import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
@@ -47,18 +46,6 @@
populateSubtypeMap(classes, definitions::definitionFor, factory);
}
- public boolean verifyEquals(Collection<DexClass> classes, DexDefinitionSupplier definitions) {
- SubtypingInfo subtypingInfo = new SubtypingInfo(classes, definitions);
- assert typeInfo.equals(subtypingInfo.typeInfo);
- assert subtypeMap.keySet().equals(subtypingInfo.subtypeMap.keySet());
- subtypeMap.forEach(
- (key, value) -> {
- assert subtypingInfo.subtypeMap.get(key).equals(value);
- });
- assert missingClasses.equals(subtypingInfo.missingClasses);
- return true;
- }
-
private void populateSuperType(
Map<DexType, Set<DexType>> map,
DexType superType,
@@ -252,20 +239,6 @@
}
@Override
- public int hashCode() {
- return Objects.hash(type, directSubtypes);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof TypeInfo)) {
- return false;
- }
- TypeInfo other = (TypeInfo) obj;
- return other.type == type && other.directSubtypes.equals(directSubtypes);
- }
-
- @Override
public String toString() {
return "TypeInfo{" + type + ", level:" + hierarchyLevel + "}";
}
diff --git a/src/main/java/com/android/tools/r8/shaking/ConsequentRootSetBuilder.java b/src/main/java/com/android/tools/r8/shaking/ConsequentRootSetBuilder.java
index 8288bde..ddb649c 100644
--- a/src/main/java/com/android/tools/r8/shaking/ConsequentRootSetBuilder.java
+++ b/src/main/java/com/android/tools/r8/shaking/ConsequentRootSetBuilder.java
@@ -5,17 +5,14 @@
import com.android.tools.r8.graph.AppInfoWithClassHierarchy;
import com.android.tools.r8.graph.AppView;
-import com.android.tools.r8.graph.SubtypingInfo;
class ConsequentRootSetBuilder extends RootSetBuilder {
private final Enqueuer enqueuer;
ConsequentRootSetBuilder(
- AppView<? extends AppInfoWithClassHierarchy> appView,
- SubtypingInfo subtypingInfo,
- Enqueuer enqueuer) {
- super(appView, subtypingInfo, null);
+ AppView<? extends AppInfoWithClassHierarchy> appView, Enqueuer enqueuer) {
+ super(appView, appView.appInfo().app(), null);
this.enqueuer = enqueuer;
}
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 4d91ba3..bf5ef76 100644
--- a/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
+++ b/src/main/java/com/android/tools/r8/shaking/Enqueuer.java
@@ -178,7 +178,7 @@
// Don't hold a direct pointer to app info (use appView).
private AppInfoWithClassHierarchy appInfo;
private final AppView<AppInfoWithClassHierarchy> appView;
- private SubtypingInfo subtypingInfo;
+ private final SubtypingInfo subtypingInfo;
private final InternalOptions options;
private RootSet rootSet;
private ProguardClassFilter dontWarnPatterns;
@@ -344,15 +344,14 @@
Enqueuer(
AppView<? extends AppInfoWithClassHierarchy> appView,
- SubtypingInfo subtypingInfo,
GraphConsumer keptGraphConsumer,
Mode mode) {
assert appView.appServices() != null;
InternalOptions options = appView.options();
this.appInfo = appView.appInfo();
this.appView = appView.withClassHierarchy();
- this.subtypingInfo = subtypingInfo;
- assert subtypingInfo.verifyEquals(appView.appInfo().app().asDirect().allClasses(), appView);
+ this.subtypingInfo =
+ new SubtypingInfo(appView.appInfo().app().asDirect().allClasses(), appView);
this.forceProguardCompatibility = options.forceProguardCompatibility;
this.graphReporter = new GraphReporter(appView, keptGraphConsumer);
this.mode = mode;
@@ -2726,10 +2725,8 @@
// Now all additions are computed, the application is atomically extended with those additions.
Builder appBuilder = appInfo.app().asDirect().builder();
additions.amendApplication(appBuilder);
- DirectMappedDexApplication app = appBuilder.build();
- appInfo = new AppInfoWithClassHierarchy(app);
+ appInfo = new AppInfoWithClassHierarchy(appBuilder.build());
appView.setAppInfo(appInfo);
- subtypingInfo = new SubtypingInfo(app.allClasses(), app);
// Finally once all synthesized items "exist" it is now safe to continue tracing. The new work
// items are enqueued and the fixed point will continue once this subroutine returns.
@@ -3114,7 +3111,7 @@
}
}
ConsequentRootSetBuilder consequentSetBuilder =
- new ConsequentRootSetBuilder(appView, subtypingInfo, this);
+ new ConsequentRootSetBuilder(appView, this);
IfRuleEvaluator ifRuleEvaluator =
new IfRuleEvaluator(
appView,
@@ -3226,7 +3223,7 @@
}
private ConsequentRootSet computeDelayedInterfaceMethodSyntheticBridges() {
- RootSetBuilder builder = new RootSetBuilder(appView, subtypingInfo);
+ RootSetBuilder builder = new RootSetBuilder(appView);
for (DelayedRootSetActionItem delayedRootSetActionItem : rootSet.delayedRootSetActionItems) {
if (delayedRootSetActionItem.isInterfaceMethodSyntheticBridgeAction()) {
handleInterfaceMethodSyntheticBridgeAction(
diff --git a/src/main/java/com/android/tools/r8/shaking/EnqueuerFactory.java b/src/main/java/com/android/tools/r8/shaking/EnqueuerFactory.java
index 743f0df..ddc5f62 100644
--- a/src/main/java/com/android/tools/r8/shaking/EnqueuerFactory.java
+++ b/src/main/java/com/android/tools/r8/shaking/EnqueuerFactory.java
@@ -8,24 +8,21 @@
import com.android.tools.r8.graph.AppInfoWithClassHierarchy;
import com.android.tools.r8.graph.AppView;
import com.android.tools.r8.graph.DexType;
-import com.android.tools.r8.graph.SubtypingInfo;
import com.android.tools.r8.shaking.Enqueuer.Mode;
import java.util.Set;
public class EnqueuerFactory {
public static Enqueuer createForInitialTreeShaking(
- AppView<? extends AppInfoWithClassHierarchy> appView, SubtypingInfo subtypingInfo) {
- return new Enqueuer(appView, subtypingInfo, null, Mode.INITIAL_TREE_SHAKING);
+ AppView<? extends AppInfoWithClassHierarchy> appView) {
+ return new Enqueuer(appView, null, Mode.INITIAL_TREE_SHAKING);
}
public static Enqueuer createForFinalTreeShaking(
AppView<? extends AppInfoWithClassHierarchy> appView,
- SubtypingInfo subtypingInfo,
GraphConsumer keptGraphConsumer,
Set<DexType> initialMissingTypes) {
- Enqueuer enqueuer =
- new Enqueuer(appView, subtypingInfo, keptGraphConsumer, Mode.FINAL_TREE_SHAKING);
+ Enqueuer enqueuer = new Enqueuer(appView, keptGraphConsumer, Mode.FINAL_TREE_SHAKING);
appView.withProtoShrinker(
shrinker -> enqueuer.setInitialDeadProtoTypes(shrinker.getDeadProtoTypes()));
enqueuer.setInitialMissingTypes(initialMissingTypes);
@@ -33,21 +30,17 @@
}
public static Enqueuer createForMainDexTracing(
- AppView<? extends AppInfoWithClassHierarchy> appView, SubtypingInfo subtypingInfo) {
- return createForMainDexTracing(appView, subtypingInfo, null);
+ AppView<? extends AppInfoWithClassHierarchy> appView) {
+ return createForMainDexTracing(appView, null);
}
public static Enqueuer createForMainDexTracing(
- AppView<? extends AppInfoWithClassHierarchy> appView,
- SubtypingInfo subtypingInfo,
- GraphConsumer keptGraphConsumer) {
- return new Enqueuer(appView, subtypingInfo, keptGraphConsumer, Mode.MAIN_DEX_TRACING);
+ AppView<? extends AppInfoWithClassHierarchy> appView, GraphConsumer keptGraphConsumer) {
+ return new Enqueuer(appView, keptGraphConsumer, Mode.MAIN_DEX_TRACING);
}
public static Enqueuer createForWhyAreYouKeeping(
- AppView<? extends AppInfoWithClassHierarchy> appView,
- SubtypingInfo subtypingInfo,
- GraphConsumer keptGraphConsumer) {
- return new Enqueuer(appView, subtypingInfo, keptGraphConsumer, Mode.WHY_ARE_YOU_KEEPING);
+ AppView<? extends AppInfoWithClassHierarchy> appView, GraphConsumer keptGraphConsumer) {
+ return new Enqueuer(appView, keptGraphConsumer, Mode.WHY_ARE_YOU_KEEPING);
}
}
diff --git a/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java b/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java
index 058693e..88c9fe2 100644
--- a/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java
+++ b/src/main/java/com/android/tools/r8/shaking/RootSetBuilder.java
@@ -115,19 +115,17 @@
public RootSetBuilder(
AppView<? extends AppInfoWithClassHierarchy> appView,
- SubtypingInfo subtypingInfo,
+ DexApplication application,
Iterable<? extends ProguardConfigurationRule> rules) {
this.appView = appView;
- this.subtypingInfo = subtypingInfo;
- this.application = appView.appInfo().app().asDirect();
+ this.application = application.asDirect();
+ this.subtypingInfo = new SubtypingInfo(this.application.allClasses(), this.application);
this.rules = rules;
this.options = appView.options();
- assert subtypingInfo.verifyEquals(this.application.allClasses(), this.application);
}
- public RootSetBuilder(
- AppView<? extends AppInfoWithClassHierarchy> appView, SubtypingInfo subtypingInfo) {
- this(appView, subtypingInfo, null);
+ public RootSetBuilder(AppView<? extends AppInfoWithClassHierarchy> appView) {
+ this(appView, appView.appInfo().app(), null);
}
void handleMatchedAnnotation(AnnotationMatchResult annotation) {
diff --git a/src/test/java/com/android/tools/r8/TestBase.java b/src/test/java/com/android/tools/r8/TestBase.java
index 7c3ddff..6c3ed35 100644
--- a/src/test/java/com/android/tools/r8/TestBase.java
+++ b/src/test/java/com/android/tools/r8/TestBase.java
@@ -34,7 +34,6 @@
import com.android.tools.r8.graph.DexType;
import com.android.tools.r8.graph.DirectMappedDexApplication;
import com.android.tools.r8.graph.SmaliWriter;
-import com.android.tools.r8.graph.SubtypingInfo;
import com.android.tools.r8.jasmin.JasminBuilder;
import com.android.tools.r8.origin.Origin;
import com.android.tools.r8.references.ClassReference;
@@ -619,16 +618,15 @@
AppView<AppInfoWithClassHierarchy> appView = computeAppViewWithSubtyping(app);
// Run the tree shaker to compute an instance of AppInfoWithLiveness.
ExecutorService executor = Executors.newSingleThreadExecutor();
- DirectMappedDexApplication application = appView.appInfo().app().asDirect();
- SubtypingInfo subtypingInfo = new SubtypingInfo(application.allClasses(), application);
+ DexApplication application = appView.appInfo().app();
RootSet rootSet =
new RootSetBuilder(
appView,
- subtypingInfo,
+ application,
proguardConfigurationRulesGenerator.apply(appView.appInfo().dexItemFactory()))
.run(executor);
AppInfoWithLiveness appInfoWithLiveness =
- EnqueuerFactory.createForInitialTreeShaking(appView, subtypingInfo)
+ EnqueuerFactory.createForInitialTreeShaking(appView)
.traceApplication(rootSet, ProguardClassFilter.empty(), executor, application.timing);
// We do not run the tree pruner to ensure that the hierarchy is as designed and not modified
// due to liveness.
diff --git a/src/test/java/com/android/tools/r8/ir/InlineTest.java b/src/test/java/com/android/tools/r8/ir/InlineTest.java
index a2246c0..dc0585a 100644
--- a/src/test/java/com/android/tools/r8/ir/InlineTest.java
+++ b/src/test/java/com/android/tools/r8/ir/InlineTest.java
@@ -11,8 +11,6 @@
import com.android.tools.r8.graph.AppView;
import com.android.tools.r8.graph.DexApplication;
import com.android.tools.r8.graph.DexItemFactory;
-import com.android.tools.r8.graph.DirectMappedDexApplication;
-import com.android.tools.r8.graph.SubtypingInfo;
import com.android.tools.r8.ir.code.BasicBlock;
import com.android.tools.r8.ir.code.IRCode;
import com.android.tools.r8.ir.code.Instruction;
@@ -49,20 +47,18 @@
MethodSubject method,
List<IRCode> additionalCode)
throws ExecutionException {
- DirectMappedDexApplication directApp = application.asDirect();
AppView<AppInfoWithClassHierarchy> appView =
- AppView.createForR8(new AppInfoWithClassHierarchy(directApp), options);
+ AppView.createForR8(new AppInfoWithClassHierarchy(application.asDirect()), options);
appView.setAppServices(AppServices.builder(appView).build());
ExecutorService executorService = ThreadUtils.getExecutorService(options);
- SubtypingInfo subtypingInfo = new SubtypingInfo(directApp.allClasses(), directApp);
appView.setRootSet(
new RootSetBuilder(
appView,
- subtypingInfo,
+ application,
ImmutableList.of(ProguardKeepRule.defaultKeepAllRule(unused -> {})))
.run(executorService));
Timing timing = Timing.empty();
- Enqueuer enqueuer = EnqueuerFactory.createForInitialTreeShaking(appView, subtypingInfo);
+ Enqueuer enqueuer = EnqueuerFactory.createForInitialTreeShaking(appView);
appView.setAppInfo(
enqueuer.traceApplication(
appView.rootSet(), ProguardClassFilter.empty(), executorService, timing));
diff --git a/src/test/java/com/android/tools/r8/ir/conversion/PartialCallGraphTest.java b/src/test/java/com/android/tools/r8/ir/conversion/PartialCallGraphTest.java
index 1ea4e67..5f07b54 100644
--- a/src/test/java/com/android/tools/r8/ir/conversion/PartialCallGraphTest.java
+++ b/src/test/java/com/android/tools/r8/ir/conversion/PartialCallGraphTest.java
@@ -10,15 +10,21 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import com.android.tools.r8.dex.ApplicationReader;
+import com.android.tools.r8.graph.AppInfoWithClassHierarchy;
+import com.android.tools.r8.graph.AppServices;
import com.android.tools.r8.graph.AppView;
import com.android.tools.r8.graph.DexClass;
import com.android.tools.r8.graph.DexEncodedMethod;
+import com.android.tools.r8.graph.DirectMappedDexApplication;
import com.android.tools.r8.ir.conversion.CallGraph.Node;
import com.android.tools.r8.shaking.AppInfoWithLiveness;
+import com.android.tools.r8.shaking.Enqueuer;
+import com.android.tools.r8.shaking.EnqueuerFactory;
import com.android.tools.r8.shaking.ProguardConfigurationParser;
+import com.android.tools.r8.shaking.RootSetBuilder;
import com.android.tools.r8.utils.AndroidApp;
import com.android.tools.r8.utils.InternalOptions;
-import com.android.tools.r8.utils.Reporter;
import com.android.tools.r8.utils.ThreadUtils;
import com.android.tools.r8.utils.Timing;
import com.google.common.collect.ImmutableList;
@@ -30,24 +36,33 @@
public class PartialCallGraphTest extends CallGraphTestBase {
private final AppView<AppInfoWithLiveness> appView;
- private final InternalOptions options;
- private final ExecutorService executorService;
+ private final InternalOptions options = new InternalOptions();
+ private final ExecutorService executorService = ThreadUtils.getExecutorService(options);
public PartialCallGraphTest() throws Exception {
+ Timing timing = Timing.empty();
AndroidApp app = testForD8().addProgramClasses(TestClass.class).compile().app;
+ DirectMappedDexApplication application =
+ new ApplicationReader(app, options, timing).read().toDirect();
+ AppView<AppInfoWithClassHierarchy> appView =
+ AppView.createForR8(new AppInfoWithClassHierarchy(application), options);
+ appView.setAppServices(AppServices.builder(appView).build());
+ ProguardConfigurationParser parser =
+ new ProguardConfigurationParser(appView.dexItemFactory(), options.reporter);
+ parser.parse(
+ createConfigurationForTesting(
+ ImmutableList.of("-keep class ** { void m1(); void m5(); }")));
+ appView.setRootSet(
+ new RootSetBuilder(
+ appView, application, parser.getConfig().getRules()).run(executorService));
+ Enqueuer enqueuer = EnqueuerFactory.createForInitialTreeShaking(appView);
this.appView =
- computeAppViewWithLiveness(
- app,
- factory -> {
- ProguardConfigurationParser parser =
- new ProguardConfigurationParser(factory, new Reporter());
- parser.parse(
- createConfigurationForTesting(
- ImmutableList.of("-keep class ** { void m1(); void m5(); }")));
- return parser.getConfig().getRules();
- });
- this.options = appView.options();
- this.executorService = ThreadUtils.getExecutorService(options);
+ appView.setAppInfo(
+ enqueuer.traceApplication(
+ appView.rootSet(),
+ parser.getConfig().getDontWarnPatterns(),
+ executorService,
+ timing));
}
@Test
diff --git a/src/test/java/com/android/tools/r8/naming/NamingTestBase.java b/src/test/java/com/android/tools/r8/naming/NamingTestBase.java
index 385911c..74bae45 100644
--- a/src/test/java/com/android/tools/r8/naming/NamingTestBase.java
+++ b/src/test/java/com/android/tools/r8/naming/NamingTestBase.java
@@ -10,7 +10,6 @@
import com.android.tools.r8.graph.AppView;
import com.android.tools.r8.graph.DexItemFactory;
import com.android.tools.r8.graph.DirectMappedDexApplication;
-import com.android.tools.r8.graph.SubtypingInfo;
import com.android.tools.r8.shaking.Enqueuer;
import com.android.tools.r8.shaking.EnqueuerFactory;
import com.android.tools.r8.shaking.ProguardConfiguration;
@@ -62,7 +61,6 @@
protected NamingLens runMinifier(List<Path> configPaths) throws ExecutionException {
ProguardConfiguration configuration =
ToolHelper.loadProguardConfiguration(dexItemFactory, configPaths);
-
InternalOptions options = new InternalOptions(configuration, new Reporter());
options.programConsumer = DexIndexedConsumer.emptyConsumer();
@@ -70,12 +68,11 @@
AppView<AppInfoWithClassHierarchy> appView =
AppView.createForR8(new AppInfoWithClassHierarchy(program), options);
- SubtypingInfo subtypingInfo = new SubtypingInfo(program.allClasses(), program);
appView.setRootSet(
- new RootSetBuilder(appView, subtypingInfo, configuration.getRules()).run(executor));
+ new RootSetBuilder(appView, program, configuration.getRules()).run(executor));
appView.setAppServices(AppServices.builder(appView).build());
- Enqueuer enqueuer = EnqueuerFactory.createForInitialTreeShaking(appView, subtypingInfo);
+ Enqueuer enqueuer = EnqueuerFactory.createForInitialTreeShaking(appView);
appView.setAppInfo(
enqueuer.traceApplication(
appView.rootSet(), configuration.getDontWarnPatterns(), executor, timing));