29 * specified method and that such method will not be deoptimized
30 * on high abort ratio.
31 * @library /test/lib /
32 * @modules java.base/jdk.internal.misc
33 * java.management
34 * @build sun.hotspot.WhiteBox
35 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
36 * sun.hotspot.WhiteBox$WhiteBoxPermission
37 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
38 * -XX:+WhiteBoxAPI
39 * compiler.rtm.method_options.TestUseRTMLockElidingOption
40 */
41
42 package compiler.rtm.method_options;
43
44 import compiler.testlibrary.rtm.AbortProvoker;
45 import compiler.testlibrary.rtm.AbortType;
46 import compiler.testlibrary.rtm.RTMLockingStatistics;
47 import compiler.testlibrary.rtm.RTMTestBase;
48 import compiler.testlibrary.rtm.predicate.SupportedCPU;
49 import compiler.testlibrary.rtm.predicate.SupportedVM;
50 import jdk.test.lib.Asserts;
51 import jdk.test.lib.process.OutputAnalyzer;
52 import jdk.test.lib.cli.CommandLineOptionTest;
53 import jdk.test.lib.cli.predicate.AndPredicate;
54
55 import java.util.List;
56
57 /**
58 * Test verifies that method tagged with option <i>UseRTMLockElidingOption</i>
59 * will use RTM-based lock elision, but will be never deoptimized with
60 * <i>rtm_state_change reason</i>.
61 * Test invokes compiled method and checks that no deoptimization with
62 * <i>rtm_state_change</i> reason had happened and that that VM output
63 * contains RTM locking statistics for compiled method and that total locks
64 * count equals to method's invocations.
65 * Since last assert is pretty strict, test uses -XX:RTMRetryCount=0 in order
66 * to avoid issue with retriable aborts described in
67 * {@link TestUseRTMAfterLockInflation}.
68 */
69 public class TestUseRTMLockElidingOption extends CommandLineOptionTest {
70 private TestUseRTMLockElidingOption() {
71 super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
72 }
73
74 @Override
75 public void runTestCases() throws Throwable {
76 verifyOption(false);
77 verifyOption(true);
78 }
79
80 public void verifyOption(boolean useStackLock) throws Throwable {
81 AbortProvoker provoker = AbortType.XABORT.provoker();
82 String logFileName = String.format("rtm_deopt_%s_stack_lock.xml",
83 (useStackLock ? "use" : "no"));
84 String methodOption = String.format("-XX:CompileCommand=option," +
85 "%s,UseRTMLockEliding", provoker.getMethodWithLockName());
86
87 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
88 logFileName,
89 provoker,
90 CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
91 useStackLock),
|
29 * specified method and that such method will not be deoptimized
30 * on high abort ratio.
31 * @library /test/lib /
32 * @modules java.base/jdk.internal.misc
33 * java.management
34 * @build sun.hotspot.WhiteBox
35 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
36 * sun.hotspot.WhiteBox$WhiteBoxPermission
37 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
38 * -XX:+WhiteBoxAPI
39 * compiler.rtm.method_options.TestUseRTMLockElidingOption
40 */
41
42 package compiler.rtm.method_options;
43
44 import compiler.testlibrary.rtm.AbortProvoker;
45 import compiler.testlibrary.rtm.AbortType;
46 import compiler.testlibrary.rtm.RTMLockingStatistics;
47 import compiler.testlibrary.rtm.RTMTestBase;
48 import compiler.testlibrary.rtm.predicate.SupportedCPU;
49 import compiler.testlibrary.rtm.predicate.SupportedOS;
50 import compiler.testlibrary.rtm.predicate.SupportedVM;
51 import jdk.test.lib.Asserts;
52 import jdk.test.lib.process.OutputAnalyzer;
53 import jdk.test.lib.cli.CommandLineOptionTest;
54 import jdk.test.lib.cli.predicate.AndPredicate;
55
56 import java.util.List;
57
58 /**
59 * Test verifies that method tagged with option <i>UseRTMLockElidingOption</i>
60 * will use RTM-based lock elision, but will be never deoptimized with
61 * <i>rtm_state_change reason</i>.
62 * Test invokes compiled method and checks that no deoptimization with
63 * <i>rtm_state_change</i> reason had happened and that that VM output
64 * contains RTM locking statistics for compiled method and that total locks
65 * count equals to method's invocations.
66 * Since last assert is pretty strict, test uses -XX:RTMRetryCount=0 in order
67 * to avoid issue with retriable aborts described in
68 * {@link TestUseRTMAfterLockInflation}.
69 */
70 public class TestUseRTMLockElidingOption extends CommandLineOptionTest {
71 private TestUseRTMLockElidingOption() {
72 super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
73 }
74
75 @Override
76 public void runTestCases() throws Throwable {
77 verifyOption(false);
78 verifyOption(true);
79 }
80
81 public void verifyOption(boolean useStackLock) throws Throwable {
82 AbortProvoker provoker = AbortType.XABORT.provoker();
83 String logFileName = String.format("rtm_deopt_%s_stack_lock.xml",
84 (useStackLock ? "use" : "no"));
85 String methodOption = String.format("-XX:CompileCommand=option," +
86 "%s,UseRTMLockEliding", provoker.getMethodWithLockName());
87
88 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
89 logFileName,
90 provoker,
91 CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
92 useStackLock),
|