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/485-checker-dce-switch/expected.txt0
-rw-r--r--test/485-checker-dce-switch/info.txt1
-rw-r--r--test/485-checker-dce-switch/src/Main.java192
-rw-r--r--test/526-checker-caller-callee-regs/src/Main.java18
-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
-rwxr-xr-xtest/run-test15
9 files changed, 287 insertions, 5 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/485-checker-dce-switch/expected.txt b/test/485-checker-dce-switch/expected.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/485-checker-dce-switch/expected.txt
diff --git a/test/485-checker-dce-switch/info.txt b/test/485-checker-dce-switch/info.txt
new file mode 100644
index 0000000000..6653526827
--- /dev/null
+++ b/test/485-checker-dce-switch/info.txt
@@ -0,0 +1 @@
+Tests that DCE can remove a packed switch.
diff --git a/test/485-checker-dce-switch/src/Main.java b/test/485-checker-dce-switch/src/Main.java
new file mode 100644
index 0000000000..019d876ec8
--- /dev/null
+++ b/test/485-checker-dce-switch/src/Main.java
@@ -0,0 +1,192 @@
+/*
+ * 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 {
+
+ public static int $inline$method() {
+ return 5;
+ }
+
+ /// CHECK-START: int Main.wholeSwitchDead(int) dead_code_elimination_final (before)
+ /// CHECK-DAG: PackedSwitch
+
+ /// CHECK-START: int Main.wholeSwitchDead(int) dead_code_elimination_final (after)
+ /// CHECK-DAG: <<Const100:i\d+>> IntConstant 100
+ /// CHECK-DAG: Return [<<Const100>>]
+
+ /// CHECK-START: int Main.wholeSwitchDead(int) dead_code_elimination_final (after)
+ /// CHECK-NOT: PackedSwitch
+
+ public static int wholeSwitchDead(int j) {
+ int i = $inline$method();
+ int l = 100;
+ if (i > 100) {
+ switch(j) {
+ case 1:
+ i++;
+ break;
+ case 2:
+ i = 99;
+ break;
+ case 3:
+ i = 100;
+ break;
+ case 4:
+ i = -100;
+ break;
+ case 5:
+ i = 7;
+ break;
+ case 6:
+ i = -9;
+ break;
+ }
+ l += i;
+ }
+
+ return l;
+ }
+
+ /// CHECK-START: int Main.constantSwitch_InRange() dead_code_elimination_final (before)
+ /// CHECK-DAG: PackedSwitch
+
+ /// CHECK-START: int Main.constantSwitch_InRange() dead_code_elimination_final (after)
+ /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7
+ /// CHECK-DAG: Return [<<Const7>>]
+
+ /// CHECK-START: int Main.constantSwitch_InRange() dead_code_elimination_final (after)
+ /// CHECK-NOT: PackedSwitch
+
+ public static int constantSwitch_InRange() {
+ int i = $inline$method();
+ switch(i) {
+ case 1:
+ i++;
+ break;
+ case 2:
+ i = 99;
+ break;
+ case 3:
+ i = 100;
+ break;
+ case 4:
+ i = -100;
+ break;
+ case 5:
+ i = 7;
+ break;
+ case 6:
+ i = -9;
+ break;
+ }
+
+ return i;
+ }
+
+ /// CHECK-START: int Main.constantSwitch_AboveRange() dead_code_elimination_final (before)
+ /// CHECK-DAG: PackedSwitch
+
+ /// CHECK-START: int Main.constantSwitch_AboveRange() dead_code_elimination_final (after)
+ /// CHECK-DAG: <<Const15:i\d+>> IntConstant 15
+ /// CHECK-DAG: Return [<<Const15>>]
+
+ /// CHECK-START: int Main.constantSwitch_AboveRange() dead_code_elimination_final (after)
+ /// CHECK-NOT: PackedSwitch
+
+ public static int constantSwitch_AboveRange() {
+ int i = $inline$method() + 10;
+ switch(i) {
+ case 1:
+ i++;
+ break;
+ case 2:
+ i = 99;
+ break;
+ case 3:
+ i = 100;
+ break;
+ case 4:
+ i = -100;
+ break;
+ case 5:
+ i = 7;
+ break;
+ case 6:
+ i = -9;
+ break;
+ }
+
+ return i;
+ }
+
+ /// CHECK-START: int Main.constantSwitch_BelowRange() dead_code_elimination_final (before)
+ /// CHECK-DAG: PackedSwitch
+
+ /// CHECK-START: int Main.constantSwitch_BelowRange() dead_code_elimination_final (after)
+ /// CHECK-DAG: <<ConstM5:i\d+>> IntConstant -5
+ /// CHECK-DAG: Return [<<ConstM5>>]
+
+ /// CHECK-START: int Main.constantSwitch_BelowRange() dead_code_elimination_final (after)
+ /// CHECK-NOT: PackedSwitch
+
+ public static int constantSwitch_BelowRange() {
+ int i = $inline$method() - 10;
+ switch(i) {
+ case 1:
+ i++;
+ break;
+ case 2:
+ i = 99;
+ break;
+ case 3:
+ i = 100;
+ break;
+ case 4:
+ i = -100;
+ break;
+ case 5:
+ i = 7;
+ break;
+ case 6:
+ i = -9;
+ break;
+ }
+
+ return i;
+ }
+
+ public static void main(String[] args) throws Exception {
+ int ret_val = wholeSwitchDead(10);
+ if (ret_val != 100) {
+ throw new Error("Incorrect return value from wholeSwitchDead:" + ret_val);
+ }
+
+ ret_val = constantSwitch_InRange();
+ if (ret_val != 7) {
+ throw new Error("Incorrect return value from constantSwitch_InRange:" + ret_val);
+ }
+
+ ret_val = constantSwitch_AboveRange();
+ if (ret_val != 15) {
+ throw new Error("Incorrect return value from constantSwitch_AboveRange:" + ret_val);
+ }
+
+ ret_val = constantSwitch_BelowRange();
+ if (ret_val != -5) {
+ throw new Error("Incorrect return value from constantSwitch_BelowRange:" + ret_val);
+ }
+ }
+}
diff --git a/test/526-checker-caller-callee-regs/src/Main.java b/test/526-checker-caller-callee-regs/src/Main.java
index a1f33014ef..f402c2cd48 100644
--- a/test/526-checker-caller-callee-regs/src/Main.java
+++ b/test/526-checker-caller-callee-regs/src/Main.java
@@ -36,6 +36,8 @@ public class Main {
// ------------------------------|------------------------|-----------------
// ARM64 callee-saved registers | [x20-x29] | x2[0-9]
// ARM callee-saved registers | [r5-r8,r10,r11] | r([5-8]|10|11)
+ // X86 callee-saved registers | [ebp,esi,edi] | e(bp|si|di)
+ // X86_64 callee-saved registers | [rbx,rbp,r12-15] | r(bx|bp|1[2-5])
/**
* Check that a value live across a function call is allocated in a callee
@@ -58,7 +60,21 @@ public class Main {
/// CHECK: Sub [<<t1>>,<<t2>>]
/// CHECK: Return
- // TODO: Add tests for other architectures.
+ /// CHECK-START-X86: int Main.$opt$LiveInCall(int) register (after)
+ /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
+ /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
+ /// CHECK: <<t1:i\d+>> Add [<<Arg>>,<<Const1>>] {{.*->e(bp|si|di)}}
+ /// CHECK: <<t2:i\d+>> InvokeStaticOrDirect
+ /// CHECK: Sub [<<t1>>,<<t2>>]
+ /// CHECK: Return
+
+ /// CHECK-START-X86_64: int Main.$opt$LiveInCall(int) register (after)
+ /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
+ /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
+ /// CHECK: <<t1:i\d+>> Add [<<Arg>>,<<Const1>>] {{.*->r(bx|bp|1[2-5])}}
+ /// CHECK: <<t2:i\d+>> InvokeStaticOrDirect
+ /// CHECK: Sub [<<t1>>,<<t2>>]
+ /// CHECK: Return
public static int $opt$LiveInCall(int arg) {
int t1 = arg + 1;
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/run-test b/test/run-test
index 828939d247..a5b6e92869 100755
--- a/test/run-test
+++ b/test/run-test
@@ -392,7 +392,7 @@ fi
# Most interesting target architecture variables are Makefile variables, not environment variables.
# Try to map the suffix64 flag and what we find in ${ANDROID_PRODUCT_OUT}/data/art-test to an architecture name.
-function guess_arch_name() {
+function guess_target_arch_name() {
grep32bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm|x86|mips)$'`
grep64bit=`ls ${ANDROID_PRODUCT_OUT}/data/art-test | grep -E '^(arm64|x86_64|mips64)$'`
if [ "x${suffix64}" = "x64" ]; then
@@ -402,6 +402,14 @@ function guess_arch_name() {
fi
}
+function guess_host_arch_name() {
+ if [ "x${suffix64}" = "x64" ]; then
+ host_arch_name="x86_64"
+ else
+ host_arch_name="x86"
+ fi
+}
+
if [ "$target_mode" = "no" ]; then
if [ "$runtime" = "jvm" ]; then
if [ "$prebuild_mode" = "yes" ]; then
@@ -437,10 +445,11 @@ elif [ "$runtime" = "art" ]; then
if [ -z "$ANDROID_HOST_OUT" ]; then
export ANDROID_HOST_OUT=$ANDROID_BUILD_TOP/out/host/linux-x86
fi
+ guess_host_arch_name
run_args="${run_args} --boot ${ANDROID_HOST_OUT}/framework/core${image_suffix}${pic_image_suffix}.art"
run_args="${run_args} --runtime-option -Djava.library.path=${ANDROID_HOST_OUT}/lib${suffix64}"
else
- guess_arch_name
+ guess_target_arch_name
run_args="${run_args} --runtime-option -Djava.library.path=/data/art-test/${target_arch_name}"
run_args="${run_args} --boot /data/art-test/core${image_suffix}${pic_image_suffix}.art"
fi
@@ -635,7 +644,7 @@ if [[ "$TEST_NAME" =~ ^[0-9]+-checker- ]]; then
run_checker="yes"
if [ "$target_mode" = "no" ]; then
cfg_output_dir="$tmp_dir"
- checker_arch_option=
+ checker_arch_option="--arch=${host_arch_name^^}"
else
cfg_output_dir="$DEX_LOCATION"
checker_arch_option="--arch=${target_arch_name^^}"