Path: blob/master/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitAArch64DefaultFlags.java
64474 views
/*1* Copyright 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 TestOnSpinWaitAArch64DefaultFlags25* @summary Check default values of '-XX:OnSpinWaitInst' and '-XX:OnSpinWaitInstCount' for AArch64 implementations.26* @bug 827713727* @library /test/lib /28*29* @requires os.arch=="aarch64"30*31* @build sun.hotspot.WhiteBox32* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox33* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions34* -XX:+WhiteBoxAPI35* compiler.onSpinWait.TestOnSpinWaitAArch64DefaultFlags36*/3738package compiler.onSpinWait;3940import java.util.Iterator;41import java.util.List;42import jdk.test.lib.process.OutputAnalyzer;43import jdk.test.lib.process.ProcessTools;44import sun.hotspot.cpuinfo.CPUInfo;4546public class TestOnSpinWaitAArch64DefaultFlags {47private static boolean isCPUModelNeoverseN1(String cpuModel) {48return cpuModel.contains("0xd0c");49}5051private static void checkFinalFlagsEqualTo(ProcessBuilder pb, String expectedOnSpinWaitInstValue, String expectedOnSpinWaitInstCountValue) throws Exception {52OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());53analyzer.shouldHaveExitValue(0);5455Iterator<String> iter = analyzer.asLines().listIterator();56String line = null;57boolean hasExpectedOnSpinWaitInstValue = false;58boolean hasExpectedOnSpinWaitInstCountValue = false;59while (iter.hasNext()) {60line = iter.next();61if (!hasExpectedOnSpinWaitInstValue && line.contains("ccstr OnSpinWaitInst")) {62hasExpectedOnSpinWaitInstValue = line.contains("= " + expectedOnSpinWaitInstValue);63}6465if (!hasExpectedOnSpinWaitInstCountValue && line.contains("uint OnSpinWaitInstCount")) {66hasExpectedOnSpinWaitInstCountValue = line.contains("= " + expectedOnSpinWaitInstCountValue);67}68}69if (!hasExpectedOnSpinWaitInstValue) {70System.out.println(analyzer.getOutput());71throw new RuntimeException("OnSpinWaitInst with the expected value '" + expectedOnSpinWaitInstValue + "' not found.");72}73if (!hasExpectedOnSpinWaitInstCountValue) {74System.out.println(analyzer.getOutput());75throw new RuntimeException("OnSpinWaitInstCount with the expected value '" + expectedOnSpinWaitInstCountValue + "' not found.");76}77}7879public static void main(String[] args) throws Exception {80List<String> cpuFeatures = CPUInfo.getFeatures();81if (cpuFeatures.isEmpty()) {82System.out.println("Skip because no CPU features are available.");83return;84}8586final String cpuModel = cpuFeatures.get(0);8788if (isCPUModelNeoverseN1(cpuModel)) {89checkFinalFlagsEqualTo(ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintFlagsFinal", "-version"),90"isb", "1");91checkFinalFlagsEqualTo(ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:OnSpinWaitInstCount=2", "-XX:+PrintFlagsFinal", "-version"),92"isb", "2");93} else {94System.out.println("Skip because no defaults for CPU model: " + cpuModel);95}96}97}9899100