Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/shenandoah/options/TestSelectiveBarrierFlags.java
32285 views
/*1* Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation.6*7* This code is distributed in the hope that it will be useful, but WITHOUT8* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or9* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License10* version 2 for more details (a copy is included in the LICENSE file that11* accompanied this code).12*13* You should have received a copy of the GNU General Public License version14* 2 along with this work; if not, write to the Free Software Foundation,15* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.16*17* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA18* or visit www.oracle.com if you need additional information or have any19* questions.20*21*/2223/*24* @test TestSelectiveBarrierFlags25* @summary Test selective barrier enabling works, by aggressively compiling HelloWorld with combinations26* of barrier flags27* @library /testlibrary28*29* @run main/othervm TestSelectiveBarrierFlags -Xint30* @run main/othervm TestSelectiveBarrierFlags -Xbatch -XX:CompileThreshold=100 -XX:TieredStopAtLevel=131* @run main/othervm TestSelectiveBarrierFlags -Xbatch -XX:CompileThreshold=100 -XX:-TieredCompilation -XX:+IgnoreUnrecognizedVMOptions -XX:+ShenandoahVerifyOptoBarriers32*/3334import java.util.*;35import java.util.concurrent.*;36import com.oracle.java.testlibrary.*;3738public class TestSelectiveBarrierFlags {3940public static void main(String[] args) throws Exception {41String[][] opts = {42new String[]{ "ShenandoahLoadRefBarrier" },43new String[] { "ShenandoahSATBBarrier", "ShenandoahStoreValEnqueueBarrier" },44new String[]{ "ShenandoahCASBarrier" },45new String[]{ "ShenandoahCloneBarrier" },46};4748int size = 1;49for (String[] l : opts) {50size *= (l.length + 1);51}5253ExecutorService pool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());5455for (int c = 0; c < size; c++) {56int t = c;5758List<String> conf = new ArrayList<>();59conf.addAll(Arrays.asList(args));60conf.add("-Xmx128m");61conf.add("-XX:+UnlockDiagnosticVMOptions");62conf.add("-XX:+UnlockExperimentalVMOptions");63conf.add("-XX:+UseShenandoahGC");64conf.add("-XX:ShenandoahGCMode=passive");6566StringBuilder sb = new StringBuilder();67for (String[] l : opts) {68// Make a choice which flag to select from the group.69// Zero means no flag is selected from the group.70int choice = t % (l.length + 1);71for (int e = 0; e < l.length; e++) {72conf.add("-XX:" + ((choice == (e + 1)) ? "+" : "-") + l[e]);73}74t = t / (l.length + 1);75}7677conf.add("TestSelectiveBarrierFlags$Test");7879pool.submit(() -> {80try {81ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(conf.toArray(new String[0]));82OutputAnalyzer output = new OutputAnalyzer(pb.start());83output.shouldHaveExitValue(0);84} catch (Exception e) {85e.printStackTrace();86System.exit(1);87}88});89}9091pool.shutdown();92pool.awaitTermination(1, TimeUnit.HOURS);93}9495public static class Test {96public static void main(String... args) {97System.out.println("HelloWorld");98}99}100101}102103104