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);
70 test4_mh = MethodHandles.filterReturnValue(test4_mh2, test4_mh1);
71
72 MethodType test5_mt = MethodType.methodType(int.class, MyValue1.class);
73 test5_mh = lookup.findVirtual(clazz, "test5_target", test5_mt);
74
75 MethodType test6_mt = MethodType.methodType(MyValue3.class);
76 MethodHandle test6_mh1 = lookup.findVirtual(clazz, "test6_target1", test6_mt);
77 MethodHandle test6_mh2 = lookup.findVirtual(clazz, "test6_target2", test6_mt);
78 MethodType boolean_mt = MethodType.methodType(boolean.class);
|
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 MethodHandles.Lookup lookup = MethodHandles.lookup();
59
60 MethodType mt = MethodType.methodType(MyValue3.class);
61 test1_mh = lookup.findVirtual(clazz, "test1_target", mt);
62 test2_mh = lookup.findVirtual(clazz, "test2_target", mt);
63 test3_mh = lookup.findVirtual(clazz, "test3_target", mt);
64
65 MethodType test4_mt1 = MethodType.methodType(int.class, MyValue1.class);
66 MethodType test4_mt2 = MethodType.methodType(MyValue1.class);
67 MethodHandle test4_mh1 = lookup.findStatic(clazz, "test4_helper1", test4_mt1);
68 MethodHandle test4_mh2 = lookup.findStatic(clazz, "test4_helper2", test4_mt2);
69 test4_mh = MethodHandles.filterReturnValue(test4_mh2, test4_mh1);
70
71 MethodType test5_mt = MethodType.methodType(int.class, MyValue1.class);
72 test5_mh = lookup.findVirtual(clazz, "test5_target", test5_mt);
73
74 MethodType test6_mt = MethodType.methodType(MyValue3.class);
75 MethodHandle test6_mh1 = lookup.findVirtual(clazz, "test6_target1", test6_mt);
76 MethodHandle test6_mh2 = lookup.findVirtual(clazz, "test6_target2", test6_mt);
77 MethodType boolean_mt = MethodType.methodType(boolean.class);
|