Merge "Rename getters in AppView for convenience"
diff --git a/src/main/java/com/android/tools/r8/R8.java b/src/main/java/com/android/tools/r8/R8.java
index b2743bc..2f40a77 100644
--- a/src/main/java/com/android/tools/r8/R8.java
+++ b/src/main/java/com/android/tools/r8/R8.java
@@ -256,7 +256,7 @@
String proguardSeedsData = null;
timing.begin("Strip unused code");
try {
- Set<DexType> missingClasses = appView.getAppInfo().getMissingClasses();
+ Set<DexType> missingClasses = appView.appInfo().getMissingClasses();
missingClasses = filterMissingClasses(
missingClasses, options.proguardConfiguration.getDontWarnPatterns());
if (!missingClasses.isEmpty()) {
@@ -273,14 +273,14 @@
// Compute kotlin info before setting the roots and before
// kotlin metadata annotation is removed.
- computeKotlinInfoForProgramClasses(application, appView.getAppInfo());
+ computeKotlinInfoForProgramClasses(application, appView.appInfo());
final ProguardConfiguration.Builder compatibility =
ProguardConfiguration.builder(application.dexItemFactory, options.reporter);
rootSet =
new RootSetBuilder(
- appView.getAppInfo(),
+ appView.appInfo(),
application,
options.proguardConfiguration.getRules(),
options)
@@ -288,8 +288,8 @@
Enqueuer enqueuer =
new Enqueuer(
- appView.getAppInfo(),
- appView.getGraphLense(),
+ appView.appInfo(),
+ appView.graphLense(),
options,
options.forceProguardCompatibility,
compatibility);
@@ -297,23 +297,23 @@
if (options.proguardConfiguration.isPrintSeeds()) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
PrintStream out = new PrintStream(bytes);
- RootSetBuilder.writeSeeds(appView.getAppInfo().withLiveness(), out, type -> true);
+ RootSetBuilder.writeSeeds(appView.appInfo().withLiveness(), out, type -> true);
out.flush();
proguardSeedsData = bytes.toString();
}
if (options.enableTreeShaking) {
TreePruner pruner =
- new TreePruner(application, appView.getAppInfo().withLiveness(), options);
+ new TreePruner(application, appView.appInfo().withLiveness(), options);
application = pruner.run();
// Recompute the subtyping information.
appView.setAppInfo(
appView
- .getAppInfo()
+ .appInfo()
.withLiveness()
.prunedCopyFrom(application, pruner.getRemovedClasses()));
- new AbstractMethodRemover(appView.getAppInfo()).run();
+ new AbstractMethodRemover(appView.appInfo()).run();
}
- new AnnotationRemover(appView.getAppInfo().withLiveness(), compatibility, options).run();
+ new AnnotationRemover(appView.appInfo().withLiveness(), compatibility, options).run();
// TODO(69445518): This is still work in progress, and this file writing is currently used
// for testing.
@@ -341,10 +341,10 @@
// We can now remove visibility bridges. Note that we do not need to update the
// invoke-targets here, as the existing invokes will simply dispatch to the now
// visible super-method. MemberRebinding, if run, will then dispatch it correctly.
- application = new VisibilityBridgeRemover(appView.getAppInfo(), application).run();
+ application = new VisibilityBridgeRemover(appView.appInfo(), application).run();
}
- if (appView.getAppInfo().hasLiveness()) {
+ if (appView.appInfo().hasLiveness()) {
AppView<AppInfoWithLiveness> appViewWithLiveness = appView.withLiveness();
if (options.proguardConfiguration.hasApplyMappingFile()) {
@@ -353,12 +353,12 @@
timing.begin("apply-mapping");
appView.setGraphLense(
new ProguardMapApplier(appView.withLiveness(), seedMapper).run(timing));
- application = application.asDirect().rewrittenWithLense(appView.getGraphLense());
+ application = application.asDirect().rewrittenWithLense(appView.graphLense());
appView.setAppInfo(
appView
- .getAppInfo()
+ .appInfo()
.withLiveness()
- .rewrittenWithLense(application.asDirect(), appView.getGraphLense()));
+ .rewrittenWithLense(application.asDirect(), appView.graphLense()));
timing.end();
}
appView.setGraphLense(new MemberRebindingAnalysis(appViewWithLiveness).run());
@@ -370,12 +370,12 @@
appView.setGraphLense(verticalClassMerger.run());
appView.setVerticallyMergedClasses(verticalClassMerger.getMergedClasses());
timing.end();
- application = application.asDirect().rewrittenWithLense(appView.getGraphLense());
+ application = application.asDirect().rewrittenWithLense(appView.graphLense());
appViewWithLiveness.setAppInfo(
appViewWithLiveness
- .getAppInfo()
+ .appInfo()
.prunedCopyFrom(application, verticalClassMerger.getRemovedClasses())
- .rewrittenWithLense(application.asDirect(), appView.getGraphLense()));
+ .rewrittenWithLense(application.asDirect(), appView.graphLense()));
}
// Collect switch maps and ordinals maps.
appViewWithLiveness.setAppInfo(new SwitchMapCollector(appViewWithLiveness, options).run());
@@ -411,16 +411,15 @@
// Overwrite SourceFile if specified. This step should be done after IR conversion.
timing.begin("Rename SourceFile");
- new SourceFileRewriter(appView.getAppInfo(), options).run();
+ new SourceFileRewriter(appView.appInfo(), options).run();
timing.end();
if (!options.mainDexKeepRules.isEmpty()) {
appView.setAppInfo(new AppInfoWithSubtyping(application));
- Enqueuer enqueuer =
- new Enqueuer(appView.getAppInfo(), appView.getGraphLense(), options, true);
+ Enqueuer enqueuer = new Enqueuer(appView.appInfo(), appView.graphLense(), options, true);
// Lets find classes which may have code executed before secondary dex files installation.
RootSet mainDexRootSet =
- new RootSetBuilder(appView.getAppInfo(), application, options.mainDexKeepRules, options)
+ new RootSetBuilder(appView.appInfo(), application, options.mainDexKeepRules, options)
.run(executorService);
AppInfoWithLiveness mainDexAppInfo =
enqueuer.traceMainDex(mainDexRootSet, executorService, timing);
@@ -442,20 +441,19 @@
try {
Enqueuer enqueuer =
new Enqueuer(
- appView.getAppInfo(),
- appView.getGraphLense(),
+ appView.appInfo(),
+ appView.graphLense(),
options,
options.forceProguardCompatibility);
appView.setAppInfo(enqueuer.traceApplication(rootSet, executorService, timing));
AppView<AppInfoWithLiveness> appViewWithLiveness = appView.withLiveness();
if (options.enableTreeShaking) {
- TreePruner pruner =
- new TreePruner(application, appViewWithLiveness.getAppInfo(), options);
+ TreePruner pruner = new TreePruner(application, appViewWithLiveness.appInfo(), options);
application = pruner.run();
appViewWithLiveness.setAppInfo(
appViewWithLiveness
- .getAppInfo()
+ .appInfo()
.prunedCopyFrom(application, pruner.getRemovedClasses()));
// Print reasons on the application after pruning, so that we reflect the actual result.
ReasonPrinter reasonPrinter = enqueuer.getReasonPrinter(rootSet.reasonAsked);
@@ -476,8 +474,7 @@
// will happen. Just avoid the overhead.
NamingLens namingLens =
options.enableMinification
- ? new Minifier(
- appView.getAppInfo().withLiveness(), rootSet, desugaredCallSites, options)
+ ? new Minifier(appView.appInfo().withLiveness(), rootSet, desugaredCallSites, options)
.run(timing)
: NamingLens.getIdentityLens();
timing.end();
@@ -489,7 +486,7 @@
ClassNameMapper classNameMapper =
LineNumberOptimizer.run(
application,
- appView.getGraphLense(),
+ appView.graphLense(),
namingLens,
options.lineNumberOptimization == LineNumberOptimization.IDENTITY_MAPPING);
timing.end();
@@ -512,7 +509,7 @@
executorService,
application,
application.deadCode,
- appView.getGraphLense(),
+ appView.graphLense(),
namingLens,
proguardSeedsData,
options,
diff --git a/src/main/java/com/android/tools/r8/graph/AppView.java b/src/main/java/com/android/tools/r8/graph/AppView.java
index 47671c6..3e4d611 100644
--- a/src/main/java/com/android/tools/r8/graph/AppView.java
+++ b/src/main/java/com/android/tools/r8/graph/AppView.java
@@ -24,11 +24,6 @@
return appInfo;
}
- // TODO(christofferqa): Remove and carry out renamings in a separate CL.
- public T getAppInfo() {
- return appInfo;
- }
-
public void setAppInfo(T appInfo) {
this.appInfo = appInfo;
}
@@ -37,20 +32,10 @@
return dexItemFactory;
}
- // TODO(christofferqa): Remove and carry out renamings in a separate CL.
- public DexItemFactory getDexItemFactory() {
- return dexItemFactory;
- }
-
public GraphLense graphLense() {
return graphLense;
}
- // TODO(christofferqa): Remove and carry out renamings in a separate CL.
- public GraphLense getGraphLense() {
- return graphLense;
- }
-
public void setGraphLense(GraphLense graphLense) {
this.graphLense = graphLense;
}
@@ -81,11 +66,6 @@
}
@Override
- public AppInfoWithLiveness getAppInfo() {
- return AppView.this.getAppInfo().withLiveness();
- }
-
- @Override
public void setAppInfo(AppInfoWithLiveness appInfoWithLiveness) {
@SuppressWarnings("unchecked")
T appInfo = (T) appInfoWithLiveness;
@@ -98,21 +78,11 @@
}
@Override
- public DexItemFactory getDexItemFactory() {
- return AppView.this.dexItemFactory;
- }
-
- @Override
public GraphLense graphLense() {
return AppView.this.graphLense();
}
@Override
- public GraphLense getGraphLense() {
- return AppView.this.getGraphLense();
- }
-
- @Override
public void setGraphLense(GraphLense graphLense) {
AppView.this.setGraphLense(graphLense);
}
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java b/src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java
index a7e5114..1881f79 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java
@@ -233,7 +233,7 @@
InternalOptions options,
Timing timing,
CfgPrinter printer) {
- this(appView.getAppInfo(), options, timing, printer, appView);
+ this(appView.appInfo(), options, timing, printer, appView);
}
private boolean enableInterfaceMethodDesugaring() {
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/EnumOrdinalMapCollector.java b/src/main/java/com/android/tools/r8/ir/optimize/EnumOrdinalMapCollector.java
index e23b534..8c8f428 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/EnumOrdinalMapCollector.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/EnumOrdinalMapCollector.java
@@ -38,8 +38,8 @@
private final Map<DexType, Reference2IntMap<DexField>> ordinalsMaps = new IdentityHashMap<>();
public EnumOrdinalMapCollector(AppView<AppInfoWithLiveness> appView, InternalOptions options) {
- this.appInfo = appView.getAppInfo();
- this.graphLense = appView.getGraphLense();
+ this.appInfo = appView.appInfo();
+ this.graphLense = appView.graphLense();
this.options = options;
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/SwitchMapCollector.java b/src/main/java/com/android/tools/r8/ir/optimize/SwitchMapCollector.java
index c2fbc9e..fbe2e93 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/SwitchMapCollector.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/SwitchMapCollector.java
@@ -71,8 +71,8 @@
private final Map<DexField, Int2ReferenceMap<DexField>> switchMaps = new IdentityHashMap<>();
public SwitchMapCollector(AppView<AppInfoWithLiveness> appView, InternalOptions options) {
- this.appInfo = appView.getAppInfo();
- this.graphLense = appView.getGraphLense();
+ this.appInfo = appView.appInfo();
+ this.graphLense = appView.graphLense();
this.options = options;
switchMapPrefix = appInfo.dexItemFactory.createString("$SwitchMap$");
intArrayType = appInfo.dexItemFactory.createType("[I");
diff --git a/src/main/java/com/android/tools/r8/naming/ProguardMapApplier.java b/src/main/java/com/android/tools/r8/naming/ProguardMapApplier.java
index f114a7e..25df058 100644
--- a/src/main/java/com/android/tools/r8/naming/ProguardMapApplier.java
+++ b/src/main/java/com/android/tools/r8/naming/ProguardMapApplier.java
@@ -35,9 +35,9 @@
private final SeedMapper seedMapper;
public ProguardMapApplier(AppView<AppInfoWithLiveness> appView, SeedMapper seedMapper) {
- assert appView.getGraphLense().isContextFreeForMethods();
- this.appInfo = appView.getAppInfo();
- this.previousLense = appView.getGraphLense();
+ assert appView.graphLense().isContextFreeForMethods();
+ this.appInfo = appView.appInfo();
+ this.previousLense = appView.graphLense();
this.seedMapper = seedMapper;
}
diff --git a/src/main/java/com/android/tools/r8/optimize/ClassAndMemberPublicizer.java b/src/main/java/com/android/tools/r8/optimize/ClassAndMemberPublicizer.java
index 50571f3..480eee0 100644
--- a/src/main/java/com/android/tools/r8/optimize/ClassAndMemberPublicizer.java
+++ b/src/main/java/com/android/tools/r8/optimize/ClassAndMemberPublicizer.java
@@ -62,8 +62,8 @@
// Phase 2: Visit classes and promote class/member to public if possible.
timing.begin("Phase 2: promoteToPublic");
- DexType.forAllInterfaces(appView.getDexItemFactory(), this::publicizeType);
- publicizeType(appView.getDexItemFactory().objectType);
+ DexType.forAllInterfaces(appView.dexItemFactory(), this::publicizeType);
+ publicizeType(appView.dexItemFactory().objectType);
timing.end();
return lenseBuilder.build(appView);
@@ -94,7 +94,7 @@
return false;
}
- if (appView.getDexItemFactory().isClassConstructor(encodedMethod.method)) {
+ if (appView.dexItemFactory().isClassConstructor(encodedMethod.method)) {
return false;
}
@@ -105,7 +105,7 @@
}
assert accessFlags.isPrivate();
- if (appView.getDexItemFactory().isConstructor(encodedMethod.method)) {
+ if (appView.dexItemFactory().isConstructor(encodedMethod.method)) {
accessFlags.unsetPrivate();
accessFlags.setPublic();
return false;
diff --git a/src/main/java/com/android/tools/r8/optimize/MemberRebindingAnalysis.java b/src/main/java/com/android/tools/r8/optimize/MemberRebindingAnalysis.java
index c1d7403..0b6a84d 100644
--- a/src/main/java/com/android/tools/r8/optimize/MemberRebindingAnalysis.java
+++ b/src/main/java/com/android/tools/r8/optimize/MemberRebindingAnalysis.java
@@ -30,9 +30,9 @@
private final MemberRebindingLense.Builder builder;
public MemberRebindingAnalysis(AppView<AppInfoWithLiveness> appView) {
- assert appView.getGraphLense().isContextFreeForMethods();
- this.appInfo = appView.getAppInfo();
- this.lense = appView.getGraphLense();
+ assert appView.graphLense().isContextFreeForMethods();
+ this.appInfo = appView.appInfo();
+ this.lense = appView.graphLense();
this.builder = MemberRebindingLense.builder(appInfo);
}
diff --git a/src/main/java/com/android/tools/r8/optimize/PublicizerLense.java b/src/main/java/com/android/tools/r8/optimize/PublicizerLense.java
index ad7effd..b11393a 100644
--- a/src/main/java/com/android/tools/r8/optimize/PublicizerLense.java
+++ b/src/main/java/com/android/tools/r8/optimize/PublicizerLense.java
@@ -27,8 +27,8 @@
ImmutableMap.of(),
null,
null,
- appView.getGraphLense(),
- appView.getAppInfo().dexItemFactory);
+ appView.graphLense(),
+ appView.dexItemFactory());
this.appView = appView;
this.publicizedMethods = publicizedMethods;
}
@@ -48,9 +48,9 @@
private boolean publicizedMethodIsPresentOnHolder(DexMethod method, DexEncodedMethod context) {
GraphLenseLookupResult lookup =
- appView.getGraphLense().lookupMethod(method, context, Type.VIRTUAL);
+ appView.graphLense().lookupMethod(method, context, Type.VIRTUAL);
DexMethod signatureInCurrentWorld = lookup.getMethod();
- DexClass clazz = appView.getAppInfo().definitionFor(signatureInCurrentWorld.holder);
+ DexClass clazz = appView.appInfo().definitionFor(signatureInCurrentWorld.holder);
assert clazz != null;
DexEncodedMethod actualEncodedTarget = clazz.lookupVirtualMethod(signatureInCurrentWorld);
assert actualEncodedTarget != null;
diff --git a/src/main/java/com/android/tools/r8/shaking/VerticalClassMerger.java b/src/main/java/com/android/tools/r8/shaking/VerticalClassMerger.java
index 9eafe9a..03272a5 100644
--- a/src/main/java/com/android/tools/r8/shaking/VerticalClassMerger.java
+++ b/src/main/java/com/android/tools/r8/shaking/VerticalClassMerger.java
@@ -218,9 +218,9 @@
InternalOptions options,
Timing timing) {
this.application = application;
- this.appInfo = appView.getAppInfo();
+ this.appInfo = appView.appInfo();
this.executorService = executorService;
- this.graphLense = appView.getGraphLense();
+ this.graphLense = appView.graphLense();
this.methodPoolCollection = new MethodPoolCollection(application);
this.options = options;
this.renamedMembersLense = new VerticalClassMergerGraphLense.Builder();
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 c1d9234..932c09b 100644
--- a/src/test/java/com/android/tools/r8/naming/NamingTestBase.java
+++ b/src/test/java/com/android/tools/r8/naming/NamingTestBase.java
@@ -75,7 +75,7 @@
ExecutorService executor = ThreadUtils.getExecutorService(1);
- AppInfoWithSubtyping appInfo = appView.getAppInfo();
+ AppInfoWithSubtyping appInfo = appView.appInfo();
RootSet rootSet = new RootSetBuilder(appInfo, program, configuration.getRules(), options)
.run(executor);