26 import jdk.test.lib.Asserts;
27 import java.lang.reflect.Method;
28 import java.util.Arrays;
29
30 /*
31 * @test
32 * @summary Test nullable value type arrays
33 * @library /testlibrary /test/lib /compiler/whitebox /
34 * @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64")
35 * @compile TestNullableArrays.java
36 * @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform
37 * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
38 * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI
39 * compiler.valhalla.valuetypes.ValueTypeTest
40 * compiler.valhalla.valuetypes.TestNullableArrays
41 */
42 public class TestNullableArrays extends ValueTypeTest {
43 // Unlike C2, C1 intrinsics never deoptimize System.arraycopy. Instead, we fall back to
44 // a normal method invocation when encountering flattened arrays.
45 private static void assertDeoptimizedByC2(Method m) {
46 int CompLevel_none = 0, // Interpreter
47 CompLevel_simple = 1, // C1
48 CompLevel_limited_profile = 2, // C1, invocation & backedge counters
49 CompLevel_full_profile = 3, // C1, invocation & backedge counters + mdo
50 CompLevel_full_optimization = 4; // C2 or JVMCI
51
52 if (USE_COMPILER && !XCOMP && WHITE_BOX.isMethodCompiled(m, false) &&
53 WHITE_BOX.getMethodCompilationLevel(m, false) >= CompLevel_full_optimization) {
54 throw new RuntimeException("Type check should have caused it to deoptimize");
55 }
56 }
57
58 // Extra VM parameters for some test scenarios. See ValueTypeTest.getVMParameters()
59 @Override
60 public String[] getExtraVMParameters(int scenario) {
61 switch (scenario) {
62 case 2: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"};
63 case 3: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"};
64 case 4: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"};
65 case 5: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"};
66 }
67 return null;
68 }
69
70 public static void main(String[] args) throws Throwable {
71 TestNullableArrays test = new TestNullableArrays();
72 test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class);
73 }
|
26 import jdk.test.lib.Asserts;
27 import java.lang.reflect.Method;
28 import java.util.Arrays;
29
30 /*
31 * @test
32 * @summary Test nullable value type arrays
33 * @library /testlibrary /test/lib /compiler/whitebox /
34 * @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64")
35 * @compile TestNullableArrays.java
36 * @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform
37 * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
38 * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI
39 * compiler.valhalla.valuetypes.ValueTypeTest
40 * compiler.valhalla.valuetypes.TestNullableArrays
41 */
42 public class TestNullableArrays extends ValueTypeTest {
43 // Unlike C2, C1 intrinsics never deoptimize System.arraycopy. Instead, we fall back to
44 // a normal method invocation when encountering flattened arrays.
45 private static void assertDeoptimizedByC2(Method m) {
46 if (isCompiledByC2(m)) {
47 throw new RuntimeException("Type check should have caused it to deoptimize");
48 }
49 }
50
51 // Extra VM parameters for some test scenarios. See ValueTypeTest.getVMParameters()
52 @Override
53 public String[] getExtraVMParameters(int scenario) {
54 switch (scenario) {
55 case 2: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"};
56 case 3: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"};
57 case 4: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"};
58 case 5: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"};
59 }
60 return null;
61 }
62
63 public static void main(String[] args) throws Throwable {
64 TestNullableArrays test = new TestNullableArrays();
65 test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class);
66 }
|