Rename TypeLatticeElement related methods
Change-Id: I617440c0651383dec6e0030fe52a500b84eb26a6
diff --git a/src/main/java/com/android/tools/r8/cf/FixedLocalValue.java b/src/main/java/com/android/tools/r8/cf/FixedLocalValue.java
index 1b68ef6..cc78305 100644
--- a/src/main/java/com/android/tools/r8/cf/FixedLocalValue.java
+++ b/src/main/java/com/android/tools/r8/cf/FixedLocalValue.java
@@ -18,7 +18,7 @@
private final Phi phi;
public FixedLocalValue(Phi phi) {
- super(phi.getNumber(), phi.getTypeLattice(), phi.getLocalInfo());
+ super(phi.getNumber(), phi.getType(), phi.getLocalInfo());
this.phi = phi;
}
diff --git a/src/main/java/com/android/tools/r8/cf/TypeVerificationHelper.java b/src/main/java/com/android/tools/r8/cf/TypeVerificationHelper.java
index e77cba3..1c97e33 100644
--- a/src/main/java/com/android/tools/r8/cf/TypeVerificationHelper.java
+++ b/src/main/java/com/android/tools/r8/cf/TypeVerificationHelper.java
@@ -188,9 +188,9 @@
}
// All types are reference types so the join is either a class or an array.
if (result.isClassType()) {
- return result.asClassTypeLatticeElement().getClassType();
+ return result.asClassType().getClassType();
} else if (result.isArrayType()) {
- return result.asArrayTypeLatticeElement().getArrayType(appView.dexItemFactory());
+ return result.asArrayType().toDexType(appView.dexItemFactory());
}
throw new CompilationError("Unexpected join " + result + " of types: " +
String.join(", ",
diff --git a/src/main/java/com/android/tools/r8/cf/code/CfConstNumber.java b/src/main/java/com/android/tools/r8/cf/code/CfConstNumber.java
index 8977303..da5d12a 100644
--- a/src/main/java/com/android/tools/r8/cf/code/CfConstNumber.java
+++ b/src/main/java/com/android/tools/r8/cf/code/CfConstNumber.java
@@ -128,7 +128,7 @@
@Override
public void buildIR(IRBuilder builder, CfState state, CfSourceCode code) {
- builder.addConst(type.toPrimitiveTypeLattice(), state.push(type).register, value);
+ builder.addConst(type.toPrimitiveType(), state.push(type).register, value);
}
@Override
diff --git a/src/main/java/com/android/tools/r8/graph/DexItemFactory.java b/src/main/java/com/android/tools/r8/graph/DexItemFactory.java
index bfaf19c..db2287c 100644
--- a/src/main/java/com/android/tools/r8/graph/DexItemFactory.java
+++ b/src/main/java/com/android/tools/r8/graph/DexItemFactory.java
@@ -1201,7 +1201,7 @@
if (invokedMethod == charSequenceConstructor) {
// NullPointerException - if seq is null.
Value seqValue = invoke.inValues().get(1);
- return !seqValue.getTypeLattice().isNullable();
+ return !seqValue.getType().isNullable();
}
if (invokedMethod == defaultConstructor) {
@@ -1220,7 +1220,7 @@
if (invokedMethod == stringConstructor) {
// NullPointerException - if str is null.
Value strValue = invoke.inValues().get(1);
- return !strValue.getTypeLattice().isNullable();
+ return !strValue.getType().isNullable();
}
assert false : "Unexpected invoke targeting `" + invokedMethod.toSourceString() + "`";
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/ClassInitializationAnalysis.java b/src/main/java/com/android/tools/r8/ir/analysis/ClassInitializationAnalysis.java
index 7270d42..ce60332 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/ClassInitializationAnalysis.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/ClassInitializationAnalysis.java
@@ -278,7 +278,7 @@
instruction.isInstanceGet()
? instruction.asInstanceGet().object()
: instruction.asInstancePut().object();
- if (object.getTypeLattice().isNullable()) {
+ if (object.getType().isNullable()) {
// If the receiver is null we cannot be sure that the holder has been initialized.
return false;
}
@@ -294,7 +294,7 @@
Query mode,
AnalysisAssumption assumption) {
if (assumption == AnalysisAssumption.NONE) {
- if (instruction.getReceiver().getTypeLattice().isNullable()) {
+ if (instruction.getReceiver().getType().isNullable()) {
// If the receiver is null we cannot be sure that the holder has been initialized.
return false;
}
@@ -311,7 +311,7 @@
Query mode,
AnalysisAssumption assumption) {
if (assumption == AnalysisAssumption.NONE) {
- if (instruction.getReceiver().getTypeLattice().isNullable()) {
+ if (instruction.getReceiver().getType().isNullable()) {
// If the receiver is null we cannot be sure that the holder has been initialized.
return false;
}
@@ -362,7 +362,7 @@
Query mode,
AnalysisAssumption assumption) {
if (assumption == AnalysisAssumption.NONE) {
- if (instruction.getReceiver().getTypeLattice().isNullable()) {
+ if (instruction.getReceiver().getType().isNullable()) {
// If the receiver is null we cannot be sure that the holder has been initialized.
return false;
}
@@ -406,7 +406,7 @@
Query mode,
AnalysisAssumption assumption) {
if (assumption == AnalysisAssumption.NONE) {
- if (instruction.getReceiver().getTypeLattice().isNullable()) {
+ if (instruction.getReceiver().getType().isNullable()) {
// If the receiver is null we cannot be sure that the holder has been initialized.
return false;
}
@@ -554,9 +554,9 @@
// implies that the type of the receiver must be initialized.
if (!method.isStatic()) {
assert arguments.size() > 0;
- TypeLatticeElement type = arguments.get(0).getTypeLattice();
+ TypeLatticeElement type = arguments.get(0).getType();
if (type.isClassType()) {
- enqueue(type.asClassTypeLatticeElement().getClassType(), visited, worklist);
+ enqueue(type.asClassType().getClassType(), visited, worklist);
}
}
// If an invoke to a method succeeds, and the method would have thrown and exception if the
@@ -566,9 +566,9 @@
if (nonNullParamOrThrowFacts != null) {
for (int i = 0; i < arguments.size(); i++) {
if (nonNullParamOrThrowFacts.get(i)) {
- TypeLatticeElement type = arguments.get(i).getTypeLattice();
+ TypeLatticeElement type = arguments.get(i).getType();
if (type.isClassType()) {
- enqueue(type.asClassTypeLatticeElement().getClassType(), visited, worklist);
+ enqueue(type.asClassType().getClassType(), visited, worklist);
}
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/TypeChecker.java b/src/main/java/com/android/tools/r8/ir/analysis/TypeChecker.java
index 01a7e3d..7d0f569 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/TypeChecker.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/TypeChecker.java
@@ -67,7 +67,7 @@
if (instruction.isReturnVoid()) {
return true;
}
- TypeLatticeElement valueType = instruction.returnValue().getTypeLattice();
+ TypeLatticeElement valueType = instruction.returnValue().getType();
TypeLatticeElement returnType =
TypeLatticeElement.fromDexType(
method.method.proto.returnType, Nullability.maybeNull(), appView);
@@ -75,7 +75,7 @@
return true;
}
- if (returnType.isClassType() && valueType.isReference()) {
+ if (returnType.isClassType() && valueType.isReferenceType()) {
// Interface types are treated like Object according to the JVM spec.
// https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.10.1.2-100
DexClass clazz = appView.definitionFor(method.method.proto.returnType);
@@ -91,7 +91,7 @@
public boolean checkFieldPut(FieldInstruction instruction) {
assert instruction.isFieldPut();
- TypeLatticeElement valueType = instruction.value().getTypeLattice();
+ TypeLatticeElement valueType = instruction.value().getType();
TypeLatticeElement fieldType =
TypeLatticeElement.fromDexType(
instruction.getField().type, valueType.nullability(), appView);
@@ -99,7 +99,7 @@
return true;
}
- if (fieldType.isClassType() && valueType.isReference()) {
+ if (fieldType.isClassType() && valueType.isReferenceType()) {
// Interface types are treated like Object according to the JVM spec.
// https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.10.1.2-100
DexClass clazz = appView.definitionFor(instruction.getField().type);
@@ -110,7 +110,7 @@
}
public boolean check(Throw instruction) {
- TypeLatticeElement valueType = instruction.exception().getTypeLattice();
+ TypeLatticeElement valueType = instruction.exception().getType();
TypeLatticeElement throwableType =
TypeLatticeElement.fromDexType(
appView.dexItemFactory().throwableType, valueType.nullability(), appView);
@@ -119,7 +119,7 @@
private boolean isSubtypeOf(
TypeLatticeElement expectedSubtype, TypeLatticeElement expectedSupertype) {
- return (expectedSubtype.isNullType() && expectedSupertype.isReference())
+ return (expectedSubtype.isNullType() && expectedSupertype.isReferenceType())
|| expectedSubtype.lessThanOrEqual(expectedSupertype, appView)
|| expectedSubtype.isBasedOnMissingClass(appView);
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/equivalence/BasicBlockBehavioralSubsumption.java b/src/main/java/com/android/tools/r8/ir/analysis/equivalence/BasicBlockBehavioralSubsumption.java
index 7422417..27c4e19 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/equivalence/BasicBlockBehavioralSubsumption.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/equivalence/BasicBlockBehavioralSubsumption.java
@@ -192,7 +192,7 @@
Value outValue = instruction.outValue();
Value otherOutValue = other.outValue();
- if (!outValue.getTypeLattice().equals(otherOutValue.getTypeLattice())) {
+ if (!outValue.getType().equals(otherOutValue.getType())) {
return false;
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/escape/EscapeAnalysis.java b/src/main/java/com/android/tools/r8/ir/analysis/escape/EscapeAnalysis.java
index 466edeb..43e484d 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/escape/EscapeAnalysis.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/escape/EscapeAnalysis.java
@@ -83,7 +83,7 @@
// Returns the set of instructions where the value of interest can escape from the code.
private void run(IRCode code, Value valueOfInterest, Predicate<Instruction> stoppingCriterion) {
- assert valueOfInterest.getTypeLattice().isReference();
+ assert valueOfInterest.getType().isReferenceType();
assert trackedValues.isEmpty();
assert valuesToTrack.isEmpty();
@@ -153,13 +153,13 @@
}
if (couldIntroduceTrackedValueAlias) {
Value outValue = user.outValue();
- assert outValue != null && outValue.getTypeLattice().isReference();
+ assert outValue != null && outValue.getType().isReferenceType();
addToWorklist(outValue);
}
// Track propagated values through which the value of interest can escape indirectly.
Value propagatedValue = getPropagatedSubject(alias, user);
if (propagatedValue != null && propagatedValue != alias) {
- assert propagatedValue.getTypeLattice().isReference();
+ assert propagatedValue.getType().isReferenceType();
addToWorklist(propagatedValue);
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/proto/GeneratedMessageLiteBuilderShrinker.java b/src/main/java/com/android/tools/r8/ir/analysis/proto/GeneratedMessageLiteBuilderShrinker.java
index 8da13ed..614c7a0 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/proto/GeneratedMessageLiteBuilderShrinker.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/proto/GeneratedMessageLiteBuilderShrinker.java
@@ -218,7 +218,7 @@
continue;
}
ClassTypeLatticeElement receiverType =
- invoke.getReceiver().getDynamicUpperBoundType(appView).asClassTypeLatticeElement();
+ invoke.getReceiver().getDynamicUpperBoundType(appView).asClassType();
if (receiverType != null) {
AppInfoWithClassHierarchy appInfo = appView.appInfo();
DexType rawReceiverType = receiverType.getClassType();
@@ -269,9 +269,9 @@
if (definition.getInvokedMethod() != appView.dexItemFactory().enumMethods.ordinal) {
return false;
}
- TypeLatticeElement enumType = definition.getReceiver().getTypeLattice();
+ TypeLatticeElement enumType = definition.getReceiver().getType();
return enumType.isClassType()
- && enumType.asClassTypeLatticeElement().getClassType() == references.methodToInvokeType;
+ && enumType.asClassType().getClassType() == references.methodToInvokeType;
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/proto/schema/ProtoEnqueuerExtension.java b/src/main/java/com/android/tools/r8/ir/analysis/proto/schema/ProtoEnqueuerExtension.java
index e2837c4..b57b75e 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/proto/schema/ProtoEnqueuerExtension.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/proto/schema/ProtoEnqueuerExtension.java
@@ -322,15 +322,15 @@
TypeLatticeElement containerType, extensionType;
if (invokedMethod == references.generatedMessageLiteMethods.newRepeatedGeneratedExtension) {
- containerType = invoke.arguments().get(0).getTypeLattice();
- extensionType = invoke.arguments().get(1).getTypeLattice();
+ containerType = invoke.arguments().get(0).getType();
+ extensionType = invoke.arguments().get(1).getType();
} else if (invokedMethod
== references.generatedMessageLiteMethods.newSingularGeneratedExtension) {
- containerType = invoke.arguments().get(0).getTypeLattice();
- extensionType = invoke.arguments().get(2).getTypeLattice();
+ containerType = invoke.arguments().get(0).getType();
+ extensionType = invoke.arguments().get(2).getType();
} else if (references.generatedExtensionMethods.isConstructor(invokedMethod)) {
- containerType = invoke.arguments().get(1).getTypeLattice();
- extensionType = invoke.arguments().get(3).getTypeLattice();
+ containerType = invoke.arguments().get(1).getType();
+ extensionType = invoke.arguments().get(3).getType();
} else {
return;
}
@@ -346,9 +346,8 @@
extensionGraph
.computeIfAbsent(
- containerType.asClassTypeLatticeElement().getClassType(),
- ignore -> Sets.newIdentityHashSet())
- .add(extensionType.asClassTypeLatticeElement().getClassType());
+ containerType.asClassType().getClassType(), ignore -> Sets.newIdentityHashSet())
+ .add(extensionType.asClassType().getClassType());
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/type/ArrayTypeLatticeElement.java b/src/main/java/com/android/tools/r8/ir/analysis/type/ArrayTypeLatticeElement.java
index 64885a8..b237d83 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/type/ArrayTypeLatticeElement.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/type/ArrayTypeLatticeElement.java
@@ -31,45 +31,45 @@
Nullability nullability,
NullabilityVariants<ArrayTypeLatticeElement> variants) {
super(nullability);
- assert memberTypeLattice.isPrimitive() || memberTypeLattice.nullability().isMaybeNull();
+ assert memberTypeLattice.isPrimitiveType() || memberTypeLattice.nullability().isMaybeNull();
this.memberTypeLattice = memberTypeLattice;
this.variants = variants;
}
- public DexType getArrayType(DexItemFactory factory) {
- TypeLatticeElement baseTypeLattice = getArrayBaseTypeLattice();
+ public DexType toDexType(DexItemFactory factory) {
+ TypeLatticeElement baseTypeLattice = getBaseType();
DexType baseType;
- if (baseTypeLattice.isPrimitive()) {
- baseType = baseTypeLattice.asPrimitiveTypeLatticeElement().toDexType(factory);
+ if (baseTypeLattice.isPrimitiveType()) {
+ baseType = baseTypeLattice.asPrimitiveType().toDexType(factory);
} else {
assert baseTypeLattice.isClassType();
- baseType = baseTypeLattice.asClassTypeLatticeElement().getClassType();
+ baseType = baseTypeLattice.asClassType().getClassType();
}
return factory.createArrayType(getNesting(), baseType);
}
public int getNesting() {
int nesting = 1;
- TypeLatticeElement member = getArrayMemberTypeAsMemberType();
+ TypeLatticeElement member = getMemberType();
while (member.isArrayType()) {
++nesting;
- member = member.asArrayTypeLatticeElement().getArrayMemberTypeAsMemberType();
+ member = member.asArrayType().getMemberType();
}
return nesting;
}
- public TypeLatticeElement getArrayMemberTypeAsMemberType() {
+ public TypeLatticeElement getMemberType() {
return memberTypeLattice;
}
- public TypeLatticeElement getArrayMemberTypeAsValueType() {
+ public TypeLatticeElement getMemberTypeAsValueType() {
return memberTypeLattice.isFineGrainedType() ? getInt() : memberTypeLattice;
}
- public TypeLatticeElement getArrayBaseTypeLattice() {
- TypeLatticeElement base = getArrayMemberTypeAsMemberType();
+ public TypeLatticeElement getBaseType() {
+ TypeLatticeElement base = getMemberType();
while (base.isArrayType()) {
- base = base.asArrayTypeLatticeElement().getArrayMemberTypeAsMemberType();
+ base = base.asArrayType().getMemberType();
}
return base;
}
@@ -100,7 +100,7 @@
}
@Override
- public ArrayTypeLatticeElement asArrayTypeLatticeElement() {
+ public ArrayTypeLatticeElement asArrayType() {
return this;
}
@@ -132,7 +132,7 @@
@Override
public ArrayTypeLatticeElement fixupClassTypeReferences(
Function<DexType, DexType> mapping, AppView<? extends AppInfoWithSubtyping> appView) {
- if (memberTypeLattice.isReference()) {
+ if (memberTypeLattice.isReferenceType()) {
TypeLatticeElement substitutedMemberType =
memberTypeLattice.fixupClassTypeReferences(mapping, appView);
if (substitutedMemberType != memberTypeLattice) {
@@ -171,18 +171,17 @@
if (aMember.isArrayType() && bMember.isArrayType()) {
TypeLatticeElement join =
joinMember(
- aMember.asArrayTypeLatticeElement().memberTypeLattice,
- bMember.asArrayTypeLatticeElement().memberTypeLattice,
+ aMember.asArrayType().memberTypeLattice,
+ bMember.asArrayType().memberTypeLattice,
appView,
maybeNull());
return join == null ? null : ArrayTypeLatticeElement.create(join, nullability);
}
if (aMember.isClassType() && bMember.isClassType()) {
- ReferenceTypeLatticeElement join =
- aMember.asClassTypeLatticeElement().join(bMember.asClassTypeLatticeElement(), appView);
+ ReferenceTypeLatticeElement join = aMember.asClassType().join(bMember.asClassType(), appView);
return ArrayTypeLatticeElement.create(join, nullability);
}
- if (aMember.isPrimitive() || bMember.isPrimitive()) {
+ if (aMember.isPrimitiveType() || bMember.isPrimitiveType()) {
return objectClassType(appView, nullability);
}
return objectArrayType(appView, nullability);
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/type/ClassTypeLatticeElement.java b/src/main/java/com/android/tools/r8/ir/analysis/type/ClassTypeLatticeElement.java
index 0499222..955ede2 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/type/ClassTypeLatticeElement.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/type/ClassTypeLatticeElement.java
@@ -114,7 +114,7 @@
}
@Override
- public ClassTypeLatticeElement asClassTypeLatticeElement() {
+ public ClassTypeLatticeElement asClassType() {
return this;
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/type/DestructivePhiTypeUpdater.java b/src/main/java/com/android/tools/r8/ir/analysis/type/DestructivePhiTypeUpdater.java
index 6449294..aa243b2 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/type/DestructivePhiTypeUpdater.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/type/DestructivePhiTypeUpdater.java
@@ -40,7 +40,7 @@
Deque<Phi> worklist = new ArrayDeque<>(affectedPhis);
while (!worklist.isEmpty()) {
Phi phi = worklist.poll();
- phi.setTypeLattice(TypeLatticeElement.getBottom());
+ phi.setType(TypeLatticeElement.getBottom());
for (Phi affectedPhi : phi.uniquePhiUsers()) {
if (affectedPhis.add(affectedPhi)) {
worklist.add(affectedPhi);
@@ -57,9 +57,9 @@
while (!worklist.isEmpty()) {
Phi phi = worklist.poll();
TypeLatticeElement newType = phi.computePhiType(appView);
- if (!phi.getTypeLattice().equals(newType)) {
+ if (!phi.getType().equals(newType)) {
assert !newType.isBottom();
- phi.setTypeLattice(newType);
+ phi.setType(newType);
worklist.addAll(phi.uniquePhiUsers());
affectedValues.addAll(phi.affectedValues());
}
@@ -80,12 +80,12 @@
for (Value operand : phi.getOperands()) {
if (operand.isPhi()) {
Phi operandPhi = operand.asPhi();
- TypeLatticeElement operandType = operandPhi.getTypeLattice();
+ TypeLatticeElement operandType = operandPhi.getType();
assert !affectedPhis.contains(operandPhi) || operandType.isBottom();
assert affectedPhis.contains(operandPhi)
- || operandType.isPrimitive()
+ || operandType.isPrimitiveType()
|| operandType.isNullType()
- || (operandType.isReference()
+ || (operandType.isReferenceType()
&& operandType.fixupClassTypeReferences(mapping, appView) == operandType);
}
}
@@ -98,7 +98,7 @@
while (blocks.hasNext()) {
BasicBlock block = blocks.next();
for (Phi phi : block.getPhis()) {
- TypeLatticeElement phiTypeLattice = phi.getTypeLattice();
+ TypeLatticeElement phiTypeLattice = phi.getType();
TypeLatticeElement substituted = phiTypeLattice.fixupClassTypeReferences(mapping, appView);
assert substituted == phiTypeLattice || affectedPhis.contains(phi);
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/type/PrimitiveTypeLatticeElement.java b/src/main/java/com/android/tools/r8/ir/analysis/type/PrimitiveTypeLatticeElement.java
index 6a16fdc..b3f5845 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/type/PrimitiveTypeLatticeElement.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/type/PrimitiveTypeLatticeElement.java
@@ -20,12 +20,12 @@
}
@Override
- public boolean isPrimitive() {
+ public boolean isPrimitiveType() {
return true;
}
@Override
- public PrimitiveTypeLatticeElement asPrimitiveTypeLatticeElement() {
+ public PrimitiveTypeLatticeElement asPrimitiveType() {
return this;
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/type/ReferenceTypeLatticeElement.java b/src/main/java/com/android/tools/r8/ir/analysis/type/ReferenceTypeLatticeElement.java
index b888ae5..ec02aa3 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/type/ReferenceTypeLatticeElement.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/type/ReferenceTypeLatticeElement.java
@@ -69,7 +69,7 @@
return nullability;
}
- static ReferenceTypeLatticeElement getNullTypeLatticeElement() {
+ static ReferenceTypeLatticeElement getNullType() {
return NULL_INSTANCE;
}
@@ -88,12 +88,12 @@
}
@Override
- public boolean isReference() {
+ public boolean isReferenceType() {
return true;
}
@Override
- public ReferenceTypeLatticeElement asReferenceTypeLatticeElement() {
+ public ReferenceTypeLatticeElement asReferenceType() {
return this;
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/type/TypeAnalysis.java b/src/main/java/com/android/tools/r8/ir/analysis/type/TypeAnalysis.java
index 0596d7b..adcc6d0 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/type/TypeAnalysis.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/type/TypeAnalysis.java
@@ -113,7 +113,7 @@
}
private void analyzeValue(Value value) {
- TypeLatticeElement previous = value.getTypeLattice();
+ TypeLatticeElement previous = value.getType();
TypeLatticeElement derived =
value.isPhi() ? value.asPhi().computePhiType(appView) : value.definition.evaluate(appView);
assert mayHaveImpreciseTypes || derived.isPreciseType();
@@ -124,7 +124,7 @@
private void updateTypeOfValue(Value value, TypeLatticeElement type) {
assert mode != Mode.UNSET;
- TypeLatticeElement current = value.getTypeLattice();
+ TypeLatticeElement current = value.getType();
if (current.equals(type)) {
return;
}
@@ -161,7 +161,7 @@
TypeLatticeElement lattice = receiver.getDynamicUpperBoundType(appView);
DexType staticReceiverType = invoke.getInvokedMethod().holder;
if (lattice.isClassType()) {
- ClassTypeLatticeElement classType = lattice.asClassTypeLatticeElement();
+ ClassTypeLatticeElement classType = lattice.asClassType();
DexType refinedType = classType.getClassType();
if (refinedType == appView.dexItemFactory().objectType) {
Set<DexType> interfaces = classType.getInterfaces();
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/type/TypeLatticeElement.java b/src/main/java/com/android/tools/r8/ir/analysis/type/TypeLatticeElement.java
index de7b894..6743aa3 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/type/TypeLatticeElement.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/type/TypeLatticeElement.java
@@ -66,7 +66,7 @@
}
public static ReferenceTypeLatticeElement getNull() {
- return ReferenceTypeLatticeElement.getNullTypeLatticeElement();
+ return ReferenceTypeLatticeElement.getNullType();
}
public TypeLatticeElement fixupClassTypeReferences(
@@ -100,24 +100,22 @@
if (isTop() || other.isTop()) {
return getTop();
}
- if (isPrimitive()) {
- return other.isPrimitive()
- ? asPrimitiveTypeLatticeElement().join(other.asPrimitiveTypeLatticeElement())
- : getTop();
+ if (isPrimitiveType()) {
+ return other.isPrimitiveType() ? asPrimitiveType().join(other.asPrimitiveType()) : getTop();
}
- if (other.isPrimitive()) {
+ if (other.isPrimitiveType()) {
// By the above case, !(isPrimitive())
return getTop();
}
// From now on, this and other are precise reference types, i.e., either ArrayType or ClassType.
- assert isReference() && other.isReference();
+ assert isReferenceType() && other.isReferenceType();
assert isPreciseType() && other.isPreciseType();
Nullability nullabilityJoin = nullability().join(other.nullability());
if (isNullType()) {
- return other.asReferenceTypeLatticeElement().getOrCreateVariant(nullabilityJoin);
+ return other.asReferenceType().getOrCreateVariant(nullabilityJoin);
}
if (other.isNullType()) {
- return this.asReferenceTypeLatticeElement().getOrCreateVariant(nullabilityJoin);
+ return this.asReferenceType().getOrCreateVariant(nullabilityJoin);
}
if (getClass() != other.getClass()) {
return objectClassType(appView, nullabilityJoin);
@@ -125,11 +123,11 @@
// From now on, getClass() == other.getClass()
if (isArrayType()) {
assert other.isArrayType();
- return asArrayTypeLatticeElement().join(other.asArrayTypeLatticeElement(), appView);
+ return asArrayType().join(other.asArrayType(), appView);
}
if (isClassType()) {
assert other.isClassType();
- return asClassTypeLatticeElement().join(other.asClassTypeLatticeElement(), appView);
+ return asClassType().join(other.asClassType(), appView);
}
throw new Unreachable("unless a new type lattice is introduced.");
}
@@ -194,15 +192,15 @@
if (other.isBottom()) {
return false;
}
- if (isPrimitive()) {
+ if (isPrimitiveType()) {
// Primitives cannot be nullable.
return lessThanOrEqual(other, appView);
}
- assert isReference() && other.isReference();
+ assert isReferenceType() && other.isReferenceType();
ReferenceTypeLatticeElement otherAsNullable =
other.isNullable()
- ? other.asReferenceTypeLatticeElement()
- : other.asReferenceTypeLatticeElement().getOrCreateVariant(Nullability.maybeNull());
+ ? other.asReferenceType()
+ : other.asReferenceType().getOrCreateVariant(Nullability.maybeNull());
return lessThanOrEqual(otherAsNullable, appView);
}
@@ -216,14 +214,14 @@
if (this == other) {
return true;
}
- if (isPrimitive() || other.isPrimitive()) {
+ if (isPrimitiveType() || other.isPrimitiveType()) {
return false;
}
- assert isReference() && other.isReference();
+ assert isReferenceType() && other.isReferenceType();
ReferenceTypeLatticeElement thisAsMaybeNull =
- this.asReferenceTypeLatticeElement().getOrCreateVariant(Nullability.maybeNull());
+ this.asReferenceType().getOrCreateVariant(Nullability.maybeNull());
ReferenceTypeLatticeElement otherAsMaybeNull =
- other.asReferenceTypeLatticeElement().getOrCreateVariant(Nullability.maybeNull());
+ other.asReferenceType().getOrCreateVariant(Nullability.maybeNull());
return thisAsMaybeNull.equals(otherAsMaybeNull);
}
@@ -255,11 +253,11 @@
return false;
}
- public boolean isReference() {
+ public boolean isReferenceType() {
return false;
}
- public ReferenceTypeLatticeElement asReferenceTypeLatticeElement() {
+ public ReferenceTypeLatticeElement asReferenceType() {
return null;
}
@@ -267,7 +265,7 @@
return false;
}
- public ArrayTypeLatticeElement asArrayTypeLatticeElement() {
+ public ArrayTypeLatticeElement asArrayType() {
return null;
}
@@ -275,15 +273,15 @@
return false;
}
- public ClassTypeLatticeElement asClassTypeLatticeElement() {
+ public ClassTypeLatticeElement asClassType() {
return null;
}
- public boolean isPrimitive() {
+ public boolean isPrimitiveType() {
return false;
}
- public PrimitiveTypeLatticeElement asPrimitiveTypeLatticeElement() {
+ public PrimitiveTypeLatticeElement asPrimitiveType() {
return null;
}
@@ -377,27 +375,24 @@
public static ClassTypeLatticeElement objectClassType(
AppView<?> appView, Nullability nullability) {
- return fromDexType(appView.dexItemFactory().objectType, nullability, appView)
- .asClassTypeLatticeElement();
+ return fromDexType(appView.dexItemFactory().objectType, nullability, appView).asClassType();
}
static ArrayTypeLatticeElement objectArrayType(AppView<?> appView, Nullability nullability) {
DexItemFactory dexItemFactory = appView.dexItemFactory();
return fromDexType(
dexItemFactory.createArrayType(1, dexItemFactory.objectType), nullability, appView)
- .asArrayTypeLatticeElement();
+ .asArrayType();
}
public static ClassTypeLatticeElement classClassType(
AppView<?> appView, Nullability nullability) {
- return fromDexType(appView.dexItemFactory().classType, nullability, appView)
- .asClassTypeLatticeElement();
+ return fromDexType(appView.dexItemFactory().classType, nullability, appView).asClassType();
}
public static ClassTypeLatticeElement stringClassType(
AppView<?> appView, Nullability nullability) {
- return fromDexType(appView.dexItemFactory().stringType, nullability, appView)
- .asClassTypeLatticeElement();
+ return fromDexType(appView.dexItemFactory().stringType, nullability, appView).asClassType();
}
public static TypeLatticeElement fromDexType(
@@ -418,7 +413,7 @@
}
public boolean isValueTypeCompatible(TypeLatticeElement other) {
- return (isReference() && other.isReference())
+ return (isReferenceType() && other.isReferenceType())
|| (isSinglePrimitive() && other.isSinglePrimitive())
|| (isWidePrimitive() && other.isWidePrimitive());
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/type/TypeUtils.java b/src/main/java/com/android/tools/r8/ir/analysis/type/TypeUtils.java
index 912b379..915ec44 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/type/TypeUtils.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/type/TypeUtils.java
@@ -10,6 +10,6 @@
public static boolean isNullPointerException(TypeLatticeElement type, AppView<?> appView) {
return type.isClassType()
- && type.asClassTypeLatticeElement().getClassType() == appView.dexItemFactory().npeType;
+ && type.asClassType().getClassType() == appView.dexItemFactory().npeType;
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/value/SingleConstClassValue.java b/src/main/java/com/android/tools/r8/ir/analysis/value/SingleConstClassValue.java
index 897b31e..5eb135b 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/value/SingleConstClassValue.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/value/SingleConstClassValue.java
@@ -63,13 +63,11 @@
@Override
public Instruction createMaterializingInstruction(
AppView<? extends AppInfoWithSubtyping> appView, IRCode code, TypeAndLocalInfoSupplier info) {
- TypeLatticeElement typeLattice = info.getTypeLattice();
+ TypeLatticeElement typeLattice = info.getOutType();
DebugLocalInfo debugLocalInfo = info.getLocalInfo();
assert typeLattice.isClassType();
assert appView
- .isSubtype(
- appView.dexItemFactory().classType,
- typeLattice.asClassTypeLatticeElement().getClassType())
+ .isSubtype(appView.dexItemFactory().classType, typeLattice.asClassType().getClassType())
.isTrue();
Value returnedValue =
code.createValue(classClassType(appView, definitelyNotNull()), debugLocalInfo);
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/value/SingleFieldValue.java b/src/main/java/com/android/tools/r8/ir/analysis/value/SingleFieldValue.java
index 5479737..c07d41e 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/value/SingleFieldValue.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/value/SingleFieldValue.java
@@ -40,8 +40,7 @@
DexType fieldType = field.type;
if (fieldType.isClassType()) {
ClassTypeLatticeElement fieldClassType =
- TypeLatticeElement.fromDexType(fieldType, maybeNull(), appView)
- .asClassTypeLatticeElement();
+ TypeLatticeElement.fromDexType(fieldType, maybeNull(), appView).asClassType();
return appView.appInfo().mayHaveFinalizeMethodDirectlyOrIndirectly(fieldClassType);
}
assert fieldType.isArrayType() || fieldType.isPrimitiveType();
@@ -77,7 +76,7 @@
public Instruction createMaterializingInstruction(
AppView<? extends AppInfoWithSubtyping> appView, IRCode code, TypeAndLocalInfoSupplier info) {
TypeLatticeElement type = TypeLatticeElement.fromDexType(field.type, maybeNull(), appView);
- assert type.lessThanOrEqual(info.getTypeLattice(), appView);
+ assert type.lessThanOrEqual(info.getOutType(), appView);
Value outValue = code.createValue(type, info.getLocalInfo());
return new StaticGet(outValue, field);
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/value/SingleNumberValue.java b/src/main/java/com/android/tools/r8/ir/analysis/value/SingleNumberValue.java
index b408c90..8218853a 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/value/SingleNumberValue.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/value/SingleNumberValue.java
@@ -68,12 +68,13 @@
@Override
public Instruction createMaterializingInstruction(
AppView<? extends AppInfoWithSubtyping> appView, IRCode code, TypeAndLocalInfoSupplier info) {
- TypeLatticeElement typeLattice = info.getTypeLattice();
+ TypeLatticeElement typeLattice = info.getOutType();
DebugLocalInfo debugLocalInfo = info.getLocalInfo();
- assert !typeLattice.isReference() || value == 0;
+ assert !typeLattice.isReferenceType() || value == 0;
Value returnedValue =
code.createValue(
- typeLattice.isReference() ? TypeLatticeElement.getNull() : typeLattice, debugLocalInfo);
+ typeLattice.isReferenceType() ? TypeLatticeElement.getNull() : typeLattice,
+ debugLocalInfo);
return new ConstNumber(returnedValue, value);
}
diff --git a/src/main/java/com/android/tools/r8/ir/analysis/value/SingleStringValue.java b/src/main/java/com/android/tools/r8/ir/analysis/value/SingleStringValue.java
index a7439c0..66d4789 100644
--- a/src/main/java/com/android/tools/r8/ir/analysis/value/SingleStringValue.java
+++ b/src/main/java/com/android/tools/r8/ir/analysis/value/SingleStringValue.java
@@ -65,13 +65,11 @@
AppView<? extends AppInfoWithSubtyping> appView,
IRCode code,
TypeAndLocalInfoSupplier info) {
- TypeLatticeElement typeLattice = info.getTypeLattice();
+ TypeLatticeElement typeLattice = info.getOutType();
DebugLocalInfo debugLocalInfo = info.getLocalInfo();
assert typeLattice.isClassType();
assert appView
- .isSubtype(
- appView.dexItemFactory().stringType,
- typeLattice.asClassTypeLatticeElement().getClassType())
+ .isSubtype(appView.dexItemFactory().stringType, typeLattice.asClassType().getClassType())
.isTrue();
Value returnedValue =
code.createValue(stringClassType(appView, definitelyNotNull()), debugLocalInfo);
diff --git a/src/main/java/com/android/tools/r8/ir/code/Argument.java b/src/main/java/com/android/tools/r8/ir/code/Argument.java
index 1db2ba6..ea0ece8 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Argument.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Argument.java
@@ -122,7 +122,7 @@
@Override
public TypeLatticeElement evaluate(AppView<?> appView) {
- return outValue.getTypeLattice();
+ return outValue.getType();
}
@Override
diff --git a/src/main/java/com/android/tools/r8/ir/code/ArrayGet.java b/src/main/java/com/android/tools/r8/ir/code/ArrayGet.java
index b6eb113..92ec78a 100644
--- a/src/main/java/com/android/tools/r8/ir/code/ArrayGet.java
+++ b/src/main/java/com/android/tools/r8/ir/code/ArrayGet.java
@@ -60,9 +60,9 @@
@Override
public boolean couldIntroduceAnAlias(AppView<?> appView, Value root) {
- assert root != null && root.getTypeLattice().isReference();
+ assert root != null && root.getType().isReferenceType();
assert outValue != null;
- return outValue.getTypeLattice().isReference();
+ return outValue.getType().isReferenceType();
}
@Override
@@ -86,13 +86,12 @@
instruction = new AgetObject(dest, array, index);
break;
case BOOLEAN_OR_BYTE:
- ArrayTypeLatticeElement arrayType = array().getTypeLattice().asArrayTypeLatticeElement();
- if (arrayType != null
- && arrayType.getArrayMemberTypeAsMemberType() == TypeLatticeElement.getBoolean()) {
+ ArrayTypeLatticeElement arrayType = array().getType().asArrayType();
+ if (arrayType != null && arrayType.getMemberType() == TypeLatticeElement.getBoolean()) {
instruction = new AgetBoolean(dest, array, index);
} else {
- assert array().getTypeLattice().isDefinitelyNull()
- || arrayType.getArrayMemberTypeAsMemberType() == TypeLatticeElement.getByte();
+ assert array().getType().isDefinitelyNull()
+ || arrayType.getMemberType() == TypeLatticeElement.getByte();
instruction = new AgetByte(dest, array, index);
}
break;
@@ -164,7 +163,7 @@
@Override
public DexType computeVerificationType(AppView<?> appView, TypeVerificationHelper helper) {
// This method is not called for ArrayGet on primitive array.
- assert this.outValue.getTypeLattice().isReference();
+ assert this.outValue.getType().isReferenceType();
DexType arrayType = helper.getDexType(array());
if (arrayType == DexItemFactory.nullValueType) {
// JVM 8 §4.10.1.9.aaload: Array component type of null is null.
@@ -186,9 +185,8 @@
@Override
public TypeLatticeElement evaluate(AppView<?> appView) {
- ArrayTypeLatticeElement arrayTypeLattice = array().getTypeLattice().isArrayType()
- ? array().getTypeLattice().asArrayTypeLatticeElement()
- : null;
+ ArrayTypeLatticeElement arrayTypeLattice =
+ array().getType().isArrayType() ? array().getType().asArrayType() : null;
switch (getMemberType()) {
case OBJECT:
// If the out-type of the array is bottom (the input array must be definitely null), then
@@ -198,35 +196,31 @@
TypeLatticeElement valueType =
arrayTypeLattice == null
? TypeLatticeElement.getNull()
- : arrayTypeLattice.getArrayMemberTypeAsValueType();
- assert valueType.isReference();
+ : arrayTypeLattice.getMemberTypeAsValueType();
+ assert valueType.isReferenceType();
return valueType;
case BOOLEAN_OR_BYTE:
case CHAR:
case SHORT:
case INT:
- assert arrayTypeLattice == null
- || arrayTypeLattice.getArrayMemberTypeAsValueType().isInt();
+ assert arrayTypeLattice == null || arrayTypeLattice.getMemberTypeAsValueType().isInt();
return TypeLatticeElement.getInt();
case FLOAT:
- assert arrayTypeLattice == null
- || arrayTypeLattice.getArrayMemberTypeAsValueType().isFloat();
+ assert arrayTypeLattice == null || arrayTypeLattice.getMemberTypeAsValueType().isFloat();
return TypeLatticeElement.getFloat();
case LONG:
- assert arrayTypeLattice == null
- || arrayTypeLattice.getArrayMemberTypeAsValueType().isLong();
+ assert arrayTypeLattice == null || arrayTypeLattice.getMemberTypeAsValueType().isLong();
return TypeLatticeElement.getLong();
case DOUBLE:
- assert arrayTypeLattice == null
- || arrayTypeLattice.getArrayMemberTypeAsValueType().isDouble();
+ assert arrayTypeLattice == null || arrayTypeLattice.getMemberTypeAsValueType().isDouble();
return TypeLatticeElement.getDouble();
case INT_OR_FLOAT:
assert arrayTypeLattice == null
- || arrayTypeLattice.getArrayMemberTypeAsValueType().isSinglePrimitive();
+ || arrayTypeLattice.getMemberTypeAsValueType().isSinglePrimitive();
return checkConstraint(dest(), ValueTypeConstraint.INT_OR_FLOAT);
case LONG_OR_DOUBLE:
assert arrayTypeLattice == null
- || arrayTypeLattice.getArrayMemberTypeAsValueType().isWidePrimitive();
+ || arrayTypeLattice.getMemberTypeAsValueType().isWidePrimitive();
return checkConstraint(dest(), ValueTypeConstraint.LONG_OR_DOUBLE);
default:
throw new Unreachable("Unexpected member type: " + getMemberType());
@@ -259,9 +253,8 @@
@Override
public boolean outTypeKnownToBeBoolean(Set<Phi> seen) {
- return array().getTypeLattice().isArrayType()
- && array().getTypeLattice().asArrayTypeLatticeElement().getArrayMemberTypeAsMemberType()
- == TypeLatticeElement.getBoolean();
+ return array().getType().isArrayType()
+ && array().getType().asArrayType().getMemberType() == TypeLatticeElement.getBoolean();
}
@Override
diff --git a/src/main/java/com/android/tools/r8/ir/code/ArrayLength.java b/src/main/java/com/android/tools/r8/ir/code/ArrayLength.java
index da92bf3..2745e59 100644
--- a/src/main/java/com/android/tools/r8/ir/code/ArrayLength.java
+++ b/src/main/java/com/android/tools/r8/ir/code/ArrayLength.java
@@ -75,7 +75,7 @@
@Override
public AbstractError instructionInstanceCanThrow(AppView<?> appView, DexType context) {
- if (array().typeLattice.isNullable()) {
+ if (array().type.isNullable()) {
return AbstractError.specific(appView.dexItemFactory().npeType);
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/ArrayPut.java b/src/main/java/com/android/tools/r8/ir/code/ArrayPut.java
index b1046d3..d307e37 100644
--- a/src/main/java/com/android/tools/r8/ir/code/ArrayPut.java
+++ b/src/main/java/com/android/tools/r8/ir/code/ArrayPut.java
@@ -79,13 +79,12 @@
instruction = new AputObject(value, array, index);
break;
case BOOLEAN_OR_BYTE:
- ArrayTypeLatticeElement arrayType = array().getTypeLattice().asArrayTypeLatticeElement();
- if (arrayType != null
- && arrayType.getArrayMemberTypeAsMemberType() == TypeLatticeElement.getBoolean()) {
+ ArrayTypeLatticeElement arrayType = array().getType().asArrayType();
+ if (arrayType != null && arrayType.getMemberType() == TypeLatticeElement.getBoolean()) {
instruction = new AputBoolean(value, array, index);
} else {
- assert array().getTypeLattice().isDefinitelyNull()
- || arrayType.getArrayMemberTypeAsMemberType() == TypeLatticeElement.getByte();
+ assert array().getType().isDefinitelyNull()
+ || arrayType.getMemberType() == TypeLatticeElement.getByte();
instruction = new AputByte(value, array, index);
}
break;
@@ -166,13 +165,12 @@
}
// Check for type errors.
- TypeLatticeElement arrayType = array.getTypeLattice();
- TypeLatticeElement valueType = value().getTypeLattice();
+ TypeLatticeElement arrayType = array.getType();
+ TypeLatticeElement valueType = value().getType();
if (!arrayType.isArrayType()) {
return true;
}
- TypeLatticeElement memberType =
- arrayType.asArrayTypeLatticeElement().getArrayMemberTypeAsValueType();
+ TypeLatticeElement memberType = arrayType.asArrayType().getMemberTypeAsValueType();
if (!valueType.lessThanOrEqualUpToNullability(memberType, appView)) {
return true;
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/Assume.java b/src/main/java/com/android/tools/r8/ir/code/Assume.java
index 37de422..6f06252 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Assume.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Assume.java
@@ -164,10 +164,10 @@
@Override
public boolean couldIntroduceAnAlias(AppView<?> appView, Value root) {
- assert root != null && root.getTypeLattice().isReference();
+ assert root != null && root.getType().isReferenceType();
assert outValue != null;
- TypeLatticeElement outType = outValue.getTypeLattice();
- if (outType.isPrimitive()) {
+ TypeLatticeElement outType = outValue.getType();
+ if (outType.isPrimitiveType()) {
return false;
}
if (assumption.isAssumeNone()) {
@@ -179,14 +179,17 @@
}
if (appView.appInfo().hasSubtyping()) {
if (outType.isClassType()
- && root.getTypeLattice().isClassType()
- && appView.appInfo().withSubtyping().inDifferentHierarchy(
- outType.asClassTypeLatticeElement().getClassType(),
- root.getTypeLattice().asClassTypeLatticeElement().getClassType())) {
+ && root.getType().isClassType()
+ && appView
+ .appInfo()
+ .withSubtyping()
+ .inDifferentHierarchy(
+ outType.asClassType().getClassType(),
+ root.getType().asClassType().getClassType())) {
return false;
}
}
- return outType.isReference();
+ return outType.isReferenceType();
}
@Override
@@ -242,11 +245,11 @@
@Override
public TypeLatticeElement evaluate(AppView<?> appView) {
if (assumption.isAssumeNone() || assumption.isAssumeDynamicType()) {
- return src().getTypeLattice();
+ return src().getType();
}
if (assumption.isAssumeNonNull()) {
- assert src().getTypeLattice().isReference();
- return src().getTypeLattice().asReferenceTypeLatticeElement().asMeetWithNotNull();
+ assert src().getType().isReferenceType();
+ return src().getType().asReferenceType().asMeetWithNotNull();
}
throw new Unimplemented();
}
@@ -275,18 +278,17 @@
public boolean verifyTypes(AppView<?> appView) {
assert super.verifyTypes(appView);
- TypeLatticeElement inType = src().getTypeLattice();
- TypeLatticeElement outType = outValue().getTypeLattice();
+ TypeLatticeElement inType = src().getType();
+ TypeLatticeElement outType = outValue().getType();
if (isAssumeNone() || isAssumeDynamicType()) {
- assert inType.isReference() : inType;
+ assert inType.isReferenceType() : inType;
assert outType.equals(inType)
: "At " + this + System.lineSeparator() + outType + " != " + inType;
} else {
assert isAssumeNonNull() : this;
- assert inType.isReference() : inType;
- assert inType.isNullType()
- || outType.equals(inType.asReferenceTypeLatticeElement().asMeetWithNotNull())
- : "At " + this + System.lineSeparator() + outType + " != " + inType;
+ assert inType.isReferenceType() : inType;
+ assert inType.isNullType() || outType.equals(inType.asReferenceType().asMeetWithNotNull())
+ : "At " + this + System.lineSeparator() + outType + " != " + inType;
}
return true;
}
@@ -351,7 +353,7 @@
@Override
public boolean verifyCorrectnessOfValues(Value dest, Value src, AppView<?> appView) {
- assert dest.getTypeLattice() == src.getTypeLattice();
+ assert dest.getType() == src.getType();
return true;
}
}
@@ -382,7 +384,7 @@
@Override
public boolean verifyCorrectnessOfValues(Value dest, Value src, AppView<?> appView) {
- assert dynamicUpperBoundType.lessThanOrEqualUpToNullability(src.getTypeLattice(), appView);
+ assert dynamicUpperBoundType.lessThanOrEqualUpToNullability(src.getType(), appView);
return true;
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/BasicBlock.java b/src/main/java/com/android/tools/r8/ir/code/BasicBlock.java
index 584ea2c..eddd4e4 100644
--- a/src/main/java/com/android/tools/r8/ir/code/BasicBlock.java
+++ b/src/main/java/com/android/tools/r8/ir/code/BasicBlock.java
@@ -1750,7 +1750,7 @@
if (hasMoveException) {
// Remove the move-exception instruction.
move = entry().asMoveException();
- exceptionTypeLattice = move.outValue().getTypeLattice();
+ exceptionTypeLattice = move.outValue().getType();
exceptionType = move.getExceptionType();
assert move.getDebugValues().isEmpty();
getInstructions().remove(0);
diff --git a/src/main/java/com/android/tools/r8/ir/code/BasicBlockInstructionListIterator.java b/src/main/java/com/android/tools/r8/ir/code/BasicBlockInstructionListIterator.java
index 98f4c97..d6cb10c 100644
--- a/src/main/java/com/android/tools/r8/ir/code/BasicBlockInstructionListIterator.java
+++ b/src/main/java/com/android/tools/r8/ir/code/BasicBlockInstructionListIterator.java
@@ -228,7 +228,7 @@
throw new IllegalStateException();
}
- assert !current.hasOutValue() || current.outValue().getTypeLattice().isInt();
+ assert !current.hasOutValue() || current.outValue().getType().isInt();
// Replace the instruction by const-number.
ConstNumber constNumber = code.createIntConstant(value, current.getLocalInfo());
@@ -250,7 +250,7 @@
// Replace the instruction by static-get.
TypeLatticeElement newType = TypeLatticeElement.fromDexType(field.type, maybeNull(), appView);
- TypeLatticeElement oldType = current.hasOutValue() ? current.outValue().getTypeLattice() : null;
+ TypeLatticeElement oldType = current.hasOutValue() ? current.outValue().getType() : null;
Value value = code.createValue(newType, current.getLocalInfo());
StaticGet staticGet = new StaticGet(value, field);
for (Value inValue : current.inValues()) {
@@ -535,8 +535,7 @@
// instruction if the program still type checks without the cast.
Value receiver = invoke.inValues().get(0);
TypeLatticeElement castTypeLattice =
- TypeLatticeElement.fromDexType(
- downcast, receiver.getTypeLattice().nullability(), appView);
+ TypeLatticeElement.fromDexType(downcast, receiver.getType().nullability(), appView);
CheckCast castInstruction =
new CheckCast(code.createValue(castTypeLattice), receiver, downcast);
castInstruction.setPosition(invoke.getPosition());
diff --git a/src/main/java/com/android/tools/r8/ir/code/CheckCast.java b/src/main/java/com/android/tools/r8/ir/code/CheckCast.java
index a084a0f..6c45d90 100644
--- a/src/main/java/com/android/tools/r8/ir/code/CheckCast.java
+++ b/src/main/java/com/android/tools/r8/ir/code/CheckCast.java
@@ -161,18 +161,18 @@
@Override
public TypeLatticeElement evaluate(AppView<?> appView) {
- return TypeLatticeElement.fromDexType(type, object().getTypeLattice().nullability(), appView);
+ return TypeLatticeElement.fromDexType(type, object().getType().nullability(), appView);
}
@Override
public boolean verifyTypes(AppView<?> appView) {
assert super.verifyTypes(appView);
- TypeLatticeElement inType = object().getTypeLattice();
+ TypeLatticeElement inType = object().getType();
assert inType.isPreciseType();
- TypeLatticeElement outType = outValue().getTypeLattice();
+ TypeLatticeElement outType = outValue().getType();
TypeLatticeElement castType =
TypeLatticeElement.fromDexType(getType(), inType.nullability(), appView);
diff --git a/src/main/java/com/android/tools/r8/ir/code/ConstClass.java b/src/main/java/com/android/tools/r8/ir/code/ConstClass.java
index a9089f8..61947cf 100644
--- a/src/main/java/com/android/tools/r8/ir/code/ConstClass.java
+++ b/src/main/java/com/android/tools/r8/ir/code/ConstClass.java
@@ -46,7 +46,7 @@
Value newValue =
new Value(
code.valueNumberGenerator.next(),
- original.outValue().getTypeLattice(),
+ original.outValue().getType(),
original.getLocalInfo());
return copyOf(newValue, original);
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/ConstMethodHandle.java b/src/main/java/com/android/tools/r8/ir/code/ConstMethodHandle.java
index 446601c..07aa3a1 100644
--- a/src/main/java/com/android/tools/r8/ir/code/ConstMethodHandle.java
+++ b/src/main/java/com/android/tools/r8/ir/code/ConstMethodHandle.java
@@ -40,7 +40,7 @@
Value newValue =
new Value(
code.valueNumberGenerator.next(),
- original.outValue().getTypeLattice(),
+ original.outValue().getType(),
original.getLocalInfo());
return copyOf(newValue, original);
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/ConstMethodType.java b/src/main/java/com/android/tools/r8/ir/code/ConstMethodType.java
index bb3f574..6b2350b 100644
--- a/src/main/java/com/android/tools/r8/ir/code/ConstMethodType.java
+++ b/src/main/java/com/android/tools/r8/ir/code/ConstMethodType.java
@@ -40,7 +40,7 @@
Value newValue =
new Value(
code.valueNumberGenerator.next(),
- original.outValue().getTypeLattice(),
+ original.outValue().getType(),
original.getLocalInfo());
return copyOf(newValue, original);
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/ConstNumber.java b/src/main/java/com/android/tools/r8/ir/code/ConstNumber.java
index 84f33f3..5b72a5a 100644
--- a/src/main/java/com/android/tools/r8/ir/code/ConstNumber.java
+++ b/src/main/java/com/android/tools/r8/ir/code/ConstNumber.java
@@ -54,10 +54,11 @@
}
public static ConstNumber copyOf(IRCode code, ConstNumber original) {
- Value newValue = new Value(
- code.valueNumberGenerator.next(),
- original.outValue().getTypeLattice(),
- original.getLocalInfo());
+ Value newValue =
+ new Value(
+ code.valueNumberGenerator.next(),
+ original.outValue().getType(),
+ original.getLocalInfo());
return copyOf(newValue, original);
}
@@ -250,7 +251,7 @@
@Override
public String toString() {
if (outValue != null) {
- return super.toString() + " " + value + " (" + outValue().getTypeLattice() + ")";
+ return super.toString() + " " + value + " (" + outValue().getType() + ")";
} else {
return super.toString() + " " + value + " (dead)";
}
@@ -315,15 +316,13 @@
@Override
public TypeLatticeElement evaluate(AppView<?> appView) {
- return outValue().getTypeLattice();
+ return outValue().getType();
}
@Override
public boolean verifyTypes(AppView<?> appView) {
assert super.verifyTypes(appView);
- assert !isZero()
- || outValue().getTypeLattice().isPrimitive()
- || outValue().getTypeLattice().isNullType();
+ assert !isZero() || outValue().getType().isPrimitiveType() || outValue().getType().isNullType();
return true;
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/ConstString.java b/src/main/java/com/android/tools/r8/ir/code/ConstString.java
index a80bc66..729f67d 100644
--- a/src/main/java/com/android/tools/r8/ir/code/ConstString.java
+++ b/src/main/java/com/android/tools/r8/ir/code/ConstString.java
@@ -42,8 +42,9 @@
public static ConstString copyOf(IRCode code, ConstString original) {
Value newValue =
- new Value(code.valueNumberGenerator.next(),
- original.outValue().getTypeLattice(),
+ new Value(
+ code.valueNumberGenerator.next(),
+ original.outValue().getType(),
original.getLocalInfo());
return copyOf(newValue, original);
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/DebugLocalWrite.java b/src/main/java/com/android/tools/r8/ir/code/DebugLocalWrite.java
index 453a564..5884660 100644
--- a/src/main/java/com/android/tools/r8/ir/code/DebugLocalWrite.java
+++ b/src/main/java/com/android/tools/r8/ir/code/DebugLocalWrite.java
@@ -79,7 +79,7 @@
@Override
public boolean verifyTypes(AppView<?> appView) {
super.verifyTypes(appView);
- assert src().getTypeLattice().lessThanOrEqual(outValue().getTypeLattice(), appView);
+ assert src().getType().lessThanOrEqual(outValue().getType(), appView);
return true;
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/DexItemBasedConstString.java b/src/main/java/com/android/tools/r8/ir/code/DexItemBasedConstString.java
index 979f172..8826e12 100644
--- a/src/main/java/com/android/tools/r8/ir/code/DexItemBasedConstString.java
+++ b/src/main/java/com/android/tools/r8/ir/code/DexItemBasedConstString.java
@@ -48,8 +48,9 @@
public static DexItemBasedConstString copyOf(IRCode code, DexItemBasedConstString original) {
Value newValue =
- new Value(code.valueNumberGenerator.next(),
- original.outValue().getTypeLattice(),
+ new Value(
+ code.valueNumberGenerator.next(),
+ original.outValue().getType(),
original.getLocalInfo());
return copyOf(newValue, original);
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/Dup.java b/src/main/java/com/android/tools/r8/ir/code/Dup.java
index 79fe507..cddc41e 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Dup.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Dup.java
@@ -70,7 +70,7 @@
@Override
public void buildCf(CfBuilder builder) {
- if (this.inValues.get(0).getTypeLattice().isWidePrimitive()) {
+ if (this.inValues.get(0).getType().isWidePrimitive()) {
builder.add(new CfStackInstruction(Opcode.Dup2));
} else {
builder.add(new CfStackInstruction(Opcode.Dup));
diff --git a/src/main/java/com/android/tools/r8/ir/code/Dup2.java b/src/main/java/com/android/tools/r8/ir/code/Dup2.java
index 2c24e04..465c408 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Dup2.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Dup2.java
@@ -33,8 +33,8 @@
private Dup2(StackValues dest, Value srcBottom, Value srcTop) {
super(dest, ImmutableList.of(srcBottom, srcTop));
- assert !srcBottom.getTypeLattice().isWidePrimitive();
- assert !srcTop.getTypeLattice().isWidePrimitive();
+ assert !srcBottom.getType().isWidePrimitive();
+ assert !srcTop.getType().isWidePrimitive();
assert dest.getStackValues().length == 4;
assert srcBottom.isValueOnStack() && !(srcBottom instanceof StackValues);
assert srcTop.isValueOnStack() && !(srcTop instanceof StackValues);
diff --git a/src/main/java/com/android/tools/r8/ir/code/FieldInstruction.java b/src/main/java/com/android/tools/r8/ir/code/FieldInstruction.java
index 507ae25..b28a815 100644
--- a/src/main/java/com/android/tools/r8/ir/code/FieldInstruction.java
+++ b/src/main/java/com/android/tools/r8/ir/code/FieldInstruction.java
@@ -114,7 +114,7 @@
if (isInstanceGet() || isInstancePut()) {
if (!assumption.canAssumeReceiverIsNotNull()) {
Value receiver = inValues.get(0);
- if (receiver.isAlwaysNull(appView) || receiver.typeLattice.isNullable()) {
+ if (receiver.isAlwaysNull(appView) || receiver.type.isNullable()) {
return AbstractError.specific(appView.dexItemFactory().npeType);
}
}
@@ -189,9 +189,8 @@
AppView<AppInfoWithLiveness> appView, DexEncodedField field) {
assert isFieldPut();
- TypeLatticeElement type = value().getTypeLattice();
- TypeLatticeElement baseType =
- type.isArrayType() ? type.asArrayTypeLatticeElement().getArrayBaseTypeLattice() : type;
+ TypeLatticeElement type = value().getType();
+ TypeLatticeElement baseType = type.isArrayType() ? type.asArrayType().getBaseType() : type;
if (!baseType.isClassType()) {
return false;
}
@@ -225,7 +224,7 @@
return resolutionResult != null && resolutionResult.isProgramMethod(appView);
}
- return appInfo.mayHaveFinalizeMethodDirectlyOrIndirectly(baseType.asClassTypeLatticeElement());
+ return appInfo.mayHaveFinalizeMethodDirectlyOrIndirectly(baseType.asClassType());
}
@Override
diff --git a/src/main/java/com/android/tools/r8/ir/code/FixedRegisterValue.java b/src/main/java/com/android/tools/r8/ir/code/FixedRegisterValue.java
index b074e44..f98f696 100644
--- a/src/main/java/com/android/tools/r8/ir/code/FixedRegisterValue.java
+++ b/src/main/java/com/android/tools/r8/ir/code/FixedRegisterValue.java
@@ -21,8 +21,8 @@
@Override
public ValueType outType() {
- TypeLatticeElement type = getTypeLattice();
- if (type.isPrimitive()) {
+ TypeLatticeElement type = getType();
+ if (type.isPrimitiveType()) {
if (type.isSinglePrimitive()) {
if (type.isInt()) {
return ValueType.INT;
@@ -40,7 +40,7 @@
}
}
} else {
- assert type.isReference();
+ assert type.isReferenceType();
return ValueType.OBJECT;
}
throw new Unreachable("Unexpected imprecise type: " + type);
diff --git a/src/main/java/com/android/tools/r8/ir/code/IRCode.java b/src/main/java/com/android/tools/r8/ir/code/IRCode.java
index 883d49f..8d55d4b 100644
--- a/src/main/java/com/android/tools/r8/ir/code/IRCode.java
+++ b/src/main/java/com/android/tools/r8/ir/code/IRCode.java
@@ -565,9 +565,8 @@
return true;
}
for (Instruction instruction : instructions()) {
- if (instruction.outValue != null && instruction.outValue.getTypeLattice().isClassType()) {
- ClassTypeLatticeElement classTypeLattice =
- instruction.outValue.getTypeLattice().asClassTypeLatticeElement();
+ if (instruction.outValue != null && instruction.outValue.getType().isClassType()) {
+ ClassTypeLatticeElement classTypeLattice = instruction.outValue.getType().asClassType();
assert !verticallyMergedClasses.hasBeenMergedIntoSubtype(classTypeLattice.getClassType());
for (DexType itf : classTypeLattice.getInterfaces()) {
assert !verticallyMergedClasses.hasBeenMergedIntoSubtype(itf);
@@ -893,11 +892,11 @@
public boolean verifyNoImpreciseOrBottomTypes() {
Predicate<Value> verifyValue =
v -> {
- assert v.getTypeLattice().isPreciseType();
- assert !v.getTypeLattice().isFineGrainedType();
+ assert v.getType().isPreciseType();
+ assert !v.getType().isFineGrainedType();
// For now we assume no bottom types on IR values. We may want to reconsider this for
// representing unreachable code.
- assert !v.getTypeLattice().isBottom();
+ assert !v.getType().isBottom();
assert !(v.definition instanceof ImpreciseMemberTypeInstruction)
|| ((ImpreciseMemberTypeInstruction) v.definition).getMemberType().isPrecise();
return true;
@@ -908,9 +907,8 @@
public boolean verifyNoNullabilityBottomTypes() {
Predicate<Value> verifyValue =
v -> {
- assert v.getTypeLattice().isPrimitive()
- || v.getTypeLattice().asReferenceTypeLatticeElement().nullability()
- != Nullability.bottom();
+ assert v.getType().isPrimitiveType()
+ || v.getType().asReferenceType().nullability() != Nullability.bottom();
return true;
};
return verifySSATypeLattice(wrapSSAVerifierWithStackValueHandling(verifyValue));
diff --git a/src/main/java/com/android/tools/r8/ir/code/If.java b/src/main/java/com/android/tools/r8/ir/code/If.java
index 611ebcc..b8e3b2e 100644
--- a/src/main/java/com/android/tools/r8/ir/code/If.java
+++ b/src/main/java/com/android/tools/r8/ir/code/If.java
@@ -64,7 +64,7 @@
private static boolean verifyTypeCompatible(TypeLatticeElement valueType, If.Type ifType) {
return valueType.isInt()
|| (valueType.isFloat() && (ifType == Type.EQ || ifType == Type.NE))
- || (valueType.isReference() && (ifType == Type.EQ || ifType == Type.NE));
+ || (valueType.isReferenceType() && (ifType == Type.EQ || ifType == Type.NE));
}
private Type type;
@@ -199,14 +199,14 @@
public BasicBlock targetFromCondition(ConstNumber value) {
assert isZeroTest();
- assert verifyTypeCompatible(value.outValue().getTypeLattice(), type);
+ assert verifyTypeCompatible(value.outValue().getType(), type);
return targetFromCondition(Long.signum(value.getRawValue()));
}
public BasicBlock targetFromCondition(ConstNumber left, ConstNumber right) {
assert !isZeroTest();
assert left.outType() == right.outType();
- assert verifyTypeCompatible(left.outValue().getTypeLattice(), type);
+ assert verifyTypeCompatible(left.outValue().getType(), type);
return targetFromCondition(Long.signum(left.getRawValue() - right.getRawValue()));
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/InitClass.java b/src/main/java/com/android/tools/r8/ir/code/InitClass.java
index 8dd260c..acc908d 100644
--- a/src/main/java/com/android/tools/r8/ir/code/InitClass.java
+++ b/src/main/java/com/android/tools/r8/ir/code/InitClass.java
@@ -30,7 +30,7 @@
public InitClass(Value outValue, DexType clazz) {
super(outValue);
assert hasOutValue();
- assert outValue.getTypeLattice().isInt();
+ assert outValue.getType().isInt();
assert clazz.isClassType();
this.clazz = clazz;
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/InstanceGet.java b/src/main/java/com/android/tools/r8/ir/code/InstanceGet.java
index 6d9b8e9..e2dcc3d 100644
--- a/src/main/java/com/android/tools/r8/ir/code/InstanceGet.java
+++ b/src/main/java/com/android/tools/r8/ir/code/InstanceGet.java
@@ -68,9 +68,9 @@
@Override
public boolean couldIntroduceAnAlias(AppView<?> appView, Value root) {
- assert root != null && root.getTypeLattice().isReference();
+ assert root != null && root.getType().isReferenceType();
assert outValue != null;
- return outValue.getTypeLattice().isReference();
+ return outValue.getType().isReferenceType();
}
@Override
diff --git a/src/main/java/com/android/tools/r8/ir/code/InstancePut.java b/src/main/java/com/android/tools/r8/ir/code/InstancePut.java
index 5680260..116a3e6 100644
--- a/src/main/java/com/android/tools/r8/ir/code/InstancePut.java
+++ b/src/main/java/com/android/tools/r8/ir/code/InstancePut.java
@@ -160,7 +160,7 @@
// If the value being written by this instruction is an array, then make sure that the value
// being written by the other instruction is the exact same value. Otherwise, the verifier
// may incorrectly join the types of these arrays to Object[].
- if (value().getTypeLattice().isArrayType() && value() != instancePut.value()) {
+ if (value().getType().isArrayType() && value() != instancePut.value()) {
return false;
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/Instruction.java b/src/main/java/com/android/tools/r8/ir/code/Instruction.java
index 3f85e8a..c97c626 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Instruction.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Instruction.java
@@ -145,9 +145,9 @@
}
@Override
- public TypeLatticeElement getTypeLattice() {
+ public TypeLatticeElement getOutType() {
if (hasOutValue()) {
- return outValue().getTypeLattice();
+ return outValue().getType();
}
return null;
}
@@ -1383,7 +1383,7 @@
public abstract void insertLoadAndStores(InstructionListIterator it, LoadStoreHelper helper);
public DexType computeVerificationType(AppView<?> appView, TypeVerificationHelper helper) {
- assert outValue == null || !outValue.getTypeLattice().isReference();
+ assert outValue == null || !outValue.getType().isReferenceType();
throw new Unreachable("Instruction without object outValue cannot compute verification type");
}
@@ -1406,16 +1406,16 @@
public boolean verifyTypes(AppView<?> appView) {
// TODO(b/72693244): for instructions with invariant out type, we can verify type directly here.
if (outValue != null) {
- TypeLatticeElement outTypeLatticeElement = outValue.getTypeLattice();
+ TypeLatticeElement outTypeLatticeElement = outValue.getType();
if (outTypeLatticeElement.isArrayType()) {
DexType outBaseType =
outTypeLatticeElement
- .asArrayTypeLatticeElement()
- .getArrayType(appView.dexItemFactory())
+ .asArrayType()
+ .toDexType(appView.dexItemFactory())
.toBaseType(appView.dexItemFactory());
assert appView.graphLense().lookupType(outBaseType) == outBaseType;
} else if (outTypeLatticeElement.isClassType()) {
- DexType outType = outTypeLatticeElement.asClassTypeLatticeElement().getClassType();
+ DexType outType = outTypeLatticeElement.asClassType().getClassType();
assert appView.graphLense().lookupType(outType) == outType;
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/Invoke.java b/src/main/java/com/android/tools/r8/ir/code/Invoke.java
index 15834d9..9ef1fcc 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Invoke.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Invoke.java
@@ -167,14 +167,14 @@
protected void addInvokeAndMoveResult(
com.android.tools.r8.code.Instruction instruction, DexBuilder builder) {
if (outValue != null && outValue.needsRegister()) {
- TypeLatticeElement moveType = outValue.getTypeLattice();
+ TypeLatticeElement moveType = outValue.getType();
int register = builder.allocatedRegister(outValue, getNumber());
com.android.tools.r8.code.Instruction moveResult;
if (moveType.isSinglePrimitive()) {
moveResult = new MoveResult(register);
} else if (moveType.isWidePrimitive()) {
moveResult = new MoveResultWide(register);
- } else if (moveType.isReference()) {
+ } else if (moveType.isReferenceType()) {
moveResult = new MoveResultObject(register);
} else {
throw new Unreachable("Unexpected result type " + outType());
@@ -187,24 +187,27 @@
@Override
public boolean couldIntroduceAnAlias(AppView<?> appView, Value root) {
- assert root != null && root.getTypeLattice().isReference();
+ assert root != null && root.getType().isReferenceType();
if (outValue == null) {
return false;
}
- TypeLatticeElement outType = outValue.getTypeLattice();
- if (outType.isPrimitive()) {
+ TypeLatticeElement outType = outValue.getType();
+ if (outType.isPrimitiveType()) {
return false;
}
if (appView.appInfo().hasSubtyping()) {
if (outType.isClassType()
- && root.getTypeLattice().isClassType()
- && appView.appInfo().withSubtyping().inDifferentHierarchy(
- outType.asClassTypeLatticeElement().getClassType(),
- root.getTypeLattice().asClassTypeLatticeElement().getClassType())) {
+ && root.getType().isClassType()
+ && appView
+ .appInfo()
+ .withSubtyping()
+ .inDifferentHierarchy(
+ outType.asClassType().getClassType(),
+ root.getType().asClassType().getClassType())) {
return false;
}
}
- return outType.isReference();
+ return outType.isReferenceType();
}
@Override
diff --git a/src/main/java/com/android/tools/r8/ir/code/InvokeCustom.java b/src/main/java/com/android/tools/r8/ir/code/InvokeCustom.java
index 2c7dcfb..b2683b7 100644
--- a/src/main/java/com/android/tools/r8/ir/code/InvokeCustom.java
+++ b/src/main/java/com/android/tools/r8/ir/code/InvokeCustom.java
@@ -44,8 +44,8 @@
private static boolean verifyLambdaInterfaces(
TypeLatticeElement returnTypeLattice, Set<DexType> lambdaInterfaceSet, DexType objectType) {
- Set<DexType> primaryInterfaces = returnTypeLattice.asClassTypeLatticeElement().getInterfaces();
- if (returnTypeLattice.asClassTypeLatticeElement().getClassType() == objectType) {
+ Set<DexType> primaryInterfaces = returnTypeLattice.asClassType().getInterfaces();
+ if (returnTypeLattice.asClassType().getClassType() == objectType) {
assert primaryInterfaces.size() == 1;
// The interfaces returned by the LambdaDescriptor assumed to already contain the primary
// interface. If they're both singleton lists they must be identical and we can return the
@@ -55,8 +55,7 @@
// We arrive here if the primary interface is a missing class. In that case the
// returnTypeLattice will be the missing type as the class type.
assert primaryInterfaces.isEmpty();
- assert lambdaInterfaceSet.contains(
- returnTypeLattice.asClassTypeLatticeElement().getClassType());
+ assert lambdaInterfaceSet.contains(returnTypeLattice.asClassType().getClassType());
}
return true;
}
@@ -76,10 +75,10 @@
// The primary return type is either an interface or a missing type.
assert returnTypeLattice instanceof ClassTypeLatticeElement;
- Set<DexType> primaryInterfaces = returnTypeLattice.asClassTypeLatticeElement().getInterfaces();
+ Set<DexType> primaryInterfaces = returnTypeLattice.asClassType().getInterfaces();
DexType objectType = appView.dexItemFactory().objectType;
- if (returnTypeLattice.asClassTypeLatticeElement().getClassType() == objectType) {
+ if (returnTypeLattice.asClassType().getClassType() == objectType) {
assert primaryInterfaces.size() == 1;
// Shortcut for the common case: single interface. Save creating a new lattice type.
if (lambdaInterfaces.size() == 1) {
diff --git a/src/main/java/com/android/tools/r8/ir/code/InvokeDirect.java b/src/main/java/com/android/tools/r8/ir/code/InvokeDirect.java
index b4531c3..ddc8952 100644
--- a/src/main/java/com/android/tools/r8/ir/code/InvokeDirect.java
+++ b/src/main/java/com/android/tools/r8/ir/code/InvokeDirect.java
@@ -166,7 +166,7 @@
// Check if it could throw a NullPointerException as a result of the receiver being null.
Value receiver = getReceiver();
- if (!assumption.canAssumeReceiverIsNotNull() && receiver.getTypeLattice().isNullable()) {
+ if (!assumption.canAssumeReceiverIsNotNull() && receiver.getType().isNullable()) {
return true;
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/InvokeMethod.java b/src/main/java/com/android/tools/r8/ir/code/InvokeMethod.java
index 401b4df..9b708bc 100644
--- a/src/main/java/com/android/tools/r8/ir/code/InvokeMethod.java
+++ b/src/main/java/com/android/tools/r8/ir/code/InvokeMethod.java
@@ -161,7 +161,7 @@
// incorrectly join the types of these arrays to Object[].
for (int i = 0; i < arguments().size(); ++i) {
Value argument = arguments().get(i);
- if (argument.getTypeLattice().isArrayType() && argument != invoke.arguments().get(i)) {
+ if (argument.getType().isArrayType() && argument != invoke.arguments().get(i)) {
return false;
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/InvokeMethodWithReceiver.java b/src/main/java/com/android/tools/r8/ir/code/InvokeMethodWithReceiver.java
index e15a387..f1a2d8b 100644
--- a/src/main/java/com/android/tools/r8/ir/code/InvokeMethodWithReceiver.java
+++ b/src/main/java/com/android/tools/r8/ir/code/InvokeMethodWithReceiver.java
@@ -70,7 +70,7 @@
assert super.verifyTypes(appView);
Value receiver = getReceiver();
- TypeLatticeElement receiverType = receiver.getTypeLattice();
+ TypeLatticeElement receiverType = receiver.getType();
assert receiverType.isPreciseType();
if (appView.appInfo().hasLiveness()) {
diff --git a/src/main/java/com/android/tools/r8/ir/code/InvokeVirtual.java b/src/main/java/com/android/tools/r8/ir/code/InvokeVirtual.java
index 1218f08..711c911 100644
--- a/src/main/java/com/android/tools/r8/ir/code/InvokeVirtual.java
+++ b/src/main/java/com/android/tools/r8/ir/code/InvokeVirtual.java
@@ -154,7 +154,7 @@
// Check if it could throw a NullPointerException as a result of the receiver being null.
Value receiver = getReceiver();
- if (!assumption.canAssumeReceiverIsNotNull() && receiver.getTypeLattice().isNullable()) {
+ if (!assumption.canAssumeReceiverIsNotNull() && receiver.getType().isNullable()) {
return true;
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/Load.java b/src/main/java/com/android/tools/r8/ir/code/Load.java
index e1885b0..79355b1 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Load.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Load.java
@@ -90,7 +90,7 @@
@Override
public TypeLatticeElement evaluate(AppView<?> appView) {
- return src().getTypeLattice();
+ return src().getType();
}
@Override
diff --git a/src/main/java/com/android/tools/r8/ir/code/Move.java b/src/main/java/com/android/tools/r8/ir/code/Move.java
index 3478645..9c7e389 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Move.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Move.java
@@ -73,7 +73,7 @@
@Override
public String toString() {
- return super.toString() + " (" + outValue().getTypeLattice() + ")";
+ return super.toString() + " (" + outValue().getType() + ")";
}
@Override
@@ -105,7 +105,7 @@
@Override
public TypeLatticeElement evaluate(AppView<?> appView) {
- return src().getTypeLattice();
+ return src().getType();
}
@Override
@@ -128,7 +128,7 @@
super.verifyTypes(appView);
// DebugLocalWrite defines it's own verification of types but should be allowed to call super.
if (!this.isDebugLocalWrite()) {
- assert src().getTypeLattice().equals(outValue().getTypeLattice());
+ assert src().getType().equals(outValue().getType());
}
return true;
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/NewArrayFilledData.java b/src/main/java/com/android/tools/r8/ir/code/NewArrayFilledData.java
index afd87ff..2211a59 100644
--- a/src/main/java/com/android/tools/r8/ir/code/NewArrayFilledData.java
+++ b/src/main/java/com/android/tools/r8/ir/code/NewArrayFilledData.java
@@ -121,7 +121,7 @@
return AbstractError.top();
}
- if (src().getTypeLattice().isNullable()) {
+ if (src().getType().isNullable()) {
return AbstractError.top();
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/NewInstance.java b/src/main/java/com/android/tools/r8/ir/code/NewInstance.java
index 384a27a..51efa0b 100644
--- a/src/main/java/com/android/tools/r8/ir/code/NewInstance.java
+++ b/src/main/java/com/android/tools/r8/ir/code/NewInstance.java
@@ -226,10 +226,9 @@
@Override
public boolean verifyTypes(AppView<?> appView) {
- TypeLatticeElement type = outValue().getTypeLattice();
+ TypeLatticeElement type = outValue().getType();
assert type.isClassType();
- assert type.asClassTypeLatticeElement().getClassType() == clazz
- || appView.options().testing.allowTypeErrors;
+ assert type.asClassType().getClassType() == clazz || appView.options().testing.allowTypeErrors;
assert type.isDefinitelyNotNull();
return true;
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/Phi.java b/src/main/java/com/android/tools/r8/ir/code/Phi.java
index 95c2608..7e68671 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Phi.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Phi.java
@@ -97,7 +97,7 @@
throw new InvalidDebugInfoException(
"Type information in locals-table is inconsistent."
+ " Cannot constrain type: "
- + typeLattice
+ + type
+ " for value: "
+ this
+ " by constraint "
@@ -115,7 +115,7 @@
throwUndefinedValueError();
}
- ValueTypeConstraint readConstraint = TypeConstraintResolver.constraintForType(typeLattice);
+ ValueTypeConstraint readConstraint = TypeConstraintResolver.constraintForType(type);
List<Value> operands = new ArrayList<>(block.getPredecessors().size());
for (BasicBlock pred : block.getPredecessors()) {
EdgeType edgeType = pred.getEdgeType(block);
@@ -125,7 +125,7 @@
if (readType != RegisterReadType.NORMAL) {
for (Value operand : operands) {
- TypeLatticeElement type = operand.getTypeLattice();
+ TypeLatticeElement type = operand.getType();
ValueTypeConstraint constraint = TypeConstraintResolver.constraintForType(type);
abortOnInvalidDebugInfo(constraint);
}
@@ -261,8 +261,8 @@
return false;
}
// Ensure that the value that replaces this phi is constrained to the type of this phi.
- if (builder != null && typeLattice.isPreciseType() && !typeLattice.isBottom()) {
- builder.constrainType(same, ValueTypeConstraint.fromTypeLattice(typeLattice));
+ if (builder != null && type.isPreciseType() && !type.isBottom()) {
+ builder.constrainType(same, ValueTypeConstraint.fromTypeLattice(type));
}
if (affectedValues != null) {
affectedValues.addAll(this.affectedValues());
@@ -320,7 +320,7 @@
}
builder.append(" <- phi");
StringUtils.append(builder, ListUtils.map(operands, Value::toString));
- builder.append(" : ").append(getTypeLattice());
+ builder.append(" : ").append(getType());
return builder.toString();
}
@@ -401,7 +401,7 @@
public TypeLatticeElement computePhiType(AppView<?> appView) {
TypeLatticeElement result = TypeLatticeElement.getBottom();
for (Value operand : getOperands()) {
- result = result.join(operand.getTypeLattice(), appView);
+ result = result.join(operand.getType(), appView);
}
return result;
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/Return.java b/src/main/java/com/android/tools/r8/ir/code/Return.java
index 037f856..9977857 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Return.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Return.java
@@ -44,7 +44,7 @@
public TypeLatticeElement getReturnType() {
assert !isReturnVoid();
- return returnValue().getTypeLattice();
+ return returnValue().getType();
}
public Value returnValue() {
@@ -58,7 +58,7 @@
}
int register = builder.allocatedRegister(returnValue(), getNumber());
TypeLatticeElement returnType = getReturnType();
- if (returnType.isReference()) {
+ if (returnType.isReferenceType()) {
return new ReturnObject(register);
}
if (returnType.isSinglePrimitive()) {
@@ -124,8 +124,6 @@
@Override
public void buildCf(CfBuilder builder) {
builder.add(
- isReturnVoid()
- ? new CfReturnVoid()
- : new CfReturn(ValueType.fromTypeLattice(getReturnType())));
+ isReturnVoid() ? new CfReturnVoid() : new CfReturn(ValueType.fromType(getReturnType())));
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/StackValue.java b/src/main/java/com/android/tools/r8/ir/code/StackValue.java
index 430f290..0f497df 100644
--- a/src/main/java/com/android/tools/r8/ir/code/StackValue.java
+++ b/src/main/java/com/android/tools/r8/ir/code/StackValue.java
@@ -36,7 +36,7 @@
}
public StackValue duplicate(int height) {
- return new StackValue(typeInfo, getTypeLattice(), height);
+ return new StackValue(typeInfo, getType(), height);
}
@Override
diff --git a/src/main/java/com/android/tools/r8/ir/code/StackValues.java b/src/main/java/com/android/tools/r8/ir/code/StackValues.java
index 528cddd..83b05df 100644
--- a/src/main/java/com/android/tools/r8/ir/code/StackValues.java
+++ b/src/main/java/com/android/tools/r8/ir/code/StackValues.java
@@ -55,7 +55,7 @@
}
@Override
- public TypeLatticeElement getTypeLattice() {
+ public TypeLatticeElement getType() {
throw new Unreachable();
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/StaticGet.java b/src/main/java/com/android/tools/r8/ir/code/StaticGet.java
index a3c202b..80ad9a2 100644
--- a/src/main/java/com/android/tools/r8/ir/code/StaticGet.java
+++ b/src/main/java/com/android/tools/r8/ir/code/StaticGet.java
@@ -40,7 +40,7 @@
Value newValue =
new Value(
code.valueNumberGenerator.next(),
- original.outValue().getTypeLattice(),
+ original.outValue().getType(),
original.getLocalInfo());
return copyOf(newValue, original);
}
@@ -71,22 +71,25 @@
@Override
public boolean couldIntroduceAnAlias(AppView<?> appView, Value root) {
- assert root != null && root.getTypeLattice().isReference();
+ assert root != null && root.getType().isReferenceType();
assert outValue != null;
- TypeLatticeElement outType = outValue.getTypeLattice();
- if (outType.isPrimitive()) {
+ TypeLatticeElement outType = outValue.getType();
+ if (outType.isPrimitiveType()) {
return false;
}
if (appView.appInfo().hasSubtyping()) {
if (outType.isClassType()
- && root.getTypeLattice().isClassType()
- && appView.appInfo().withSubtyping().inDifferentHierarchy(
- outType.asClassTypeLatticeElement().getClassType(),
- root.getTypeLattice().asClassTypeLatticeElement().getClassType())) {
+ && root.getType().isClassType()
+ && appView
+ .appInfo()
+ .withSubtyping()
+ .inDifferentHierarchy(
+ outType.asClassType().getClassType(),
+ root.getType().asClassType().getClassType())) {
return false;
}
}
- return outType.isReference();
+ return outType.isReferenceType();
}
@Override
diff --git a/src/main/java/com/android/tools/r8/ir/code/StaticPut.java b/src/main/java/com/android/tools/r8/ir/code/StaticPut.java
index e7d2bdc..16c102b 100644
--- a/src/main/java/com/android/tools/r8/ir/code/StaticPut.java
+++ b/src/main/java/com/android/tools/r8/ir/code/StaticPut.java
@@ -168,7 +168,7 @@
// If the value being written by this instruction is an array, then make sure that the value
// being written by the other instruction is the exact same value. Otherwise, the verifier
// may incorrectly join the types of these arrays to Object[].
- if (value().getTypeLattice().isArrayType() && value() != staticPut.value()) {
+ if (value().getType().isArrayType() && value() != staticPut.value()) {
return false;
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/code/Store.java b/src/main/java/com/android/tools/r8/ir/code/Store.java
index 72eb683..62f1aed 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Store.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Store.java
@@ -90,7 +90,7 @@
@Override
public TypeLatticeElement evaluate(AppView<?> appView) {
- return src().getTypeLattice();
+ return src().getType();
}
@Override
diff --git a/src/main/java/com/android/tools/r8/ir/code/Swap.java b/src/main/java/com/android/tools/r8/ir/code/Swap.java
index 8cdaa77..2515934 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Swap.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Swap.java
@@ -26,7 +26,7 @@
super(dest, ImmutableList.of(src1, src2));
assert src1.isValueOnStack() && !(src1 instanceof StackValues);
assert src2.isValueOnStack() && !(src2 instanceof StackValues);
- assert !src1.getTypeLattice().isWidePrimitive() && !src2.getTypeLattice().isWidePrimitive();
+ assert !src1.getType().isWidePrimitive() && !src2.getType().isWidePrimitive();
}
@Override
diff --git a/src/main/java/com/android/tools/r8/ir/code/Throw.java b/src/main/java/com/android/tools/r8/ir/code/Throw.java
index 115e9fd..d354969 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Throw.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Throw.java
@@ -91,7 +91,7 @@
if (exception() == value) {
return true;
}
- TypeLatticeElement exceptionType = exception().getTypeLattice();
+ TypeLatticeElement exceptionType = exception().getType();
if (exceptionType.isNullType()) {
// throw null
return true;
diff --git a/src/main/java/com/android/tools/r8/ir/code/TypeAndLocalInfoSupplier.java b/src/main/java/com/android/tools/r8/ir/code/TypeAndLocalInfoSupplier.java
index 0d5cfd6..724716b 100644
--- a/src/main/java/com/android/tools/r8/ir/code/TypeAndLocalInfoSupplier.java
+++ b/src/main/java/com/android/tools/r8/ir/code/TypeAndLocalInfoSupplier.java
@@ -9,7 +9,8 @@
public interface TypeAndLocalInfoSupplier {
DebugLocalInfo getLocalInfo();
- TypeLatticeElement getTypeLattice();
+
+ TypeLatticeElement getOutType();
static TypeAndLocalInfoSupplier create(TypeLatticeElement type, DebugLocalInfo local) {
return new TypeAndLocalInfoSupplier() {
@@ -20,7 +21,7 @@
}
@Override
- public TypeLatticeElement getTypeLattice() {
+ public TypeLatticeElement getOutType() {
return type;
}
};
diff --git a/src/main/java/com/android/tools/r8/ir/code/Unop.java b/src/main/java/com/android/tools/r8/ir/code/Unop.java
index 57fad2d..dec55b7 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Unop.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Unop.java
@@ -59,7 +59,7 @@
@Override
public TypeLatticeElement evaluate(AppView<?> appView) {
- return source().getTypeLattice();
+ return source().getType();
}
@Override
diff --git a/src/main/java/com/android/tools/r8/ir/code/Value.java b/src/main/java/com/android/tools/r8/ir/code/Value.java
index 25ed39f..5308ae7 100644
--- a/src/main/java/com/android/tools/r8/ir/code/Value.java
+++ b/src/main/java/com/android/tools/r8/ir/code/Value.java
@@ -57,26 +57,25 @@
throw reporter.fatalError(
new StringDiagnostic(
"Cannot constrain type: "
- + typeLattice
+ + type
+ " for value: "
+ this
+ " by constraint: "
+ constraint,
origin,
new MethodPosition(method)));
- } else if (constrainedType != typeLattice) {
- setTypeLattice(constrainedType);
+ } else if (constrainedType != type) {
+ setType(constrainedType);
}
}
public TypeLatticeElement constrainedType(ValueTypeConstraint constraint) {
- if (constraint == ValueTypeConstraint.INT_OR_FLOAT_OR_OBJECT
- && !typeLattice.isWidePrimitive()) {
- return typeLattice;
+ if (constraint == ValueTypeConstraint.INT_OR_FLOAT_OR_OBJECT && !type.isWidePrimitive()) {
+ return type;
}
switch (constraint) {
case OBJECT:
- if (typeLattice.isTop()) {
+ if (type.isTop()) {
if (definition != null && definition.isConstNumber()) {
assert definition.asConstNumber().isZero();
return TypeLatticeElement.getNull();
@@ -84,49 +83,49 @@
return TypeLatticeElement.getBottom();
}
}
- if (typeLattice.isReference()) {
- return typeLattice;
+ if (type.isReferenceType()) {
+ return type;
}
- if (typeLattice.isBottom()) {
+ if (type.isBottom()) {
// Only a few instructions may propagate a bottom input to a bottom output.
assert isPhi()
|| definition.isDebugLocalWrite()
|| (definition.isArrayGet()
&& definition.asArrayGet().getMemberType() == MemberType.OBJECT);
- return typeLattice;
+ return type;
}
break;
case INT:
- if (typeLattice.isTop() || (typeLattice.isSinglePrimitive() && !typeLattice.isFloat())) {
+ if (type.isTop() || (type.isSinglePrimitive() && !type.isFloat())) {
return TypeLatticeElement.getInt();
}
break;
case FLOAT:
- if (typeLattice.isTop() || (typeLattice.isSinglePrimitive() && !typeLattice.isInt())) {
+ if (type.isTop() || (type.isSinglePrimitive() && !type.isInt())) {
return TypeLatticeElement.getFloat();
}
break;
case INT_OR_FLOAT:
- if (typeLattice.isTop()) {
+ if (type.isTop()) {
return TypeLatticeElement.getSingle();
}
- if (typeLattice.isSinglePrimitive()) {
- return typeLattice;
+ if (type.isSinglePrimitive()) {
+ return type;
}
break;
case LONG:
- if (typeLattice.isWidePrimitive() && !typeLattice.isDouble()) {
+ if (type.isWidePrimitive() && !type.isDouble()) {
return TypeLatticeElement.getLong();
}
break;
case DOUBLE:
- if (typeLattice.isWidePrimitive() && !typeLattice.isLong()) {
+ if (type.isWidePrimitive() && !type.isLong()) {
return TypeLatticeElement.getDouble();
}
break;
case LONG_OR_DOUBLE:
- if (typeLattice.isWidePrimitive()) {
- return typeLattice;
+ if (type.isWidePrimitive()) {
+ return type;
}
break;
default:
@@ -228,13 +227,13 @@
private boolean isThis = false;
private LongInterval valueRange;
private DebugData debugData;
- protected TypeLatticeElement typeLattice;
+ protected TypeLatticeElement type;
- public Value(int number, TypeLatticeElement typeLattice, DebugLocalInfo local) {
- assert typeLattice != null;
+ public Value(int number, TypeLatticeElement type, DebugLocalInfo local) {
+ assert type != null;
this.number = number;
this.debugData = local == null ? null : new DebugData(local);
- this.typeLattice = typeLattice;
+ this.type = type;
}
public boolean isFixedRegisterValue() {
@@ -310,7 +309,7 @@
}
public int requiredRegisters() {
- return typeLattice.requiredRegisters();
+ return type.requiredRegisters();
}
public DebugLocalInfo getLocalInfo() {
@@ -553,14 +552,11 @@
// Not always null as the value can be changed via the debugger.
return false;
}
- if (typeLattice.isDefinitelyNull()) {
+ if (type.isDefinitelyNull()) {
return true;
}
- if (typeLattice.isClassType() && appView.appInfo().hasLiveness()) {
- return typeLattice
- .asClassTypeLatticeElement()
- .getClassType()
- .isAlwaysNull(appView.withLiveness());
+ if (type.isClassType() && appView.appInfo().hasLiveness()) {
+ return type.asClassType().getClassType().isAlwaysNull(appView.withLiveness());
}
return false;
}
@@ -831,7 +827,7 @@
builder.append("(");
if (isConstant && definition.asConstNumber().outValue != null) {
ConstNumber constNumber = definition.asConstNumber();
- if (constNumber.outValue().getTypeLattice().isSinglePrimitive()) {
+ if (constNumber.outValue().getType().isSinglePrimitive()) {
builder.append((int) constNumber.getRawValue());
} else {
builder.append(constNumber.getRawValue());
@@ -852,7 +848,7 @@
}
public ValueType outType() {
- return ValueType.fromTypeLattice(typeLattice);
+ return ValueType.fromType(type);
}
public ConstInstruction getConstInstruction() {
@@ -921,9 +917,9 @@
* Returns whether this value is known to never be <code>null</code>.
*/
public boolean isNeverNull() {
- assert typeLattice.isReference();
+ assert type.isReferenceType();
return (definition != null && definition.isAssumeNonNull())
- || typeLattice.nullability().isDefinitelyNotNull();
+ || type.nullability().isDefinitelyNotNull();
}
public boolean isArgument() {
@@ -956,7 +952,7 @@
}
public boolean knownToBeBoolean(Set<Phi> seen) {
- if (!getTypeLattice().isInt()) {
+ if (!getType().isInt()) {
return false;
}
@@ -1014,11 +1010,11 @@
public LongInterval getValueRange() {
if (isConstNumber()) {
- if (typeLattice.isSinglePrimitive()) {
+ if (type.isSinglePrimitive()) {
int value = getConstInstruction().asConstNumber().getIntValue();
return new LongInterval(value, value);
} else {
- assert typeLattice.isWidePrimitive();
+ assert type.isWidePrimitive();
long value = getConstInstruction().asConstNumber().getLongValue();
return new LongInterval(value, value);
}
@@ -1096,22 +1092,22 @@
*
* @param newType The new type lattice element
*/
- public void setTypeLattice(TypeLatticeElement newType) {
+ public void setType(TypeLatticeElement newType) {
assert newType != null;
- typeLattice = newType;
+ type = newType;
}
public void widening(AppView<?> appView, TypeLatticeElement newType) {
// During WIDENING (due to fix-point iteration), type update is monotonically upwards,
// i.e., towards something wider.
- assert this.typeLattice.lessThanOrEqual(newType, appView)
+ assert this.type.lessThanOrEqual(newType, appView)
: "During WIDENING, "
+ newType
+ " < "
- + typeLattice
+ + type
+ " at "
+ (isPhi() ? asPhi().printPhi() : definition.toString());
- setTypeLattice(newType);
+ setType(newType);
}
public void narrowing(AppView<?> appView, TypeLatticeElement newType) {
@@ -1119,18 +1115,18 @@
// i.e., towards something narrower, with more specific type info.
assert (!appView.options().testing.enableNarrowingChecksInD8
&& !appView.enableWholeProgramOptimizations())
- || !this.typeLattice.strictlyLessThan(newType, appView)
+ || !this.type.strictlyLessThan(newType, appView)
: "During NARROWING, "
- + typeLattice
+ + type
+ " < "
+ newType
+ " at "
+ (isPhi() ? asPhi().printPhi() : definition.toString());
- setTypeLattice(newType);
+ setType(newType);
}
- public TypeLatticeElement getTypeLattice() {
- return typeLattice;
+ public TypeLatticeElement getType() {
+ return type;
}
public TypeLatticeElement getDynamicUpperBoundType(
@@ -1155,20 +1151,19 @@
aliasedValue.definition.asAssumeDynamicType().getAssumption().getDynamicUpperBoundType();
// For precision, verify that the dynamic type is at least as precise as the static type.
- assert lattice.lessThanOrEqualUpToNullability(typeLattice, appView)
- : typeLattice + " < " + lattice;
+ assert lattice.lessThanOrEqualUpToNullability(type, appView) : type + " < " + lattice;
} else {
// Otherwise, simply use the static type.
- lattice = typeLattice;
+ lattice = type;
}
// Account for nullability, which could be flown from non-null assumption in between dynamic
// type assumption or simply from array/object creation.
- if (typeLattice.isDefinitelyNotNull() && lattice.isNullable()) {
+ if (type.isDefinitelyNotNull() && lattice.isNullable()) {
// Having non-null assumption means it is a reference type.
- assert lattice.isReference();
+ assert lattice.isReferenceType();
// Then, we can return the non-null variant of dynamic type if both assumptions are aliased.
- return lattice.asReferenceTypeLatticeElement().asMeetWithNotNull();
+ return lattice.asReferenceType().asMeetWithNotNull();
}
return lattice;
}
@@ -1195,14 +1190,14 @@
if (aliasedValue != null) {
ClassTypeLatticeElement lattice =
aliasedValue.definition.asAssumeDynamicType().getAssumption().getDynamicLowerBoundType();
- return lattice != null && typeLattice.isDefinitelyNotNull() && lattice.isNullable()
+ return lattice != null && type.isDefinitelyNotNull() && lattice.isNullable()
? lattice.asMeetWithNotNull()
: lattice;
}
// If it is a final or effectively-final class type, then we know the lower bound.
- if (getTypeLattice().isClassType()) {
- ClassTypeLatticeElement classType = getTypeLattice().asClassTypeLatticeElement();
+ if (getType().isClassType()) {
+ ClassTypeLatticeElement classType = getType().asClassType();
DexType type = classType.getClassType();
DexClass clazz = appView.definitionFor(type);
if (clazz != null && clazz.isEffectivelyFinal(appView)) {
diff --git a/src/main/java/com/android/tools/r8/ir/code/ValueType.java b/src/main/java/com/android/tools/r8/ir/code/ValueType.java
index 865c7d4..2b8e3cb 100644
--- a/src/main/java/com/android/tools/r8/ir/code/ValueType.java
+++ b/src/main/java/com/android/tools/r8/ir/code/ValueType.java
@@ -102,26 +102,26 @@
}
}
- public static ValueType fromTypeLattice(TypeLatticeElement typeLatticeElement) {
- if (typeLatticeElement.isReference()) {
+ public static ValueType fromType(TypeLatticeElement type) {
+ if (type.isReferenceType()) {
return OBJECT;
}
- if (typeLatticeElement.isInt()) {
+ if (type.isInt()) {
return INT;
}
- if (typeLatticeElement.isFloat()) {
+ if (type.isFloat()) {
return FLOAT;
}
- if (typeLatticeElement.isLong()) {
+ if (type.isLong()) {
return LONG;
}
- if (typeLatticeElement.isDouble()) {
+ if (type.isDouble()) {
return DOUBLE;
}
- throw new Unreachable("Unexpected conversion of imprecise type: " + typeLatticeElement);
+ throw new Unreachable("Unexpected conversion of imprecise type: " + type);
}
- public PrimitiveTypeLatticeElement toPrimitiveTypeLattice() {
+ public PrimitiveTypeLatticeElement toPrimitiveType() {
switch (this) {
case INT:
return TypeLatticeElement.getInt();
diff --git a/src/main/java/com/android/tools/r8/ir/code/ValueTypeConstraint.java b/src/main/java/com/android/tools/r8/ir/code/ValueTypeConstraint.java
index 1f7f97b..531ccce 100644
--- a/src/main/java/com/android/tools/r8/ir/code/ValueTypeConstraint.java
+++ b/src/main/java/com/android/tools/r8/ir/code/ValueTypeConstraint.java
@@ -130,7 +130,7 @@
}
public static ValueTypeConstraint fromTypeLattice(TypeLatticeElement typeLatticeElement) {
- if (typeLatticeElement.isReference()) {
+ if (typeLatticeElement.isReferenceType()) {
return OBJECT;
}
if (typeLatticeElement.isFineGrainedType() || typeLatticeElement.isInt()) {
@@ -157,7 +157,7 @@
throw new Unreachable("Unexpected conversion of type: " + typeLatticeElement);
}
- public PrimitiveTypeLatticeElement toPrimitiveTypeLattice() {
+ public PrimitiveTypeLatticeElement toPrimitiveType() {
switch (this) {
case INT:
return TypeLatticeElement.getInt();
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/CfBuilder.java b/src/main/java/com/android/tools/r8/ir/conversion/CfBuilder.java
index a16d39d..b94a110 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/CfBuilder.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/CfBuilder.java
@@ -234,7 +234,7 @@
// Insert ConstNumber(v, -1) before Not.
it.previous();
- Value constValue = code.createValue(inValue.getTypeLattice());
+ Value constValue = code.createValue(inValue.getType());
Instruction newInstruction = new ConstNumber(constValue, -1);
newInstruction.setBlock(block);
newInstruction.setPosition(current.getPosition());
@@ -386,7 +386,7 @@
|| constNumber == null
|| add == null
|| store == null
- || constNumber.outValue().getTypeLattice() != TypeLatticeElement.getInt()) {
+ || constNumber.outValue().getType() != TypeLatticeElement.getInt()) {
it.next();
continue;
}
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/DexBuilder.java b/src/main/java/com/android/tools/r8/ir/conversion/DexBuilder.java
index 8af9977..631ed81 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/DexBuilder.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/DexBuilder.java
@@ -1404,7 +1404,7 @@
@Override
public void addInstructions(DexBuilder builder, List<Instruction> instructions) {
Move move = getMove();
- TypeLatticeElement moveType = move.outValue().getTypeLattice();
+ TypeLatticeElement moveType = move.outValue().getType();
int src = srcRegister(builder);
int dest = destRegister(builder);
Instruction instruction;
@@ -1418,7 +1418,7 @@
instruction = new com.android.tools.r8.code.Move(dest, src);
} else if (moveType.isWidePrimitive()) {
instruction = new MoveWide(dest, src);
- } else if (moveType.isReference()) {
+ } else if (moveType.isReferenceType()) {
instruction = new MoveObject(dest, src);
} else {
throw new Unreachable("Unexpected type: " + move.outType());
@@ -1429,7 +1429,7 @@
instruction = new MoveFrom16(dest, src);
} else if (moveType.isWidePrimitive()) {
instruction = new MoveWideFrom16(dest, src);
- } else if (moveType.isReference()) {
+ } else if (moveType.isReferenceType()) {
instruction = new MoveObjectFrom16(dest, src);
} else {
throw new Unreachable("Unexpected type: " + move.outType());
@@ -1440,7 +1440,7 @@
instruction = new Move16(dest, src);
} else if (moveType.isWidePrimitive()) {
instruction = new MoveWide16(dest, src);
- } else if (moveType.isReference()) {
+ } else if (moveType.isReferenceType()) {
instruction = new MoveObject16(dest, src);
} else {
throw new Unreachable("Unexpected type: " + move.outType());
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/IRBuilder.java b/src/main/java/com/android/tools/r8/ir/conversion/IRBuilder.java
index e87f619..f9421e2 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/IRBuilder.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/IRBuilder.java
@@ -1010,8 +1010,7 @@
// Note that the write register must not lookup outgoing local information and the local is
// never considered clobbered by a start (if the in value has local info it must have been
// marked ended elsewhere).
- Value out = writeRegister(
- register, incomingValue.getTypeLattice(), ThrowingInfo.NO_THROW, local);
+ Value out = writeRegister(register, incomingValue.getType(), ThrowingInfo.NO_THROW, local);
DebugLocalWrite write = new DebugLocalWrite(out, incomingValue);
addInstruction(write);
}
@@ -1124,7 +1123,7 @@
public void addCheckCast(int value, DexType type) {
Value in = readRegister(value, ValueTypeConstraint.OBJECT);
TypeLatticeElement castTypeLattice =
- TypeLatticeElement.fromDexType(type, in.getTypeLattice().nullability(), appView);
+ TypeLatticeElement.fromDexType(type, in.getType().nullability(), appView);
Value out = writeRegister(value, castTypeLattice, ThrowingInfo.CAN_THROW);
CheckCast instruction = new CheckCast(out, in, type);
assert instruction.instructionTypeCanThrow();
@@ -1268,7 +1267,7 @@
// If the move is writing to a different local we must construct a new value.
DebugLocalInfo destLocal = getOutgoingLocal(dest);
if (destLocal != null && destLocal != in.getLocalInfo()) {
- Value out = writeRegister(dest, in.getTypeLattice(), ThrowingInfo.NO_THROW);
+ Value out = writeRegister(dest, in.getType(), ThrowingInfo.NO_THROW);
addInstruction(new DebugLocalWrite(out, in));
return;
}
@@ -2182,14 +2181,14 @@
// A debug initiated value must have a precise type constraint.
assert typeConstraint.isPrecise();
TypeLatticeElement type =
- typeConstraint.isObject() ? getNull() : typeConstraint.toPrimitiveTypeLattice();
+ typeConstraint.isObject() ? getNull() : typeConstraint.toPrimitiveType();
if (uninitializedDebugLocalValues == null) {
uninitializedDebugLocalValues = new Int2ReferenceOpenHashMap<>();
}
List<Value> values = uninitializedDebugLocalValues.get(register);
if (values != null) {
for (Value value : values) {
- if (value.getTypeLattice() == type) {
+ if (value.getType() == type) {
return value;
}
}
@@ -2340,7 +2339,7 @@
private void addInstruction(Instruction ir, Position position) {
assert verifyOutValueType(ir);
- hasImpreciseValues |= ir.outValue() != null && !ir.outValue().getTypeLattice().isPreciseType();
+ hasImpreciseValues |= ir.outValue() != null && !ir.outValue().getType().isPreciseType();
ir.setPosition(position);
attachLocalValues(ir);
currentBlock.add(ir, metadata);
@@ -2373,11 +2372,11 @@
private boolean verifyOutValueType(Instruction ir) {
assert ir.outValue() == null
|| ir.isArrayGet()
- || ir.evaluate(appView) == ir.outValue().getTypeLattice();
+ || ir.evaluate(appView) == ir.outValue().getType();
assert ir.outValue() == null
|| !ir.isArrayGet()
- || ir.evaluate(appView) == ir.outValue().getTypeLattice()
- || (ir.outValue().getTypeLattice().isBottom() && ir.evaluate(appView).isReference());
+ || ir.evaluate(appView) == ir.outValue().getType()
+ || (ir.outValue().getType().isBottom() && ir.evaluate(appView).isReferenceType());
return true;
}
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/LensCodeRewriter.java b/src/main/java/com/android/tools/r8/ir/conversion/LensCodeRewriter.java
index 6f1ff03d..acc8d97 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/LensCodeRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/LensCodeRewriter.java
@@ -86,7 +86,7 @@
private Value makeOutValue(Instruction insn, IRCode code) {
if (insn.outValue() != null) {
- TypeLatticeElement oldType = insn.outValue().getTypeLattice();
+ TypeLatticeElement oldType = insn.outValue().getType();
TypeLatticeElement newType =
oldType.fixupClassTypeReferences(appView.graphLense()::lookupType, appView);
return code.createValue(newType, insn.getLocalInfo());
@@ -123,8 +123,7 @@
InvokeCustom newInvokeCustom =
new InvokeCustom(newCallSite, newOutValue, invokeCustom.inValues());
iterator.replaceCurrentInstruction(newInvokeCustom);
- if (newOutValue != null
- && newOutValue.getTypeLattice() != invokeCustom.outValue().getTypeLattice()) {
+ if (newOutValue != null && newOutValue.getType() != invokeCustom.outValue().getType()) {
affectedPhis.addAll(newOutValue.uniquePhiUsers());
}
}
@@ -135,8 +134,7 @@
if (newHandle != handle) {
Value newOutValue = makeOutValue(current, code);
iterator.replaceCurrentInstruction(new ConstMethodHandle(newOutValue, newHandle));
- if (newOutValue != null
- && newOutValue.getTypeLattice() != current.outValue().getTypeLattice()) {
+ if (newOutValue != null && newOutValue.getType() != current.outValue().getType()) {
affectedPhis.addAll(newOutValue.uniquePhiUsers());
}
}
@@ -250,8 +248,7 @@
Invoke newInvoke =
Invoke.create(actualInvokeType, actualTarget, null, newOutValue, newInValues);
iterator.replaceCurrentInstruction(newInvoke);
- if (newOutValue != null
- && newOutValue.getTypeLattice() != current.outValue().getTypeLattice()) {
+ if (newOutValue != null && newOutValue.getType() != current.outValue().getType()) {
affectedPhis.addAll(newOutValue.uniquePhiUsers());
}
@@ -287,16 +284,14 @@
Value newOutValue = makeOutValue(current, code);
iterator.replaceCurrentInstruction(
new InvokeStatic(replacementMethod, newOutValue, current.inValues()));
- if (newOutValue != null
- && newOutValue.getTypeLattice() != current.outValue().getTypeLattice()) {
+ if (newOutValue != null && newOutValue.getType() != current.outValue().getType()) {
affectedPhis.addAll(current.outValue().uniquePhiUsers());
}
} else if (actualField != field) {
Value newOutValue = makeOutValue(instanceGet, code);
iterator.replaceCurrentInstruction(
new InstanceGet(newOutValue, instanceGet.object(), actualField));
- if (newOutValue != null
- && newOutValue.getTypeLattice() != current.outValue().getTypeLattice()) {
+ if (newOutValue != null && newOutValue.getType() != current.outValue().getType()) {
affectedPhis.addAll(newOutValue.uniquePhiUsers());
}
}
@@ -328,15 +323,13 @@
Value newOutValue = makeOutValue(current, code);
iterator.replaceCurrentInstruction(
new InvokeStatic(replacementMethod, newOutValue, current.inValues()));
- if (newOutValue != null
- && newOutValue.getTypeLattice() != current.outValue().getTypeLattice()) {
+ if (newOutValue != null && newOutValue.getType() != current.outValue().getType()) {
affectedPhis.addAll(newOutValue.uniquePhiUsers());
}
} else if (actualField != field) {
Value newOutValue = makeOutValue(staticGet, code);
iterator.replaceCurrentInstruction(new StaticGet(newOutValue, actualField));
- if (newOutValue != null
- && newOutValue.getTypeLattice() != current.outValue().getTypeLattice()) {
+ if (newOutValue != null && newOutValue.getType() != current.outValue().getType()) {
affectedPhis.addAll(newOutValue.uniquePhiUsers());
}
}
@@ -399,11 +392,11 @@
.replaceInstructionIfTypeChanged(type, NewInstance::new);
} else if (current.outValue() != null) {
// For all other instructions, substitute any changed type.
- TypeLatticeElement typeLattice = current.outValue().getTypeLattice();
+ TypeLatticeElement typeLattice = current.outValue().getType();
TypeLatticeElement substituted =
typeLattice.fixupClassTypeReferences(graphLense::lookupType, appView);
if (substituted != typeLattice) {
- current.outValue().setTypeLattice(substituted);
+ current.outValue().setType(substituted);
affectedPhis.addAll(current.outValue().uniquePhiUsers());
}
}
@@ -434,7 +427,7 @@
// TODO(b/150188380): Add API to insert a const instruction with a type lattice.
Value rewrittenDefaultValue = iterator.insertConstIntInstruction(code, appView.options(), 0);
iterator.next();
- rewrittenDefaultValue.setTypeLattice(defaultValueLatticeElement(newType));
+ rewrittenDefaultValue.setType(defaultValueLatticeElement(newType));
return rewrittenDefaultValue;
}
return initialValue;
@@ -692,7 +685,7 @@
Instruction newInstruction = constructor.apply(newType, newOutValue);
iterator.replaceCurrentInstruction(newInstruction);
if (newOutValue != null) {
- if (newOutValue.getTypeLattice() != current.outValue().getTypeLattice()) {
+ if (newOutValue.getType() != current.outValue().getType()) {
affectedPhis.addAll(newOutValue.uniquePhiUsers());
} else {
assert current.hasInvariantOutType();
diff --git a/src/main/java/com/android/tools/r8/ir/conversion/TypeConstraintResolver.java b/src/main/java/com/android/tools/r8/ir/conversion/TypeConstraintResolver.java
index 7257d49..b902d95 100644
--- a/src/main/java/com/android/tools/r8/ir/conversion/TypeConstraintResolver.java
+++ b/src/main/java/com/android/tools/r8/ir/conversion/TypeConstraintResolver.java
@@ -106,7 +106,7 @@
List<Value> impreciseValues = new ArrayList<>();
for (BasicBlock block : code.blocks) {
for (Phi phi : block.getPhis()) {
- if (!phi.getTypeLattice().isPreciseType()) {
+ if (!phi.getType().isPreciseType()) {
impreciseValues.add(phi);
}
for (Value value : phi.getOperands()) {
@@ -114,8 +114,7 @@
}
}
for (Instruction instruction : block.getInstructions()) {
- if (instruction.outValue() != null
- && !instruction.outValue().getTypeLattice().isPreciseType()) {
+ if (instruction.outValue() != null && !instruction.outValue().getType().isPreciseType()) {
impreciseValues.add(instruction.outValue());
}
@@ -151,7 +150,7 @@
"Cannot determine precise type for value: "
+ stillImprecise.get(0)
+ ", its imprecise type is: "
- + stillImprecise.get(0).getTypeLattice(),
+ + stillImprecise.get(0).getType(),
code.origin,
new MethodPosition(code.method.method)));
}
@@ -161,7 +160,7 @@
ArrayList<Value> stillImprecise = new ArrayList<>(impreciseValues.size());
for (Value value : impreciseValues) {
builder.constrainType(value, getCanonicalTypeConstraint(value, finished));
- if (!value.getTypeLattice().isPreciseType()) {
+ if (!value.getType().isPreciseType()) {
stillImprecise.add(value);
}
}
@@ -173,10 +172,10 @@
assert !type.isPrecise();
Value canonical = canonical(value);
ValueTypeConstraint constraint;
- if (array.getTypeLattice().isArrayType()) {
+ if (array.getType().isArrayType()) {
// If the array type is known it uniquely defines the actual member type.
- ArrayTypeLatticeElement arrayType = array.getTypeLattice().asArrayTypeLatticeElement();
- constraint = ValueTypeConstraint.fromTypeLattice(arrayType.getArrayMemberTypeAsValueType());
+ ArrayTypeLatticeElement arrayType = array.getType().asArrayType();
+ constraint = ValueTypeConstraint.fromTypeLattice(arrayType.getMemberTypeAsValueType());
} else {
// If not, e.g., the array input is null, the canonical value determines the final type.
constraint = getCanonicalTypeConstraint(canonical, true);
@@ -192,7 +191,7 @@
}
private ValueTypeConstraint getCanonicalTypeConstraint(Value value, boolean finished) {
- ValueTypeConstraint type = constraintForType(canonical(value).getTypeLattice());
+ ValueTypeConstraint type = constraintForType(canonical(value).getType());
switch (type) {
case INT_OR_FLOAT_OR_OBJECT:
// There is never a second round for resolving object vs single.
@@ -231,7 +230,7 @@
ArrayPut put = user.asArrayPut();
assert value == put.value();
assert !put.getMemberType().isPrecise();
- assert put.array().getTypeLattice().isDefinitelyNull();
+ assert put.array().getType().isDefinitelyNull();
} else {
assert false;
}
@@ -244,8 +243,8 @@
if (canonical1 == canonical2) {
return;
}
- TypeLatticeElement type1 = canonical1.getTypeLattice();
- TypeLatticeElement type2 = canonical2.getTypeLattice();
+ TypeLatticeElement type1 = canonical1.getType();
+ TypeLatticeElement type2 = canonical2.getType();
if (type1.isPreciseType() && type2.isPreciseType()) {
if (type1 != type2 && constraintForType(type1) != constraintForType(type2)) {
throw new CompilationError(
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/DesugaredLibraryAPIConverter.java b/src/main/java/com/android/tools/r8/ir/desugar/DesugaredLibraryAPIConverter.java
index 45c5bd2..58b1fc6 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/DesugaredLibraryAPIConverter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/DesugaredLibraryAPIConverter.java
@@ -522,7 +522,7 @@
DexMethod conversionMethod = createConversionMethod(argType, argType, argVivifiedType);
// The value is null only if the input is null.
Value convertedValue =
- createConversionValue(code, inValue.getTypeLattice().nullability(), argVivifiedType);
+ createConversionValue(code, inValue.getType().nullability(), argVivifiedType);
return new InvokeStatic(conversionMethod, convertedValue, Collections.singletonList(inValue));
}
@@ -533,9 +533,9 @@
Value outValue = invokeMethod.outValue();
outValue.replaceUsers(convertedValue);
// The only user of out value is now the new invoke static, so no type propagation is required.
- outValue.setTypeLattice(
+ outValue.setType(
TypeLatticeElement.fromDexType(
- returnVivifiedType, outValue.getTypeLattice().nullability(), appView));
+ returnVivifiedType, outValue.getType().nullability(), appView));
return new InvokeStatic(conversionMethod, convertedValue, Collections.singletonList(outValue));
}
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/LambdaRewriter.java b/src/main/java/com/android/tools/r8/ir/desugar/LambdaRewriter.java
index 770f170..737a203 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/LambdaRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/LambdaRewriter.java
@@ -352,8 +352,8 @@
// result:
// NewInstance rResult <- LambdaClass
// Invoke-Direct { rResult, rArg0, rArg1, ... }; method: void LambdaClass.<init>(...)
- lambdaInstanceValue.setTypeLattice(
- lambdaInstanceValue.getTypeLattice().asReferenceTypeLatticeElement().asDefinitelyNotNull());
+ lambdaInstanceValue.setType(
+ lambdaInstanceValue.getType().asReferenceType().asDefinitelyNotNull());
NewInstance newInstance = new NewInstance(lambdaClass.type, lambdaInstanceValue);
instructions.replaceCurrentInstruction(newInstance);
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/AliasIntroducer.java b/src/main/java/com/android/tools/r8/ir/optimize/AliasIntroducer.java
index cc97597..7219eb0 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/AliasIntroducer.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/AliasIntroducer.java
@@ -46,15 +46,14 @@
}
Value outValue = current.outValue();
// TODO(b/129859039): We may need similar concept when adding/testing assume-range
- if (outValue.getTypeLattice().isPrimitive()
- || outValue.getTypeLattice().isNullType()) {
+ if (outValue.getType().isPrimitiveType() || outValue.getType().isNullType()) {
continue;
}
// Split block if needed
BasicBlock insertionBlock =
block.hasCatchHandlers() ? instructionIterator.split(code, blockIterator) : block;
// Replace usages of out-value by the out-value of the AssumeNone instruction.
- Value aliasedValue = code.createValue(outValue.getTypeLattice(), outValue.getLocalInfo());
+ Value aliasedValue = code.createValue(outValue.getType(), outValue.getLocalInfo());
outValue.replaceUsers(aliasedValue);
// Insert AssumeNone instruction.
Assume<NoAssumption> assumeNone =
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/AssumeDynamicTypeRemover.java b/src/main/java/com/android/tools/r8/ir/optimize/AssumeDynamicTypeRemover.java
index 6bb9b03..9102f53 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/AssumeDynamicTypeRemover.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/AssumeDynamicTypeRemover.java
@@ -68,7 +68,7 @@
Value outValue = assumeDynamicTypeInstruction.outValue();
// Check if we need to run the type analysis for the affected values of the out-value.
- if (!outValue.getTypeLattice().equals(inValue.getTypeLattice())) {
+ if (!outValue.getType().equals(inValue.getType())) {
affectedValues.addAll(outValue.affectedValues());
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/CallSiteOptimizationInfoPropagator.java b/src/main/java/com/android/tools/r8/ir/optimize/CallSiteOptimizationInfoPropagator.java
index 627aec5..285bb94 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/CallSiteOptimizationInfoPropagator.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/CallSiteOptimizationInfoPropagator.java
@@ -223,7 +223,7 @@
}
argumentsSeen++;
Value originalArg = instr.asArgument().outValue();
- if (originalArg.hasLocalInfo() || !originalArg.getTypeLattice().isReference()) {
+ if (originalArg.hasLocalInfo() || !originalArg.getType().isReferenceType()) {
continue;
}
int argIndex = argumentsSeen - 1;
@@ -255,8 +255,8 @@
continue;
}
Value specializedArg;
- if (dynamicUpperBoundType.strictlyLessThan(originalArg.getTypeLattice(), appView)) {
- specializedArg = code.createValue(originalArg.getTypeLattice());
+ if (dynamicUpperBoundType.strictlyLessThan(originalArg.getType(), appView)) {
+ specializedArg = code.createValue(originalArg.getType());
affectedValues.addAll(originalArg.affectedValues());
originalArg.replaceUsers(specializedArg);
Assume<DynamicTypeAssumption> assumeType =
@@ -267,12 +267,12 @@
} else {
specializedArg = originalArg;
}
- assert specializedArg != null && specializedArg.getTypeLattice().isReference();
+ assert specializedArg != null && specializedArg.getType().isReferenceType();
if (dynamicUpperBoundType.isDefinitelyNotNull()) {
// If we already knew `arg` is never null, e.g., receiver, skip adding non-null.
- if (!specializedArg.getTypeLattice().isDefinitelyNotNull()) {
- Value nonNullArg = code.createValue(
- specializedArg.getTypeLattice().asReferenceTypeLatticeElement().asMeetWithNotNull());
+ if (!specializedArg.getType().isDefinitelyNotNull()) {
+ Value nonNullArg =
+ code.createValue(specializedArg.getType().asReferenceType().asMeetWithNotNull());
affectedValues.addAll(specializedArg.affectedValues());
specializedArg.replaceUsers(nonNullArg);
Assume<NonNullAssumption> assumeNotNull =
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/ClassInitializerDefaultsOptimization.java b/src/main/java/com/android/tools/r8/ir/optimize/ClassInitializerDefaultsOptimization.java
index 1e02c2b..12975da 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/ClassInitializerDefaultsOptimization.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/ClassInitializerDefaultsOptimization.java
@@ -395,7 +395,7 @@
}
DexField field = put.getField();
Value value = put.value();
- TypeLatticeElement valueType = value.getTypeLattice();
+ TypeLatticeElement valueType = value.getType();
if (clazz.definesStaticField(field)) {
if (isReadBefore.contains(field)) {
// Promoting this put to a class constant would cause a previous static-get
@@ -439,7 +439,7 @@
isWrittenBefore.remove(field);
}
continue;
- } else if (valueType.isReference() && valueType.isDefinitelyNotNull()) {
+ } else if (valueType.isReferenceType() && valueType.isDefinitelyNotNull()) {
finalFieldPuts.put(field, put);
continue;
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/CodeRewriter.java b/src/main/java/com/android/tools/r8/ir/optimize/CodeRewriter.java
index f7755d4..63a796d 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/CodeRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/CodeRewriter.java
@@ -260,8 +260,8 @@
}
Value value = ifInstruction.lhs();
- if (!value.getTypeLattice().isReference()) {
- assert value.getTypeLattice().isPrimitive();
+ if (!value.getType().isReferenceType()) {
+ assert value.getType().isPrimitiveType();
continue;
}
@@ -1244,7 +1244,7 @@
// Make sure that we are only narrowing information here. Note, in cases where
// we cannot find the definition of types, computing lessThanOrEqual will
// return false unless it is object.
- if (argument.getTypeLattice().lessThanOrEqual(outValue.getTypeLattice(), appView)) {
+ if (argument.getType().lessThanOrEqual(outValue.getType(), appView)) {
affectedValues.addAll(outValue.affectedValues());
assumeDynamicTypeRemover.markUsersForRemoval(outValue);
mayHaveRemovedTrivialPhi |= outValue.numberOfPhiUsers() > 0;
@@ -1362,15 +1362,15 @@
// If the in-value is `null` and the cast-type is a float-array type, then trivial check-cast
// elimination may lead to verification errors. See b/123269162.
if (options.canHaveArtCheckCastVerifierBug()) {
- if (inValue.getTypeLattice().isNullType()
+ if (inValue.getType().isNullType()
&& castType.isArrayType()
&& castType.toBaseType(dexItemFactory).isFloatType()) {
return RemoveCheckCastInstructionIfTrivialResult.NO_REMOVALS;
}
}
- TypeLatticeElement inTypeLattice = inValue.getTypeLattice();
- TypeLatticeElement outTypeLattice = outValue.getTypeLattice();
+ TypeLatticeElement inTypeLattice = inValue.getType();
+ TypeLatticeElement outTypeLattice = outValue.getType();
TypeLatticeElement castTypeLattice =
TypeLatticeElement.fromDexType(castType, inTypeLattice.nullability(), appView);
@@ -1417,7 +1417,7 @@
}
Value inValue = instanceOf.value();
- TypeLatticeElement inType = inValue.getTypeLattice();
+ TypeLatticeElement inType = inValue.getType();
TypeLatticeElement instanceOfType =
TypeLatticeElement.fromDexType(instanceOf.type(), inType.nullability(), appView);
Value aliasValue = inValue.getAliasedValue();
@@ -1442,8 +1442,7 @@
if (result == InstanceOfResult.UNKNOWN) {
if (inType.isClassType()
- && isNeverInstantiatedDirectlyOrIndirectly(
- inType.asClassTypeLatticeElement().getClassType())) {
+ && isNeverInstantiatedDirectlyOrIndirectly(inType.asClassType().getClassType())) {
// The type of the in-value is a program class, and is never instantiated directly or
// indirectly. This, the in-value must be null, meaning that the instance-of instruction
// will always evaluate to false.
@@ -2053,8 +2052,8 @@
for (ConstInstruction value : values) {
stringValues.add(value.outValue());
}
- Value invokeValue = code.createValue(
- newArray.outValue().getTypeLattice(), newArray.getLocalInfo());
+ Value invokeValue =
+ code.createValue(newArray.outValue().getType(), newArray.getLocalInfo());
InvokeNewArray invoke =
new InvokeNewArray(dexItemFactory.stringArrayType, invokeValue, stringValues);
for (Value value : newArray.inValues()) {
@@ -2462,11 +2461,11 @@
} else if (theIf.getType() == Type.EQ || theIf.getType() == Type.NE) {
if (theIf.isZeroTest()) {
if (!lhs.isConstNumber()) {
- TypeLatticeElement l = lhs.getTypeLattice();
- if (l.isReference() && lhs.isNeverNull()) {
+ TypeLatticeElement l = lhs.getType();
+ if (l.isReferenceType() && lhs.isNeverNull()) {
simplifyIfWithKnownCondition(code, block, theIf, 1);
} else {
- if (!l.isPrimitive() && !l.isNullable()) {
+ if (!l.isPrimitiveType() && !l.isNullable()) {
simplifyIfWithKnownCondition(code, block, theIf, 1);
}
}
@@ -2721,12 +2720,12 @@
}
if (dominatorTree.get().dominatedBy(block, dominator)) {
- if (newValue.getTypeLattice().lessThanOrEqual(value.getTypeLattice(), appView)) {
+ if (newValue.getType().lessThanOrEqual(value.getType(), appView)) {
value.replaceUsers(newValue);
block.listIterator(code, constNumber).removeOrReplaceByDebugLocalRead();
constantWithValueIterator.remove();
changed = true;
- } else if (value.getTypeLattice().isNullType()) {
+ } else if (value.getType().isNullType()) {
// TODO(b/120257211): Need a mechanism to determine if `newValue` can be used at all of
// the use sites of `value` without introducing a type error.
}
@@ -2875,7 +2874,7 @@
(theIf.getType() == Type.EQ &&
trueNumber.isIntegerOne() &&
falseNumber.isIntegerZero())) {
- Value newOutValue = code.createValue(phi.getTypeLattice(), phi.getLocalInfo());
+ Value newOutValue = code.createValue(phi.getType(), phi.getLocalInfo());
ConstNumber cstToUse = trueNumber.isIntegerOne() ? trueNumber : falseNumber;
BasicBlock phiBlock = phi.getBlock();
Position phiPosition = phiBlock.getPosition();
@@ -3388,7 +3387,7 @@
eol.link(successor);
Value argument = arguments.get(i);
- if (!argument.getTypeLattice().isReference()) {
+ if (!argument.getType().isReferenceType()) {
iterator.add(new InvokeVirtual(print, null, ImmutableList.of(out, primitive)));
} else {
// Insert "if (argument != null) ...".
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/DefaultInliningOracle.java b/src/main/java/com/android/tools/r8/ir/optimize/DefaultInliningOracle.java
index 463bfce..d225220 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/DefaultInliningOracle.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/DefaultInliningOracle.java
@@ -250,7 +250,7 @@
for (int index = 0; index < arguments.size(); index++) {
Value argument = arguments.get(index);
if ((argument.isArgument()
- || (argument.getTypeLattice().isReference() && argument.isNeverNull()))
+ || (argument.getType().isReferenceType() && argument.isNeverNull()))
&& hints.get(index)) {
// 5-4 instructions per parameter check are expected to be removed.
instructionLimit += 4;
@@ -304,15 +304,15 @@
Reason reason,
WhyAreYouNotInliningReporter whyAreYouNotInliningReporter) {
Value receiver = invoke.getReceiver();
- if (receiver.getTypeLattice().isDefinitelyNull()) {
+ if (receiver.getType().isDefinitelyNull()) {
// A definitely null receiver will throw an error on call site.
whyAreYouNotInliningReporter.reportReceiverDefinitelyNull();
return null;
}
InlineAction action = new InlineAction(singleTarget, invoke, reason);
- if (receiver.getTypeLattice().isNullable()) {
- assert !receiver.getTypeLattice().isDefinitelyNull();
+ if (receiver.getType().isNullable()) {
+ assert !receiver.getType().isDefinitelyNull();
// When inlining an instance method call, we need to preserve the null check for the
// receiver. Therefore, if the receiver may be null and the candidate inlinee does not
// throw if the receiver is null before any other side effect, then we must synthesize a
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/Devirtualizer.java b/src/main/java/com/android/tools/r8/ir/optimize/Devirtualizer.java
index 0c53a4c..0beedcb 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/Devirtualizer.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/Devirtualizer.java
@@ -101,8 +101,8 @@
// the out-value of the cast instruction is a more precise type than the in-value,
// otherwise we could introduce type errors.
Value oldReceiver = newCheckCast.object();
- TypeLatticeElement oldReceiverType = oldReceiver.getTypeLattice();
- TypeLatticeElement newReceiverType = newReceiver.getTypeLattice();
+ TypeLatticeElement oldReceiverType = oldReceiver.getType();
+ TypeLatticeElement newReceiverType = newReceiver.getType();
if (newReceiverType.lessThanOrEqual(oldReceiverType, appView)
&& dominatorTree.dominatedBy(block, devirtualizedInvoke.getBlock())) {
assert nonNull.src() == oldReceiver;
@@ -166,7 +166,7 @@
// (out <-) invoke-virtual a, ... A#foo
if (holderType != invoke.getInvokedMethod().holder) {
Value receiver = invoke.getReceiver();
- TypeLatticeElement receiverTypeLattice = receiver.getTypeLattice();
+ TypeLatticeElement receiverTypeLattice = receiver.getType();
TypeLatticeElement castTypeLattice =
TypeLatticeElement.fromDexType(
holderType, receiverTypeLattice.nullability(), appView);
@@ -262,7 +262,7 @@
*/
private DexMethod rebindVirtualInvokeToMostSpecific(
DexMethod target, Value receiver, DexType context) {
- if (!receiver.getTypeLattice().isClassType()) {
+ if (!receiver.getType().isClassType()) {
return target;
}
DexEncodedMethod encodedTarget = appView.definitionFor(target);
@@ -273,9 +273,7 @@
return target;
}
DexType receiverType =
- appView
- .graphLense()
- .lookupType(receiver.getTypeLattice().asClassTypeLatticeElement().getClassType());
+ appView.graphLense().lookupType(receiver.getType().asClassType().getClassType());
if (receiverType == target.holder) {
// Virtual invoke is already as specific as it can get.
return target;
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/DynamicTypeOptimization.java b/src/main/java/com/android/tools/r8/ir/optimize/DynamicTypeOptimization.java
index 0a314aa..ce43448 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/DynamicTypeOptimization.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/DynamicTypeOptimization.java
@@ -110,14 +110,14 @@
Value outValue = current.outValue();
boolean isTrivial =
(dynamicUpperBoundType == null
- || !dynamicUpperBoundType.strictlyLessThan(outValue.getTypeLattice(), appView))
+ || !dynamicUpperBoundType.strictlyLessThan(outValue.getType(), appView))
&& dynamicLowerBoundType == null;
if (isTrivial) {
continue;
}
if (dynamicUpperBoundType == null) {
- dynamicUpperBoundType = outValue.getTypeLattice();
+ dynamicUpperBoundType = outValue.getType();
}
// Split block if needed (only debug instructions are allowed after the throwing
@@ -126,8 +126,7 @@
block.hasCatchHandlers() ? instructionIterator.split(code, blockIterator) : block;
// Replace usages of out-value by the out-value of the AssumeDynamicType instruction.
- Value specializedOutValue =
- code.createValue(outValue.getTypeLattice(), outValue.getLocalInfo());
+ Value specializedOutValue = code.createValue(outValue.getType(), outValue.getLocalInfo());
outValue.replaceUsers(specializedOutValue);
// Insert AssumeDynamicType instruction.
@@ -184,7 +183,7 @@
result = dynamicLowerBoundType;
} else if (dynamicLowerBoundType.equalUpToNullability(result)) {
if (dynamicLowerBoundType.nullability() != result.nullability()) {
- result = dynamicLowerBoundType.join(result, appView).asClassTypeLatticeElement();
+ result = dynamicLowerBoundType.join(result, appView).asClassType();
}
} else {
return null;
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/IdempotentFunctionCallCanonicalizer.java b/src/main/java/com/android/tools/r8/ir/optimize/IdempotentFunctionCallCanonicalizer.java
index ebf6e57..5dba772 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/IdempotentFunctionCallCanonicalizer.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/IdempotentFunctionCallCanonicalizer.java
@@ -149,7 +149,7 @@
// Check if the call could throw a NPE as a result of the receiver being null.
if (current.isInvokeMethodWithReceiver()) {
Value receiver = current.asInvokeMethodWithReceiver().getReceiver().getAliasedValue();
- if (receiver.getTypeLattice().isNullable()) {
+ if (receiver.getType().isNullable()) {
continue;
}
}
@@ -195,39 +195,42 @@
.filter(a -> a.getValue().size() > 1)
.sorted((a, b) -> Integer.compare(b.getValue().size(), a.getValue().size()))
.limit(MAX_CANONICALIZED_CALL)
- .forEach((entry) -> {
- InvokeMethod invoke = entry.getKey();
- if (Log.ENABLED) {
- if (factory.libraryMethodsWithReturnValueDependingOnlyOnArguments
- .contains(invoke.getInvokedMethod())) {
- numberOfLibraryCallCanonicalization += entry.getValue().size() - 1;
- } else {
- numberOfProgramCallCanonicalization += entry.getValue().size() - 1;
- }
- }
- Value canonicalizedValue = code.createValue(
- invoke.outValue().getTypeLattice(), invoke.outValue().getLocalInfo());
- Invoke canonicalizedInvoke =
- Invoke.create(
- invoke.getType(),
- invoke.getInvokedMethod(),
- null,
- canonicalizedValue,
- invoke.inValues());
- // Note that it is fine to use any position, since the invoke has no side effects, which
- // is guaranteed not to throw. That is, we will never have a stack trace with this call.
- // Nonetheless, here we pick the position of the very first invocation.
- Position firstInvocationPosition = entry.getValue().get(0).definition.getPosition();
- canonicalizedInvoke.setPosition(firstInvocationPosition);
- if (invoke.inValues().size() > 0) {
- insertCanonicalizedInvokeWithInValues(code, canonicalizedInvoke);
- } else {
- insertCanonicalizedInvokeWithoutInValues(code, canonicalizedInvoke);
- }
- for (Value oldOutValue : entry.getValue()) {
- deadInvocations.put(oldOutValue.definition.asInvokeMethod(), canonicalizedValue);
- }
- });
+ .forEach(
+ (entry) -> {
+ InvokeMethod invoke = entry.getKey();
+ if (Log.ENABLED) {
+ if (factory.libraryMethodsWithReturnValueDependingOnlyOnArguments.contains(
+ invoke.getInvokedMethod())) {
+ numberOfLibraryCallCanonicalization += entry.getValue().size() - 1;
+ } else {
+ numberOfProgramCallCanonicalization += entry.getValue().size() - 1;
+ }
+ }
+ Value canonicalizedValue =
+ code.createValue(invoke.outValue().getType(), invoke.outValue().getLocalInfo());
+ Invoke canonicalizedInvoke =
+ Invoke.create(
+ invoke.getType(),
+ invoke.getInvokedMethod(),
+ null,
+ canonicalizedValue,
+ invoke.inValues());
+ // Note that it is fine to use any position, since the invoke has no side effects,
+ // which
+ // is guaranteed not to throw. That is, we will never have a stack trace with this
+ // call.
+ // Nonetheless, here we pick the position of the very first invocation.
+ Position firstInvocationPosition = entry.getValue().get(0).definition.getPosition();
+ canonicalizedInvoke.setPosition(firstInvocationPosition);
+ if (invoke.inValues().size() > 0) {
+ insertCanonicalizedInvokeWithInValues(code, canonicalizedInvoke);
+ } else {
+ insertCanonicalizedInvokeWithoutInValues(code, canonicalizedInvoke);
+ }
+ for (Value oldOutValue : entry.getValue()) {
+ deadInvocations.put(oldOutValue.definition.asInvokeMethod(), canonicalizedValue);
+ }
+ });
if (!deadInvocations.isEmpty()) {
for (BasicBlock block : code.blocks) {
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/MemberValuePropagation.java b/src/main/java/com/android/tools/r8/ir/optimize/MemberValuePropagation.java
index 7e25c8a..26c007e 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/MemberValuePropagation.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/MemberValuePropagation.java
@@ -139,7 +139,7 @@
.createMaterializingInstruction(appView, code, instruction);
}
- TypeLatticeElement typeLattice = instruction.outValue().getTypeLattice();
+ TypeLatticeElement typeLattice = instruction.outValue().getType();
if (returnValueRule.isField()) {
DexField field = returnValueRule.getField();
assert typeLattice
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/NonNullTracker.java b/src/main/java/com/android/tools/r8/ir/optimize/NonNullTracker.java
index 4fa0312..358ecd0 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/NonNullTracker.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/NonNullTracker.java
@@ -214,10 +214,10 @@
if (knownToBeNonNullValue.isArgument()
|| !dominatedUsers.isEmpty()
|| !dominatedPhiUsersWithPositions.isEmpty()) {
- TypeLatticeElement typeLattice = knownToBeNonNullValue.getTypeLattice();
+ TypeLatticeElement typeLattice = knownToBeNonNullValue.getType();
Value nonNullValue =
code.createValue(
- typeLattice.asReferenceTypeLatticeElement().asMeetWithNotNull(),
+ typeLattice.asReferenceType().asMeetWithNotNull(),
knownToBeNonNullValue.getLocalInfo());
affectedValues.addAll(knownToBeNonNullValue.affectedValues());
Assume<NonNullAssumption> nonNull =
@@ -316,11 +316,11 @@
// ...
// A: non_null_rcv <- non-null(rcv)
// ...y
- TypeLatticeElement typeLattice = knownToBeNonNullValue.getTypeLattice();
- assert typeLattice.isReference();
+ TypeLatticeElement typeLattice = knownToBeNonNullValue.getType();
+ assert typeLattice.isReferenceType();
Value nonNullValue =
code.createValue(
- typeLattice.asReferenceTypeLatticeElement().asMeetWithNotNull(),
+ typeLattice.asReferenceType().asMeetWithNotNull(),
knownToBeNonNullValue.getLocalInfo());
affectedValues.addAll(knownToBeNonNullValue.affectedValues());
Assume<NonNullAssumption> nonNull =
@@ -369,9 +369,9 @@
}
private static boolean isNullableReferenceTypeWithUsers(Value value) {
- TypeLatticeElement type = value.getTypeLattice();
- return type.isReference()
- && type.asReferenceTypeLatticeElement().isNullable()
+ TypeLatticeElement type = value.getType();
+ return type.isReferenceType()
+ && type.asReferenceType().isNullable()
&& value.numberOfAllUsers() > 0;
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/Outliner.java b/src/main/java/com/android/tools/r8/ir/optimize/Outliner.java
index 4ce7ede..c82971f 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/Outliner.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/Outliner.java
@@ -4,9 +4,9 @@
package com.android.tools.r8.ir.optimize;
+import static com.android.tools.r8.graph.DexProgramClass.asProgramClassOrNull;
import static com.android.tools.r8.ir.analysis.type.Nullability.definitelyNotNull;
import static com.android.tools.r8.ir.analysis.type.Nullability.maybeNull;
-import static com.android.tools.r8.graph.DexProgramClass.asProgramClassOrNull;
import com.android.tools.r8.dex.Constants;
import com.android.tools.r8.errors.Unreachable;
@@ -933,7 +933,7 @@
private boolean supportedArgumentType(Value value) {
// All non array types are supported.
- if (!value.getTypeLattice().isArrayType()) {
+ if (!value.getType().isArrayType()) {
return true;
}
// Avoid array type elements which have interfaces, as Art does not have the same semantics
@@ -942,14 +942,13 @@
&& appView.options().isGeneratingClassFiles()) {
return true;
}
- ArrayTypeLatticeElement arrayTypeLatticeElement =
- value.getTypeLattice().asArrayTypeLatticeElement();
- TypeLatticeElement arrayBaseType = arrayTypeLatticeElement.getArrayBaseTypeLattice();
- if (arrayBaseType.isPrimitive()) {
+ ArrayTypeLatticeElement arrayTypeLatticeElement = value.getType().asArrayType();
+ TypeLatticeElement arrayBaseType = arrayTypeLatticeElement.getBaseType();
+ if (arrayBaseType.isPrimitiveType()) {
return true;
}
if (arrayBaseType.isClassType()) {
- return arrayBaseType.asClassTypeLatticeElement().getInterfaces().size() == 0;
+ return arrayBaseType.asClassType().getInterfaces().size() == 0;
}
return false;
}
@@ -958,10 +957,9 @@
assert supportedArgumentType(value);
DexItemFactory itemFactory = appView.options().itemFactory;
DexType objectType = itemFactory.objectType;
- TypeLatticeElement valueLatticeElement = value.getTypeLattice();
+ TypeLatticeElement valueLatticeElement = value.getType();
if (valueLatticeElement.isClassType()) {
- ClassTypeLatticeElement valueClassTypeLatticeElement =
- value.getTypeLattice().asClassTypeLatticeElement();
+ ClassTypeLatticeElement valueClassTypeLatticeElement = value.getType().asClassType();
// For values of lattice type java.lang.Object and only one interface use the interface as
// the type of the outline argument. If there are several interfaces these interfaces don't
// have a common super interface nor are they implemented by a common superclass so the
@@ -973,14 +971,14 @@
return valueClassTypeLatticeElement.getClassType();
}
} else if (valueLatticeElement.isArrayType()) {
- return value.getTypeLattice().asArrayTypeLatticeElement().getArrayType(itemFactory);
+ return value.getType().asArrayType().toDexType(itemFactory);
} else if (valueLatticeElement.isNullType()) {
// For values which are always null use the actual type at the call site.
return argumentTypeFromInvoke(invoke, argumentIndex);
} else {
- assert valueLatticeElement.isPrimitive();
- assert valueLatticeElement.asPrimitiveTypeLatticeElement().hasDexType();
- DexType type = valueLatticeElement.asPrimitiveTypeLatticeElement().toDexType(itemFactory);
+ assert valueLatticeElement.isPrimitiveType();
+ assert valueLatticeElement.asPrimitiveType().hasDexType();
+ DexType type = valueLatticeElement.asPrimitiveType().toDexType(itemFactory);
if (valueLatticeElement.isInt()) {
// In the type lattice boolean, byte, short and char are all int. However, as the
// outline argument type use the actual primitive type at the call site.
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/ReflectionOptimizer.java b/src/main/java/com/android/tools/r8/ir/optimize/ReflectionOptimizer.java
index 055eeca..c0ccaf1 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/ReflectionOptimizer.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/ReflectionOptimizer.java
@@ -90,7 +90,7 @@
if (in.hasLocalInfo()) {
return null;
}
- TypeLatticeElement inType = in.getTypeLattice();
+ TypeLatticeElement inType = in.getType();
// Check the receiver is either class type or array type. Also make sure it is not
// nullable.
if (!(inType.isClassType() || inType.isArrayType())
@@ -99,8 +99,8 @@
}
DexType type =
inType.isClassType()
- ? inType.asClassTypeLatticeElement().getClassType()
- : inType.asArrayTypeLatticeElement().getArrayType(dexItemFactory);
+ ? inType.asClassType().getClassType()
+ : inType.asArrayType().toDexType(dexItemFactory);
DexType baseType = type.toBaseType(dexItemFactory);
// Make sure base type is a class type.
if (!baseType.isClassType()) {
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/ServiceLoaderRewriter.java b/src/main/java/com/android/tools/r8/ir/optimize/ServiceLoaderRewriter.java
index e8799da..d626168 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/ServiceLoaderRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/ServiceLoaderRewriter.java
@@ -135,7 +135,7 @@
InvokeVirtual classLoaderInvoke =
serviceLoaderLoad.inValues().get(1).definition.asInvokeVirtual();
boolean isGetClassLoaderOnConstClassOrNull =
- serviceLoaderLoad.inValues().get(1).getTypeLattice().isNullType()
+ serviceLoaderLoad.inValues().get(1).getType().isNullType()
|| (classLoaderInvoke != null
&& classLoaderInvoke.inValues().size() == 1
&& classLoaderInvoke.getReceiver().getAliasedValue().isConstClass()
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/classinliner/ClassInlinerReceiverAnalysis.java b/src/main/java/com/android/tools/r8/ir/optimize/classinliner/ClassInlinerReceiverAnalysis.java
index f6e6e70..52a2bde 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/classinliner/ClassInlinerReceiverAnalysis.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/classinliner/ClassInlinerReceiverAnalysis.java
@@ -47,7 +47,7 @@
this.code = code;
this.receiver = code.getThis();
assert !receiver.hasAliasedValue();
- assert receiver.getTypeLattice().isClassType();
+ assert receiver.getType().isClassType();
}
public OptionalBool computeReturnsReceiver() {
@@ -87,12 +87,12 @@
return OptionalBool.TRUE;
}
- ClassTypeLatticeElement valueType = value.getTypeLattice().asClassTypeLatticeElement();
+ ClassTypeLatticeElement valueType = value.getType().asClassType();
if (valueType == null) {
return OptionalBool.FALSE;
}
- ClassTypeLatticeElement receiverType = receiver.getTypeLattice().asClassTypeLatticeElement();
+ ClassTypeLatticeElement receiverType = receiver.getType().asClassType();
if (!valueType.isRelatedTo(receiverType, appView)) {
// Guaranteed not to return the receiver.
return OptionalBool.FALSE;
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/classinliner/FieldValueHelper.java b/src/main/java/com/android/tools/r8/ir/optimize/classinliner/FieldValueHelper.java
index 832e8b9..bcc7f7c 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/classinliner/FieldValueHelper.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/classinliner/FieldValueHelper.java
@@ -113,8 +113,8 @@
phi.addOperands(operands, false);
TypeLatticeElement phiType = phi.computePhiType(appView);
- assert phiType.lessThanOrEqual(phi.getTypeLattice(), appView);
- phi.setTypeLattice(phiType);
+ assert phiType.lessThanOrEqual(phi.getType(), appView);
+ phi.setType(phiType);
value = phi;
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/classinliner/InlineCandidateProcessor.java b/src/main/java/com/android/tools/r8/ir/optimize/classinliner/InlineCandidateProcessor.java
index 22344de..78a3ef9 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/classinliner/InlineCandidateProcessor.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/classinliner/InlineCandidateProcessor.java
@@ -1031,7 +1031,7 @@
}
// A definitely null receiver will throw an error on call site.
- if (receiver.getTypeLattice().nullability().isDefinitelyNull()) {
+ if (receiver.getType().nullability().isDefinitelyNull()) {
return false;
}
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/enums/EnumUnboxer.java b/src/main/java/com/android/tools/r8/ir/optimize/enums/EnumUnboxer.java
index fb02388..865bb11 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/enums/EnumUnboxer.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/enums/EnumUnboxer.java
@@ -110,14 +110,13 @@
private DexProgramClass getEnumUnboxingCandidateOrNull(TypeLatticeElement lattice) {
if (lattice.isClassType()) {
- DexType classType = lattice.asClassTypeLatticeElement().getClassType();
+ DexType classType = lattice.asClassType().getClassType();
return getEnumUnboxingCandidateOrNull(classType);
}
if (lattice.isArrayType()) {
- ArrayTypeLatticeElement arrayLattice = lattice.asArrayTypeLatticeElement();
- if (arrayLattice.getArrayBaseTypeLattice().isClassType()) {
- DexType classType =
- arrayLattice.getArrayBaseTypeLattice().asClassTypeLatticeElement().getClassType();
+ ArrayTypeLatticeElement arrayLattice = lattice.asArrayType();
+ if (arrayLattice.getBaseType().isClassType()) {
+ DexType classType = arrayLattice.getBaseType().asClassType().getClassType();
return getEnumUnboxingCandidateOrNull(classType);
}
}
@@ -137,7 +136,7 @@
for (Instruction instruction : block.getInstructions()) {
Value outValue = instruction.outValue();
if (outValue != null) {
- DexProgramClass enumClass = getEnumUnboxingCandidateOrNull(outValue.getTypeLattice());
+ DexProgramClass enumClass = getEnumUnboxingCandidateOrNull(outValue.getType());
if (enumClass != null) {
Reason reason = validateEnumUsages(code, outValue, enumClass);
if (reason == Reason.ELIGIBLE) {
@@ -149,7 +148,7 @@
eligibleEnums.add(enumClass.type);
}
}
- if (outValue.getTypeLattice().isNullType()) {
+ if (outValue.getType().isNullType()) {
addNullDependencies(outValue.uniqueUsers(), eligibleEnums);
}
}
@@ -181,14 +180,14 @@
}
}
for (Phi phi : block.getPhis()) {
- DexProgramClass enumClass = getEnumUnboxingCandidateOrNull(phi.getTypeLattice());
+ DexProgramClass enumClass = getEnumUnboxingCandidateOrNull(phi.getType());
if (enumClass != null) {
Reason reason = validateEnumUsages(code, phi, enumClass);
if (reason == Reason.ELIGIBLE) {
eligibleEnums.add(enumClass.type);
}
}
- if (phi.getTypeLattice().isNullType()) {
+ if (phi.getType().isNullType()) {
addNullDependencies(phi.uniqueUsers(), eligibleEnums);
}
}
@@ -241,7 +240,7 @@
}
for (Phi phi : value.uniquePhiUsers()) {
for (Value operand : phi.getOperands()) {
- if (getEnumUnboxingCandidateOrNull(operand.getTypeLattice()) != enumClass) {
+ if (getEnumUnboxingCandidateOrNull(operand.getType()) != enumClass) {
markEnumAsUnboxable(Reason.INVALID_PHI, enumClass);
return Reason.INVALID_PHI;
}
@@ -437,11 +436,11 @@
return Reason.ELIGIBLE;
}
// e == MyEnum.X
- TypeLatticeElement leftType = anIf.lhs().getTypeLattice();
- TypeLatticeElement rightType = anIf.rhs().getTypeLattice();
+ TypeLatticeElement leftType = anIf.lhs().getType();
+ TypeLatticeElement rightType = anIf.rhs().getType();
if (leftType.equalUpToNullability(rightType)) {
assert leftType.isClassType();
- assert leftType.asClassTypeLatticeElement().getClassType() == enumClass.type;
+ assert leftType.asClassType().getClassType() == enumClass.type;
return Reason.ELIGIBLE;
}
return Reason.INVALID_IF_TYPES;
@@ -464,20 +463,15 @@
// We need to prove that the value to put in and the array have correct types.
ArrayPut arrayPut = instruction.asArrayPut();
assert arrayPut.getMemberType() == MemberType.OBJECT;
- TypeLatticeElement arrayType = arrayPut.array().getTypeLattice();
+ TypeLatticeElement arrayType = arrayPut.array().getType();
assert arrayType.isArrayType();
- assert arrayType.asArrayTypeLatticeElement().getArrayBaseTypeLattice().isClassType();
- ClassTypeLatticeElement arrayBaseType =
- arrayType
- .asArrayTypeLatticeElement()
- .getArrayBaseTypeLattice()
- .asClassTypeLatticeElement();
- TypeLatticeElement valueBaseType = arrayPut.value().getTypeLattice();
+ assert arrayType.asArrayType().getBaseType().isClassType();
+ ClassTypeLatticeElement arrayBaseType = arrayType.asArrayType().getBaseType().asClassType();
+ TypeLatticeElement valueBaseType = arrayPut.value().getType();
if (valueBaseType.isArrayType()) {
- assert valueBaseType.asArrayTypeLatticeElement().getArrayBaseTypeLattice().isClassType();
- assert valueBaseType.asArrayTypeLatticeElement().getNesting()
- == arrayType.asArrayTypeLatticeElement().getNesting() - 1;
- valueBaseType = valueBaseType.asArrayTypeLatticeElement().getArrayBaseTypeLattice();
+ assert valueBaseType.asArrayType().getBaseType().isClassType();
+ assert valueBaseType.asArrayType().getNesting() == arrayType.asArrayType().getNesting() - 1;
+ valueBaseType = valueBaseType.asArrayType().getBaseType();
}
if (arrayBaseType.equalUpToNullability(valueBaseType)
&& arrayBaseType.getClassType() == enumClass.type) {
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/enums/EnumUnboxingRewriter.java b/src/main/java/com/android/tools/r8/ir/optimize/enums/EnumUnboxingRewriter.java
index 1514d99..dff61a2 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/enums/EnumUnboxingRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/enums/EnumUnboxingRewriter.java
@@ -99,7 +99,7 @@
InvokeMethodWithReceiver invokeMethod = instruction.asInvokeMethodWithReceiver();
DexMethod invokedMethod = invokeMethod.getInvokedMethod();
if (invokedMethod == factory.enumMethods.ordinal
- && invokeMethod.getReceiver().getTypeLattice().isInt()) {
+ && invokeMethod.getReceiver().getType().isInt()) {
instruction =
new InvokeStatic(
ordinalUtilityMethod, invokeMethod.outValue(), invokeMethod.inValues());
@@ -127,7 +127,7 @@
instruction = new ConstNumber(staticGet.outValue(), enumValueInfo.convertToInt());
staticGet
.outValue()
- .setTypeLattice(PrimitiveTypeLatticeElement.fromNumericType(NumericType.INT));
+ .setType(PrimitiveTypeLatticeElement.fromNumericType(NumericType.INT));
iterator.replaceCurrentInstruction(instruction);
affectedPhis.addAll(staticGet.outValue().uniquePhiUsers());
}
@@ -149,34 +149,30 @@
}
private boolean shouldRewriteArrayAccess(ArrayAccess arrayAccess) {
- ArrayTypeLatticeElement arrayType =
- arrayAccess.array().getTypeLattice().asArrayTypeLatticeElement();
+ ArrayTypeLatticeElement arrayType = arrayAccess.array().getType().asArrayType();
return arrayAccess.getMemberType() == MemberType.OBJECT
&& arrayType.getNesting() == 1
- && arrayType.getArrayBaseTypeLattice().isInt();
+ && arrayType.getBaseType().isInt();
}
private boolean validateEnumToUnboxRemoved(Instruction instruction) {
if (instruction.isArrayAccess()) {
ArrayAccess arrayAccess = instruction.asArrayAccess();
- ArrayTypeLatticeElement arrayType =
- arrayAccess.array().getTypeLattice().asArrayTypeLatticeElement();
+ ArrayTypeLatticeElement arrayType = arrayAccess.array().getType().asArrayType();
assert arrayAccess.getMemberType() != MemberType.OBJECT
|| arrayType.getNesting() > 1
- || arrayType.getArrayBaseTypeLattice().isReference();
+ || arrayType.getBaseType().isReferenceType();
}
if (instruction.outValue() == null) {
return true;
}
- TypeLatticeElement typeLattice = instruction.outValue().getTypeLattice();
+ TypeLatticeElement typeLattice = instruction.outValue().getType();
assert !typeLattice.isClassType()
- || !enumsToUnbox.containsEnum(typeLattice.asClassTypeLatticeElement().getClassType());
+ || !enumsToUnbox.containsEnum(typeLattice.asClassType().getClassType());
if (typeLattice.isArrayType()) {
- TypeLatticeElement arrayBaseTypeLattice =
- typeLattice.asArrayTypeLatticeElement().getArrayBaseTypeLattice();
+ TypeLatticeElement arrayBaseTypeLattice = typeLattice.asArrayType().getBaseType();
assert !arrayBaseTypeLattice.isClassType()
- || !enumsToUnbox.containsEnum(
- arrayBaseTypeLattice.asClassTypeLatticeElement().getClassType());
+ || !enumsToUnbox.containsEnum(arrayBaseTypeLattice.asClassType().getClassType());
}
return true;
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/info/ConcreteCallSiteOptimizationInfo.java b/src/main/java/com/android/tools/r8/ir/optimize/info/ConcreteCallSiteOptimizationInfo.java
index 702074a..c1e893e 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/info/ConcreteCallSiteOptimizationInfo.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/info/ConcreteCallSiteOptimizationInfo.java
@@ -65,9 +65,9 @@
assert other.getDynamicUpperBoundType(i) == null;
continue;
}
- assert thisUpperBoundType.isReference();
+ assert thisUpperBoundType.isReferenceType();
TypeLatticeElement otherUpperBoundType = other.getDynamicUpperBoundType(i);
- assert otherUpperBoundType != null && otherUpperBoundType.isReference();
+ assert otherUpperBoundType != null && otherUpperBoundType.isReferenceType();
result.dynamicUpperBoundTypes.put(
i, thisUpperBoundType.join(otherUpperBoundType, appView));
}
@@ -111,7 +111,7 @@
return true;
}
- if (!staticTypes[i].isReference()) {
+ if (!staticTypes[i].isReferenceType()) {
continue;
}
TypeLatticeElement dynamicUpperBoundType = getDynamicUpperBoundType(i);
@@ -176,10 +176,10 @@
}
}
- if (arg.getTypeLattice().isPrimitive()) {
+ if (arg.getType().isPrimitiveType()) {
continue;
}
- assert arg.getTypeLattice().isReference();
+ assert arg.getType().isReferenceType();
newCallSiteInfo.dynamicUpperBoundTypes.put(i, arg.getDynamicUpperBoundType(appView));
}
if (newCallSiteInfo.hasUsefulOptimizationInfo(appView, method)) {
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/info/MethodOptimizationInfoCollector.java b/src/main/java/com/android/tools/r8/ir/optimize/info/MethodOptimizationInfoCollector.java
index 50158e6..373c4b3 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/info/MethodOptimizationInfoCollector.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/info/MethodOptimizationInfoCollector.java
@@ -357,14 +357,14 @@
return;
}
Value returnValue = firstExit.returnValue();
- boolean isNeverNull = returnValue.getTypeLattice().isReference() && returnValue.isNeverNull();
+ boolean isNeverNull = returnValue.getType().isReferenceType() && returnValue.isNeverNull();
for (int i = 1; i < normalExits.size(); i++) {
Return exit = normalExits.get(i).exit().asReturn();
Value value = exit.returnValue();
if (value != returnValue) {
returnValue = null;
}
- isNeverNull &= value.getTypeLattice().isReference() && value.isNeverNull();
+ isNeverNull &= value.getType().isReferenceType() && value.isNeverNull();
}
if (returnValue != null) {
Value aliasedValue = returnValue.getAliasedValue();
@@ -1156,7 +1156,7 @@
for (int index = 0; index < arguments.size(); index++) {
Value argument = arguments.get(index);
// Consider reference-type parameter only.
- if (!argument.getTypeLattice().isReference()) {
+ if (!argument.getType().isReferenceType()) {
continue;
}
// The receiver is always non-null on normal exits.
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/info/MutableFieldOptimizationInfo.java b/src/main/java/com/android/tools/r8/ir/optimize/info/MutableFieldOptimizationInfo.java
index f7a4b57..c6a2a84 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/info/MutableFieldOptimizationInfo.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/info/MutableFieldOptimizationInfo.java
@@ -43,9 +43,9 @@
TypeLatticeElement dynamicLowerBoundType =
this.dynamicLowerBoundType.fixupClassTypeReferences(mapping, appView);
if (dynamicLowerBoundType.isClassType()) {
- this.dynamicLowerBoundType = dynamicLowerBoundType.asClassTypeLatticeElement();
+ this.dynamicLowerBoundType = dynamicLowerBoundType.asClassType();
} else {
- assert dynamicLowerBoundType.isPrimitive();
+ assert dynamicLowerBoundType.isPrimitiveType();
this.dynamicLowerBoundType = null;
this.dynamicUpperBoundType = null;
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/info/UpdatableMethodOptimizationInfo.java b/src/main/java/com/android/tools/r8/ir/optimize/info/UpdatableMethodOptimizationInfo.java
index f50a3d1..e74e771 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/info/UpdatableMethodOptimizationInfo.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/info/UpdatableMethodOptimizationInfo.java
@@ -152,10 +152,9 @@
TypeLatticeElement returnsObjectWithLowerBoundType =
this.returnsObjectWithLowerBoundType.fixupClassTypeReferences(mapping, appView);
if (returnsObjectWithLowerBoundType.isClassType()) {
- this.returnsObjectWithLowerBoundType =
- returnsObjectWithLowerBoundType.asClassTypeLatticeElement();
+ this.returnsObjectWithLowerBoundType = returnsObjectWithLowerBoundType.asClassType();
} else {
- assert returnsObjectWithLowerBoundType.isPrimitive();
+ assert returnsObjectWithLowerBoundType.isPrimitiveType();
this.returnsObjectWithUpperBoundType = DefaultMethodOptimizationInfo.UNKNOWN_TYPE;
this.returnsObjectWithLowerBoundType = DefaultMethodOptimizationInfo.UNKNOWN_CLASS_TYPE;
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/info/field/InstanceFieldTypeInitializationInfo.java b/src/main/java/com/android/tools/r8/ir/optimize/info/field/InstanceFieldTypeInitializationInfo.java
index 91d1aef..a66ec87 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/info/field/InstanceFieldTypeInitializationInfo.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/info/field/InstanceFieldTypeInitializationInfo.java
@@ -56,8 +56,7 @@
return UnknownInstanceFieldInitializationInfo.getInstance();
}
if (dynamicUpperBoundType.isClassType()
- && unboxedEnums.containsEnum(
- dynamicUpperBoundType.asClassTypeLatticeElement().getClassType())) {
+ && unboxedEnums.containsEnum(dynamicUpperBoundType.asClassType().getClassType())) {
// No point in tracking the type of primitives.
return UnknownInstanceFieldInitializationInfo.getInstance();
}
@@ -65,7 +64,7 @@
dynamicLowerBoundType != null
? dynamicLowerBoundType
.fixupClassTypeReferences(lens::lookupType, appView.withSubtyping())
- .asClassTypeLatticeElement()
+ .asClassType()
: null,
dynamicUpperBoundType.fixupClassTypeReferences(lens::lookupType, appView.withSubtyping()));
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/lambda/LambdaMerger.java b/src/main/java/com/android/tools/r8/ir/optimize/lambda/LambdaMerger.java
index 510c122..ce2394c 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/lambda/LambdaMerger.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/lambda/LambdaMerger.java
@@ -594,8 +594,7 @@
// able to propagate the type information correctly, since lambda merging is neither a
// narrowing nor a widening.
for (Value value : transitivelyTypeAffectedValues) {
- value.setTypeLattice(
- value.getTypeLattice().fixupClassTypeReferences(optimizationInfoFixer, appView));
+ value.setType(value.getType().fixupClassTypeReferences(optimizationInfoFixer, appView));
}
// Filter out the type affected phis and destructively update the type of the phis. This is
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/library/ObjectsMethodOptimizer.java b/src/main/java/com/android/tools/r8/ir/optimize/library/ObjectsMethodOptimizer.java
index 975aca8..f76aeae 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/library/ObjectsMethodOptimizer.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/library/ObjectsMethodOptimizer.java
@@ -42,7 +42,7 @@
private void optimizeRequireNonNull(
InstructionListIterator instructionIterator, InvokeMethod invoke, Set<Value> affectedValues) {
Value inValue = invoke.inValues().get(0);
- if (inValue.getTypeLattice().isDefinitelyNotNull()) {
+ if (inValue.getType().isDefinitelyNotNull()) {
Value outValue = invoke.outValue();
if (outValue != null) {
affectedValues.addAll(outValue.affectedValues());
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/peepholes/DupDupDupPeephole.java b/src/main/java/com/android/tools/r8/ir/optimize/peepholes/DupDupDupPeephole.java
index 8d84870..b1b2eb54 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/peepholes/DupDupDupPeephole.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/peepholes/DupDupDupPeephole.java
@@ -28,11 +28,11 @@
public class DupDupDupPeephole implements BasicBlockPeephole {
private final Point dup1Exp =
- new Point((i) -> i.isDup() && !i.inValues().get(0).getTypeLattice().isWidePrimitive());
+ new Point((i) -> i.isDup() && !i.inValues().get(0).getType().isWidePrimitive());
private final Point dup2Exp =
- new Point((i) -> i.isDup() && !i.inValues().get(0).getTypeLattice().isWidePrimitive());
+ new Point((i) -> i.isDup() && !i.inValues().get(0).getType().isWidePrimitive());
private final Point dup3Exp =
- new Point((i) -> i.isDup() && !i.inValues().get(0).getTypeLattice().isWidePrimitive());
+ new Point((i) -> i.isDup() && !i.inValues().get(0).getType().isWidePrimitive());
private final PeepholeLayout layout = PeepholeLayout.lookBackward(dup1Exp, dup2Exp, dup3Exp);
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/peepholes/MoveLoadUpPeephole.java b/src/main/java/com/android/tools/r8/ir/optimize/peepholes/MoveLoadUpPeephole.java
index 49a74d1..c3ee52a 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/peepholes/MoveLoadUpPeephole.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/peepholes/MoveLoadUpPeephole.java
@@ -113,7 +113,7 @@
Instruction current = it.next();
if (position != current.getPosition()
|| !current.isConstNumber()
- || current.outValue().getTypeLattice() != TypeLatticeElement.getInt()
+ || current.outValue().getType() != TypeLatticeElement.getInt()
|| current.asConstNumber().getIntValue() < -128
|| current.asConstNumber().getIntValue() > 127
|| !it.hasNext()) {
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/peepholes/StoreSequenceLoadPeephole.java b/src/main/java/com/android/tools/r8/ir/optimize/peepholes/StoreSequenceLoadPeephole.java
index 421bdbf..1ff49d0 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/peepholes/StoreSequenceLoadPeephole.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/peepholes/StoreSequenceLoadPeephole.java
@@ -40,7 +40,7 @@
new Point(
(i) -> {
if (!i.isStore()
- || i.asStore().src().getTypeLattice().isWidePrimitive()
+ || i.asStore().src().getType().isWidePrimitive()
|| i.outValue().hasLocalInfo()
|| i.asStore().outValue().numberOfAllUsers() != 1) {
return false;
@@ -102,7 +102,7 @@
lastOut = stackValues[stackValues.length - 1];
}
- if (lastOut == null || lastOut.getTypeLattice().isWidePrimitive()) {
+ if (lastOut == null || lastOut.getType().isWidePrimitive()) {
return false;
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/staticizer/StaticizingProcessor.java b/src/main/java/com/android/tools/r8/ir/optimize/staticizer/StaticizingProcessor.java
index 9c8b4d5..af2c1bd 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/staticizer/StaticizingProcessor.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/staticizer/StaticizingProcessor.java
@@ -536,7 +536,7 @@
Value newValue = null;
Value outValue = invoke.outValue();
if (outValue != null) {
- newValue = code.createValue(outValue.getTypeLattice());
+ newValue = code.createValue(outValue.getType());
DebugLocalInfo localInfo = outValue.getLocalInfo();
if (localInfo != null) {
newValue.setLocalInfo(localInfo);
@@ -564,7 +564,7 @@
new StaticGet(
code.createValue(
TypeLatticeElement.fromDexType(
- field.type, outValue.getTypeLattice().nullability(), appView),
+ field.type, outValue.getType().nullability(), appView),
outValue.getLocalInfo()),
field));
}
@@ -593,7 +593,7 @@
? null
: code.createValue(
TypeLatticeElement.fromDexType(
- returnType, outValue.getTypeLattice().nullability(), appView),
+ returnType, outValue.getType().nullability(), appView),
outValue.getLocalInfo());
it.replaceCurrentInstruction(new InvokeStatic(newMethod, newOutValue, invoke.inValues()));
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/string/StringBuilderOptimizer.java b/src/main/java/com/android/tools/r8/ir/optimize/string/StringBuilderOptimizer.java
index 6c714c9..388bea7 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/string/StringBuilderOptimizer.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/string/StringBuilderOptimizer.java
@@ -294,8 +294,8 @@
}
// Make sure builder is neither phi nor coming from outside of the method.
assert !builder.isPhi() && builder.definition.isNewInstance();
- assert builder.getTypeLattice().isClassType();
- DexType builderType = builder.getTypeLattice().asClassTypeLatticeElement().getClassType();
+ assert builder.getType().isClassType();
+ DexType builderType = builder.getType().asClassType().getClassType();
assert optimizationConfiguration.isBuilderType(builderType);
EscapeAnalysis escapeAnalysis =
new EscapeAnalysis(
@@ -442,7 +442,7 @@
if (number == null) {
return addition;
}
- if (arg.getTypeLattice().isPrimitive()) {
+ if (arg.getType().isPrimitiveType()) {
if (argType == factory.booleanType) {
addition = String.valueOf(number.intValue() != 0);
} else if (argType == factory.byteType) {
@@ -460,7 +460,7 @@
} else if (argType == factory.doubleType) {
addition = String.valueOf(number.doubleValue());
}
- } else if (arg.getTypeLattice().isNullType()) {
+ } else if (arg.getType().isNullType()) {
assert number.intValue() == 0;
addition = "null";
}
@@ -815,7 +815,7 @@
public boolean isBuilderInitWithInitialValue(InvokeMethod invoke) {
return isBuilderInit(invoke.getInvokedMethod())
&& invoke.inValues().size() == 2
- && !invoke.inValues().get(1).getTypeLattice().isPrimitive();
+ && !invoke.inValues().get(1).getType().isPrimitiveType();
}
@Override
@@ -838,13 +838,13 @@
return false;
}
assert invoke.inValues().size() == 2;
- TypeLatticeElement argType = invoke.inValues().get(1).getTypeLattice();
- if (!argType.isPrimitive() && !argType.isClassType() && !argType.isNullType()) {
+ TypeLatticeElement argType = invoke.inValues().get(1).getType();
+ if (!argType.isPrimitiveType() && !argType.isClassType() && !argType.isNullType()) {
numberOfBuildersWithUnsupportedArg++;
return false;
}
if (argType.isClassType()) {
- DexType argClassType = argType.asClassTypeLatticeElement().getClassType();
+ DexType argClassType = argType.asClassType().getClassType();
return canHandleArgumentType(argClassType);
}
return true;
@@ -868,8 +868,8 @@
private StringBuilderOptimizerEscapeAnalysisConfiguration(Value builder) {
this.builder = builder;
- assert builder.getTypeLattice().isClassType();
- builderType = builder.getTypeLattice().asClassTypeLatticeElement().getClassType();
+ assert builder.getType().isClassType();
+ builderType = builder.getType().asClassType().getClassType();
}
private void logEscapingRoute(boolean legitimate) {
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/string/StringOptimizer.java b/src/main/java/com/android/tools/r8/ir/optimize/string/StringOptimizer.java
index 072f762..8bb429b 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/string/StringOptimizer.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/string/StringOptimizer.java
@@ -525,7 +525,7 @@
continue;
}
Value out = invoke.outValue();
- TypeLatticeElement inType = in.getTypeLattice();
+ TypeLatticeElement inType = in.getType();
if (out != null && in.isAlwaysNull(appView)) {
affectedValues.addAll(out.affectedValues());
Value nullStringValue =
@@ -538,7 +538,7 @@
numberOfSimplifiedConversions++;
} else if (inType.nullability().isDefinitelyNotNull()
&& inType.isClassType()
- && inType.asClassTypeLatticeElement().getClassType().equals(factory.stringType)) {
+ && inType.asClassType().getClassType().equals(factory.stringType)) {
if (out != null) {
affectedValues.addAll(out.affectedValues());
removeOrReplaceByDebugLocalWrite(invoke, it, in, out);
@@ -555,10 +555,10 @@
}
assert invoke.inValues().size() == 1;
Value in = invoke.getReceiver();
- TypeLatticeElement inType = in.getTypeLattice();
+ TypeLatticeElement inType = in.getType();
if (inType.nullability().isDefinitelyNotNull()
&& inType.isClassType()
- && inType.asClassTypeLatticeElement().getClassType().equals(factory.stringType)) {
+ && inType.asClassType().getClassType().equals(factory.stringType)) {
Value out = invoke.outValue();
if (out != null) {
affectedValues.addAll(out.affectedValues());
diff --git a/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java b/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java
index 5dcdbd8..15200bc 100644
--- a/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java
+++ b/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java
@@ -2800,7 +2800,7 @@
argument.isLinked() ||
argument == previous ||
argument.hasRegisterConstraint()) {
- newArgument = createValue(argument.getTypeLattice());
+ newArgument = createValue(argument.getType());
Move move = new Move(newArgument, argument);
move.setBlock(invoke.getBlock());
replaceArgument(invoke, i, newArgument);
diff --git a/src/main/java/com/android/tools/r8/ir/regalloc/RegisterMove.java b/src/main/java/com/android/tools/r8/ir/regalloc/RegisterMove.java
index dda59e6..78e06d7 100644
--- a/src/main/java/com/android/tools/r8/ir/regalloc/RegisterMove.java
+++ b/src/main/java/com/android/tools/r8/ir/regalloc/RegisterMove.java
@@ -82,14 +82,14 @@
if (dstDiff != 0) {
return dstDiff;
}
- if (type.isPrimitive() != o.type.isPrimitive()) {
- return Boolean.compare(type.isPrimitive(), o.type.isPrimitive());
+ if (type.isPrimitiveType() != o.type.isPrimitiveType()) {
+ return Boolean.compare(type.isPrimitiveType(), o.type.isPrimitiveType());
}
if (type.isWidePrimitive() != o.type.isWidePrimitive()) {
return Boolean.compare(type.isWidePrimitive(), o.type.isWidePrimitive());
}
- if (type.isReference() != o.type.isReference()) {
- return Boolean.compare(type.isReference(), o.type.isReference());
+ if (type.isReferenceType() != o.type.isReferenceType()) {
+ return Boolean.compare(type.isReferenceType(), o.type.isReferenceType());
}
if (definition == null) {
if (o.definition != null) {
diff --git a/src/main/java/com/android/tools/r8/ir/regalloc/RegisterMoveScheduler.java b/src/main/java/com/android/tools/r8/ir/regalloc/RegisterMoveScheduler.java
index 08afab7..f309cd8 100644
--- a/src/main/java/com/android/tools/r8/ir/regalloc/RegisterMoveScheduler.java
+++ b/src/main/java/com/android/tools/r8/ir/regalloc/RegisterMoveScheduler.java
@@ -139,17 +139,14 @@
if (move.definition.isArgument()) {
Argument argument = move.definition.asArgument();
int argumentRegister = argument.outValue().getLiveIntervals().getRegister();
- Value to =
- new FixedRegisterValue(argument.outValue().getTypeLattice(), move.dst);
- Value from =
- new FixedRegisterValue(argument.outValue().getTypeLattice(), argumentRegister);
+ Value to = new FixedRegisterValue(argument.outValue().getType(), move.dst);
+ Value from = new FixedRegisterValue(argument.outValue().getType(), argumentRegister);
instruction = new Move(to, from);
} else {
assert move.definition.isOutConstant();
ConstInstruction definition = move.definition.getOutConstantConstInstruction();
if (definition.isConstNumber()) {
- Value to =
- new FixedRegisterValue(move.definition.outValue().getTypeLattice(), move.dst);
+ Value to = new FixedRegisterValue(move.definition.outValue().getType(), move.dst);
instruction = new ConstNumber(to, definition.asConstNumber().getRawValue());
} else {
throw new Unreachable("Unexpected definition");
diff --git a/src/main/java/com/android/tools/r8/ir/regalloc/SpillMoveSet.java b/src/main/java/com/android/tools/r8/ir/regalloc/SpillMoveSet.java
index a5506d9..16a1bf2 100644
--- a/src/main/java/com/android/tools/r8/ir/regalloc/SpillMoveSet.java
+++ b/src/main/java/com/android/tools/r8/ir/regalloc/SpillMoveSet.java
@@ -198,11 +198,11 @@
}
private TypeLatticeElement moveTypeForIntervals(LiveIntervals to, LiveIntervals from) {
- TypeLatticeElement toType = to.getValue().getTypeLattice();
- TypeLatticeElement fromType = from.getValue().getTypeLattice();
- if (toType.isReference() || fromType.isReference()) {
- assert fromType.isReference() || fromType.isSinglePrimitive();
- assert toType.isReference() || toType.isSinglePrimitive();
+ TypeLatticeElement toType = to.getValue().getType();
+ TypeLatticeElement fromType = from.getValue().getType();
+ if (toType.isReferenceType() || fromType.isReferenceType()) {
+ assert fromType.isReferenceType() || fromType.isSinglePrimitive();
+ assert toType.isReferenceType() || toType.isSinglePrimitive();
return objectType;
}
assert toType == fromType;
diff --git a/src/main/java/com/android/tools/r8/naming/IdentifierNameStringMarker.java b/src/main/java/com/android/tools/r8/naming/IdentifierNameStringMarker.java
index eb799b5..d5873a9 100644
--- a/src/main/java/com/android/tools/r8/naming/IdentifierNameStringMarker.java
+++ b/src/main/java/com/android/tools/r8/naming/IdentifierNameStringMarker.java
@@ -161,7 +161,7 @@
assert iterator.peekPrevious() == fieldPut;
iterator.previous();
// Prepare $decoupled just before $fieldPut
- Value newIn = code.createValue(in.getTypeLattice(), in.getLocalInfo());
+ Value newIn = code.createValue(in.getType(), in.getLocalInfo());
DexItemBasedConstString decoupled =
new DexItemBasedConstString(
newIn, itemBasedString, ClassNameComputationInfo.none(), throwingInfo);
@@ -227,7 +227,7 @@
}
// Prepare $decoupled just before $invoke
- Value newIn = code.createValue(in.getTypeLattice(), in.getLocalInfo());
+ Value newIn = code.createValue(in.getType(), in.getLocalInfo());
DexItemBasedConstString decoupled =
new DexItemBasedConstString(
newIn, itemBasedString, ClassNameComputationInfo.none(), throwingInfo);
@@ -294,7 +294,7 @@
assert iterator.peekPrevious() == invoke;
iterator.previous();
// Prepare $decoupled just before $invoke
- Value newIn = code.createValue(in.getTypeLattice(), in.getLocalInfo());
+ Value newIn = code.createValue(in.getType(), in.getLocalInfo());
DexItemBasedConstString decoupled =
new DexItemBasedConstString(
newIn, itemBasedString, ClassNameComputationInfo.none(), throwingInfo);
diff --git a/src/test/java/com/android/tools/r8/ir/LinearFlowIteratorTest.java b/src/test/java/com/android/tools/r8/ir/LinearFlowIteratorTest.java
index 88785c4..0d31dca 100644
--- a/src/test/java/com/android/tools/r8/ir/LinearFlowIteratorTest.java
+++ b/src/test/java/com/android/tools/r8/ir/LinearFlowIteratorTest.java
@@ -153,7 +153,7 @@
IRCode code = simpleCode();
InstructionListIterator it = new LinearFlowInstructionListIterator(code, code.blocks.get(1));
Instruction current = it.previous();
- assertTrue(current.isConstNumber() && current.outValue().getTypeLattice().isReference());
+ assertTrue(current.isConstNumber() && current.outValue().getType().isReferenceType());
it.next();
current = it.next();
assertTrue(current.isArrayGet());
diff --git a/src/test/java/com/android/tools/r8/ir/analysis/type/ArrayTypeTest.java b/src/test/java/com/android/tools/r8/ir/analysis/type/ArrayTypeTest.java
index 74a49ed..3a322fb 100644
--- a/src/test/java/com/android/tools/r8/ir/analysis/type/ArrayTypeTest.java
+++ b/src/test/java/com/android/tools/r8/ir/analysis/type/ArrayTypeTest.java
@@ -69,13 +69,13 @@
value = arrayPutInstruction.value();
}
- assertTrue(array.getTypeLattice().isArrayType());
+ assertTrue(array.getType().isArrayType());
- ArrayTypeLatticeElement arrayType = array.getTypeLattice().asArrayTypeLatticeElement();
- TypeLatticeElement elementType = arrayType.getArrayMemberTypeAsMemberType();
+ ArrayTypeLatticeElement arrayType = array.getType().asArrayType();
+ TypeLatticeElement elementType = arrayType.getMemberType();
assertEquals(getFloat(), elementType);
- assertEquals(getFloat(), value.getTypeLattice());
+ assertEquals(getFloat(), value.getType());
}
}
};
@@ -89,13 +89,13 @@
Value array = arrayPutInstruction.array();
Value value = arrayPutInstruction.value();
- assertTrue(array.getTypeLattice().isArrayType());
+ assertTrue(array.getType().isArrayType());
- ArrayTypeLatticeElement arrayType = array.getTypeLattice().asArrayTypeLatticeElement();
- TypeLatticeElement elementType = arrayType.getArrayMemberTypeAsMemberType();
+ ArrayTypeLatticeElement arrayType = array.getType().asArrayType();
+ TypeLatticeElement elementType = arrayType.getMemberType();
assertEquals(getFloat(), elementType);
- assertEquals(getFloat(), value.getTypeLattice());
+ assertEquals(getFloat(), value.getType());
}
{
@@ -104,7 +104,7 @@
code,
instruction ->
instruction.isConstNumber() && instruction.asConstNumber().getRawValue() != 0);
- assertEquals(getFloat(), constNumberInstruction.outValue().getTypeLattice());
+ assertEquals(getFloat(), constNumberInstruction.outValue().getType());
}
};
}
@@ -115,7 +115,7 @@
for (BasicBlock block : code.blocks) {
for (Phi phi : block.getPhis()) {
phiCount++;
- assertEquals(getInt(), phi.getTypeLattice());
+ assertEquals(getInt(), phi.getType());
}
}
assertEquals(2, phiCount);
diff --git a/src/test/java/com/android/tools/r8/ir/analysis/type/ConstrainedPrimitiveTypeTest.java b/src/test/java/com/android/tools/r8/ir/analysis/type/ConstrainedPrimitiveTypeTest.java
index 9471d46..441b9db 100644
--- a/src/test/java/com/android/tools/r8/ir/analysis/type/ConstrainedPrimitiveTypeTest.java
+++ b/src/test/java/com/android/tools/r8/ir/analysis/type/ConstrainedPrimitiveTypeTest.java
@@ -98,7 +98,7 @@
for (Instruction instruction : code.instructions()) {
if (instruction.isConstNumber()) {
ConstNumber constNumberInstruction = instruction.asConstNumber();
- assertEquals(expectedType, constNumberInstruction.outValue().getTypeLattice());
+ assertEquals(expectedType, constNumberInstruction.outValue().getType());
}
}
diff --git a/src/test/java/com/android/tools/r8/ir/analysis/type/NullabilityTest.java b/src/test/java/com/android/tools/r8/ir/analysis/type/NullabilityTest.java
index e4fb7b1..52ca07d 100644
--- a/src/test/java/com/android/tools/r8/ir/analysis/type/NullabilityTest.java
+++ b/src/test/java/com/android/tools/r8/ir/analysis/type/NullabilityTest.java
@@ -61,11 +61,11 @@
TypeLatticeElement l) {
// Due to the last invocation that will check nullability of the argument,
// there is one exceptional mapping to PRIMITIVE.
- if (l.isPrimitive()) {
+ if (l.isPrimitiveType()) {
return;
}
assertTrue(l.isClassType());
- ClassTypeLatticeElement lattice = l.asClassTypeLatticeElement();
+ ClassTypeLatticeElement lattice = l.asClassType();
// Receiver
if (lattice.getClassType().equals(receiverType)) {
assertFalse(l.isNullable());
@@ -87,7 +87,7 @@
InvokeMethodWithReceiver invoke = instruction.asInvokeMethodWithReceiver();
if (invoke.getInvokedMethod().name.toString().contains("hash")) {
metInvokeVirtual = true;
- TypeLatticeElement l = invoke.getReceiver().getTypeLattice();
+ TypeLatticeElement l = invoke.getReceiver().getType();
assertEquals(npeCaught, l.isNullable());
}
}
@@ -96,13 +96,16 @@
}
private void forEachOutValue(IRCode irCode, BiConsumer<Value, TypeLatticeElement> consumer) {
- irCode.instructionIterator().forEachRemaining(instruction -> {
- Value outValue = instruction.outValue();
- if (outValue != null) {
- TypeLatticeElement element = outValue.getTypeLattice();
- consumer.accept(outValue, element);
- }
- });
+ irCode
+ .instructionIterator()
+ .forEachRemaining(
+ instruction -> {
+ Value outValue = instruction.outValue();
+ if (outValue != null) {
+ TypeLatticeElement element = outValue.getType();
+ consumer.accept(outValue, element);
+ }
+ });
}
@Test
@@ -186,13 +189,13 @@
irCode,
(v, l) -> {
if (l.isArrayType()) {
- ArrayTypeLatticeElement lattice = l.asArrayTypeLatticeElement();
+ ArrayTypeLatticeElement lattice = l.asArrayType();
assertEquals(1, lattice.getNesting());
- TypeLatticeElement elementTypeLattice = lattice.getArrayMemberTypeAsMemberType();
+ TypeLatticeElement elementTypeLattice = lattice.getMemberType();
assertTrue(elementTypeLattice.isClassType());
assertEquals(
appInfo.dexItemFactory().stringType,
- elementTypeLattice.asClassTypeLatticeElement().getClassType());
+ elementTypeLattice.asClassType().getClassType());
assertEquals(v.definition.isArgument(), l.isNullable());
} else if (l.isClassType()) {
verifyClassTypeLattice(expectedLattices, mainClass, v, l);
@@ -228,13 +231,13 @@
irCode,
(v, l) -> {
if (l.isArrayType()) {
- ArrayTypeLatticeElement lattice = l.asArrayTypeLatticeElement();
+ ArrayTypeLatticeElement lattice = l.asArrayType();
assertEquals(1, lattice.getNesting());
- TypeLatticeElement elementTypeLattice = lattice.getArrayMemberTypeAsMemberType();
+ TypeLatticeElement elementTypeLattice = lattice.getMemberType();
assertTrue(elementTypeLattice.isClassType());
assertEquals(
appInfo.dexItemFactory().stringType,
- elementTypeLattice.asClassTypeLatticeElement().getClassType());
+ elementTypeLattice.asClassType().getClassType());
assertEquals(v.definition.isArgument(), l.isNullable());
} else if (l.isClassType()) {
verifyClassTypeLattice(expectedLattices, mainClass, v, l);
diff --git a/src/test/java/com/android/tools/r8/ir/analysis/type/TypeAnalysisTest.java b/src/test/java/com/android/tools/r8/ir/analysis/type/TypeAnalysisTest.java
index 198ffa3..727499c 100644
--- a/src/test/java/com/android/tools/r8/ir/analysis/type/TypeAnalysisTest.java
+++ b/src/test/java/com/android/tools/r8/ir/analysis/type/TypeAnalysisTest.java
@@ -121,13 +121,16 @@
private static void forEachOutValue(
IRCode irCode, BiConsumer<Value, TypeLatticeElement> consumer) {
- irCode.instructionIterator().forEachRemaining(instruction -> {
- Value outValue = instruction.outValue();
- if (outValue != null) {
- TypeLatticeElement element = outValue.getTypeLattice();
- consumer.accept(outValue, element);
- }
- });
+ irCode
+ .instructionIterator()
+ .forEachRemaining(
+ instruction -> {
+ Value outValue = instruction.outValue();
+ if (outValue != null) {
+ TypeLatticeElement element = outValue.getType();
+ consumer.accept(outValue, element);
+ }
+ });
}
// Simple one path with a lot of arithmetic operations.
@@ -173,8 +176,8 @@
(v, l) -> {
if (v == finalArray) {
assertTrue(l.isArrayType());
- ArrayTypeLatticeElement lattice = l.asArrayTypeLatticeElement();
- assertTrue(lattice.getArrayMemberTypeAsMemberType().isPrimitive());
+ ArrayTypeLatticeElement lattice = l.asArrayType();
+ assertTrue(lattice.getMemberType().isPrimitiveType());
assertEquals(1, lattice.getNesting());
assertFalse(lattice.isNullable());
}
@@ -200,8 +203,8 @@
(v, l) -> {
if (v == finalArray) {
assertTrue(l.isArrayType());
- ArrayTypeLatticeElement lattice = l.asArrayTypeLatticeElement();
- assertTrue(lattice.getArrayMemberTypeAsMemberType().isPrimitive());
+ ArrayTypeLatticeElement lattice = l.asArrayType();
+ assertTrue(lattice.getMemberType().isPrimitiveType());
assertEquals(1, lattice.getNesting());
assertFalse(lattice.isNullable());
}
@@ -213,14 +216,16 @@
MethodSubject loop2Subject =
inspector.clazz("Test").method(new MethodSignature("loop2", "void", ImmutableList.of()));
IRCode irCode = loop2Subject.buildIR();
- forEachOutValue(irCode, (v, l) -> {
- if (l.isClassType()) {
- ClassTypeLatticeElement lattice = l.asClassTypeLatticeElement();
- assertEquals("Ljava/io/PrintStream;", lattice.getClassType().toDescriptorString());
- // TODO(b/70795205): Can be refined by using control-flow info.
- assertTrue(l.isNullable());
- }
- });
+ forEachOutValue(
+ irCode,
+ (v, l) -> {
+ if (l.isClassType()) {
+ ClassTypeLatticeElement lattice = l.asClassType();
+ assertEquals("Ljava/io/PrintStream;", lattice.getClassType().toDescriptorString());
+ // TODO(b/70795205): Can be refined by using control-flow info.
+ assertTrue(l.isNullable());
+ }
+ });
}
// move-exception
@@ -230,13 +235,15 @@
.clazz("Test")
.method(new MethodSignature("test2_throw", "int", ImmutableList.of()));
IRCode irCode = test2Subject.buildIR();
- forEachOutValue(irCode, (v, l) -> {
- if (l.isClassType()) {
- ClassTypeLatticeElement lattice = l.asClassTypeLatticeElement();
- assertEquals("Ljava/lang/Throwable;", lattice.getClassType().toDescriptorString());
- assertFalse(l.isNullable());
- }
- });
+ forEachOutValue(
+ irCode,
+ (v, l) -> {
+ if (l.isClassType()) {
+ ClassTypeLatticeElement lattice = l.asClassType();
+ assertEquals("Ljava/lang/Throwable;", lattice.getClassType().toDescriptorString());
+ assertFalse(l.isNullable());
+ }
+ });
}
// One very complicated example.
diff --git a/src/test/java/com/android/tools/r8/ir/analysis/type/TypeConstraintOnTrivialPhiTest.java b/src/test/java/com/android/tools/r8/ir/analysis/type/TypeConstraintOnTrivialPhiTest.java
index 80d752e..cf997e0 100644
--- a/src/test/java/com/android/tools/r8/ir/analysis/type/TypeConstraintOnTrivialPhiTest.java
+++ b/src/test/java/com/android/tools/r8/ir/analysis/type/TypeConstraintOnTrivialPhiTest.java
@@ -113,7 +113,7 @@
private static Consumer<IRCode> testInspector(TypeLatticeElement expectedType) {
return code -> {
ConstNumber constNumberInstruction = getMatchingInstruction(code, Instruction::isConstNumber);
- assertEquals(expectedType, constNumberInstruction.outValue().getTypeLattice());
+ assertEquals(expectedType, constNumberInstruction.outValue().getType());
};
}
}
diff --git a/src/test/java/com/android/tools/r8/ir/analysis/type/TypeLatticeTest.java b/src/test/java/com/android/tools/r8/ir/analysis/type/TypeLatticeTest.java
index cac6ef5..3291053 100644
--- a/src/test/java/com/android/tools/r8/ir/analysis/type/TypeLatticeTest.java
+++ b/src/test/java/com/android/tools/r8/ir/analysis/type/TypeLatticeTest.java
@@ -537,7 +537,7 @@
appView.withSubtyping().appInfo().registerNewTypeForTesting(type, factory.objectType);
TypeLatticeElement nonNullType = fromDexType(type, Nullability.definitelyNotNull(), appView);
ReferenceTypeLatticeElement nullableType =
- nonNullType.asReferenceTypeLatticeElement().getOrCreateVariant(Nullability.maybeNull());
+ nonNullType.asReferenceType().getOrCreateVariant(Nullability.maybeNull());
assertTrue(strictlyLessThan(nonNullType, nullableType));
assertTrue(lessThanOrEqual(nonNullType, nullableType));
assertFalse(lessThanOrEqual(nullableType, nonNullType));
diff --git a/src/test/java/com/android/tools/r8/ir/analysis/type/UnconstrainedPrimitiveTypeTest.java b/src/test/java/com/android/tools/r8/ir/analysis/type/UnconstrainedPrimitiveTypeTest.java
index d08b323..7778202 100644
--- a/src/test/java/com/android/tools/r8/ir/analysis/type/UnconstrainedPrimitiveTypeTest.java
+++ b/src/test/java/com/android/tools/r8/ir/analysis/type/UnconstrainedPrimitiveTypeTest.java
@@ -120,7 +120,7 @@
for (Instruction instruction : code.instructions()) {
if (instruction.isConstNumber()) {
ConstNumber constNumberInstruction = instruction.asConstNumber();
- assertEquals(expectedType, constNumberInstruction.outValue().getTypeLattice());
+ assertEquals(expectedType, constNumberInstruction.outValue().getType());
}
}
diff --git a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeDirectNegativeTest.java b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeDirectNegativeTest.java
index 27db8be..8814ead 100644
--- a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeDirectNegativeTest.java
+++ b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeDirectNegativeTest.java
@@ -62,8 +62,7 @@
TypeLatticeElement upperBoundType = callSiteOptimizationInfo.getDynamicUpperBoundType(1);
assert upperBoundType.isDefinitelyNotNull();
assert upperBoundType.isClassType()
- && upperBoundType.asClassTypeLatticeElement()
- .getClassType().toSourceString().endsWith("$Base");
+ && upperBoundType.asClassType().getClassType().toSourceString().endsWith("$Base");
}
private void inspect(CodeInspector inspector) {
diff --git a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeDirectPositiveTest.java b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeDirectPositiveTest.java
index 67bb7db..4a508c1 100644
--- a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeDirectPositiveTest.java
+++ b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeDirectPositiveTest.java
@@ -73,8 +73,7 @@
}
assert upperBoundType.isDefinitelyNotNull();
assert upperBoundType.isClassType()
- && upperBoundType.asClassTypeLatticeElement()
- .getClassType().toSourceString().endsWith("$Sub1");
+ && upperBoundType.asClassType().getClassType().toSourceString().endsWith("$Sub1");
}
private void inspect(CodeInspector inspector) {
diff --git a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeInterfaceNegativeTest.java b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeInterfaceNegativeTest.java
index 1493d73..71a709e 100644
--- a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeInterfaceNegativeTest.java
+++ b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeInterfaceNegativeTest.java
@@ -67,8 +67,7 @@
TypeLatticeElement upperBoundType = callSiteOptimizationInfo.getDynamicUpperBoundType(1);
assert upperBoundType.isDefinitelyNotNull();
assert upperBoundType.isClassType()
- && upperBoundType.asClassTypeLatticeElement()
- .getClassType().toSourceString().endsWith("$Base");
+ && upperBoundType.asClassType().getClassType().toSourceString().endsWith("$Base");
}
private void inspect(CodeInspector inspector) {
diff --git a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeInterfacePositiveTest.java b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeInterfacePositiveTest.java
index 24cad5b..e436d17 100644
--- a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeInterfacePositiveTest.java
+++ b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeInterfacePositiveTest.java
@@ -68,12 +68,10 @@
assert upperBoundType.isDefinitelyNotNull();
if (encodedMethod.method.holder.toSourceString().endsWith("$A")) {
assert upperBoundType.isClassType()
- && upperBoundType.asClassTypeLatticeElement()
- .getClassType().toSourceString().endsWith("$Sub1");
+ && upperBoundType.asClassType().getClassType().toSourceString().endsWith("$Sub1");
} else {
assert upperBoundType.isClassType()
- && upperBoundType.asClassTypeLatticeElement()
- .getClassType().toSourceString().endsWith("$Base");
+ && upperBoundType.asClassType().getClassType().toSourceString().endsWith("$Base");
}
}
diff --git a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeStaticNegativeTest.java b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeStaticNegativeTest.java
index 6291f4d..22759bf 100644
--- a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeStaticNegativeTest.java
+++ b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeStaticNegativeTest.java
@@ -59,8 +59,7 @@
TypeLatticeElement upperBoundType = callSiteOptimizationInfo.getDynamicUpperBoundType(0);
assert upperBoundType.isDefinitelyNotNull();
assert upperBoundType.isClassType()
- && upperBoundType.asClassTypeLatticeElement()
- .getClassType().toSourceString().endsWith("$Base");
+ && upperBoundType.asClassType().getClassType().toSourceString().endsWith("$Base");
}
private void inspect(CodeInspector inspector) {
diff --git a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeStaticPositiveTest.java b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeStaticPositiveTest.java
index f31919a..c20bbcc 100644
--- a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeStaticPositiveTest.java
+++ b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeStaticPositiveTest.java
@@ -66,8 +66,7 @@
TypeLatticeElement upperBoundType = callSiteOptimizationInfo.getDynamicUpperBoundType(0);
assert upperBoundType.isDefinitelyNotNull();
assert upperBoundType.isClassType()
- && upperBoundType.asClassTypeLatticeElement()
- .getClassType().toSourceString().endsWith("$Sub1");
+ && upperBoundType.asClassType().getClassType().toSourceString().endsWith("$Sub1");
}
private void inspect(CodeInspector inspector) {
diff --git a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeVirtualNegativeTest.java b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeVirtualNegativeTest.java
index cc0a69f..6c30a03 100644
--- a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeVirtualNegativeTest.java
+++ b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeVirtualNegativeTest.java
@@ -66,8 +66,7 @@
TypeLatticeElement upperBoundType = callSiteOptimizationInfo.getDynamicUpperBoundType(1);
assert upperBoundType.isDefinitelyNotNull();
assert upperBoundType.isClassType()
- && upperBoundType.asClassTypeLatticeElement()
- .getClassType().toSourceString().endsWith("$Base");
+ && upperBoundType.asClassType().getClassType().toSourceString().endsWith("$Base");
} else {
assert methodName.equals("test");
assert callSiteOptimizationInfo.getDynamicUpperBoundType(0).isDefinitelyNotNull();
diff --git a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeVirtualPositiveTest.java b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeVirtualPositiveTest.java
index f49d16e..c79d513 100644
--- a/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeVirtualPositiveTest.java
+++ b/src/test/java/com/android/tools/r8/ir/optimize/callsites/dynamicupperboundtype/InvokeVirtualPositiveTest.java
@@ -73,8 +73,7 @@
}
assert upperBoundType.isDefinitelyNotNull();
assert upperBoundType.isClassType()
- && upperBoundType.asClassTypeLatticeElement()
- .getClassType().toSourceString().endsWith("$Sub1");
+ && upperBoundType.asClassType().getClassType().toSourceString().endsWith("$Sub1");
}
private void inspect(CodeInspector inspector) {
diff --git a/src/test/java/com/android/tools/r8/ir/optimize/callsites/nullability/InvokeInterfaceNegativeTest.java b/src/test/java/com/android/tools/r8/ir/optimize/callsites/nullability/InvokeInterfaceNegativeTest.java
index 3fde0f1..d39e0df 100644
--- a/src/test/java/com/android/tools/r8/ir/optimize/callsites/nullability/InvokeInterfaceNegativeTest.java
+++ b/src/test/java/com/android/tools/r8/ir/optimize/callsites/nullability/InvokeInterfaceNegativeTest.java
@@ -67,8 +67,7 @@
TypeLatticeElement upperBoundType = callSiteOptimizationInfo.getDynamicUpperBoundType(1);
assert upperBoundType.isNullable();
assert upperBoundType.isClassType()
- && upperBoundType.asClassTypeLatticeElement()
- .getClassType().toSourceString().endsWith("$A");
+ && upperBoundType.asClassType().getClassType().toSourceString().endsWith("$A");
}
private void inspect(CodeInspector inspector) {
diff --git a/src/test/java/com/android/tools/r8/ir/optimize/callsites/nullability/InvokeVirtualNegativeTest.java b/src/test/java/com/android/tools/r8/ir/optimize/callsites/nullability/InvokeVirtualNegativeTest.java
index e36d2e9..6b1dd06 100644
--- a/src/test/java/com/android/tools/r8/ir/optimize/callsites/nullability/InvokeVirtualNegativeTest.java
+++ b/src/test/java/com/android/tools/r8/ir/optimize/callsites/nullability/InvokeVirtualNegativeTest.java
@@ -66,8 +66,7 @@
TypeLatticeElement upperBoundType = callSiteOptimizationInfo.getDynamicUpperBoundType(1);
assert upperBoundType.isNullable();
assert upperBoundType.isClassType()
- && upperBoundType.asClassTypeLatticeElement()
- .getClassType().equals(encodedMethod.method.holder);
+ && upperBoundType.asClassType().getClassType().equals(encodedMethod.method.holder);
} else {
assert methodName.equals("test");
assert callSiteOptimizationInfo.getDynamicUpperBoundType(0).isDefinitelyNotNull();
diff --git a/src/test/java/com/android/tools/r8/ir/optimize/callsites/nullability/InvokeVirtualPositiveTest.java b/src/test/java/com/android/tools/r8/ir/optimize/callsites/nullability/InvokeVirtualPositiveTest.java
index e05b279..cc5f664 100644
--- a/src/test/java/com/android/tools/r8/ir/optimize/callsites/nullability/InvokeVirtualPositiveTest.java
+++ b/src/test/java/com/android/tools/r8/ir/optimize/callsites/nullability/InvokeVirtualPositiveTest.java
@@ -63,8 +63,7 @@
CallSiteOptimizationInfo callSiteOptimizationInfo = encodedMethod.getCallSiteOptimizationInfo();
TypeLatticeElement upperBoundType = callSiteOptimizationInfo.getDynamicUpperBoundType(1);
assert upperBoundType.isClassType()
- && upperBoundType.asClassTypeLatticeElement()
- .getClassType().toSourceString().endsWith("$A");
+ && upperBoundType.asClassType().getClassType().toSourceString().endsWith("$A");
if (encodedMethod.method.holder.toSourceString().endsWith("$A")) {
assert upperBoundType.isDefinitelyNotNull();
} else {