28 * @summary Verify that RTMTotalCountIncrRate option affects
29 * RTM locking statistics.
30 * @library /test/lib /
31 * @modules java.base/jdk.internal.misc
32 * java.management
33 * @build sun.hotspot.WhiteBox
34 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
35 * sun.hotspot.WhiteBox$WhiteBoxPermission
36 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
37 * -XX:+WhiteBoxAPI
38 * compiler.rtm.locking.TestRTMTotalCountIncrRate
39 */
40
41 package compiler.rtm.locking;
42
43 import compiler.testlibrary.rtm.AbortProvoker;
44 import compiler.testlibrary.rtm.CompilableTest;
45 import compiler.testlibrary.rtm.RTMLockingStatistics;
46 import compiler.testlibrary.rtm.RTMTestBase;
47 import compiler.testlibrary.rtm.predicate.SupportedCPU;
48 import compiler.testlibrary.rtm.predicate.SupportedVM;
49 import jdk.internal.misc.Unsafe;
50 import jdk.test.lib.Asserts;
51 import jdk.test.lib.process.OutputAnalyzer;
52 import jdk.test.lib.unsafe.UnsafeHelper;
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 with RTMTotalCountIncrRate=1 RTM locking statistics
60 * contains precise information abort attempted locks and that with other values
61 * statistics contains information abort non-zero locking attempts.
62 * Since assert done for RTMTotalCountIncrRate=1 is pretty strict, test uses
63 * -XX:RTMRetryCount=0 to avoid issue with retriable aborts. For more details on
64 * that issue see {@link TestUseRTMAfterLockInflation}.
65 */
66 public class TestRTMTotalCountIncrRate extends CommandLineOptionTest {
67 private TestRTMTotalCountIncrRate() {
68 super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
69 }
70
71 @Override
72 protected void runTestCases() throws Throwable {
73 verifyLocksCount(1, false);
74 verifyLocksCount(64, false);
75 verifyLocksCount(128, false);
76 verifyLocksCount(1, true);
77 verifyLocksCount(64, true);
78 verifyLocksCount(128, true);
79 }
80
81 private void verifyLocksCount(int incrRate, boolean useStackLock)
82 throws Throwable{
83 CompilableTest test = new Test();
84
85 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
86 test,
87 CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
88 useStackLock),
|
28 * @summary Verify that RTMTotalCountIncrRate option affects
29 * RTM locking statistics.
30 * @library /test/lib /
31 * @modules java.base/jdk.internal.misc
32 * java.management
33 * @build sun.hotspot.WhiteBox
34 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
35 * sun.hotspot.WhiteBox$WhiteBoxPermission
36 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
37 * -XX:+WhiteBoxAPI
38 * compiler.rtm.locking.TestRTMTotalCountIncrRate
39 */
40
41 package compiler.rtm.locking;
42
43 import compiler.testlibrary.rtm.AbortProvoker;
44 import compiler.testlibrary.rtm.CompilableTest;
45 import compiler.testlibrary.rtm.RTMLockingStatistics;
46 import compiler.testlibrary.rtm.RTMTestBase;
47 import compiler.testlibrary.rtm.predicate.SupportedCPU;
48 import compiler.testlibrary.rtm.predicate.SupportedOS;
49 import compiler.testlibrary.rtm.predicate.SupportedVM;
50 import jdk.internal.misc.Unsafe;
51 import jdk.test.lib.Asserts;
52 import jdk.test.lib.process.OutputAnalyzer;
53 import jdk.test.lib.unsafe.UnsafeHelper;
54 import jdk.test.lib.cli.CommandLineOptionTest;
55 import jdk.test.lib.cli.predicate.AndPredicate;
56
57 import java.util.List;
58
59 /**
60 * Test verifies that with RTMTotalCountIncrRate=1 RTM locking statistics
61 * contains precise information abort attempted locks and that with other values
62 * statistics contains information abort non-zero locking attempts.
63 * Since assert done for RTMTotalCountIncrRate=1 is pretty strict, test uses
64 * -XX:RTMRetryCount=0 to avoid issue with retriable aborts. For more details on
65 * that issue see {@link TestUseRTMAfterLockInflation}.
66 */
67 public class TestRTMTotalCountIncrRate extends CommandLineOptionTest {
68 private TestRTMTotalCountIncrRate() {
69 super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
70 }
71
72 @Override
73 protected void runTestCases() throws Throwable {
74 verifyLocksCount(1, false);
75 verifyLocksCount(64, false);
76 verifyLocksCount(128, false);
77 verifyLocksCount(1, true);
78 verifyLocksCount(64, true);
79 verifyLocksCount(128, true);
80 }
81
82 private void verifyLocksCount(int incrRate, boolean useStackLock)
83 throws Throwable{
84 CompilableTest test = new Test();
85
86 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
87 test,
88 CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
89 useStackLock),
|