diff options
| author | 2015-01-06 16:53:10 +0000 | |
|---|---|---|
| committer | 2015-01-06 16:53:10 +0000 | |
| commit | c70153fe1d7af7f7108d81dba7833b9ce449a426 (patch) | |
| tree | c6e5922a920b9a2898ddb192e90d1f74e9029511 | |
| parent | 95d9a03db4471ef6d72853aedaa2bcd896ff0ca7 (diff) | |
| parent | cfe71e59c667abb35bc2363c49af7f8b549c44d0 (diff) | |
Merge "ART: Fix divide-by-zero for ARM"
| -rw-r--r-- | compiler/dex/quick/arm/int_arm.cc | 8 | ||||
| -rw-r--r-- | test/800-smali/expected.txt | 1 | ||||
| -rw-r--r-- | test/800-smali/smali/move_exc.smali | 29 | ||||
| -rw-r--r-- | test/800-smali/src/Main.java | 1 |
4 files changed, 39 insertions, 0 deletions
diff --git a/compiler/dex/quick/arm/int_arm.cc b/compiler/dex/quick/arm/int_arm.cc index fe1d12610a..b1ed11cc61 100644 --- a/compiler/dex/quick/arm/int_arm.cc +++ b/compiler/dex/quick/arm/int_arm.cc @@ -567,6 +567,14 @@ bool ArmMir2Lir::SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_div // Try to convert *lit to 1 RegRegRegShift/RegRegShift form. bool ArmMir2Lir::GetEasyMultiplyOp(int lit, ArmMir2Lir::EasyMultiplyOp* op) { + if (lit == 0) { + // Special case for *divide-by-zero*. The ops won't actually be used to generate code, as + // GenArithOpIntLit will directly generate exception-throwing code, and multiply-by-zero will + // have been optimized away earlier. + op->op = kOpInvalid; + return true; + } + if (IsPowerOfTwo(lit)) { op->op = kOpLsl; op->shift = LowestSetBit(lit); diff --git a/test/800-smali/expected.txt b/test/800-smali/expected.txt index d7aede30c6..6cb08f483e 100644 --- a/test/800-smali/expected.txt +++ b/test/800-smali/expected.txt @@ -12,4 +12,5 @@ FloatIntConstPassing b/18718277 b/18800943 (1) b/18800943 (2) +MoveExc Done! diff --git a/test/800-smali/smali/move_exc.smali b/test/800-smali/smali/move_exc.smali new file mode 100644 index 0000000000..4ade4bc728 --- /dev/null +++ b/test/800-smali/smali/move_exc.smali @@ -0,0 +1,29 @@ +.class public LMoveExc; +.super Ljava/lang/Object; + + +.method public constructor <init>()V +.registers 1 + invoke-direct {p0}, Ljava/lang/Object;-><init>()V + return-void +.end method + +.method public static run()V +.registers 6 +:Label1 + const v1, 15 + const v2, 0 + div-int v0, v1, v2 + +:Label2 + goto :Label4 + +:Label3 + move-exception v3 + throw v3 + +:Label4 + return-void + +.catchall {:Label1 .. :Label2} :Label3 +.end method diff --git a/test/800-smali/src/Main.java b/test/800-smali/src/Main.java index ea25da6fd0..2eda85083f 100644 --- a/test/800-smali/src/Main.java +++ b/test/800-smali/src/Main.java @@ -68,6 +68,7 @@ public class Main { testCases.add(new TestCase("b/18718277", "B18718277", "getInt", null, null, 0)); testCases.add(new TestCase("b/18800943 (1)", "B18800943_1", "n_a", null, new VerifyError(), 0)); testCases.add(new TestCase("b/18800943 (2)", "B18800943_2", "n_a", null, new VerifyError(), 0)); + testCases.add(new TestCase("MoveExc", "MoveExc", "run", null, new ArithmeticException(), null)); } public void runTests() { |