summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/004-JniTest/expected.txt1
-rw-r--r--test/004-JniTest/jni_test.cc8
-rw-r--r--test/004-JniTest/src/Main.java15
-rwxr-xr-xtest/137-cfi/run7
-rw-r--r--test/445-checker-licm/src/Main.java28
-rw-r--r--test/458-checker-instruct-simplification/src/Main.java138
-rw-r--r--test/706-checker-scheduler/src/Main.java64
-rw-r--r--test/AllFields/AllFields.java2
-rw-r--r--test/AllFields/AllFieldsSub.java17
-rw-r--r--test/AllFields/AllFieldsUnrelated.java17
10 files changed, 157 insertions, 140 deletions
diff --git a/test/004-JniTest/expected.txt b/test/004-JniTest/expected.txt
index 1d05160883..b09b9a22eb 100644
--- a/test/004-JniTest/expected.txt
+++ b/test/004-JniTest/expected.txt
@@ -1,4 +1,5 @@
JNI_OnLoad called
+ABC.XYZ = 12, GetStaticIntField(DEF.class, 'XYZ') = 12
Super.<init>
Super.<init>
Subclass.<init>
diff --git a/test/004-JniTest/jni_test.cc b/test/004-JniTest/jni_test.cc
index 4561895509..33a8f5bba2 100644
--- a/test/004-JniTest/jni_test.cc
+++ b/test/004-JniTest/jni_test.cc
@@ -90,6 +90,14 @@ static void testFindClassOnAttachedNativeThread(JNIEnv* env) {
CHECK(!env->ExceptionCheck());
}
+extern "C" JNIEXPORT jint JNICALL Java_Main_getFieldSubclass(JNIEnv* env,
+ jclass,
+ jobject f_obj,
+ jclass sub) {
+ jfieldID f = env->FromReflectedField(f_obj);
+ return env->GetStaticIntField(sub, f);
+}
+
// http://b/10994325
extern "C" JNIEXPORT void JNICALL Java_Main_testFindClassOnAttachedNativeThread(JNIEnv*, jclass) {
PthreadHelper(&testFindClassOnAttachedNativeThread);
diff --git a/test/004-JniTest/src/Main.java b/test/004-JniTest/src/Main.java
index 871107c56b..f94dcf6c70 100644
--- a/test/004-JniTest/src/Main.java
+++ b/test/004-JniTest/src/Main.java
@@ -18,6 +18,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Field;
import java.lang.reflect.Proxy;
import java.util.regex.Pattern;
@@ -32,6 +33,7 @@ public class Main {
throw new RuntimeException("Slow-debug flags unexpectedly off.");
}
+ testFieldSubclass();
testFindClassOnAttachedNativeThread();
testFindFieldOnAttachedNativeThread();
testReflectFieldGetFromAttachedNativeThreadNative();
@@ -65,6 +67,19 @@ public class Main {
testDoubleLoad(args[0]);
}
+ static class ABC { public static int XYZ = 12; }
+ static class DEF extends ABC {}
+ public static void testFieldSubclass() {
+ try {
+ System.out.println("ABC.XYZ = " + ABC.XYZ + ", GetStaticIntField(DEF.class, 'XYZ') = " +
+ getFieldSubclass(ABC.class.getDeclaredField("XYZ"), DEF.class));
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to test get static field on a subclass", e);
+ }
+ }
+
+ public static native int getFieldSubclass(Field f, Class sub);
+
private static native boolean registerNativesJniTest();
private static native void testCallDefaultMethods();
diff --git a/test/137-cfi/run b/test/137-cfi/run
index ebc729bc74..adea71a07f 100755
--- a/test/137-cfi/run
+++ b/test/137-cfi/run
@@ -16,10 +16,15 @@
# Test with full DWARF debugging information.
# Check full signatures of methods.
+# The option jitthreshold:0 ensures that if we run the test in JIT mode,
+# there will be JITed frames on the callstack (it synchronously JITs on first use).
${RUN} "$@" -Xcompiler-option --generate-debug-info \
+ --runtime-option -Xjitthreshold:0 \
--args --full-signatures --args --test-local --args --test-remote
# Test with minimal compressed debugging information.
# Check only method names (parameters are omitted to save space).
# Check only remote unwinding since decompression is disabled in local unwinds (b/27391690).
-${RUN} "$@" -Xcompiler-option --generate-mini-debug-info --args --test-remote
+${RUN} "$@" -Xcompiler-option --generate-mini-debug-info \
+ --runtime-option -Xjitthreshold:0 \
+ --args --test-remote
diff --git a/test/445-checker-licm/src/Main.java b/test/445-checker-licm/src/Main.java
index 00ce3a9f8e..9635e70278 100644
--- a/test/445-checker-licm/src/Main.java
+++ b/test/445-checker-licm/src/Main.java
@@ -15,6 +15,11 @@
*/
public class Main {
+ static class Dummy {
+ static int getValue() {
+ return 1;
+ }
+ }
/// CHECK-START: int Main.div() licm (before)
/// CHECK-DAG: Div loop:{{B\d+}}
@@ -107,6 +112,28 @@ public class Main {
return result;
}
+ /// CHECK-START: int Main.clinitCheck() licm (before)
+ /// CHECK-DAG: <<LoadClass:l\d+>> LoadClass loop:<<Loop:B\d+>>
+ /// CHECK-DAG: ClinitCheck [<<LoadClass>>] loop:<<Loop>>
+
+ /// CHECK-START: int Main.clinitCheck() licm (after)
+ /// CHECK-NOT: LoadClass loop:{{B\d+}}
+ /// CHECK-NOT: ClinitCheck loop:{{B\d+}}
+
+ /// CHECK-START: int Main.clinitCheck() licm (after)
+ /// CHECK-DAG: <<LoadClass:l\d+>> LoadClass loop:none
+ /// CHECK-DAG: ClinitCheck [<<LoadClass>>] loop:none
+
+ public static int clinitCheck() {
+ int i = 0;
+ int sum = 0;
+ do {
+ sum += Dummy.getValue();
+ i++;
+ } while (i < 10);
+ return sum;
+ }
+
/// CHECK-START: int Main.divAndIntrinsic(int[]) licm (before)
/// CHECK-DAG: Div loop:{{B\d+}}
@@ -213,6 +240,7 @@ public class Main {
assertEquals(18900, innerMul());
assertEquals(105, divByA(2, 0));
assertEquals(12, arrayLength(new int[] { 4, 8 }));
+ assertEquals(10, clinitCheck());
assertEquals(21, divAndIntrinsic(new int[] { 4, -2, 8, -3 }));
assertEquals(45, invariantBoundIntrinsic(-10));
assertEquals(30, invariantBodyIntrinsic(2, 3));
diff --git a/test/458-checker-instruct-simplification/src/Main.java b/test/458-checker-instruct-simplification/src/Main.java
index ccaba61722..7797f31867 100644
--- a/test/458-checker-instruct-simplification/src/Main.java
+++ b/test/458-checker-instruct-simplification/src/Main.java
@@ -2602,124 +2602,6 @@ public class Main {
return (byte)((int)(((long)(b & 0xff)) & 255L));
}
- /// CHECK-START: void Main.$noinline$testIfCondStaticEvaluation(int[], boolean) instruction_simplifier (before)
- /// CHECK-DAG: <<Param:z\d+>> ParameterValue
- /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
- /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
- /// CHECK-DAG: <<Cond0:z\d+>> Equal [<<Param>>,<<Const0>>]
- /// CHECK-DAG: If [<<Cond0>>]
- /// CHECK-DAG: <<Cond1:z\d+>> Equal [<<Param>>,<<Const0>>]
- /// CHECK-DAG: If [<<Cond1>>]
- /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Const0>>]
- /// CHECK-DAG: <<Cond2:z\d+>> Equal [<<Param>>,<<Const0>>]
- /// CHECK-DAG: If [<<Cond2>>]
- /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Const1>>]
- //
- /// CHECK-NOT: If
- /// CHECK-NOT: ArraySet
-
- /// CHECK-START: void Main.$noinline$testIfCondStaticEvaluation(int[], boolean) instruction_simplifier (after)
- /// CHECK-DAG: <<Param:z\d+>> ParameterValue
- /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
- /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
- /// CHECK-DAG: If [<<Param>>]
- /// CHECK-DAG: <<Cond1:z\d+>> Equal [<<Const1>>,<<Const0>>]
- /// CHECK-DAG: If [<<Cond1>>]
- /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Const1>>]
- /// CHECK-DAG: <<Cond2:z\d+>> Equal [<<Const0>>,<<Const0>>]
- /// CHECK-DAG: If [<<Cond2>>]
- /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Const0>>]
- //
- /// CHECK-NOT: If
- /// CHECK-NOT: ArraySet
-
- /// CHECK-START: void Main.$noinline$testIfCondStaticEvaluation(int[], boolean) dead_code_elimination$after_inlining (after)
- /// CHECK-DAG: <<Param:z\d+>> ParameterValue
- /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
- /// CHECK-DAG: If [<<Param>>]
- /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Const1>>]
- //
- /// CHECK-NOT: IntConstant 0
- /// CHECK-NOT: If [<<Param>>]
- /// CHECK-NOT: ArraySet
- private static void $noinline$testIfCondStaticEvaluation(int[] a, boolean f) {
- if (f) {
- if (f) {
- a[0] = 1;
- }
- } else {
- if (f) {
- a[0] = 0;
- }
- }
- }
-
- /// CHECK-START: void Main.$noinline$testManualUnrollWithInvarExits(int[], boolean) instruction_simplifier (before)
- /// CHECK-DAG: <<Param:z\d+>> ParameterValue loop:none
- /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 loop:none
- /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 loop:none
- /// CHECK-DAG: <<Cond0:z\d+>> Equal [<<Param>>,<<Const0>>] loop:none
- /// CHECK-DAG: If [<<Cond0>>] loop:none
- /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Const1>>] loop:none
- /// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
- /// CHECK-DAG: <<LoopCheck:z\d+>> GreaterThanOrEqual loop:<<Loop>> outer_loop:none
- /// CHECK-DAG: If [<<LoopCheck>>] loop:<<Loop>> outer_loop:none
- /// CHECK-DAG: <<Cond1:z\d+>> NotEqual [<<Param>>,<<Const0>>] loop:<<Loop>> outer_loop:none
- /// CHECK-DAG: If [<<Cond1>>] loop:<<Loop>> outer_loop:none
- /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Const1>>] loop:<<Loop>> outer_loop:none
- //
- /// CHECK-NOT: If
- /// CHECK-NOT: ArraySet
-
- /// CHECK-START: void Main.$noinline$testManualUnrollWithInvarExits(int[], boolean) instruction_simplifier (after)
- /// CHECK-DAG: <<Param:z\d+>> ParameterValue loop:none
- /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 loop:none
- /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 loop:none
- /// CHECK-DAG: If [<<Param>>] loop:none
- /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Const1>>] loop:none
- /// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
- /// CHECK-DAG: <<LoopCheck:z\d+>> GreaterThanOrEqual loop:<<Loop>> outer_loop:none
- /// CHECK-DAG: If [<<LoopCheck>>] loop:<<Loop>> outer_loop:none
- /// CHECK-DAG: <<Cond1:z\d+>> NotEqual [<<Const0>>,<<Const0>>] loop:<<Loop>> outer_loop:none
- /// CHECK-DAG: If [<<Cond1>>] loop:<<Loop>> outer_loop:none
- /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Const1>>] loop:<<Loop>> outer_loop:none
- //
- /// CHECK-NOT: If
- /// CHECK-NOT: ArraySet
-
- /// CHECK-START: void Main.$noinline$testManualUnrollWithInvarExits(int[], boolean) dead_code_elimination$after_inlining (after)
- /// CHECK-DAG: <<Param:z\d+>> ParameterValue loop:none
- /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 loop:none
- /// CHECK-DAG: If [<<Param>>] loop:none
- /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Const1>>] loop:none
- /// CHECK-DAG: <<Phi:i\d+>> Phi loop:<<Loop:B\d+>> outer_loop:none
- /// CHECK-DAG: <<LoopCheck:z\d+>> GreaterThanOrEqual loop:<<Loop>> outer_loop:none
- /// CHECK-DAG: If [<<LoopCheck>>] loop:<<Loop>> outer_loop:none
- /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<<Const1>>] loop:<<Loop>> outer_loop:none
- //
- /// CHECK-NOT: If
- /// CHECK-NOT: ArraySet
- private static void $noinline$testManualUnrollWithInvarExits(int[] a, boolean f) {
- if (f) {
- return;
- }
- a[0] = 1;
- for (int i = 1; i < a.length; i++) {
- if (f) {
- return;
- }
- a[i] = 1;
- }
- }
-
- public static final int LENGTH = 1024;
-
- private static final void initArray(int[] a) {
- for (int i = 0; i < a.length; i++) {
- a[i] = 0;
- }
- }
-
public static void main(String[] args) {
int arg = 123456;
float floatArg = 123456.125f;
@@ -2963,26 +2845,6 @@ public class Main {
assertIntEquals(1, $noinline$bug68142795Boolean(true));
assertIntEquals(0x7f, $noinline$bug68142795Elaborate((byte) 0x7f));
assertIntEquals((byte) 0x80, $noinline$bug68142795Elaborate((byte) 0x80));
-
- int[] array = new int[LENGTH];
-
- array[0] = 0;
- $noinline$testIfCondStaticEvaluation(array, true);
- assertIntEquals(array[0], 1);
- array[0] = 0;
- $noinline$testIfCondStaticEvaluation(array, false);
- assertIntEquals(array[0], 0);
-
- initArray(array);
- $noinline$testManualUnrollWithInvarExits(array, false);
- for (int i = 0; i < array.length; i++) {
- assertIntEquals(array[i], 1);
- }
- initArray(array);
- $noinline$testManualUnrollWithInvarExits(array, true);
- for (int i = 0; i < array.length; i++) {
- assertIntEquals(array[i], 0);
- }
}
private static boolean $inline$true() { return true; }
diff --git a/test/706-checker-scheduler/src/Main.java b/test/706-checker-scheduler/src/Main.java
index d21596d4bc..25e4fad714 100644
--- a/test/706-checker-scheduler/src/Main.java
+++ b/test/706-checker-scheduler/src/Main.java
@@ -523,7 +523,71 @@ public class Main {
return res;
}
+ private static void expectEquals(int expected, int result) {
+ if (expected != result) {
+ throw new Error("Expected: " + expected + ", found: " + result);
+ }
+ }
+
+ private static final int ARRAY_SIZE = 32;
+
+ // Check that VecReplicateScalar is not reordered.
+ /// CHECK-START-ARM64: void Main.testVecReplicateScalar() scheduler (before)
+ /// CHECK: Phi loop:<<Loop:B\d+>> outer_loop:none
+ /// CHECK: NewArray loop:<<Loop>> outer_loop:none
+ /// CHECK: VecReplicateScalar loop:<<Loop>> outer_loop:none
+
+ /// CHECK-START-ARM64: void Main.testVecReplicateScalar() scheduler (after)
+ /// CHECK: Phi loop:<<Loop:B\d+>> outer_loop:none
+ /// CHECK: NewArray loop:<<Loop>> outer_loop:none
+ /// CHECK: VecReplicateScalar loop:<<Loop>> outer_loop:none
+ private static void testVecReplicateScalar() {
+ for (int j = 0; j <= 8; j++) {
+ int[] a = new int[ARRAY_SIZE];
+ for (int i = 0; i < a.length; i++) {
+ a[i] += 1;
+ }
+ for (int i = 0; i < a.length; i++) {
+ expectEquals(1, a[i]);
+ }
+ }
+ }
+
+ // Check that VecSetScalars, VecReduce, VecExtractScalar are not reordered.
+ /// CHECK-START-ARM64: void Main.testVecSetScalars() scheduler (before)
+ /// CHECK: Phi loop:<<Loop:B\d+>> outer_loop:none
+ /// CHECK: NewArray loop:<<Loop>> outer_loop:none
+ /// CHECK: VecSetScalars loop:<<Loop>> outer_loop:none
+ //
+ /// CHECK: VecReduce loop:<<Loop>> outer_loop:none
+ /// CHECK: VecExtractScalar loop:<<Loop>> outer_loop:none
+ /// CHECK: InvokeStaticOrDirect loop:<<Loop>> outer_loop:none
+ /// CHECK: InvokeStaticOrDirect loop:<<Loop>> outer_loop:none
+
+ /// CHECK-START-ARM64: void Main.testVecSetScalars() scheduler (after)
+ /// CHECK: Phi loop:<<Loop:B\d+>> outer_loop:none
+ /// CHECK: NewArray loop:<<Loop>> outer_loop:none
+ /// CHECK: VecSetScalars loop:<<Loop>> outer_loop:none
+ //
+ /// CHECK: VecReduce loop:<<Loop>> outer_loop:none
+ /// CHECK: VecExtractScalar loop:<<Loop>> outer_loop:none
+ /// CHECK: InvokeStaticOrDirect loop:<<Loop>> outer_loop:none
+ /// CHECK: InvokeStaticOrDirect loop:<<Loop>> outer_loop:none
+ private static void testVecSetScalars() {
+ for (int j = 0; j <= 8; j++) {
+ int[] a = new int[ARRAY_SIZE];
+ int s = 5;
+ for (int i = 0; i < ARRAY_SIZE; i++) {
+ s+=a[i];
+ }
+ expectEquals(a[0], 0);
+ expectEquals(s, 5);
+ }
+ }
+
public static void main(String[] args) {
+ testVecSetScalars();
+ testVecReplicateScalar();
if ((arrayAccess() + intDiv(10)) != -35) {
System.out.println("FAIL");
}
diff --git a/test/AllFields/AllFields.java b/test/AllFields/AllFields.java
index d5eac8fa2e..24f8ba1a0b 100644
--- a/test/AllFields/AllFields.java
+++ b/test/AllFields/AllFields.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-class AllFields {
+public class AllFields {
static boolean sZ;
static byte sB;
static char sC;
diff --git a/test/AllFields/AllFieldsSub.java b/test/AllFields/AllFieldsSub.java
new file mode 100644
index 0000000000..d5f933f88d
--- /dev/null
+++ b/test/AllFields/AllFieldsSub.java
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2017 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 AllFieldsSub extends AllFields { }
diff --git a/test/AllFields/AllFieldsUnrelated.java b/test/AllFields/AllFieldsUnrelated.java
new file mode 100644
index 0000000000..4db66b1886
--- /dev/null
+++ b/test/AllFields/AllFieldsUnrelated.java
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2017 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 AllFieldsUnrelated { }