Path: blob/master/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java
41152 views
/*1* Copyright (c) 2019, 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* @test25* @bug 8235539 824571726* @summary Tests effect of -XX:+EnableJVMCIProduct on EnableJVMCI and UseJVMCICompiler27* @requires vm.flagless28* @requires vm.jvmci29* @library /test/lib30* @run driver TestEnableJVMCIProduct31*/3233import jdk.test.lib.process.ProcessTools;34import jdk.test.lib.process.OutputAnalyzer;3536public class TestEnableJVMCIProduct {3738static class Expectation {39final String name;40final String value;41final String origin;42final String pattern;43Expectation(final String name, String value, String origin) {44this.name = name;45this.value = value;46this.origin = origin;47this.pattern = "bool +" + name + " += " + value + " +\\{JVMCI product\\} \\{" + origin + "\\}";48}49}5051public static void main(String[] args) throws Exception {52// Test EnableJVMCIProduct without any other explicit JVMCI option53test("-XX:-PrintWarnings",54new Expectation("EnableJVMCI", "true", "default"),55new Expectation("UseJVMCICompiler", "true", "default"));56test("-XX:+UseJVMCICompiler",57new Expectation("EnableJVMCI", "true", "default"),58new Expectation("UseJVMCICompiler", "true", "command line"));59test("-XX:-UseJVMCICompiler",60new Expectation("EnableJVMCI", "true", "default"),61new Expectation("UseJVMCICompiler", "false", "command line"));62test("-XX:+EnableJVMCI",63new Expectation("EnableJVMCI", "true", "command line"),64new Expectation("UseJVMCICompiler", "true", "default"));65test("-XX:-EnableJVMCI",66new Expectation("EnableJVMCI", "false", "command line"),67new Expectation("UseJVMCICompiler", "false", "default"));68test("-XX:+EnableJVMCIProduct",69new Expectation("EnableJVMCIProduct", "true", "command line"),70new Expectation("EnableJVMCI", "true", "default"),71new Expectation("UseJVMCICompiler", "true", "default"));72}7374static void test(String explicitFlag, Expectation... expectations) throws Exception {75ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(76"-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCIProduct", "-XX:-UnlockExperimentalVMOptions",77explicitFlag,78"-XX:+PrintFlagsFinal", "-version");79OutputAnalyzer output = new OutputAnalyzer(pb.start());80for (Expectation expectation : expectations) {81output.stdoutShouldMatch(expectation.pattern);82}83if (output.getExitValue() != 0) {84// This should only happen when JVMCI compilation is requested and the VM has no85// JVMCI compiler (e.g. Graal is not included in the build)86output.stdoutShouldMatch("No JVMCI compiler found");87}88}89}909192