Path: blob/master/test/hotspot/jtreg/compiler/arguments/TestPrintOptoAssemblyLineNumbers.java
41152 views
/*1* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.2* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*/2324/*25* @test26* @bug 803344127* @summary Test to ensure that line numbers are now present with the -XX:+PrintOptoAssembly command line option28*29* @requires vm.flagless30* @requires vm.compiler2.enabled & vm.debug == true31*32* @library /test/lib33* @run driver compiler.arguments.TestPrintOptoAssemblyLineNumbers34*/3536package compiler.arguments;3738import jdk.test.lib.process.OutputAnalyzer;39import jdk.test.lib.process.ProcessTools;4041// THIS TEST IS LINE NUMBER SENSITIVE4243public class TestPrintOptoAssemblyLineNumbers {44public static void main(String[] args) throws Throwable {45// create subprocess to run some code with -XX:+PrintOptoAssembly enabled46String[] procArgs = new String[] {47"-XX:+UnlockDiagnosticVMOptions",48"-XX:-TieredCompilation",49"-XX:+PrintOptoAssembly",50CheckC2OptoAssembly.class.getName()51};5253ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);54OutputAnalyzer oa = new OutputAnalyzer(pb.start());55oa.shouldHaveExitValue(0);5657if (oa.getOutput().contains("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11")) {58// if C2 optimizer invoked ensure output includes line numbers:59oa.stdoutShouldContain("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11 (line 72)");60}61}6263public static class CheckC2OptoAssembly { // contents of this class serves to just invoke C264public static boolean foo(String arg) {65return arg.contains("45");66}6768public static void main(String[] args) {69int count = 0;70for (int x = 0; x < 200_000; x++) {71if (foo("something" + x)) { // <- test expects this line of code to be on line 7272count += 1;73}74}75System.out.println("count: " + count);76}77}78}798081