Path: blob/master/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitNoneAArch64.java
64474 views
/*1* Copyright (c) 2021, Amazon.com Inc. or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test TestOnSpinWaitNoneAArch6425* @summary Checks that java.lang.Thread.onSpinWait is not intrinsified when '-XX:OnSpinWaitInst=none' is used26* @bug 818667027* @library /test/lib28*29* @requires vm.flagless30* @requires os.arch=="aarch64"31*32* @run driver compiler.onSpinWait.TestOnSpinWaitNoneAArch6433*/3435package compiler.onSpinWait;3637import java.util.ArrayList;38import jdk.test.lib.process.OutputAnalyzer;39import jdk.test.lib.process.ProcessTools;4041public class TestOnSpinWaitNoneAArch64 {4243public static void main(String[] args) throws Exception {44ArrayList<String> command = new ArrayList<String>();45command.add("-XX:+IgnoreUnrecognizedVMOptions");46command.add("-showversion");47command.add("-XX:-TieredCompilation");48command.add("-Xbatch");49command.add("-XX:+PrintCompilation");50command.add("-XX:+UnlockDiagnosticVMOptions");51command.add("-XX:+PrintInlining");52command.add("-XX:OnSpinWaitInst=none");53command.add(Launcher.class.getName());5455// Test C2 compiler56ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(command);5758OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());5960analyzer.shouldHaveExitValue(0);6162// The test is applicable only to C2 (present in Server VM).63if (analyzer.getStderr().contains("Server VM")) {64analyzer.shouldNotContain("java.lang.Thread::onSpinWait (1 bytes) (intrinsic)");65}66}6768static class Launcher {6970public static void main(final String[] args) throws Exception {71int end = 20_000;7273for (int i=0; i < end; i++) {74test();75}76}77static void test() {78java.lang.Thread.onSpinWait();79}80}81}828384