1 /*
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
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 */
81 }
82 verifyMonitorState(monitor, true /* inflated */);
83 return monitor;
84 }
85
86 /**
87 * Verifies that {@code monitor} is a stack-lock or inflated lock depending
88 * on {@code shouldBeInflated} value. If {@code monitor} is inflated while
89 * it is expected that it should be a stack-lock, then this method attempts
90 * to deflate it by forcing a safepoint and then verifies the state once
91 * again.
92 *
93 * @param monitor monitor to be verified.
94 * @param shouldBeInflated flag indicating whether or not monitor is
95 * expected to be inflated.
96 * @throws RuntimeException if the {@code monitor} in a wrong state.
97 */
98 public static void verifyMonitorState(Object monitor,
99 boolean shouldBeInflated) {
100 if (!shouldBeInflated && WHITE_BOX.isMonitorInflated(monitor)) {
101 WHITE_BOX.forceSafepoint();
102 }
103 Asserts.assertEQ(WHITE_BOX.isMonitorInflated(monitor), shouldBeInflated,
104 "Monitor in a wrong state.");
105 }
106 /**
107 * Verifies that monitor used by the {@code provoker} is a stack-lock or
108 * inflated lock depending on {@code shouldBeInflated} value. If such
109 * monitor is inflated while it is expected that it should be a stack-lock,
110 * then this method attempts to deflate it by forcing a safepoint and then
111 * verifies the state once again.
112 *
113 * @param provoker AbortProvoker whose monitor's state should be verified.
114 * @param shouldBeInflated flag indicating whether or not monitor is
115 * expected to be inflated.
116 * @throws RuntimeException if the {@code monitor} in a wrong state.
117 */
118 public static void verifyMonitorState(AbortProvoker provoker,
119 boolean shouldBeInflated) {
120 verifyMonitorState(provoker.monitor, shouldBeInflated);
121 }
|
1 /*
2 * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
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 */
81 }
82 verifyMonitorState(monitor, true /* inflated */);
83 return monitor;
84 }
85
86 /**
87 * Verifies that {@code monitor} is a stack-lock or inflated lock depending
88 * on {@code shouldBeInflated} value. If {@code monitor} is inflated while
89 * it is expected that it should be a stack-lock, then this method attempts
90 * to deflate it by forcing a safepoint and then verifies the state once
91 * again.
92 *
93 * @param monitor monitor to be verified.
94 * @param shouldBeInflated flag indicating whether or not monitor is
95 * expected to be inflated.
96 * @throws RuntimeException if the {@code monitor} in a wrong state.
97 */
98 public static void verifyMonitorState(Object monitor,
99 boolean shouldBeInflated) {
100 if (!shouldBeInflated && WHITE_BOX.isMonitorInflated(monitor)) {
101 boolean did_deflation = WHITE_BOX.deflateIdleMonitors();
102 Asserts.assertEQ(did_deflation, true,
103 "deflateIdleMonitors() should have worked.");
104 }
105 Asserts.assertEQ(WHITE_BOX.isMonitorInflated(monitor), shouldBeInflated,
106 "Monitor in a wrong state.");
107 }
108 /**
109 * Verifies that monitor used by the {@code provoker} is a stack-lock or
110 * inflated lock depending on {@code shouldBeInflated} value. If such
111 * monitor is inflated while it is expected that it should be a stack-lock,
112 * then this method attempts to deflate it by forcing a safepoint and then
113 * verifies the state once again.
114 *
115 * @param provoker AbortProvoker whose monitor's state should be verified.
116 * @param shouldBeInflated flag indicating whether or not monitor is
117 * expected to be inflated.
118 * @throws RuntimeException if the {@code monitor} in a wrong state.
119 */
120 public static void verifyMonitorState(AbortProvoker provoker,
121 boolean shouldBeInflated) {
122 verifyMonitorState(provoker.monitor, shouldBeInflated);
123 }
|