1 /* 2 * Copyright (c) 2024, 2025, 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 it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 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 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 /** 26 * @test 27 * @bug 8319850 28 * @summary PrintInlining should print which methods are late inlines 29 * @modules java.base/jdk.internal.misc 30 * @library /test/lib 31 * @requires vm.flagless 32 * @requires vm.debug == true 33 * 34 * @run driver compiler.inlining.LateInlinePrinting 35 */ 36 37 package compiler.inlining; 38 39 import jdk.test.lib.process.OutputAnalyzer; 40 import jdk.test.lib.process.ProcessTools; 41 42 public class LateInlinePrinting { 43 public static class TestLateInlining { 44 public static void main(String[] args) { 45 for (int i = 0; i < 20_000; i++) { 46 test1(); 47 test2(); 48 } 49 } 50 51 private static void test1() { 52 test3(); 53 testFailInline(); 54 testFailInline(); 55 test2(); 56 } 57 58 private static void test2() { 59 inlined1(); 60 inlined2(); 61 } 62 63 private static void test3() {} 64 65 private static void testFailInline() {} 66 67 private static void inlined1() {} 68 69 private static void inlined2() {} 70 } 71 72 73 public static void main(String[] args) throws Exception { 74 ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( 75 "-XX:-TieredCompilation", "-XX:-UseOnStackReplacement", "-XX:-BackgroundCompilation", 76 "-XX:+PrintCompilation", 77 "-XX:CompileCommand=compileonly,compiler.inlining.LateInlinePrinting$TestLateInlining::test1", 78 "-XX:CompileCommand=compileonly,compiler.inlining.LateInlinePrinting$TestLateInlining::test2", 79 "-XX:CompileCommand=quiet", "-XX:+PrintInlining", "-XX:+AlwaysIncrementalInline", 80 "-XX:CompileCommand=dontinline,compiler.inlining.LateInlinePrinting$TestLateInlining::testFailInline", 81 TestLateInlining.class.getName() 82 ); 83 84 OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); 85 analyzer.shouldHaveExitValue(0); 86 87 analyzer.shouldContain("compiler.inlining.LateInlinePrinting$TestLateInlining::test2 (7 bytes)"); 88 analyzer.shouldContain("@ 0 compiler.inlining.LateInlinePrinting$TestLateInlining::inlined1 (1 bytes) inline (hot) late inline succeeded"); 89 analyzer.shouldContain("@ 3 compiler.inlining.LateInlinePrinting$TestLateInlining::inlined2 (1 bytes) inline (hot) late inline succeeded"); 90 91 analyzer.shouldContain("compiler.inlining.LateInlinePrinting$TestLateInlining::test1 (13 bytes)"); 92 analyzer.shouldContain("@ 0 compiler.inlining.LateInlinePrinting$TestLateInlining::test3 (1 bytes) inline (hot) late inline succeeded"); 93 analyzer.shouldContain("@ 3 compiler.inlining.LateInlinePrinting$TestLateInlining::testFailInline (1 bytes) failed to inline: disallowed by CompileCommand"); 94 analyzer.shouldContain("@ 6 compiler.inlining.LateInlinePrinting$TestLateInlining::testFailInline (1 bytes) failed to inline: disallowed by CompileCommand"); 95 analyzer.shouldContain("@ 9 compiler.inlining.LateInlinePrinting$TestLateInlining::test2 (7 bytes) inline (hot) late inline succeeded"); 96 analyzer.shouldContain("@ 0 compiler.inlining.LateInlinePrinting$TestLateInlining::inlined1 (1 bytes) inline (hot) late inline succeeded"); 97 analyzer.shouldContain("@ 3 compiler.inlining.LateInlinePrinting$TestLateInlining::inlined2 (1 bytes) inline (hot) late inline succeeded"); 98 } 99 }