Minor cleanups to member rebinding and method access collection
Change-Id: I200d8667205fb3922beb89069e617bb3da0948ae
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 532abbd..a9ebda5 100644
--- a/src/main/java/com/android/tools/r8/graph/AppView.java
+++ b/src/main/java/com/android/tools/r8/graph/AppView.java
@@ -1107,7 +1107,7 @@
AppView<AppInfoWithLiveness> appViewWithLiveness = appView.withLiveness();
MethodAccessInfoCollection methodAccessInfoCollection =
appViewWithLiveness.appInfo().getMethodAccessInfoCollection();
- methodAccessInfoCollection.modifier().commit(appViewWithLiveness);
+ assert methodAccessInfoCollection.verify(appViewWithLiveness);
}
return true;
}
diff --git a/src/main/java/com/android/tools/r8/graph/MethodAccessInfoCollection.java b/src/main/java/com/android/tools/r8/graph/MethodAccessInfoCollection.java
index 542a558..3b8681b 100644
--- a/src/main/java/com/android/tools/r8/graph/MethodAccessInfoCollection.java
+++ b/src/main/java/com/android/tools/r8/graph/MethodAccessInfoCollection.java
@@ -212,6 +212,34 @@
});
}
+ public boolean verify(AppView<AppInfoWithLiveness> appView) {
+ assert verifyNoNonResolving(appView);
+ return true;
+ }
+
+ public boolean verifyNoNonResolving(AppView<AppInfoWithLiveness> appView) {
+ verifyNoNonResolving(appView, directInvokes);
+ verifyNoNonResolving(appView, interfaceInvokes);
+ verifyNoNonResolving(appView, staticInvokes);
+ verifyNoNonResolving(appView, superInvokes);
+ verifyNoNonResolving(appView, virtualInvokes);
+ return true;
+ }
+
+ private void verifyNoNonResolving(
+ AppView<AppInfoWithLiveness> appView, Map<DexMethod, ?> invokes) {
+ if (!isThrowingMap(invokes)) {
+ for (DexMethod method : invokes.keySet()) {
+ MethodResolutionResult result =
+ appView.appInfo().unsafeResolveMethodDueToDexFormatLegacy(method);
+ assert !result.isFailedResolution()
+ : "Unexpected method that does not resolve: " + method.toSourceString();
+ assert !result.isSignaturePolymorphicResolution(method, appView.dexItemFactory())
+ : "Unexpected signature polymorphic resolution: " + method.toSourceString();
+ }
+ }
+ }
+
public abstract static class Builder<T extends Map<DexMethod, ProgramMethodSet>> {
private final T directInvokes;
@@ -374,29 +402,6 @@
});
}
- public boolean verifyNoNonResolving(AppView<AppInfoWithLiveness> appView) {
- verifyNoNonResolving(appView, directInvokes);
- verifyNoNonResolving(appView, interfaceInvokes);
- verifyNoNonResolving(appView, staticInvokes);
- verifyNoNonResolving(appView, superInvokes);
- verifyNoNonResolving(appView, virtualInvokes);
- return true;
- }
-
- private void verifyNoNonResolving(
- AppView<AppInfoWithLiveness> appView, Map<DexMethod, ?> invokes) {
- if (!isThrowingMap(invokes)) {
- for (DexMethod method : invokes.keySet()) {
- MethodResolutionResult result =
- appView.appInfo().unsafeResolveMethodDueToDexFormatLegacy(method);
- assert !result.isFailedResolution()
- : "Unexpected method that does not resolve: " + method.toSourceString();
- assert !result.isSignaturePolymorphicResolution(method, appView.dexItemFactory())
- : "Unexpected signature polymorphic resolution: " + method.toSourceString();
- }
- }
- }
-
public MethodAccessInfoCollection build() {
return new MethodAccessInfoCollection(
directInvokes, interfaceInvokes, staticInvokes, superInvokes, virtualInvokes);
@@ -437,9 +442,5 @@
collection.forEachSuperInvoke(this::registerInvokeSuperInContexts);
collection.forEachVirtualInvoke(this::registerInvokeVirtualInContexts);
}
-
- public void commit(AppView<AppInfoWithLiveness> appView) {
- assert verifyNoNonResolving(appView);
- }
}
}
diff --git a/src/main/java/com/android/tools/r8/graph/lens/GraphLensUtils.java b/src/main/java/com/android/tools/r8/graph/lens/GraphLensUtils.java
index b7175d3..5a7c463 100644
--- a/src/main/java/com/android/tools/r8/graph/lens/GraphLensUtils.java
+++ b/src/main/java/com/android/tools/r8/graph/lens/GraphLensUtils.java
@@ -10,16 +10,10 @@
public static Deque<NonIdentityGraphLens> extractNonIdentityLenses(GraphLens lens) {
Deque<NonIdentityGraphLens> lenses = new ArrayDeque<>();
- if (lens.isNonIdentityLens()) {
- lenses.addFirst(lens.asNonIdentityLens());
- while (true) {
- GraphLens previous = lenses.getFirst().getPrevious();
- if (previous.isNonIdentityLens()) {
- lenses.addFirst(previous.asNonIdentityLens());
- } else {
- break;
- }
- }
+ while (lens.isNonIdentityLens()) {
+ NonIdentityGraphLens nonIdentityLens = lens.asNonIdentityLens();
+ lenses.addFirst(nonIdentityLens);
+ lens = nonIdentityLens.getPrevious();
}
return lenses;
}
diff --git a/src/main/java/com/android/tools/r8/optimize/bridgehoisting/BridgeHoisting.java b/src/main/java/com/android/tools/r8/optimize/bridgehoisting/BridgeHoisting.java
index 4b4b611..7503fa5 100644
--- a/src/main/java/com/android/tools/r8/optimize/bridgehoisting/BridgeHoisting.java
+++ b/src/main/java/com/android/tools/r8/optimize/bridgehoisting/BridgeHoisting.java
@@ -114,7 +114,7 @@
assert false;
}
});
- methodAccessInfoCollectionModifier.commit(appView);
+ methodAccessInfoCollection.verify(appView);
}
}