1 /* 2 * Copyright (c) 2000, 2023, 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_JVMCI_JVMCI_GLOBALS_HPP 26 #define SHARE_JVMCI_JVMCI_GLOBALS_HPP 27 28 #include "runtime/globals_shared.hpp" 29 #include "utilities/vmEnums.hpp" 30 31 class fileStream; 32 33 #define LIBJVMCI_ERR_FILE "hs_err_pid%p_libjvmci.log" 34 #define DEFAULT_COMPILER_IDLE_DELAY 1000 35 36 // 37 // Declare all global flags used by the JVMCI compiler. Only flags that need 38 // to be accessible to the JVMCI C++ code should be defined here. 39 // 40 #define JVMCI_FLAGS(develop, \ 41 develop_pd, \ 42 product, \ 43 product_pd, \ 44 notproduct, \ 45 range, \ 46 constraint) \ 47 \ 48 product(bool, EnableJVMCI, false, EXPERIMENTAL, \ 49 "Enable JVMCI") \ 50 \ 51 product(bool, UseGraalJIT, false, EXPERIMENTAL, \ 52 "Select the Graal JVMCI compiler. This is an alias for: " \ 53 " -XX:+EnableJVMCIProduct " \ 54 " -Djvmci.Compiler=graal ") \ 55 \ 56 product(bool, EnableJVMCIProduct, false, EXPERIMENTAL, \ 57 "Allow JVMCI to be used in product mode. This alters a subset of "\ 58 "JVMCI flags to be non-experimental, defaults UseJVMCICompiler " \ 59 "and EnableJVMCI to true and defaults UseJVMCINativeLibrary " \ 60 "to true if a JVMCI native library is available.") \ 61 \ 62 product(bool, UseJVMCICompiler, false, EXPERIMENTAL, \ 63 "Use JVMCI as the default compiler. Defaults to true if " \ 64 "EnableJVMCIProduct is true.") \ 65 \ 66 product(uint, JVMCIThreadsPerNativeLibraryRuntime, 1, EXPERIMENTAL, \ 67 "Max number of threads per JVMCI native runtime. " \ 68 "Specify 0 to force use of a single JVMCI native runtime. " \ 69 "Specify 1 to force a single JVMCI native runtime per thread. ") \ 70 range(0, max_jint) \ 71 \ 72 product(uint, JVMCICompilerIdleDelay, DEFAULT_COMPILER_IDLE_DELAY, EXPERIMENTAL, \ 73 "Number of milliseconds a JVMCI compiler queue should wait for " \ 74 "a compilation task before being considered idle. When a JVMCI " \ 75 "compiler queue becomes idle, it is detached from its JVMCIRuntime. "\ 76 "Once the last thread is detached from a JVMCIRuntime, all " \ 77 "resources associated with the runtime are reclaimed. To use a " \ 78 "new runtime for every JVMCI compilation, set this value to 0 " \ 79 "and set JVMCIThreadsPerNativeLibraryRuntime to 1.") \ 80 range(0, max_jint) \ 81 \ 82 product(bool, JVMCIPrintProperties, false, EXPERIMENTAL, \ 83 "Prints properties used by the JVMCI compiler and exits") \ 84 \ 85 product(bool, BootstrapJVMCI, false, EXPERIMENTAL, \ 86 "Bootstrap JVMCI before running Java main method. This " \ 87 "initializes the compile queue with a small set of methods " \ 88 "and processes the queue until it is empty. Combining this with " \ 89 "-XX:-TieredCompilation makes JVMCI compile more of itself.") \ 90 \ 91 product(bool, EagerJVMCI, false, EXPERIMENTAL, \ 92 "Force eager JVMCI initialization") \ 93 \ 94 product(bool, PrintBootstrap, true, EXPERIMENTAL, \ 95 "Print JVMCI bootstrap progress and summary") \ 96 \ 97 product(intx, JVMCIThreads, 1, EXPERIMENTAL, \ 98 "Force number of JVMCI compiler threads to use. Ignored if " \ 99 "UseJVMCICompiler is false.") \ 100 range(1, max_jint) \ 101 \ 102 product(intx, JVMCIHostThreads, 1, EXPERIMENTAL, \ 103 "Force number of C1 compiler threads. Ignored if " \ 104 "UseJVMCICompiler is false.") \ 105 range(1, max_jint) \ 106 \ 107 NOT_COMPILER2(product(intx, MaxVectorSize, 64, \ 108 "Max vector size in bytes, " \ 109 "actual size could be less depending on elements type") \ 110 range(0, max_jint)) \ 111 \ 112 NOT_COMPILER2(product(bool, ReduceInitialCardMarks, true, \ 113 "Defer write barriers of young objects")) \ 114 \ 115 product(intx, JVMCIEventLogLevel, 1, EXPERIMENTAL, \ 116 "Event log level for JVMCI") \ 117 range(0, 4) \ 118 \ 119 product(intx, JVMCITraceLevel, 0, EXPERIMENTAL, \ 120 "Trace level for JVMCI") \ 121 range(0, 4) \ 122 \ 123 product(intx, JVMCICounterSize, 0, EXPERIMENTAL, \ 124 "Reserved size for benchmark counters") \ 125 range(0, 1000000) \ 126 \ 127 product(bool, JVMCICountersExcludeCompiler, true, EXPERIMENTAL, \ 128 "Exclude JVMCI compiler threads from benchmark counters") \ 129 \ 130 product(intx, JVMCINMethodSizeLimit, (80*K)*wordSize, EXPERIMENTAL, \ 131 "Maximum size of a compiled method.") \ 132 range(0, max_jint) \ 133 \ 134 product(ccstr, JVMCILibPath, nullptr, EXPERIMENTAL, \ 135 "LD path for loading the JVMCI shared library") \ 136 \ 137 product(ccstr, JVMCILibDumpJNIConfig, nullptr, EXPERIMENTAL, \ 138 "Dumps to the given file a description of the classes, fields " \ 139 "and methods the JVMCI shared library must provide") \ 140 \ 141 product(bool, UseJVMCINativeLibrary, false, EXPERIMENTAL, \ 142 "Execute JVMCI Java code from a shared library (\"libjvmci\") " \ 143 "instead of loading it from class files and executing it " \ 144 "on the HotSpot heap. Defaults to true if EnableJVMCIProduct is " \ 145 "true and a JVMCI native library is available.") \ 146 \ 147 product(double, JVMCINativeLibraryThreadFraction, 0.33, EXPERIMENTAL, \ 148 "The fraction of compiler threads used by libjvmci. " \ 149 "The remaining compiler threads are used by C1.") \ 150 range(0.0, 1.0) \ 151 \ 152 product(ccstr, JVMCINativeLibraryErrorFile, nullptr, EXPERIMENTAL, \ 153 "If an error in the JVMCI native library occurs, save the " \ 154 "error data to this file" \ 155 "[default: ./" LIBJVMCI_ERR_FILE "] (%p replaced with pid)") \ 156 \ 157 NOT_COMPILER2(product(bool, UseMultiplyToLenIntrinsic, false, DIAGNOSTIC, \ 158 "Enables intrinsification of BigInteger.multiplyToLen()")) \ 159 \ 160 NOT_COMPILER2(product(bool, UseSquareToLenIntrinsic, false, DIAGNOSTIC, \ 161 "Enables intrinsification of BigInteger.squareToLen()")) \ 162 \ 163 NOT_COMPILER2(product(bool, UseMulAddIntrinsic, false, DIAGNOSTIC, \ 164 "Enables intrinsification of BigInteger.mulAdd()")) \ 165 \ 166 NOT_COMPILER2(product(bool, UseMontgomeryMultiplyIntrinsic, false, DIAGNOSTIC, \ 167 "Enables intrinsification of BigInteger.montgomeryMultiply()")) \ 168 \ 169 NOT_COMPILER2(product(bool, UseMontgomerySquareIntrinsic, false, DIAGNOSTIC, \ 170 "Enables intrinsification of BigInteger.montgomerySquare()")) 171 172 // end of JVMCI_FLAGS 173 174 DECLARE_FLAGS(JVMCI_FLAGS) 175 176 // The base name for the shared library containing the JVMCI based compiler 177 #define JVMCI_SHARED_LIBRARY_NAME "jvmcicompiler" 178 179 class JVMCIGlobals { 180 private: 181 static fileStream* _jni_config_file; 182 public: 183 184 // Returns true if jvmci flags are consistent. If not consistent, 185 // an error message describing the inconsistency is printed before 186 // returning false. 187 static bool check_jvmci_flags_are_consistent(); 188 189 // Convert JVMCI experimental flags to product 190 static bool enable_jvmci_product_mode(JVMFlagOrigin origin, bool use_graal_jit); 191 192 // Returns true iff the GC fully supports JVMCI. 193 static bool gc_supports_jvmci(); 194 195 // Check and turn off EnableJVMCI if selected GC does not support JVMCI. 196 static void check_jvmci_supported_gc(); 197 198 static fileStream* get_jni_config_file() { return _jni_config_file; } 199 }; 200 #endif // SHARE_JVMCI_JVMCI_GLOBALS_HPP