13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @bug 8031320
27 * @summary Verify that UseRTMLockEliding option could be applied to
28 * specified method and that such method will not be deoptimized
29 * on high abort ratio.
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.method_options.TestUseRTMLockElidingOption
39 */
40
41 package compiler.rtm.method_options;
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 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 SupportedOS(), 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),
92 methodOption,
93 "-XX:RTMTotalCountIncrRate=1",
94 "-XX:RTMRetryCount=0",
105
106 Asserts.assertEQ(firedTraps, 0,
107 "Method deoptimization with rtm_state_change is unexpected");
108
109 List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
110 provoker.getMethodWithLockName(), outputAnalyzer.getOutput());
111
112 Asserts.assertEQ(statistics.size(), 1,
113 "VM output should contain exactly one RTM locking "
114 + "statistics entry for method "
115 + provoker.getMethodWithLockName());
116
117 RTMLockingStatistics lock = statistics.get(0);
118
119 Asserts.assertEQ(lock.getTotalLocks(), AbortProvoker.DEFAULT_ITERATIONS,
120 "Expected to get total locks count equal to total amount of "
121 + "lock attempts.");
122 }
123
124 public static void main(String args[]) throws Throwable {
125 new TestUseRTMLockElidingOption().test();
126 }
127 }
|
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @bug 8031320
27 * @summary Verify that UseRTMLockEliding option could be applied to
28 * specified method and that such method will not be deoptimized
29 * on high abort ratio.
30 * @library /test/lib /
31 * @modules java.base/jdk.internal.misc
32 * java.management
33 * @requires vm.flavor == "server" & !vm.emulatedClient & vm.rtm.cpu & vm.rtm.os
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 jdk.test.lib.Asserts;
49 import jdk.test.lib.process.OutputAnalyzer;
50 import jdk.test.lib.cli.CommandLineOptionTest;
51
52 import java.util.List;
53
54 /**
55 * Test verifies that method tagged with option <i>UseRTMLockElidingOption</i>
56 * will use RTM-based lock elision, but will be never deoptimized with
57 * <i>rtm_state_change reason</i>.
58 * Test invokes compiled method and checks that no deoptimization with
59 * <i>rtm_state_change</i> reason had happened and that that VM output
60 * contains RTM locking statistics for compiled method and that total locks
61 * count equals to method's invocations.
62 * Since last assert is pretty strict, test uses -XX:RTMRetryCount=0 in order
63 * to avoid issue with retriable aborts described in
64 * {@link TestUseRTMAfterLockInflation}.
65 */
66 public class TestUseRTMLockElidingOption {
67
68 public void runTestCases() throws Throwable {
69 verifyOption(false);
70 verifyOption(true);
71 }
72
73 public void verifyOption(boolean useStackLock) throws Throwable {
74 AbortProvoker provoker = AbortType.XABORT.provoker();
75 String logFileName = String.format("rtm_deopt_%s_stack_lock.xml",
76 (useStackLock ? "use" : "no"));
77 String methodOption = String.format("-XX:CompileCommand=option," +
78 "%s,UseRTMLockEliding", provoker.getMethodWithLockName());
79
80 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
81 logFileName,
82 provoker,
83 CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
84 useStackLock),
85 methodOption,
86 "-XX:RTMTotalCountIncrRate=1",
87 "-XX:RTMRetryCount=0",
98
99 Asserts.assertEQ(firedTraps, 0,
100 "Method deoptimization with rtm_state_change is unexpected");
101
102 List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
103 provoker.getMethodWithLockName(), outputAnalyzer.getOutput());
104
105 Asserts.assertEQ(statistics.size(), 1,
106 "VM output should contain exactly one RTM locking "
107 + "statistics entry for method "
108 + provoker.getMethodWithLockName());
109
110 RTMLockingStatistics lock = statistics.get(0);
111
112 Asserts.assertEQ(lock.getTotalLocks(), AbortProvoker.DEFAULT_ITERATIONS,
113 "Expected to get total locks count equal to total amount of "
114 + "lock attempts.");
115 }
116
117 public static void main(String args[]) throws Throwable {
118 new TestUseRTMLockElidingOption().runTestCases();
119 }
120 }
|