Path: blob/master/test/hotspot/jtreg/gc/shenandoah/options/TestLoopMiningArguments.java
41155 views
/*1* Copyright (c) 2017, 2019, 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/*25* @test TestLoopMiningArguments26* @summary Test that loop mining arguments are sane27* @requires vm.gc.Shenandoah28* @requires vm.flavor == "server"29* @library /test/lib30* @run driver TestLoopMiningArguments31*/3233import java.util.*;3435import jdk.test.lib.Asserts;36import jdk.test.lib.process.ProcessTools;37import jdk.test.lib.process.OutputAnalyzer;3839public class TestLoopMiningArguments {4041public static void testWith(String msg, boolean cls, int iters, String... args) throws Exception {42String[] cmds = Arrays.copyOf(args, args.length + 3);43cmds[args.length] = "-Xmx128m";44cmds[args.length + 1] = "-XX:+PrintFlagsFinal";45cmds[args.length + 2] = "-version";46ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds);47OutputAnalyzer output = new OutputAnalyzer(pb.start());48output.shouldHaveExitValue(0);49output.shouldContain("UseCountedLoopSafepoints");50output.shouldContain("LoopStripMiningIter");5152Asserts.assertEQ(output.firstMatch("(.+?) UseCountedLoopSafepoints.+?= (.+?) (.+?)", 2), Boolean.toString(cls), msg + ", but got wrong CLS");53Asserts.assertEQ(output.firstMatch("(.+?) LoopStripMiningIter.+?= (.+?) (.+?)", 2), String.valueOf(iters), msg + ", but got wrong LSM");54}5556public static void main(String[] args) throws Exception {57testWith("Shenandoah should have CLS and LSM enabled",58true, 1000,59"-XX:+UnlockExperimentalVMOptions",60"-XX:+UseShenandoahGC"61);6263testWith("Shenandoah with +CLS should set LSM = 1",64true, 1,65"-XX:+UnlockExperimentalVMOptions",66"-XX:+UseShenandoahGC",67"-XX:+UseCountedLoopSafepoints"68);6970testWith("Shenandoah GC with +CLS should not override LSM>1",71true, 10,72"-XX:+UnlockExperimentalVMOptions",73"-XX:+UseShenandoahGC",74"-XX:LoopStripMiningIter=10",75"-XX:+UseCountedLoopSafepoints"76);7778testWith("Shenandoah GC with +CLS should not override LSM=1",79true, 1,80"-XX:+UnlockExperimentalVMOptions",81"-XX:+UseShenandoahGC",82"-XX:LoopStripMiningIter=1",83"-XX:+UseCountedLoopSafepoints"84);8586testWith("Shenandoah GC with +CLS should override LSM=0 to 1",87true, 1,88"-XX:+UnlockExperimentalVMOptions",89"-XX:+UseShenandoahGC",90"-XX:LoopStripMiningIter=0",91"-XX:+UseCountedLoopSafepoints"92);9394testWith("Shenandoah GC with -CLS should set LSM = 0",95false, 0,96"-XX:+UnlockExperimentalVMOptions",97"-XX:+UseShenandoahGC",98"-XX:-UseCountedLoopSafepoints"99);100101testWith("Shenandoah GC with -CLS should override LSM to 0",102false, 0,103"-XX:+UnlockExperimentalVMOptions",104"-XX:+UseShenandoahGC",105"-XX:LoopStripMiningIter=10",106"-XX:-UseCountedLoopSafepoints"107);108}109110}111112113