aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMads Ager <ager@google.com>2017-09-14 14:36:04 +0200
committerMads Ager <ager@google.com>2017-09-14 12:36:42 +0000
commitf6d1235ea3ad06bfd4da542e98aa65435441dbc2 (patch)
treed6ed3bd06d71789b799e833b0e323050658b0001
parentd75264485343ef8c0bc30ac9fa16cc2cd3caa385 (diff)
downloadr8-f6d1235ea3ad06bfd4da542e98aa65435441dbc2.tar.gz
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
-rw-r--r--src/main/java/com/android/tools/r8/D8.java2
-rw-r--r--src/main/java/com/android/tools/r8/R8.java2
-rw-r--r--src/main/java/com/android/tools/r8/ir/conversion/DexBuilder.java24
3 files changed, 19 insertions, 9 deletions
diff --git a/src/main/java/com/android/tools/r8/D8.java b/src/main/java/com/android/tools/r8/D8.java
index b6922258e..7c3855551 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 @@ import java.util.concurrent.ExecutorService;
*/
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 deb4987f4..a2fcbf10a 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 @@ import java.util.concurrent.Executors;
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 da067d80b..95db3e81d 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 @@ public class DexBuilder {
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 @@ public class DexBuilder {
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);
}
}