Version 0.1.13.
R=zerny@google.com
Merge: Make sure that we never emit 'goto next instruction'.
CL: https://r8-review.googlesource.com/c/r8/+/6463
Change-Id: Ice66b907bc5393664ad9bfc09665dfd54ccaeca2
diff --git a/src/main/java/com/android/tools/r8/D8.java b/src/main/java/com/android/tools/r8/D8.java
index b692225..7c38555 100644
--- a/src/main/java/com/android/tools/r8/D8.java
+++ b/src/main/java/com/android/tools/r8/D8.java
@@ -55,7 +55,7 @@
*/
public final class D8 {
- private static final String VERSION = "v0.1.12";
+ private static final String VERSION = "v0.1.13";
private static final int STATUS_ERROR = 1;
private D8() {}
diff --git a/src/main/java/com/android/tools/r8/R8.java b/src/main/java/com/android/tools/r8/R8.java
index deb4987..a2fcbf1 100644
--- a/src/main/java/com/android/tools/r8/R8.java
+++ b/src/main/java/com/android/tools/r8/R8.java
@@ -71,7 +71,7 @@
public class R8 {
- private static final String VERSION = "v0.1.12";
+ private static final String VERSION = "v0.1.13";
private final Timing timing = new Timing("R8");
private final InternalOptions options;
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 da067d8..95db3e8 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
@@ -827,15 +827,25 @@
int source = builder.getInfo(jump).getOffset();
Info targetInfo = builder.getTargetInfo(jump.getTarget());
int relativeOffset = targetInfo.getOffset() - source;
- // We should never generate a goto to the following instruction or two consecutive returns.
- // TODO(b/34726595): We might have a goto to the following instruction if we fail to DCE.
- // assert relativeOffset != size;
- Instruction dex;
// Emit a return if the target is a return and the size of the return is the computed
// size of this instruction.
if (targetInfo.getIR().isReturn() && size == targetInfo.getSize()) {
- dex = targetInfo.getIR().asReturn().createDexInstruction(builder);
+ Instruction dex = targetInfo.getIR().asReturn().createDexInstruction(builder);
+ dex.setOffset(getOffset()); // for better printing of the dex code.
+ instructions.add(dex);
+ } else if (size == relativeOffset) {
+ // We should never generate a goto targeting the next instruction. However, if we do
+ // we replace it with nops. This works around a dalvik bug where the dalvik tracing
+ // jit crashes on 'goto next instruction' on Android 4.1.1.
+ // TODO(b/34726595): We currently do hit this case and we should see if we can avoid that.
+ for (int i = 0; i < size; i++) {
+ Instruction dex = new Nop();
+ assert dex.getSize() == 1;
+ dex.setOffset(getOffset() + i); // for better printing of the dex code.
+ instructions.add(dex);
+ }
} else {
+ Instruction dex;
switch (size) {
case 1:
assert relativeOffset != 0;
@@ -856,9 +866,9 @@
default:
throw new Unreachable("Unexpected size for goto instruction: " + size);
}
+ dex.setOffset(getOffset()); // for better printing of the dex code.
+ instructions.add(dex);
}
- dex.setOffset(getOffset()); // for better printing of the dex code.
- instructions.add(dex);
}
}