27 * @summary Verify that RTMSpinLoopCount affects time spent |
27 * @summary Verify that RTMSpinLoopCount affects time spent |
28 * between locking attempts. |
28 * between locking attempts. |
29 * @library /test/lib / |
29 * @library /test/lib / |
30 * @modules java.base/jdk.internal.misc |
30 * @modules java.base/jdk.internal.misc |
31 * java.management |
31 * java.management |
|
32 * @requires vm.flavor == "server" & !vm.emulatedClient & vm.rtm.cpu & vm.rtm.os |
32 * @build sun.hotspot.WhiteBox |
33 * @build sun.hotspot.WhiteBox |
33 * @run driver ClassFileInstaller sun.hotspot.WhiteBox |
34 * @run driver ClassFileInstaller sun.hotspot.WhiteBox |
34 * sun.hotspot.WhiteBox$WhiteBoxPermission |
35 * sun.hotspot.WhiteBox$WhiteBoxPermission |
35 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
36 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
36 * -XX:+WhiteBoxAPI |
37 * -XX:+WhiteBoxAPI |
41 |
42 |
42 import compiler.testlibrary.rtm.BusyLock; |
43 import compiler.testlibrary.rtm.BusyLock; |
43 import compiler.testlibrary.rtm.CompilableTest; |
44 import compiler.testlibrary.rtm.CompilableTest; |
44 import compiler.testlibrary.rtm.RTMLockingStatistics; |
45 import compiler.testlibrary.rtm.RTMLockingStatistics; |
45 import compiler.testlibrary.rtm.RTMTestBase; |
46 import compiler.testlibrary.rtm.RTMTestBase; |
46 import compiler.testlibrary.rtm.predicate.SupportedCPU; |
|
47 import compiler.testlibrary.rtm.predicate.SupportedOS; |
|
48 import compiler.testlibrary.rtm.predicate.SupportedVM; |
|
49 import jdk.test.lib.Asserts; |
47 import jdk.test.lib.Asserts; |
50 import jdk.test.lib.process.OutputAnalyzer; |
48 import jdk.test.lib.process.OutputAnalyzer; |
51 import jdk.test.lib.cli.CommandLineOptionTest; |
49 import jdk.test.lib.cli.CommandLineOptionTest; |
52 import jdk.test.lib.cli.predicate.AndPredicate; |
|
53 |
50 |
54 import java.util.List; |
51 import java.util.List; |
55 |
52 |
56 /** |
53 /** |
57 * Test verifies that RTMSpinLoopCount increase time spent between retries |
54 * Test verifies that RTMSpinLoopCount increase time spent between retries |
58 * by comparing amount of retries done with different RTMSpinLoopCount's values. |
55 * by comparing amount of retries done with different RTMSpinLoopCount's values. |
59 */ |
56 */ |
60 public class TestRTMSpinLoopCount extends CommandLineOptionTest { |
57 public class TestRTMSpinLoopCount { |
61 private static final int LOCKING_TIME = 1000; |
58 private static final int LOCKING_TIME = 1000; |
62 private static final int RTM_RETRY_COUNT = 1000; |
59 private static final int RTM_RETRY_COUNT = 1000; |
63 private static final boolean INFLATE_MONITOR = true; |
60 private static final boolean INFLATE_MONITOR = true; |
64 private static final long MAX_ABORTS = RTM_RETRY_COUNT + 1L; |
61 private static final long MAX_ABORTS = RTM_RETRY_COUNT + 1L; |
65 private static final int[] SPIN_LOOP_COUNTS |
62 private static final int[] SPIN_LOOP_COUNTS |
66 = new int[] { 0, 100, 1_000, 1_000_000, 10_000_000 }; |
63 = new int[] { 0, 100, 1_000, 1_000_000, 10_000_000 }; |
67 |
64 |
68 private TestRTMSpinLoopCount() { |
|
69 super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM())); |
|
70 } |
|
71 |
|
72 @Override |
|
73 protected void runTestCases() throws Throwable { |
65 protected void runTestCases() throws Throwable { |
74 long[] aborts = new long[TestRTMSpinLoopCount.SPIN_LOOP_COUNTS.length]; |
66 long[] aborts = new long[TestRTMSpinLoopCount.SPIN_LOOP_COUNTS.length]; |
75 for (int i = 0; i < TestRTMSpinLoopCount.SPIN_LOOP_COUNTS.length; i++) { |
67 for (int i = 0; i < TestRTMSpinLoopCount.SPIN_LOOP_COUNTS.length; i++) { |
76 aborts[i] = getAbortsCountOnLockBusy( |
68 aborts[i] = getAbortsCountOnLockBusy( |
77 TestRTMSpinLoopCount.SPIN_LOOP_COUNTS[i]); |
69 TestRTMSpinLoopCount.SPIN_LOOP_COUNTS[i]); |