28 * @summary Verify that rtm locking is used for stack locks before
29 * inflation and after it used for inflated locks.
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.TestUseRTMAfterLockInflation
39 */
40
41 package compiler.rtm.locking;
42
43 import compiler.testlibrary.rtm.AbortProvoker;
44 import compiler.testlibrary.rtm.AbortType;
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.test.lib.Asserts;
50 import jdk.test.lib.process.OutputAnalyzer;
51 import jdk.test.lib.cli.CommandLineOptionTest;
52 import jdk.test.lib.cli.predicate.AndPredicate;
53
54 import java.util.List;
55
56 /**
57 * Test verifies that RTM is used after lock inflation by executing compiled
58 * method with RTM-based lock elision using stack lock first, then that lock
59 * is inflated and the same compiled method invoked again.
60 *
61 * Compiled method invoked {@code AbortProvoker.DEFAULT_ITERATIONS} times before
62 * lock inflation and the same amount of times after inflation.
63 * As a result total locks count should be equal to
64 * {@code 2 * AbortProvoker.DEFAULT_ITERATIONS}.
65 * It is a pretty strict assertion which could fail if some retriable abort
66 * happened: it could be {@code AbortType.RETRIABLE} or
67 * {@code AbortType.MEM_CONFLICT}, but unfortunately abort can has both these
68 * reasons simultaneously. In order to avoid false negative failures related
69 * to incorrect aborts counting, -XX:RTMRetryCount=0 is used.
70 */
71 public class TestUseRTMAfterLockInflation extends CommandLineOptionTest {
72 private static final long EXPECTED_LOCKS
73 = 2L * AbortProvoker.DEFAULT_ITERATIONS;
74
75 private TestUseRTMAfterLockInflation() {
76 super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
77 }
78
79 @Override
80 protected void runTestCases() throws Throwable {
81 AbortProvoker provoker = AbortType.XABORT.provoker();
82 long totalLocksCount = 0;
83
84 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
85 provoker,
86 "-XX:+UseRTMForStackLocks",
87 "-XX:RTMTotalCountIncrRate=1",
88 "-XX:RTMRetryCount=0",
89 "-XX:+PrintPreciseRTMLockingStatistics",
90 Test.class.getName(),
91 AbortType.XABORT.toString());
92
93 outputAnalyzer.shouldHaveExitValue(0);
94
95 List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
96 provoker.getMethodWithLockName(), outputAnalyzer.getOutput());
|
28 * @summary Verify that rtm locking is used for stack locks before
29 * inflation and after it used for inflated locks.
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.TestUseRTMAfterLockInflation
39 */
40
41 package compiler.rtm.locking;
42
43 import compiler.testlibrary.rtm.AbortProvoker;
44 import compiler.testlibrary.rtm.AbortType;
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.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 RTM is used after lock inflation by executing compiled
59 * method with RTM-based lock elision using stack lock first, then that lock
60 * is inflated and the same compiled method invoked again.
61 *
62 * Compiled method invoked {@code AbortProvoker.DEFAULT_ITERATIONS} times before
63 * lock inflation and the same amount of times after inflation.
64 * As a result total locks count should be equal to
65 * {@code 2 * AbortProvoker.DEFAULT_ITERATIONS}.
66 * It is a pretty strict assertion which could fail if some retriable abort
67 * happened: it could be {@code AbortType.RETRIABLE} or
68 * {@code AbortType.MEM_CONFLICT}, but unfortunately abort can has both these
69 * reasons simultaneously. In order to avoid false negative failures related
70 * to incorrect aborts counting, -XX:RTMRetryCount=0 is used.
71 */
72 public class TestUseRTMAfterLockInflation extends CommandLineOptionTest {
73 private static final long EXPECTED_LOCKS
74 = 2L * AbortProvoker.DEFAULT_ITERATIONS;
75
76 private TestUseRTMAfterLockInflation() {
77 super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
78 }
79
80 @Override
81 protected void runTestCases() throws Throwable {
82 AbortProvoker provoker = AbortType.XABORT.provoker();
83 long totalLocksCount = 0;
84
85 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
86 provoker,
87 "-XX:+UseRTMForStackLocks",
88 "-XX:RTMTotalCountIncrRate=1",
89 "-XX:RTMRetryCount=0",
90 "-XX:+PrintPreciseRTMLockingStatistics",
91 Test.class.getName(),
92 AbortType.XABORT.toString());
93
94 outputAnalyzer.shouldHaveExitValue(0);
95
96 List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
97 provoker.getMethodWithLockName(), outputAnalyzer.getOutput());
|