1 /* 2 * Copyright (c) 2016, 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 #ifndef SHARE_COMPILER_COMPILERDEFINITIONS_INLINE_HPP 26 #define SHARE_COMPILER_COMPILERDEFINITIONS_INLINE_HPP 27 28 #include "compiler/compilerDefinitions.hpp" 29 30 #include "compiler/compiler_globals.hpp" 31 #include "runtime/arguments.hpp" 32 33 inline bool CompilerConfig::is_interpreter_only() { 34 return Arguments::is_interpreter_only() || TieredStopAtLevel == CompLevel_none; 35 } 36 37 inline bool CompilerConfig::is_jvmci_compiler() { return JVMCI_ONLY(has_jvmci() && UseJVMCICompiler) NOT_JVMCI(false); } 38 inline bool CompilerConfig::is_jvmci() { return JVMCI_ONLY(has_jvmci() && EnableJVMCI ) NOT_JVMCI(false); } 39 40 // is_*_only() functions describe situations in which the JVM is in one way or another 41 // forced to use a particular compiler or their combination. The constraint functions 42 // deliberately ignore the fact that there may also be methods installed 43 // through JVMCI (where the JVMCI compiler was invoked not through the broker). Be sure 44 // to check for those (using is_jvmci()) in situations where it matters. 45 // 46 47 // Is the JVM in a configuration that permits only c1-compiled methods (level 1,2,3)? 48 inline bool CompilerConfig::is_c1_only() { 49 if (!is_interpreter_only() && has_c1()) { 50 const bool c1_only = !has_c2() && !is_jvmci_compiler(); 51 const bool tiered_degraded_to_c1_only = TieredCompilation && TieredStopAtLevel >= CompLevel_simple && TieredStopAtLevel < CompLevel_full_optimization; 52 const bool c1_only_compilation_mode = CompilationModeFlag::quick_only(); 53 return c1_only || tiered_degraded_to_c1_only || c1_only_compilation_mode; 54 } 55 return false; 56 } 57 58 inline bool CompilerConfig::is_c1_or_interpreter_only_no_jvmci() { 59 assert(!is_jvmci_compiler() || is_jvmci(), "JVMCI compiler implies enabled JVMCI"); 60 return !is_jvmci() && (is_interpreter_only() || is_c1_only()); 61 } 62 63 inline bool CompilerConfig::is_c1_only_no_jvmci() { 64 return is_c1_only() && !is_jvmci(); 65 } 66 67 // Is the JVM in a configuration that permits only c1-compiled methods at level 1? 68 inline bool CompilerConfig::is_c1_simple_only() { 69 if (is_c1_only()) { 70 const bool tiered_degraded_to_level_1 = TieredCompilation && TieredStopAtLevel == CompLevel_simple; 71 const bool c1_only_compilation_mode = CompilationModeFlag::quick_only(); 72 const bool tiered_off = !TieredCompilation; 73 return tiered_degraded_to_level_1 || c1_only_compilation_mode || tiered_off; 74 } 75 return false; 76 } 77 78 inline bool CompilerConfig::is_c2_enabled() { 79 return has_c2() && !is_interpreter_only() && !is_c1_only() && !is_jvmci_compiler(); 80 } 81 82 inline bool CompilerConfig::is_jvmci_compiler_enabled() { 83 return is_jvmci_compiler() && !is_interpreter_only() && !is_c1_only(); 84 } 85 // Is the JVM in a configuration that permits only c2-compiled methods? 86 inline bool CompilerConfig::is_c2_only() { 87 if (is_c2_enabled()) { 88 const bool c2_only = !has_c1(); 89 // There is no JVMCI compiler to replace C2 in the broker, and the user (or ergonomics) 90 // is forcing C1 off. 91 const bool c2_only_compilation_mode = CompilationModeFlag::high_only(); 92 const bool tiered_off = !TieredCompilation; 93 return c2_only || c2_only_compilation_mode || tiered_off; 94 } 95 return false; 96 } 97 98 // Is the JVM in a configuration that permits only jvmci-compiled methods? 99 inline bool CompilerConfig::is_jvmci_compiler_only() { 100 if (is_jvmci_compiler_enabled()) { 101 const bool jvmci_compiler_only = !has_c1(); 102 // JVMCI compiler replaced C2 and the user (or ergonomics) is forcing C1 off. 103 const bool jvmci_only_compilation_mode = CompilationModeFlag::high_only(); 104 const bool tiered_off = !TieredCompilation; 105 return jvmci_compiler_only || jvmci_only_compilation_mode || tiered_off; 106 } 107 return false; 108 } 109 110 inline bool CompilerConfig::is_c2_or_jvmci_compiler_only() { 111 return is_c2_only() || is_jvmci_compiler_only(); 112 } 113 114 // Tiered is basically C1 & (C2 | JVMCI) minus all the odd cases with restrictions. 115 inline bool CompilerConfig::is_tiered() { 116 assert(!is_c1_simple_only() || is_c1_only(), "c1 simple mode must imply c1-only mode"); 117 return has_tiered() && !is_interpreter_only() && !is_c1_only() && !is_c2_or_jvmci_compiler_only(); 118 } 119 120 inline bool CompilerConfig::is_c1_enabled() { 121 return has_c1() && !is_interpreter_only() && !is_c2_or_jvmci_compiler_only(); 122 } 123 124 inline bool CompilerConfig::is_c1_profiling() { 125 const bool c1_only_profiling = is_c1_only() && !is_c1_simple_only(); 126 const bool tiered = is_tiered(); 127 return c1_only_profiling || tiered; 128 } 129 130 inline bool CompilerConfig::is_c2_or_jvmci_compiler_enabled() { 131 return is_c2_enabled() || is_jvmci_compiler_enabled(); 132 } 133 134 #endif // SHARE_COMPILER_COMPILERDEFINITIONS_INLINE_HPP