29 import jdk.test.lib.Asserts;
30
31 /*
32 * @test
33 * @summary Test method handle support for value types
34 * @library /testlibrary /test/lib /compiler/whitebox /
35 * @requires os.simpleArch == "x64"
36 * @compile TestMethodHandles.java
37 * @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform
38 * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
39 * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI
40 * compiler.valhalla.valuetypes.ValueTypeTest
41 * compiler.valhalla.valuetypes.TestMethodHandles
42 */
43 public class TestMethodHandles extends ValueTypeTest {
44 // Extra VM parameters for some test scenarios. See ValueTypeTest.getVMParameters()
45 @Override
46 public String[] getExtraVMParameters(int scenario) {
47 switch (scenario) {
48 // Prevent inlining through MethodHandle linkTo adapters to stress the calling convention
49 case 2: return new String[] {"-XX:CompileCommand=dontinline,java.lang.invoke.DirectMethodHandle::internalMemberName"};
50 case 3: return new String[] {"-XX:ValueArrayElemMaxFlatSize=0"};
51 case 4: return new String[] {"-XX:CompileCommand=dontinline,java.lang.invoke.DirectMethodHandle::internalMemberName"};
52 }
53 return null;
54 }
55
56 static {
57 try {
58 Class<?> clazz = TestMethodHandles.class;
59 ClassLoader loader = clazz.getClassLoader();
60 MethodHandles.Lookup lookup = MethodHandles.lookup();
61
62 MethodType mt = MethodType.methodType(MyValue3.class);
63 test1_mh = lookup.findVirtual(clazz, "test1_target", mt);
64 test2_mh = lookup.findVirtual(clazz, "test2_target", mt);
65 test3_mh = lookup.findVirtual(clazz, "test3_target", mt);
66
67 MethodType test4_mt1 = MethodType.methodType(int.class, MyValue1.class);
68 MethodType test4_mt2 = MethodType.methodType(MyValue1.class);
69 MethodHandle test4_mh1 = lookup.findStatic(clazz, "test4_helper1", test4_mt1);
70 MethodHandle test4_mh2 = lookup.findStatic(clazz, "test4_helper2", test4_mt2);
|
29 import jdk.test.lib.Asserts;
30
31 /*
32 * @test
33 * @summary Test method handle support for value types
34 * @library /testlibrary /test/lib /compiler/whitebox /
35 * @requires os.simpleArch == "x64"
36 * @compile TestMethodHandles.java
37 * @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform
38 * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
39 * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI
40 * compiler.valhalla.valuetypes.ValueTypeTest
41 * compiler.valhalla.valuetypes.TestMethodHandles
42 */
43 public class TestMethodHandles extends ValueTypeTest {
44 // Extra VM parameters for some test scenarios. See ValueTypeTest.getVMParameters()
45 @Override
46 public String[] getExtraVMParameters(int scenario) {
47 switch (scenario) {
48 // Prevent inlining through MethodHandle linkTo adapters to stress the calling convention
49 case 2: return new String[] {"-DVerifyIR=false", "-XX:CompileCommand=dontinline,java.lang.invoke.DirectMethodHandle::internalMemberName"};
50 case 4: return new String[] {"-XX:CompileCommand=dontinline,java.lang.invoke.DirectMethodHandle::internalMemberName"};
51 }
52 return null;
53 }
54
55 static {
56 try {
57 Class<?> clazz = TestMethodHandles.class;
58 ClassLoader loader = clazz.getClassLoader();
59 MethodHandles.Lookup lookup = MethodHandles.lookup();
60
61 MethodType mt = MethodType.methodType(MyValue3.class);
62 test1_mh = lookup.findVirtual(clazz, "test1_target", mt);
63 test2_mh = lookup.findVirtual(clazz, "test2_target", mt);
64 test3_mh = lookup.findVirtual(clazz, "test3_target", mt);
65
66 MethodType test4_mt1 = MethodType.methodType(int.class, MyValue1.class);
67 MethodType test4_mt2 = MethodType.methodType(MyValue1.class);
68 MethodHandle test4_mh1 = lookup.findStatic(clazz, "test4_helper1", test4_mt1);
69 MethodHandle test4_mh2 = lookup.findStatic(clazz, "test4_helper2", test4_mt2);
|