9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25 /**
26 * @test TestOnSpinWait
27 * @summary (x86 only) checks that java.lang.Thread.onSpinWait is intrinsified
28 * @bug 8147844
29 * @modules java.base/jdk.internal.misc
30 * @library /testlibrary
31 * @requires os.arch=="x86" | os.arch=="amd64" | os.arch=="x86_64"
32 * @run main TestOnSpinWait
33 */
34
35 import java.lang.invoke.*;
36 import jdk.test.lib.*;
37 import static jdk.test.lib.Asserts.*;
38
39 public class TestOnSpinWait {
40
41 public static void main(String[] args) throws Exception {
42
43 // Test C1 compiler
44 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
45 "-XX:+IgnoreUnrecognizedVMOptions", "-showversion",
46 "-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1", "-Xbatch",
47 "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions",
48 "-XX:+PrintInlining", "TestOnSpinWait$Launcher");
49
50 OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
51
52 analyzer.shouldHaveExitValue(0);
53
54 // The test is applicable only to C1 (present in Server VM).
55 analyzer.shouldContain("java.lang.Thread::onSpinWait (1 bytes) intrinsic");
56
57 // Test C2 compiler
58 pb = ProcessTools.createJavaProcessBuilder(
59 "-XX:+IgnoreUnrecognizedVMOptions", "-showversion",
60 "-XX:-TieredCompilation", "-Xbatch",
61 "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions",
62 "-XX:+PrintInlining", "TestOnSpinWait$Launcher");
63
64 analyzer = new OutputAnalyzer(pb.start());
65
66 analyzer.shouldHaveExitValue(0);
67
68 // The test is applicable only to C2 (present in Server VM).
69 if (analyzer.getStderr().contains("Server VM")) {
70 analyzer.shouldContain("java.lang.Thread::onSpinWait (1 bytes) (intrinsic)");
71 }
72 }
73
74 static class Launcher {
75
76 public static void main(final String[] args) throws Exception {
77 int end = 20_000;
78
79 for (int i=0; i < end; i++) {
80 test();
81 }
82 }
|
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25 /**
26 * @test TestOnSpinWait
27 * @summary (x86 only) checks that java.lang.Thread.onSpinWait is intrinsified
28 * @bug 8147844
29 * @library /testlibrary
30 * @modules java.base/jdk.internal.misc
31 * @requires os.arch=="x86" | os.arch=="amd64" | os.arch=="x86_64"
32 * @run driver compiler.onSpinWait.TestOnSpinWait
33 */
34
35 package compiler.onSpinWait;
36
37 import jdk.test.lib.OutputAnalyzer;
38 import jdk.test.lib.ProcessTools;
39
40 public class TestOnSpinWait {
41
42 public static void main(String[] args) throws Exception {
43
44 // Test C1 compiler
45 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
46 "-XX:+IgnoreUnrecognizedVMOptions", "-showversion",
47 "-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1", "-Xbatch",
48 "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions",
49 "-XX:+PrintInlining", Launcher.class.getName());
50
51 OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
52
53 analyzer.shouldHaveExitValue(0);
54
55 // The test is applicable only to C1 (present in Server VM).
56 analyzer.shouldContain("java.lang.Thread::onSpinWait (1 bytes) intrinsic");
57
58 // Test C2 compiler
59 pb = ProcessTools.createJavaProcessBuilder(
60 "-XX:+IgnoreUnrecognizedVMOptions", "-showversion",
61 "-XX:-TieredCompilation", "-Xbatch",
62 "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions",
63 "-XX:+PrintInlining", Launcher.class.getName());
64
65 analyzer = new OutputAnalyzer(pb.start());
66
67 analyzer.shouldHaveExitValue(0);
68
69 // The test is applicable only to C2 (present in Server VM).
70 if (analyzer.getStderr().contains("Server VM")) {
71 analyzer.shouldContain("java.lang.Thread::onSpinWait (1 bytes) (intrinsic)");
72 }
73 }
74
75 static class Launcher {
76
77 public static void main(final String[] args) throws Exception {
78 int end = 20_000;
79
80 for (int i=0; i < end; i++) {
81 test();
82 }
83 }
|