author | bulasevich |
Wed, 20 Nov 2019 09:29:23 +0300 | |
changeset 59143 | 1037c4d14378 |
parent 58409 | a595e67d6683 |
permissions | -rw-r--r-- |
58409
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
1 |
/* |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
4 |
* |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
8 |
* |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
13 |
* accompanied this code). |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
14 |
* |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
18 |
* |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
21 |
* questions. |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
22 |
*/ |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
23 |
|
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
24 |
/* |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
25 |
* @test |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
26 |
* @bug 8184732 |
59143
1037c4d14378
8233113: ARM32: assert on UnsafeJlong mutex rank check
bulasevich
parents:
58409
diff
changeset
|
27 |
* @summary Ensure that special locks never safepoint check. |
58409
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
28 |
* @library /test/lib |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
29 |
* @modules java.base/jdk.internal.misc |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
30 |
* java.management |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
31 |
* @build sun.hotspot.WhiteBox |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
32 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
33 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
34 |
* @run main NoSafepointVerifier |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
35 |
*/ |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
36 |
|
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
37 |
import jdk.test.lib.process.ProcessTools; |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
38 |
import jdk.test.lib.process.OutputAnalyzer; |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
39 |
import jdk.test.lib.Platform; |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
40 |
|
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
41 |
import sun.hotspot.WhiteBox; |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
42 |
|
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
43 |
public class NoSafepointVerifier { |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
44 |
|
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
45 |
static void runTest(String test) throws Exception { |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
46 |
if (Platform.isDebugBuild()){ |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
47 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
48 |
"-Xbootclasspath/a:.", |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
49 |
"-XX:+UnlockDiagnosticVMOptions", |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
50 |
"-XX:+WhiteBoxAPI", |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
51 |
"-XX:-CreateCoredumpOnCrash", |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
52 |
"NoSafepointVerifier", |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
53 |
test); |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
54 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
55 |
output.shouldContain(test); |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
56 |
} |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
57 |
} |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
58 |
|
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
59 |
static String test1 = "Special locks or below should never safepoint"; |
59143
1037c4d14378
8233113: ARM32: assert on UnsafeJlong mutex rank check
bulasevich
parents:
58409
diff
changeset
|
60 |
static String test2 = "Possible safepoint reached by thread that does not allow it"; |
58409
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
61 |
|
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
62 |
public static void main(String args[]) throws Exception { |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
63 |
if (args.length > 0) { |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
64 |
if (args[0].equals(test1)) { |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
65 |
WhiteBox.getWhiteBox().assertSpecialLock(/*vm_block*/true, /*safepoint_check_always*/true); |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
66 |
} else if (args[0].equals(test2)) { |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
67 |
WhiteBox.getWhiteBox().assertSpecialLock(/*vm_block*/true, /*safepoint_check_always*/false); |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
68 |
} |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
69 |
} else { |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
70 |
runTest(test1); |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
71 |
runTest(test2); |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
72 |
} |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
73 |
} |
a595e67d6683
8184732: Deadlock detection improvements for 'special' locks
coleenp
parents:
diff
changeset
|
74 |
} |