Path: blob/master/test/hotspot/jtreg/compiler/debug/TestStressIGVNAndCCP.java
41149 views
/*1* Copyright (c) 2020, 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*/2223package compiler.debug;2425import jdk.test.lib.process.OutputAnalyzer;26import jdk.test.lib.process.ProcessTools;27import jdk.test.lib.Asserts;2829/*30* @test31* @bug 8252219 825653532* @requires vm.debug == true & vm.compiler2.enabled33* @summary Tests that stress compilations with the same seed yield the same34* IGVN and CCP traces.35* @library /test/lib /36* @run driver compiler.debug.TestStressIGVNAndCCP37*/3839public class TestStressIGVNAndCCP {4041static String phaseTrace(String stressOption, String traceOption,42int stressSeed) throws Exception {43String className = TestStressIGVNAndCCP.class.getName();44String[] procArgs = {45"-Xcomp", "-XX:-TieredCompilation", "-XX:-Inline",46"-XX:CompileOnly=" + className + "::sum", "-XX:+" + traceOption,47"-XX:+" + stressOption, "-XX:StressSeed=" + stressSeed,48className, "10"};49ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);50OutputAnalyzer out = new OutputAnalyzer(pb.start());51out.shouldHaveExitValue(0);52return out.getStdout();53}5455static String igvnTrace(int stressSeed) throws Exception {56return phaseTrace("StressIGVN", "TraceIterativeGVN", stressSeed);57}5859static String ccpTrace(int stressSeed) throws Exception {60return phaseTrace("StressCCP", "TracePhaseCCP", stressSeed);61}6263static void sum(int n) {64int acc = 0;65for (int i = 0; i < n; i++) acc += i;66System.out.println(acc);67}6869public static void main(String[] args) throws Exception {70if (args.length == 0) {71for (int s = 0; s < 10; s++) {72Asserts.assertEQ(igvnTrace(s), igvnTrace(s),73"got different IGVN traces for the same seed");74Asserts.assertEQ(ccpTrace(s), ccpTrace(s),75"got different CCP traces for the same seed");76}77} else if (args.length > 0) {78sum(Integer.parseInt(args[0]));79}80}81}828384