summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/449-checker-bce/src/Main.java26
-rw-r--r--test/458-checker-instruction-simplification/src/Main.java174
-rw-r--r--test/532-checker-nonnull-arrayset/expected.txt0
-rw-r--r--test/532-checker-nonnull-arrayset/info.txt1
-rw-r--r--test/532-checker-nonnull-arrayset/src/Main.java39
-rw-r--r--test/533-regression-debugphi/expected.txt0
-rw-r--r--test/533-regression-debugphi/info.txt2
-rw-r--r--test/533-regression-debugphi/smali/TestCase.smali72
-rw-r--r--test/533-regression-debugphi/src/Main.java22
9 files changed, 335 insertions, 1 deletions
diff --git a/test/449-checker-bce/src/Main.java b/test/449-checker-bce/src/Main.java
index a746664160..f06c250dc7 100644
--- a/test/449-checker-bce/src/Main.java
+++ b/test/449-checker-bce/src/Main.java
@@ -249,6 +249,25 @@ public class Main {
array[Integer.MAX_VALUE - 998] = 1;
}
+ /// CHECK-START: void Main.constantIndexing6(int[]) BCE (before)
+ /// CHECK: BoundsCheck
+ /// CHECK: ArraySet
+ /// CHECK: BoundsCheck
+ /// CHECK: ArraySet
+
+ /// CHECK-START: void Main.constantIndexing6(int[]) BCE (after)
+ /// CHECK: Deoptimize
+
+ static void constantIndexing6(int[] array) {
+ array[3] = 1;
+ array[4] = 1;
+ }
+
+ // A helper into which the actual throwing function should be inlined.
+ static void constantIndexingForward6(int[] array) {
+ constantIndexing6(array);
+ }
+
/// CHECK-START: void Main.loopPattern1(int[]) BCE (before)
/// CHECK: BoundsCheck
/// CHECK: ArraySet
@@ -602,7 +621,12 @@ public class Main {
// This will cause AIOOBE.
constantIndexing2(new int[3]);
} catch (ArrayIndexOutOfBoundsException e) {
- return 99;
+ try {
+ // This will cause AIOOBE.
+ constantIndexingForward6(new int[3]);
+ } catch (ArrayIndexOutOfBoundsException e2) {
+ return 99;
+ }
}
return 0;
}
diff --git a/test/458-checker-instruction-simplification/src/Main.java b/test/458-checker-instruction-simplification/src/Main.java
index a14200e7ce..c32d34aa6f 100644
--- a/test/458-checker-instruction-simplification/src/Main.java
+++ b/test/458-checker-instruction-simplification/src/Main.java
@@ -84,6 +84,172 @@ public class Main {
return arg & -1;
}
+ /// CHECK-START: int Main.UShr28And15(int) instruction_simplifier (before)
+ /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
+ /// CHECK-DAG: <<Const28:i\d+>> IntConstant 28
+ /// CHECK-DAG: <<Const15:i\d+>> IntConstant 15
+ /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const28>>]
+ /// CHECK-DAG: <<And:i\d+>> And [<<UShr>>,<<Const15>>]
+ /// CHECK-DAG: Return [<<And>>]
+
+ /// CHECK-START: int Main.UShr28And15(int) instruction_simplifier (after)
+ /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
+ /// CHECK-DAG: <<Const28:i\d+>> IntConstant 28
+ /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const28>>]
+ /// CHECK-DAG: Return [<<UShr>>]
+
+ /// CHECK-START: int Main.UShr28And15(int) instruction_simplifier (after)
+ /// CHECK-NOT: And
+
+ public static int UShr28And15(int arg) {
+ return (arg >>> 28) & 15;
+ }
+
+ /// CHECK-START: long Main.UShr60And15(long) instruction_simplifier (before)
+ /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
+ /// CHECK-DAG: <<Const60:i\d+>> IntConstant 60
+ /// CHECK-DAG: <<Const15:j\d+>> LongConstant 15
+ /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const60>>]
+ /// CHECK-DAG: <<And:j\d+>> And [<<UShr>>,<<Const15>>]
+ /// CHECK-DAG: Return [<<And>>]
+
+ /// CHECK-START: long Main.UShr60And15(long) instruction_simplifier (after)
+ /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
+ /// CHECK-DAG: <<Const60:i\d+>> IntConstant 60
+ /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const60>>]
+ /// CHECK-DAG: Return [<<UShr>>]
+
+ /// CHECK-START: long Main.UShr60And15(long) instruction_simplifier (after)
+ /// CHECK-NOT: And
+
+ public static long UShr60And15(long arg) {
+ return (arg >>> 60) & 15;
+ }
+
+ /// CHECK-START: int Main.UShr28And7(int) instruction_simplifier (before)
+ /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
+ /// CHECK-DAG: <<Const28:i\d+>> IntConstant 28
+ /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7
+ /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const28>>]
+ /// CHECK-DAG: <<And:i\d+>> And [<<UShr>>,<<Const7>>]
+ /// CHECK-DAG: Return [<<And>>]
+
+ /// CHECK-START: int Main.UShr28And7(int) instruction_simplifier (after)
+ /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
+ /// CHECK-DAG: <<Const28:i\d+>> IntConstant 28
+ /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7
+ /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const28>>]
+ /// CHECK-DAG: <<And:i\d+>> And [<<UShr>>,<<Const7>>]
+ /// CHECK-DAG: Return [<<And>>]
+
+ public static int UShr28And7(int arg) {
+ return (arg >>> 28) & 7;
+ }
+
+ /// CHECK-START: long Main.UShr60And7(long) instruction_simplifier (before)
+ /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
+ /// CHECK-DAG: <<Const60:i\d+>> IntConstant 60
+ /// CHECK-DAG: <<Const7:j\d+>> LongConstant 7
+ /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const60>>]
+ /// CHECK-DAG: <<And:j\d+>> And [<<UShr>>,<<Const7>>]
+ /// CHECK-DAG: Return [<<And>>]
+
+ /// CHECK-START: long Main.UShr60And7(long) instruction_simplifier (after)
+ /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
+ /// CHECK-DAG: <<Const60:i\d+>> IntConstant 60
+ /// CHECK-DAG: <<Const7:j\d+>> LongConstant 7
+ /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const60>>]
+ /// CHECK-DAG: <<And:j\d+>> And [<<UShr>>,<<Const7>>]
+ /// CHECK-DAG: Return [<<And>>]
+
+ public static long UShr60And7(long arg) {
+ return (arg >>> 60) & 7;
+ }
+
+ /// CHECK-START: int Main.Shr24And255(int) instruction_simplifier (before)
+ /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
+ /// CHECK-DAG: <<Const24:i\d+>> IntConstant 24
+ /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255
+ /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Arg>>,<<Const24>>]
+ /// CHECK-DAG: <<And:i\d+>> And [<<Shr>>,<<Const255>>]
+ /// CHECK-DAG: Return [<<And>>]
+
+ /// CHECK-START: int Main.Shr24And255(int) instruction_simplifier (after)
+ /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
+ /// CHECK-DAG: <<Const24:i\d+>> IntConstant 24
+ /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const24>>]
+ /// CHECK-DAG: Return [<<UShr>>]
+
+ /// CHECK-START: int Main.Shr24And255(int) instruction_simplifier (after)
+ /// CHECK-NOT: Shr
+ /// CHECK-NOT: And
+
+ public static int Shr24And255(int arg) {
+ return (arg >> 24) & 255;
+ }
+
+ /// CHECK-START: long Main.Shr56And255(long) instruction_simplifier (before)
+ /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
+ /// CHECK-DAG: <<Const56:i\d+>> IntConstant 56
+ /// CHECK-DAG: <<Const255:j\d+>> LongConstant 255
+ /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const56>>]
+ /// CHECK-DAG: <<And:j\d+>> And [<<Shr>>,<<Const255>>]
+ /// CHECK-DAG: Return [<<And>>]
+
+ /// CHECK-START: long Main.Shr56And255(long) instruction_simplifier (after)
+ /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
+ /// CHECK-DAG: <<Const56:i\d+>> IntConstant 56
+ /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const56>>]
+ /// CHECK-DAG: Return [<<UShr>>]
+
+ /// CHECK-START: long Main.Shr56And255(long) instruction_simplifier (after)
+ /// CHECK-NOT: Shr
+ /// CHECK-NOT: And
+
+ public static long Shr56And255(long arg) {
+ return (arg >> 56) & 255;
+ }
+
+ /// CHECK-START: int Main.Shr24And127(int) instruction_simplifier (before)
+ /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
+ /// CHECK-DAG: <<Const24:i\d+>> IntConstant 24
+ /// CHECK-DAG: <<Const127:i\d+>> IntConstant 127
+ /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Arg>>,<<Const24>>]
+ /// CHECK-DAG: <<And:i\d+>> And [<<Shr>>,<<Const127>>]
+ /// CHECK-DAG: Return [<<And>>]
+
+ /// CHECK-START: int Main.Shr24And127(int) instruction_simplifier (after)
+ /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
+ /// CHECK-DAG: <<Const24:i\d+>> IntConstant 24
+ /// CHECK-DAG: <<Const127:i\d+>> IntConstant 127
+ /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Arg>>,<<Const24>>]
+ /// CHECK-DAG: <<And:i\d+>> And [<<Shr>>,<<Const127>>]
+ /// CHECK-DAG: Return [<<And>>]
+
+ public static int Shr24And127(int arg) {
+ return (arg >> 24) & 127;
+ }
+
+ /// CHECK-START: long Main.Shr56And127(long) instruction_simplifier (before)
+ /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
+ /// CHECK-DAG: <<Const56:i\d+>> IntConstant 56
+ /// CHECK-DAG: <<Const127:j\d+>> LongConstant 127
+ /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const56>>]
+ /// CHECK-DAG: <<And:j\d+>> And [<<Shr>>,<<Const127>>]
+ /// CHECK-DAG: Return [<<And>>]
+
+ /// CHECK-START: long Main.Shr56And127(long) instruction_simplifier (after)
+ /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
+ /// CHECK-DAG: <<Const56:i\d+>> IntConstant 56
+ /// CHECK-DAG: <<Const127:j\d+>> LongConstant 127
+ /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const56>>]
+ /// CHECK-DAG: <<And:j\d+>> And [<<Shr>>,<<Const127>>]
+ /// CHECK-DAG: Return [<<And>>]
+
+ public static long Shr56And127(long arg) {
+ return (arg >> 56) & 127;
+ }
+
/// CHECK-START: long Main.Div1(long) instruction_simplifier (before)
/// CHECK-DAG: <<Arg:j\d+>> ParameterValue
/// CHECK-DAG: <<Const1:j\d+>> LongConstant 1
@@ -1109,5 +1275,13 @@ public class Main {
assertFloatEquals(DivMP25(100.0f), -400.0f);
assertDoubleEquals(DivMP25(150.0), -600.0);
assertLongEquals(Shl1(100), 200);
+ assertIntEquals(UShr28And15(0xc1234567), 0xc);
+ assertLongEquals(UShr60And15(0xc123456787654321L), 0xcL);
+ assertIntEquals(UShr28And7(0xc1234567), 0x4);
+ assertLongEquals(UShr60And7(0xc123456787654321L), 0x4L);
+ assertIntEquals(Shr24And255(0xc1234567), 0xc1);
+ assertLongEquals(Shr56And255(0xc123456787654321L), 0xc1L);
+ assertIntEquals(Shr24And127(0xc1234567), 0x41);
+ assertLongEquals(Shr56And127(0xc123456787654321L), 0x41L);
}
}
diff --git a/test/532-checker-nonnull-arrayset/expected.txt b/test/532-checker-nonnull-arrayset/expected.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/532-checker-nonnull-arrayset/expected.txt
diff --git a/test/532-checker-nonnull-arrayset/info.txt b/test/532-checker-nonnull-arrayset/info.txt
new file mode 100644
index 0000000000..e1578c8f14
--- /dev/null
+++ b/test/532-checker-nonnull-arrayset/info.txt
@@ -0,0 +1 @@
+Test that we optimize ArraySet when the value is not null.
diff --git a/test/532-checker-nonnull-arrayset/src/Main.java b/test/532-checker-nonnull-arrayset/src/Main.java
new file mode 100644
index 0000000000..7d8fff46ba
--- /dev/null
+++ b/test/532-checker-nonnull-arrayset/src/Main.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class Main {
+
+ // Check that we don't put a null check in the card marking code.
+
+ /// CHECK-START: void Main.test() instruction_simplifier (before)
+ /// CHECK: ArraySet value_can_be_null:true
+
+ /// CHECK-START: void Main.test() instruction_simplifier (after)
+ /// CHECK: ArraySet value_can_be_null:false
+
+ /// CHECK-START-X86: void Main.test() disassembly (after)
+ /// CHECK: ArraySet value_can_be_null:false
+ /// CHECK-NOT: test
+ /// CHECK: ReturnVoid
+ public static void test() {
+ Object[] array = new Object[1];
+ Object nonNull = array[0];
+ nonNull.getClass(); // Ensure nonNull has an implicit null check.
+ array[0] = nonNull;
+ }
+
+ public static void main(String[] args) {}
+}
diff --git a/test/533-regression-debugphi/expected.txt b/test/533-regression-debugphi/expected.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/533-regression-debugphi/expected.txt
diff --git a/test/533-regression-debugphi/info.txt b/test/533-regression-debugphi/info.txt
new file mode 100644
index 0000000000..a4d4857035
--- /dev/null
+++ b/test/533-regression-debugphi/info.txt
@@ -0,0 +1,2 @@
+Test a regression where DeadPhiHandling would infinitely loop over
+complicated phi dependencies.
diff --git a/test/533-regression-debugphi/smali/TestCase.smali b/test/533-regression-debugphi/smali/TestCase.smali
new file mode 100644
index 0000000000..1908e72c57
--- /dev/null
+++ b/test/533-regression-debugphi/smali/TestCase.smali
@@ -0,0 +1,72 @@
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+.class public LTestCase;
+.super Ljava/lang/Object;
+
+# This is a reduced test case that used to trigger an infinite loop
+# in the DeadPhiHandling phase of the optimizing compiler (only used
+# with debuggable flag).
+.method public static testCase(IILjava/lang/Object;)V
+ .registers 5
+ const/4 v0, 0x0
+
+ :B4
+ invoke-static {}, Ljava/lang/System;->nanoTime()J
+ goto :B7
+
+ :B7
+ invoke-static {}, Ljava/lang/System;->nanoTime()J
+ if-nez p2, :Btmp
+ goto :B111
+
+ :Btmp
+ invoke-static {}, Ljava/lang/System;->nanoTime()J
+ if-nez p2, :B9
+ goto :B110
+
+ :B13
+ invoke-static {}, Ljava/lang/System;->nanoTime()J
+ add-int v0, p0, p1
+ goto :B7
+
+ :B110
+ invoke-static {}, Ljava/lang/System;->nanoTime()J
+ add-int v0, p0, p1
+ goto :B111
+
+ :B111
+ invoke-static {}, Ljava/lang/System;->nanoTime()J
+ goto :B4
+
+ :B9
+ invoke-static {}, Ljava/lang/System;->nanoTime()J
+ if-nez p2, :B10
+
+ :B11
+ invoke-static {}, Ljava/lang/System;->nanoTime()J
+ move v1, v0
+ goto :B12
+
+ :B10
+ invoke-static {}, Ljava/lang/System;->nanoTime()J
+ move-object v1, p2
+ goto :B12
+
+ :B12
+ invoke-static {}, Ljava/lang/System;->nanoTime()J
+ goto :B13
+
+ return-void
+.end method
diff --git a/test/533-regression-debugphi/src/Main.java b/test/533-regression-debugphi/src/Main.java
new file mode 100644
index 0000000000..858770f508
--- /dev/null
+++ b/test/533-regression-debugphi/src/Main.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class Main {
+ // Workaround for b/18051191.
+ class InnerClass {}
+
+ public static void main(String[] args) {}
+}