Path: blob/master/test/hotspot/jtreg/compiler/arguments/CheckCICompilerCount.java
41149 views
/*1* Copyright (c) 2015, 2021, Oracle and/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 CheckCheckCICompilerCount25* @bug 8130858 8132525 816288126* @summary Check that correct range of values for CICompilerCount are allowed depending on whether tiered is enabled or not27* @library /test/lib /28* @requires vm.flagless29* @modules java.base/jdk.internal.misc30* java.management31* @run driver compiler.arguments.CheckCICompilerCount32*/3334package compiler.arguments;3536import jdk.test.lib.process.OutputAnalyzer;37import jdk.test.lib.process.ProcessTools;3839public class CheckCICompilerCount {40private static final String[][] NON_TIERED_ARGUMENTS = {41{42"-server",43"-XX:-TieredCompilation",44"-XX:+PrintFlagsFinal",45"-XX:CICompilerCount=0",46"-version"47},48{49"-server",50"-XX:-TieredCompilation",51"-XX:+PrintFlagsFinal",52"-XX:CICompilerCount=1",53"-version"54},55{56"-server",57"-XX:+PrintFlagsFinal",58"-XX:CICompilerCount=1",59"-XX:-TieredCompilation",60"-version"61},62{63"-client",64"-XX:-TieredCompilation",65"-XX:+PrintFlagsFinal",66"-XX:CICompilerCount=0",67"-version"68},69{70"-client",71"-XX:-TieredCompilation",72"-XX:+PrintFlagsFinal",73"-XX:CICompilerCount=1",74"-version"75},76{77"-client",78"-XX:+PrintFlagsFinal",79"-XX:CICompilerCount=1",80"-XX:-TieredCompilation",81"-version"82}83};8485private static final String[] NON_TIERED_EXPECTED_OUTPUTS = {86"CICompilerCount (0) must be at least 1",87"intx CICompilerCount = 1 {product} {command line}",88"intx CICompilerCount = 1 {product} {command line}",89"CICompilerCount (0) must be at least 1",90"intx CICompilerCount = 1 {product} {command line}",91"intx CICompilerCount = 1 {product} {command line}"92};9394private static final int[] NON_TIERED_EXIT = {951,960,970,981,990,1000101};102103private static final String[][] TIERED_ARGUMENTS = {104{105"-server",106"-XX:+TieredCompilation",107"-XX:+PrintFlagsFinal",108"-XX:CICompilerCount=1",109"-version"110},111{112"-server",113"-XX:+TieredCompilation",114"-XX:TieredStopAtLevel=1",115"-XX:+PrintFlagsFinal",116"-XX:CICompilerCount=1",117"-version"118},119{120"-server",121"-XX:+TieredCompilation",122"-XX:+PrintFlagsFinal",123"-XX:CICompilerCount=1",124"-XX:TieredStopAtLevel=1",125"-version"126},127{128"-server",129"-XX:+TieredCompilation",130"-XX:+PrintFlagsFinal",131"-XX:CICompilerCount=2",132"-version"133},134{135"-client",136"-XX:+TieredCompilation",137"-XX:+PrintFlagsFinal",138"-XX:CICompilerCount=1",139"-version"140},141{142"-client",143"-XX:+TieredCompilation",144"-XX:TieredStopAtLevel=1",145"-XX:+PrintFlagsFinal",146"-XX:CICompilerCount=1",147"-version"148},149{150"-client",151"-XX:+TieredCompilation",152"-XX:+PrintFlagsFinal",153"-XX:CICompilerCount=1",154"-XX:TieredStopAtLevel=1",155"-version"156},157{158"-client",159"-XX:+TieredCompilation",160"-XX:+PrintFlagsFinal",161"-XX:CICompilerCount=2",162"-version"163}164};165166private static final String[] TIERED_EXPECTED_OUTPUTS = {167"CICompilerCount (1) must be at least 2",168"intx CICompilerCount = 1 {product} {command line}",169"intx CICompilerCount = 1 {product} {command line}",170"intx CICompilerCount = 2 {product} {command line}",171"CICompilerCount (1) must be at least 2",172"intx CICompilerCount = 1 {product} {command line}",173"intx CICompilerCount = 1 {product} {command line}",174"intx CICompilerCount = 2 {product} {command line}",175};176177private static final int[] TIERED_EXIT = {1781,1790,1800,1810,1821,1830,1840,1850186};187188private static void verifyValidOption(String[] arguments, String expected_output, int exit, boolean tiered) throws Exception {189ProcessBuilder pb;190OutputAnalyzer out;191192pb = ProcessTools.createJavaProcessBuilder(arguments);193out = new OutputAnalyzer(pb.start());194195try {196out.shouldHaveExitValue(exit);197out.shouldContain(expected_output);198} catch (RuntimeException e) {199// Check if tiered compilation is available in this JVM200// Version. Throw exception only if it is available.201if (!(tiered && out.getOutput().contains("-XX:+TieredCompilation not supported in this VM"))) {202throw new RuntimeException(e);203}204}205}206207public static void main(String[] args) throws Exception {208if (NON_TIERED_ARGUMENTS.length != NON_TIERED_EXPECTED_OUTPUTS.length || NON_TIERED_ARGUMENTS.length != NON_TIERED_EXIT.length) {209throw new RuntimeException("Test is set up incorrectly: length of arguments, expected outputs and exit codes in non-tiered mode of operation do not match.");210}211212if (TIERED_ARGUMENTS.length != TIERED_EXPECTED_OUTPUTS.length || TIERED_ARGUMENTS.length != TIERED_EXIT.length) {213throw new RuntimeException("Test is set up incorrectly: length of arguments, expected outputs and exit codes in tiered mode of operation do not match.");214}215216for (int i = 0; i < NON_TIERED_ARGUMENTS.length; i++) {217verifyValidOption(NON_TIERED_ARGUMENTS[i], NON_TIERED_EXPECTED_OUTPUTS[i], NON_TIERED_EXIT[i], false);218}219220for (int i = 0; i < TIERED_ARGUMENTS.length; i++) {221verifyValidOption(TIERED_ARGUMENTS[i], TIERED_EXPECTED_OUTPUTS[i], TIERED_EXIT[i], true);222}223}224}225226227