< prev index next >

test/hotspot/jtreg/compiler/ciReplay/TestInliningProtectionDomain.java

Print this page

  1 /*
  2  * Copyright (c) 2021, 2024, 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  */

 75             Asserts.assertTrue(inlineesNormal.get(4).compare("compiler.ciReplay.InliningBar", "bar2", inlineesNormal.get(4).isNormalInline()));
 76             Asserts.assertTrue(inlineesReplay.get(4).compare("compiler.ciReplay.InliningBar", "bar2", inlineesReplay.get(4).isForcedByReplay() || inlineesReplay.get(4).isForcedIncrementalInlineByReplay()));
 77         }
 78     }
 79 }
 80 
 81 class ProtectionDomainTestCompiledBefore {
 82     public static void main(String[] args) {
 83         for (int i = 0; i < 10000; i++) {
 84             bar(); // Ensure that bar() was compiled
 85         }
 86         for (int i = 0; i < 10000; i++) {
 87             test();
 88         }
 89     }
 90 
 91     public static void test() {
 92         bar();
 93     }
 94 
 95     // Integer should be resolved for the protection domain of this class because the separate compilation of bar() in
 96     // the normal run will resolve all classes in the signature. Inlining succeeds.
 97     private static Integer bar() {
 98         InliningFoo.foo();
 99         return null;
100     }
101 }
102 
103 class ProtectionDomainTestNoOtherCompilationPublic {
104     public static void main(String[] args) {
105         for (int i = 0; i < 10000; i++) {
106             test();
107         }
108     }
109 
110     public static void test() {
111         bar(); // Not compiled before separately
112     }
113 
114     // Integer should be resolved for the protection domain of this class because getDeclaredMethods is called in normal run
115     // when validating main() method. In this process, all public methods of this class are visited and its signature classes
116     // are resolved. Inlining of bar() succeeds.
117     public static Integer bar() {
118         InliningFoo.foo();
119         return null;
120     }
121 }
122 
123 class ProtectionDomainTestNoOtherCompilationPrivate {
124     public static void main(String[] args) {
125         for (int i = 0; i < 10000; i++) {
126             test();
127         }
128     }
129 
130     public static void test() {
131         bar(); // Not compiled before separately
132     }
133 
134     // Integer should be unresolved for the protection domain of this class even though getDeclaredMethods is called in normal
135     // run when validating main() method. In this process, only public methods of this class are visited and its signature
136     // classes are resolved. Since this method is private, the signature classes are not resolved for this protection domain.
137     // Inlining of bar() should fail in normal run with "unresolved signature classes". Therefore, replay compilation should
138     // also not inline bar().
139     private static Integer bar() {
140         InliningFoo.foo();
141         return null;
142     }
143 }
144 
145 class ProtectionDomainTestNoOtherCompilationPrivateString {
146     public static void main(String[] args) {
147         for (int i = 0; i < 10000; i++) {
148             test();
149         }
150     }
151 
152     public static void test() {
153         bar(); // Not compiled before separately
154     }
155 
156     // Integer should be resovled for the protection domain of this class because getDeclaredMethods is called in normal run
157     // when validating main() method. In this process, public methods of this class are visited and its signature classes
158     // are resolved. bar() is private and not visited in this process (i.e. no resolution of String). But since main()
159     // has String[] as parameter, the String class will be resolved for this protection domain. Inlining of bar() succeeds.
160     private static String bar() {
161         InliningFoo.foo();
162         return null;
163     }
164 }
165 
166 class InliningFoo {
167     public static void foo() {
168         foo2();
169     }
170 
171     private static void foo2() {
172         InliningBar.bar();
173     }
174 }
175 
176 

  1 /*
  2  * Copyright (c) 2021, 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  */

 75             Asserts.assertTrue(inlineesNormal.get(4).compare("compiler.ciReplay.InliningBar", "bar2", inlineesNormal.get(4).isNormalInline()));
 76             Asserts.assertTrue(inlineesReplay.get(4).compare("compiler.ciReplay.InliningBar", "bar2", inlineesReplay.get(4).isForcedByReplay() || inlineesReplay.get(4).isForcedIncrementalInlineByReplay()));
 77         }
 78     }
 79 }
 80 
 81 class ProtectionDomainTestCompiledBefore {
 82     public static void main(String[] args) {
 83         for (int i = 0; i < 10000; i++) {
 84             bar(); // Ensure that bar() was compiled
 85         }
 86         for (int i = 0; i < 10000; i++) {
 87             test();
 88         }
 89     }
 90 
 91     public static void test() {
 92         bar();
 93     }
 94 
 95     // Thread should be resolved for the protection domain of this class because the separate compilation of bar() in
 96     // the normal run will resolve all classes in the signature. Inlining succeeds.
 97     private static Thread bar() {
 98         InliningFoo.foo();
 99         return null;
100     }
101 }
102 
103 class ProtectionDomainTestNoOtherCompilationPublic {
104     public static void main(String[] args) {
105         for (int i = 0; i < 10000; i++) {
106             test();
107         }
108     }
109 
110     public static void test() {
111         bar(); // Not compiled before separately
112     }
113 
114     // Thread should be resolved for the protection domain of this class because getDeclaredMethods is called in normal run
115     // when validating main() method. In this process, all public methods of this class are visited and its signature classes
116     // are resolved. Inlining of bar() succeeds.
117     public static Thread bar() {
118         InliningFoo.foo();
119         return null;
120     }
121 }
122 
123 class ProtectionDomainTestNoOtherCompilationPrivate {
124     public static void main(String[] args) {
125         for (int i = 0; i < 10000; i++) {
126             test();
127         }
128     }
129 
130     public static void test() {
131         bar(); // Not compiled before separately
132     }
133 
134     // Thread should be unresolved for the protection domain of this class even though getDeclaredMethods is called in normal
135     // run when validating main() method. In this process, only public methods of this class are visited and its signature
136     // classes are resolved. Since this method is private, the signature classes are not resolved for this protection domain.
137     // Inlining of bar() should fail in normal run with "unresolved signature classes". Therefore, replay compilation should
138     // also not inline bar().
139     private static Thread bar() {
140         InliningFoo.foo();
141         return null;
142     }
143 }
144 
145 class ProtectionDomainTestNoOtherCompilationPrivateString {
146     public static void main(String[] args) {
147         for (int i = 0; i < 10000; i++) {
148             test();
149         }
150     }
151 
152     public static void test() {
153         bar(); // Not compiled before separately
154     }
155 
156     // String should be resolved for the protection domain of this class because getDeclaredMethods is called in normal run
157     // when validating main() method. In this process, public methods of this class are visited and its signature classes
158     // are resolved. bar() is private and not visited in this process (i.e. no resolution of String). But since main()
159     // has String[] as parameter, the String class will be resolved for this protection domain. Inlining of bar() succeeds.
160     private static String bar() {
161         InliningFoo.foo();
162         return null;
163     }
164 }
165 
166 class InliningFoo {
167     public static void foo() {
168         foo2();
169     }
170 
171     private static void foo2() {
172         InliningBar.bar();
173     }
174 }
175 
176 
< prev index next >