author | rehn |
Tue, 26 Mar 2019 12:08:51 +0100 | |
changeset 54278 | 16999bd91ba6 |
parent 48791 | 6e079ff6c83c |
permissions | -rw-r--r-- |
47881 | 1 |
/* |
2 |
* Copyright (c) 2017, 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 |
* |
|
23 |
*/ |
|
24 |
||
25 |
import java.io.File; |
|
26 |
import java.nio.file.Paths; |
|
27 |
import java.time.Duration; |
|
28 |
||
29 |
import jdk.test.lib.process.ProcessTools; |
|
30 |
import jdk.test.lib.process.OutputAnalyzer; |
|
31 |
||
48172
e26fc5201707
8191437: AOT doesn't work easily after thread local handshakes
dlong
parents:
47881
diff
changeset
|
32 |
import sun.hotspot.WhiteBox; |
e26fc5201707
8191437: AOT doesn't work easily after thread local handshakes
dlong
parents:
47881
diff
changeset
|
33 |
|
47881 | 34 |
/* |
35 |
* @test HandshakeTransitionTest |
|
36 |
* @summary This does a sanity test of the poll in the native wrapper. |
|
37 |
* @requires vm.debug |
|
38 |
* @library /testlibrary /test/lib |
|
39 |
* @build HandshakeTransitionTest |
|
48791
6e079ff6c83c
8186635: ClassFileInstaller should be run as a driver
iignatyev
parents:
48311
diff
changeset
|
40 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
48172
e26fc5201707
8191437: AOT doesn't work easily after thread local handshakes
dlong
parents:
47881
diff
changeset
|
41 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
e26fc5201707
8191437: AOT doesn't work easily after thread local handshakes
dlong
parents:
47881
diff
changeset
|
42 |
* @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI HandshakeTransitionTest |
47881 | 43 |
*/ |
44 |
||
45 |
public class HandshakeTransitionTest { |
|
46 |
||
47 |
public static native void someTime(int ms); |
|
48 |
||
49 |
public static void main(String[] args) throws Exception { |
|
50 |
String lib = System.getProperty("test.nativepath"); |
|
48172
e26fc5201707
8191437: AOT doesn't work easily after thread local handshakes
dlong
parents:
47881
diff
changeset
|
51 |
WhiteBox wb = WhiteBox.getWhiteBox(); |
48311
d18861f20c0e
8192870: [Testbug] runtime/handshake/HandshakeTransitionTest throws NPE
dlong
parents:
48172
diff
changeset
|
52 |
Boolean useJVMCICompiler = wb.getBooleanVMFlag("UseJVMCICompiler"); |
d18861f20c0e
8192870: [Testbug] runtime/handshake/HandshakeTransitionTest throws NPE
dlong
parents:
48172
diff
changeset
|
53 |
String useJVMCICompilerStr; |
d18861f20c0e
8192870: [Testbug] runtime/handshake/HandshakeTransitionTest throws NPE
dlong
parents:
48172
diff
changeset
|
54 |
if (useJVMCICompiler != null) { |
d18861f20c0e
8192870: [Testbug] runtime/handshake/HandshakeTransitionTest throws NPE
dlong
parents:
48172
diff
changeset
|
55 |
useJVMCICompilerStr = useJVMCICompiler ? "-XX:+UseJVMCICompiler" : "-XX:-UseJVMCICompiler"; |
d18861f20c0e
8192870: [Testbug] runtime/handshake/HandshakeTransitionTest throws NPE
dlong
parents:
48172
diff
changeset
|
56 |
} else { |
d18861f20c0e
8192870: [Testbug] runtime/handshake/HandshakeTransitionTest throws NPE
dlong
parents:
48172
diff
changeset
|
57 |
// pass something innocuous |
d18861f20c0e
8192870: [Testbug] runtime/handshake/HandshakeTransitionTest throws NPE
dlong
parents:
48172
diff
changeset
|
58 |
useJVMCICompilerStr = "-XX:+UnlockExperimentalVMOptions"; |
d18861f20c0e
8192870: [Testbug] runtime/handshake/HandshakeTransitionTest throws NPE
dlong
parents:
48172
diff
changeset
|
59 |
} |
47881 | 60 |
ProcessBuilder pb = |
61 |
ProcessTools.createJavaProcessBuilder( |
|
62 |
true, |
|
63 |
"-Djava.library.path=" + lib, |
|
64 |
"-XX:+SafepointALot", |
|
54278 | 65 |
"-XX:+HandshakeALot", |
47881 | 66 |
"-XX:GuaranteedSafepointInterval=20", |
67 |
"-Xlog:ergo*", |
|
68 |
"-XX:ParallelGCThreads=1", |
|
69 |
"-XX:ConcGCThreads=1", |
|
70 |
"-XX:CICompilerCount=2", |
|
48172
e26fc5201707
8191437: AOT doesn't work easily after thread local handshakes
dlong
parents:
47881
diff
changeset
|
71 |
"-XX:+UnlockExperimentalVMOptions", |
48311
d18861f20c0e
8192870: [Testbug] runtime/handshake/HandshakeTransitionTest throws NPE
dlong
parents:
48172
diff
changeset
|
72 |
useJVMCICompilerStr, |
47881 | 73 |
"HandshakeTransitionTest$Test"); |
74 |
||
75 |
||
76 |
OutputAnalyzer output = ProcessTools.executeProcess(pb); |
|
77 |
output.reportDiagnosticSummary(); |
|
78 |
output.shouldHaveExitValue(0); |
|
79 |
output.stdoutShouldContain("JOINED"); |
|
80 |
} |
|
81 |
||
82 |
static class Test implements Runnable { |
|
83 |
final static int testLoops = 2000; |
|
84 |
final static int testSleep = 1; //ms |
|
85 |
||
86 |
public static void main(String[] args) throws Exception { |
|
87 |
System.loadLibrary("HandshakeTransitionTest"); |
|
88 |
Test test = new Test(); |
|
89 |
Thread[] threads = new Thread[64]; |
|
90 |
for (int i = 0; i<threads.length ; i++) { |
|
91 |
threads[i] = new Thread(test); |
|
92 |
threads[i].start(); |
|
93 |
} |
|
94 |
for (Thread t : threads) { |
|
95 |
t.join(); |
|
96 |
} |
|
97 |
System.out.println("JOINED"); |
|
98 |
} |
|
99 |
||
100 |
@Override |
|
101 |
public void run() { |
|
102 |
try { |
|
103 |
for (int i = 0; i<testLoops ; i++) { |
|
104 |
someTime(testSleep); |
|
105 |
} |
|
106 |
} catch (Exception e) { |
|
107 |
System.out.println(e.getMessage()); |
|
108 |
System.exit(1); |
|
109 |
} |
|
110 |
} |
|
111 |
} |
|
112 |
} |