11/*
2- * Copyright (c) 2021, 2024 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2021, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * Copyright (c) 2024, Alibaba Group Holding Limited. All Rights Reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
2525/*
2626 * @test
2727 * @summary test c1 to record type profile with CHA optimization
28- * @requires vm.flavor == "server" & ( vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4)
28+ * @requires vm.flavor == "server" & vm.flagless
2929 * @library /test/lib
3030 * @build jdk.test.whitebox.WhiteBox
3131 * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
@@ -48,6 +48,7 @@ public static void main(String[] args) throws Exception {
4848 "-Xbatch" , "-XX:-UseOnStackReplacement" ,
4949 "-XX:+UnlockDiagnosticVMOptions" , "-XX:+WhiteBoxAPI" ,
5050 "-XX:Tier3InvocationThreshold=200" , "-XX:Tier4InvocationThreshold=5000" ,
51+ "-XX:CompileCommand=CompileOnly," + Launcher .class .getName () + "::test*" ,
5152 Launcher .class .getName ());
5253 OutputAnalyzer output = ProcessTools .executeProcess (pb );
5354 System .out .println ("debug output" );
@@ -61,7 +62,7 @@ public static void main(String[] args) throws Exception {
6162 while (matcher .find ()) {
6263 matchCnt ++;
6364 }
64- Asserts .assertEquals (matchCnt , 2 ); // inline Child1::m() twice
65+ Asserts .assertEquals (2 , matchCnt ); // inline Child1::m() twice
6566 }
6667
6768 static class Launcher {
@@ -86,23 +87,23 @@ public static void main(String[] args) throws Exception {
8687
8788 static void addCompilerDirectives () {
8889 WhiteBox WB = WhiteBox .getWhiteBox ();
89- // do not inline getInstance() for test1() and test2()
90+ // Directive for test1
9091 String directive = "[{ match: [\" " + Launcher .class .getName () + "::test1\" ]," +
91- "inline:[\" -" + Launcher .class .getName ()+"::getInstance()\" ] }]" ;
92+ // Do not inline getInstance
93+ "inline:[\" -" + Launcher .class .getName ()+"::getInstance\" ] }]" ;
9294 WB .addCompilerDirective (directive );
9395
96+ // Directive for test2
9497 directive = "[{ match: [\" " + Launcher .class .getName () + "::test2\" ]," +
95- "inline:[\" -" + Launcher .class .getName ()+"::getInstance()\" ] }]" ;
96- WB .addCompilerDirective (directive );
97-
98- // do not inline test1() for test2() in c1 compilation
99- directive = "[{ match: [\" " + Launcher .class .getName () + "::test2\" ]," +
100- "c1: { inline:[\" -" + Launcher .class .getName ()+"::test1()\" ] } }]" ;
101- WB .addCompilerDirective (directive );
102-
103- // print inline tree for checking
104- directive = "[{ match: [\" " + Launcher .class .getName () + "::test2\" ]," +
105- "c2: { PrintInlining: true } }]" ;
98+ // Do not inline getInstance
99+ "inline:[\" -" + Launcher .class .getName ()+"::getInstance\" ]," +
100+ // Do not inline test1 in C1 compilation
101+ "c1: { inline:[\" -" + Launcher .class .getName ()+"::test1\" ] }," +
102+ // Make sure to inline test1 in C2 compilation
103+ "c2: { inline:[\" +" + Launcher .class .getName ()+"::test1\" ]," +
104+ // Print the inline tree for checking
105+ " PrintInlining:true }" +
106+ "}]" ;
106107 WB .addCompilerDirective (directive );
107108 }
108109
0 commit comments