Path: blob/master/test/hotspot/jtreg/gc/shenandoah/options/TestSelectiveBarrierFlags.java
41153 views
/*1* Copyright (c) 2017, 2018, Red Hat, Inc. 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*22*/2324/* @test TestSelectiveBarrierFlags25* @summary Test selective barrier enabling works, by aggressively compiling HelloWorld with combinations26* of barrier flags27* @requires vm.gc.Shenandoah28* @library /test/lib29* @run driver TestSelectiveBarrierFlags -Xint30* @run driver TestSelectiveBarrierFlags -Xbatch -XX:CompileThreshold=100 -XX:TieredStopAtLevel=131* @run driver TestSelectiveBarrierFlags -Xbatch -XX:CompileThreshold=100 -XX:-TieredCompilation -XX:+IgnoreUnrecognizedVMOptions -XX:+ShenandoahVerifyOptoBarriers32*/3334import java.util.*;35import java.util.concurrent.*;3637import jdk.test.lib.process.ProcessTools;38import jdk.test.lib.process.OutputAnalyzer;3940public class TestSelectiveBarrierFlags {4142public static void main(String[] args) throws Exception {43String[][] opts = {44new String[] { "ShenandoahLoadRefBarrier" },45new String[] { "ShenandoahSATBBarrier", "ShenandoahIUBarrier" },46new String[] { "ShenandoahCASBarrier" },47new String[] { "ShenandoahCloneBarrier" },48new String[] { "ShenandoahNMethodBarrier" },49new String[] { "ShenandoahStackWatermarkBarrier" }50};5152int size = 1;53for (String[] l : opts) {54size *= (l.length + 1);55}5657ExecutorService pool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());5859for (int c = 0; c < size; c++) {60int t = c;6162List<String> conf = new ArrayList<>();63conf.addAll(Arrays.asList(args));64conf.add("-Xmx128m");65conf.add("-XX:+UnlockDiagnosticVMOptions");66conf.add("-XX:+UnlockExperimentalVMOptions");67conf.add("-XX:+UseShenandoahGC");68conf.add("-XX:ShenandoahGCMode=passive");6970StringBuilder sb = new StringBuilder();71for (String[] l : opts) {72// Make a choice which flag to select from the group.73// Zero means no flag is selected from the group.74int choice = t % (l.length + 1);75for (int e = 0; e < l.length; e++) {76conf.add("-XX:" + ((choice == (e + 1)) ? "+" : "-") + l[e]);77}78t = t / (l.length + 1);79}8081conf.add("TestSelectiveBarrierFlags$Test");8283pool.submit(() -> {84try {85ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(conf.toArray(new String[0]));86OutputAnalyzer output = new OutputAnalyzer(pb.start());87output.shouldHaveExitValue(0);88} catch (Exception e) {89e.printStackTrace();90System.exit(1);91}92});93}9495pool.shutdown();96pool.awaitTermination(1, TimeUnit.HOURS);97}9899public static class Test {100public static void main(String... args) {101System.out.println("HelloWorld");102}103}104105}106107108