30 * method's RTM state. And if we don't use RTMDeopt, then
31 * RTM state remain the same after such deoptimization.
32 * @library /test/lib /
33 * @modules java.base/jdk.internal.misc
34 * java.management
35 * @build sun.hotspot.WhiteBox
36 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
37 * sun.hotspot.WhiteBox$WhiteBoxPermission
38 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
39 * -XX:+WhiteBoxAPI
40 * compiler.rtm.locking.TestRTMAfterNonRTMDeopt
41 */
42
43 package compiler.rtm.locking;
44
45 import compiler.testlibrary.rtm.AbortProvoker;
46 import compiler.testlibrary.rtm.CompilableTest;
47 import compiler.testlibrary.rtm.RTMLockingStatistics;
48 import compiler.testlibrary.rtm.RTMTestBase;
49 import compiler.testlibrary.rtm.predicate.SupportedCPU;
50 import compiler.testlibrary.rtm.predicate.SupportedVM;
51 import jdk.internal.misc.Unsafe;
52 import jdk.test.lib.Asserts;
53 import jdk.test.lib.process.OutputAnalyzer;
54 import jdk.test.lib.unsafe.UnsafeHelper;
55 import jdk.test.lib.cli.CommandLineOptionTest;
56 import jdk.test.lib.cli.predicate.AndPredicate;
57
58 import java.util.List;
59
60 /**
61 * To verify that with +UseRTMDeopt method's RTM state will be
62 * changed to ProfileRTM on deoptimization unrelated to
63 * rtm_state_change following sequence of events is used:
64 * <pre>
65 *
66 * rtm state ^
67 * |
68 * UseRTM | ******| ******
69 * | |
70 * ProfileRTM |******| |*****|
71 * | | | |
72 * 0-------|-----|-----|---------------------> time
73 * | | \ force abort
74 * | |
75 * | \ force deoptimization
76 * |
77 * \ force xabort
78 * </pre>
79 * When xabort is forced by native method call method should
80 * change it's state to UseRTM, because we use RTMAbortRatio=100
81 * and low RTMLockingThreshold, so at this point actual abort
82 * ratio will be below 100% and there should be enough lock
83 * attempts to recompile method without RTM profiling.
84 */
85 public class TestRTMAfterNonRTMDeopt extends CommandLineOptionTest {
86 private static final int ABORT_THRESHOLD = 1000;
87 private static final String RANGE_CHECK = "range_check";
88
89 private TestRTMAfterNonRTMDeopt() {
90 super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
91 }
92
93 @Override
94 protected void runTestCases() throws Throwable {
95 verifyRTMAfterDeopt(false, false);
96 verifyRTMAfterDeopt(true, false);
97
98 verifyRTMAfterDeopt(false, true);
99 verifyRTMAfterDeopt(true, true);
100 }
101
102 private void verifyRTMAfterDeopt(boolean useStackLock,
103 boolean useRTMDeopt) throws Throwable {
104 CompilableTest test = new Test();
105 String logFile = String.format("rtm_%s_stack_lock_%s_deopt.xml",
106 (useStackLock ? "use" : "no"), (useRTMDeopt ? "use" : "no"));
107
108 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
109 logFile,
110 test,
|
30 * method's RTM state. And if we don't use RTMDeopt, then
31 * RTM state remain the same after such deoptimization.
32 * @library /test/lib /
33 * @modules java.base/jdk.internal.misc
34 * java.management
35 * @build sun.hotspot.WhiteBox
36 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
37 * sun.hotspot.WhiteBox$WhiteBoxPermission
38 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
39 * -XX:+WhiteBoxAPI
40 * compiler.rtm.locking.TestRTMAfterNonRTMDeopt
41 */
42
43 package compiler.rtm.locking;
44
45 import compiler.testlibrary.rtm.AbortProvoker;
46 import compiler.testlibrary.rtm.CompilableTest;
47 import compiler.testlibrary.rtm.RTMLockingStatistics;
48 import compiler.testlibrary.rtm.RTMTestBase;
49 import compiler.testlibrary.rtm.predicate.SupportedCPU;
50 import compiler.testlibrary.rtm.predicate.SupportedOS;
51 import compiler.testlibrary.rtm.predicate.SupportedVM;
52 import jdk.internal.misc.Unsafe;
53 import jdk.test.lib.Asserts;
54 import jdk.test.lib.process.OutputAnalyzer;
55 import jdk.test.lib.unsafe.UnsafeHelper;
56 import jdk.test.lib.cli.CommandLineOptionTest;
57 import jdk.test.lib.cli.predicate.AndPredicate;
58
59 import java.util.List;
60
61 /**
62 * To verify that with +UseRTMDeopt method's RTM state will be
63 * changed to ProfileRTM on deoptimization unrelated to
64 * rtm_state_change following sequence of events is used:
65 * <pre>
66 *
67 * rtm state ^
68 * |
69 * UseRTM | ******| ******
70 * | |
71 * ProfileRTM |******| |*****|
72 * | | | |
73 * 0-------|-----|-----|---------------------> time
74 * | | \ force abort
75 * | |
76 * | \ force deoptimization
77 * |
78 * \ force xabort
79 * </pre>
80 * When xabort is forced by native method call method should
81 * change it's state to UseRTM, because we use RTMAbortRatio=100
82 * and low RTMLockingThreshold, so at this point actual abort
83 * ratio will be below 100% and there should be enough lock
84 * attempts to recompile method without RTM profiling.
85 */
86 public class TestRTMAfterNonRTMDeopt extends CommandLineOptionTest {
87 private static final int ABORT_THRESHOLD = 1000;
88 private static final String RANGE_CHECK = "range_check";
89
90 private TestRTMAfterNonRTMDeopt() {
91 super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
92 }
93
94 @Override
95 protected void runTestCases() throws Throwable {
96 verifyRTMAfterDeopt(false, false);
97 verifyRTMAfterDeopt(true, false);
98
99 verifyRTMAfterDeopt(false, true);
100 verifyRTMAfterDeopt(true, true);
101 }
102
103 private void verifyRTMAfterDeopt(boolean useStackLock,
104 boolean useRTMDeopt) throws Throwable {
105 CompilableTest test = new Test();
106 String logFile = String.format("rtm_%s_stack_lock_%s_deopt.xml",
107 (useStackLock ? "use" : "no"), (useRTMDeopt ? "use" : "no"));
108
109 OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
110 logFile,
111 test,
|