Version 1.6.80
Cherry pick: Do not compute inlining constraint for pinned methods
CL: https://r8-review.googlesource.com/c/r8/+/49324
Cherry pick: Remove redundant accessibility checks from inlining constraint computation
CL: https://r8-review.googlesource.com/c/r8/+/49320
CL: Fix NPE arising from the absence of synthesized type
Cherry pick: https://r8-review.googlesource.com/c/r8/+/49325
Bug: 150508871, 150454980, 150269949, 150347755
Change-Id: I30017ad4247515ef616c6a6de55f469c46260652
diff --git a/src/main/java/com/android/tools/r8/Version.java b/src/main/java/com/android/tools/r8/Version.java
index 4f95c1f..b2cd485 100644
--- a/src/main/java/com/android/tools/r8/Version.java
+++ b/src/main/java/com/android/tools/r8/Version.java
@@ -11,7 +11,7 @@
// This field is accessed from release scripts using simple pattern matching.
// Therefore, changing this field could break our release scripts.
- public static final String LABEL = "1.6.79";
+ public static final String LABEL = "1.6.80";
private Version() {
}
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 fe31d86..da3312e 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
@@ -729,6 +729,7 @@
finalizeLambdaMerging(application, feedback, builder, executorService);
if (serviceLoaderRewriter != null && serviceLoaderRewriter.getSynthesizedClass() != null) {
+ appView.appInfo().addSynthesizedClass(serviceLoaderRewriter.getSynthesizedClass());
forEachSynthesizedServiceLoaderMethod(
executorService, serviceLoaderRewriter.getSynthesizedClass());
builder.addSynthesizedClass(serviceLoaderRewriter.getSynthesizedClass(), true);
@@ -1656,17 +1657,27 @@
private void markProcessed(DexEncodedMethod method, IRCode code, OptimizationFeedback feedback) {
// After all the optimizations have take place, we compute whether method should be inlined.
- ConstraintWithTarget state;
- if (!options.enableInlining
- || inliner == null
- || method.getOptimizationInfo().isReachabilitySensitive()) {
- state = ConstraintWithTarget.NEVER;
- } else {
- state = inliner.computeInliningConstraint(code, method);
- }
+ ConstraintWithTarget state =
+ shouldComputeInliningConstraint(method)
+ ? inliner.computeInliningConstraint(code, method)
+ : ConstraintWithTarget.NEVER;
feedback.markProcessed(method, state);
}
+ private boolean shouldComputeInliningConstraint(DexEncodedMethod method) {
+ if (!options.enableInlining || inliner == null) {
+ return false;
+ }
+ if (method.isClassInitializer() || method.getOptimizationInfo().isReachabilitySensitive()) {
+ return false;
+ }
+ if (appView.appInfo().hasLiveness()
+ && appView.appInfo().withLiveness().isPinned(method.method)) {
+ return false;
+ }
+ return true;
+ }
+
private synchronized void updateHighestSortingStrings(DexEncodedMethod method) {
DexString highestSortingReferencedString = method.getCode().asDexCode().highestSortingString;
if (highestSortingReferencedString != null) {
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/InliningConstraints.java b/src/main/java/com/android/tools/r8/ir/optimize/InliningConstraints.java
index 074160b..7d4a72f 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/InliningConstraints.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/InliningConstraints.java
@@ -19,7 +19,6 @@
import com.android.tools.r8.ir.optimize.Inliner.Constraint;
import com.android.tools.r8.ir.optimize.Inliner.ConstraintWithTarget;
import com.android.tools.r8.shaking.AppInfoWithLiveness;
-import java.util.Collection;
// Computes the inlining constraint for a given instruction.
public class InliningConstraints {
@@ -377,28 +376,7 @@
ConstraintWithTarget classConstraintWithTarget =
ConstraintWithTarget.deriveConstraint(
invocationContext, methodHolder, methodClass.accessFlags, appView);
- ConstraintWithTarget result =
- ConstraintWithTarget.meet(methodConstraintWithTarget, classConstraintWithTarget, appView);
- if (result == ConstraintWithTarget.NEVER) {
- return result;
- }
-
- // For each of the actual potential targets, derive constraints based on the accessibility
- // of the method itself.
- Collection<DexEncodedMethod> targets =
- resolutionResult.lookupVirtualDispatchTargets(isInterface, appView.appInfo());
- for (DexEncodedMethod target : targets) {
- methodHolder = graphLense.lookupType(target.method.holder);
- assert appView.definitionFor(methodHolder) != null;
- methodConstraintWithTarget =
- ConstraintWithTarget.deriveConstraint(
- invocationContext, methodHolder, target.accessFlags, appView);
- result = ConstraintWithTarget.meet(result, methodConstraintWithTarget, appView);
- if (result == ConstraintWithTarget.NEVER) {
- return result;
- }
- }
-
- return result;
+ return ConstraintWithTarget.meet(
+ methodConstraintWithTarget, classConstraintWithTarget, appView);
}
}