test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitC1.java
author kvn
Wed, 08 Aug 2018 18:38:34 -0700
changeset 51341 09cc8813ae51
permissions -rw-r--r--
8207965: C2-only debug build fails Reviewed-by: kvn, iignatyev Contributed-by: xxinliu@amazon.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51341
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
     1
/*
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
     2
 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
     3
 * Copyright 2016 Azul Systems, Inc.  All Rights Reserved.
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
     5
 *
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
     8
 * published by the Free Software Foundation.
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
     9
 *
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    14
 * accompanied this code).
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    15
 *
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    19
 *
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    22
 * questions.
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    23
 */
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    24
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    25
/**
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    26
 * @test TestOnSpinWaitC1
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    27
 * @summary (x86 only) checks that java.lang.Thread.onSpinWait is intrinsified
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    28
 * @bug 8147844
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    29
 * @library /test/lib
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    30
 * @modules java.base/jdk.internal.misc
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    31
 * @requires os.arch=="x86" | os.arch=="amd64" | os.arch=="x86_64"
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    32
 * @requires vm.compiler1.enabled
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    33
 * @run driver compiler.onSpinWait.TestOnSpinWait
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    34
 */
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    35
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    36
package compiler.onSpinWait;
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    37
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    38
import jdk.test.lib.process.OutputAnalyzer;
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    39
import jdk.test.lib.process.ProcessTools;
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    40
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    41
public class TestOnSpinWaitC1 {
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    42
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    43
    public static void main(String[] args) throws Exception {
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    44
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    45
        // Test C1 compiler
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    46
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    47
          "-XX:+IgnoreUnrecognizedVMOptions", "-showversion",
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    48
          "-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1", "-Xbatch",
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    49
          "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions",
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    50
          "-XX:+PrintInlining", Launcher.class.getName());
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    51
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    52
        OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    53
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    54
        analyzer.shouldHaveExitValue(0);
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    55
        analyzer.shouldContain("java.lang.Thread::onSpinWait (1 bytes)   intrinsic");
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    56
    }
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    57
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    58
    static class Launcher {
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    59
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    60
        public static void main(final String[] args) throws Exception {
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    61
            int end = 20_000;
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    62
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    63
            for (int i=0; i < end; i++) {
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    64
                test();
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    65
            }
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    66
        }
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    67
        static void test() {
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    68
            java.lang.Thread.onSpinWait();
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    69
        }
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    70
    }
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents:
diff changeset
    71
}