Update asserts in position mapper
Allow for not having mappings if there are no throwing assertions
Change-Id: I08e6182663b8d6e9e5f371e58c8ebc95d2dc565c
diff --git a/src/main/java/com/android/tools/r8/graph/DexCode.java b/src/main/java/com/android/tools/r8/graph/DexCode.java
index 6f89669..9d6d32e 100644
--- a/src/main/java/com/android/tools/r8/graph/DexCode.java
+++ b/src/main/java/com/android/tools/r8/graph/DexCode.java
@@ -526,6 +526,15 @@
return false;
}
+ public boolean hasThrowingInstructions() {
+ for (DexInstruction instruction : instructions) {
+ if (instruction.canThrow()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
@Override
public Code asCode() {
return this;
diff --git a/src/main/java/com/android/tools/r8/utils/positions/DexPositionToPcMappedRangeMapper.java b/src/main/java/com/android/tools/r8/utils/positions/DexPositionToPcMappedRangeMapper.java
index a1bb8a5..a583e5f 100644
--- a/src/main/java/com/android/tools/r8/utils/positions/DexPositionToPcMappedRangeMapper.java
+++ b/src/main/java/com/android/tools/r8/utils/positions/DexPositionToPcMappedRangeMapper.java
@@ -84,7 +84,9 @@
mappedPositions);
}
- assert !mappedPositions.isEmpty() || dexCode.instructions.length == 1;
+ assert !mappedPositions.isEmpty()
+ || dexCode.instructions.length == 1
+ || !dexCode.hasThrowingInstructions();
pcBasedDebugInfo.recordPcMappingFor(method, pcEncodingCutoff);
return mappedPositions;
}
diff --git a/src/main/java/com/android/tools/r8/utils/positions/MappedPositionToClassNameMapperBuilder.java b/src/main/java/com/android/tools/r8/utils/positions/MappedPositionToClassNameMapperBuilder.java
index 35b4218..7bdbaa8 100644
--- a/src/main/java/com/android/tools/r8/utils/positions/MappedPositionToClassNameMapperBuilder.java
+++ b/src/main/java/com/android/tools/r8/utils/positions/MappedPositionToClassNameMapperBuilder.java
@@ -291,6 +291,7 @@
originalType)) {
assert appView.options().lineNumberOptimization.isOff()
|| hasAtMostOnePosition(appView, definition)
+ || !hasThrowingInstructions(definition)
|| appView.isCfByteCodePassThrough(definition);
return this;
}
@@ -624,6 +625,11 @@
return code.isDexCode() && code.asDexCode().instructions.length == 1;
}
+ private boolean hasThrowingInstructions(DexEncodedMethod definition) {
+ Code code = definition.getCode();
+ return code.isDexCode() && code.asDexCode().hasThrowingInstructions();
+ }
+
private ClassNaming.Builder getBuilder() {
if (builder == null) {
builder =