1 /*
  2  * Copyright (c) 1997, 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_COMPILER_COMPILER_GLOBALS_HPP
 26 #define SHARE_COMPILER_COMPILER_GLOBALS_HPP
 27 
 28 #include "compiler/compiler_globals_pd.hpp"
 29 #include "runtime/globals_shared.hpp"
 30 #ifdef COMPILER1
 31 #include "c1/c1_globals.hpp"
 32 #endif // COMPILER1
 33 #ifdef COMPILER2
 34 #include "opto/c2_globals.hpp"
 35 #endif // COMPILER2
 36 #if INCLUDE_JVMCI
 37 #include "jvmci/jvmci_globals.hpp"
 38 #endif
 39 
 40 // TODO -- currently, even if all JIT compilers are disabled, the following flags
 41 // are still available in HotSpot. This should eventually be fixed ...
 42 
 43 #define COMPILER_FLAGS(develop,                                             \
 44                        develop_pd,                                          \
 45                        product,                                             \
 46                        product_pd,                                          \
 47                        notproduct,                                          \
 48                        range,                                               \
 49                        constraint)                                          \
 50                                                                             \
 51   /* compiler interface */                                                  \
 52                                                                             \
 53   product(bool, CIPrintCompilerName, false, DIAGNOSTIC,                     \
 54           "when CIPrint is active, print the name of the active compiler")  \
 55                                                                             \
 56   product(bool, CIPrintCompileQueue, false, DIAGNOSTIC,                     \
 57           "display the contents of the compile queue whenever a "           \
 58           "compilation is enqueued")                                        \
 59                                                                             \
 60   develop(bool, CIPrintRequests, false,                                     \
 61           "display every request for compilation")                          \
 62                                                                             \
 63   product(bool, CITime, false,                                              \
 64           "collect timing information for compilation")                     \
 65                                                                             \
 66   develop(bool, CITimeVerbose, false,                                       \
 67           "be more verbose in compilation timings")                         \
 68                                                                             \
 69   develop(bool, CITimeEach, false,                                          \
 70           "display timing information after each successful compilation")   \
 71                                                                             \
 72   develop(bool, CICountOSR, false,                                          \
 73           "use a separate counter when assigning ids to osr compilations")  \
 74                                                                             \
 75   develop(bool, CICountNative, false,                                       \
 76           "use a separate counter when assigning ids to native "            \
 77           "compilations")                                                   \
 78                                                                             \
 79   develop(bool, CICompileNatives, true,                                     \
 80           "compile native methods if supported by the compiler")            \
 81                                                                             \
 82   develop_pd(bool, CICompileOSR,                                            \
 83           "compile on stack replacement methods if supported by the "       \
 84           "compiler")                                                       \
 85                                                                             \
 86   develop(bool, CIPrintMethodCodes, false,                                  \
 87           "print method bytecodes of the compiled code")                    \
 88                                                                             \
 89   develop(bool, CIPrintTypeFlow, false,                                     \
 90           "print the results of ciTypeFlow analysis")                       \
 91                                                                             \
 92   develop(bool, CITraceTypeFlow, false,                                     \
 93           "detailed per-bytecode tracing of ciTypeFlow analysis")           \
 94                                                                             \
 95   product(bool, CICompilerCountPerCPU, false,                               \
 96           "1 compiler thread for log(N CPUs)")                              \
 97                                                                             \
 98   notproduct(intx, CICrashAt, -1,                                           \
 99           "id of compilation to trigger assert in compiler thread for "     \
100           "the purpose of testing, e.g. generation of replay data")         \
101                                                                             \
102   notproduct(bool, CIObjectFactoryVerify, false,                            \
103           "enable potentially expensive verification in ciObjectFactory")   \
104                                                                             \
105   develop(intx, CIStart, 0,                                                 \
106           "The id of the first compilation to permit")                      \
107                                                                             \
108   develop(intx, CIStop, max_jint,                                           \
109           "The id of the last compilation to permit")                       \
110                                                                             \
111   develop(intx, CIStartOSR, 0,                                              \
112           "The id of the first osr compilation to permit "                  \
113           "(CICountOSR must be on)")                                        \
114                                                                             \
115   develop(intx, CIStopOSR, max_jint,                                        \
116           "The id of the last osr compilation to permit "                   \
117           "(CICountOSR must be on)")                                        \
118                                                                             \
119   develop(intx, CIBreakAtOSR, -1,                                           \
120           "The id of osr compilation to break at")                          \
121                                                                             \
122   develop(intx, CIBreakAt, -1,                                              \
123           "The id of compilation to break at")                              \
124                                                                             \
125   /* recompilation */                                                       \
126                                                                             \
127   product(double, CompileThresholdScaling, 1.0,                             \
128           "Factor to control when first compilation happens "               \
129           "(both with and without tiered compilation): "                    \
130           "values greater than 1.0 delay counter overflow, "                \
131           "values between 0 and 1.0 rush counter overflow, "                \
132           "value of 1.0 leaves compilation thresholds unchanged "           \
133           "value of 0.0 is equivalent to -Xint. "                           \
134           ""                                                                \
135           "Flag can be set as per-method option. "                          \
136           "If a value is specified for a method, compilation thresholds "   \
137           "for that method are scaled by both the value of the global flag "\
138           "and the value of the per-method flag.")                          \
139           range(0.0, DBL_MAX)                                               \
140                                                                             \
141   product(intx, Tier0InvokeNotifyFreqLog, 7,                                \
142           "Interpreter (tier 0) invocation notification frequency")         \
143           range(0, 30)                                                      \
144                                                                             \
145   product(intx, Tier2InvokeNotifyFreqLog, 11,                               \
146           "C1 without MDO (tier 2) invocation notification frequency")      \
147           range(0, 30)                                                      \
148                                                                             \
149   product(intx, Tier3InvokeNotifyFreqLog, 10,                               \
150           "C1 with MDO profiling (tier 3) invocation notification "         \
151           "frequency")                                                      \
152           range(0, 30)                                                      \
153                                                                             \
154   product(intx, Tier23InlineeNotifyFreqLog, 20,                             \
155           "Inlinee invocation (tiers 2 and 3) notification frequency")      \
156           range(0, 30)                                                      \
157                                                                             \
158   product(intx, Tier0BackedgeNotifyFreqLog, 10,                             \
159           "Interpreter (tier 0) invocation notification frequency")         \
160           range(0, 30)                                                      \
161                                                                             \
162   product(intx, Tier2BackedgeNotifyFreqLog, 14,                             \
163           "C1 without MDO (tier 2) invocation notification frequency")      \
164           range(0, 30)                                                      \
165                                                                             \
166   product(intx, Tier3BackedgeNotifyFreqLog, 13,                             \
167           "C1 with MDO profiling (tier 3) invocation notification "         \
168           "frequency")                                                      \
169           range(0, 30)                                                      \
170                                                                             \
171   product(intx, Tier2CompileThreshold, 0,                                   \
172           "threshold at which tier 2 compilation is invoked")               \
173           range(0, max_jint)                                                \
174                                                                             \
175   product(intx, Tier2BackEdgeThreshold, 0,                                  \
176           "Back edge threshold at which tier 2 compilation is invoked")     \
177           range(0, max_jint)                                                \
178                                                                             \
179   product(intx, Tier3InvocationThreshold, 200,                              \
180           "Compile if number of method invocations crosses this "           \
181           "threshold")                                                      \
182           range(0, max_jint)                                                \
183                                                                             \
184   product(intx, Tier3MinInvocationThreshold, 100,                           \
185           "Minimum invocation to compile at tier 3")                        \
186           range(0, max_jint)                                                \
187                                                                             \
188   product(intx, Tier3CompileThreshold, 2000,                                \
189           "Threshold at which tier 3 compilation is invoked (invocation "   \
190           "minimum must be satisfied)")                                     \
191           range(0, max_jint)                                                \
192                                                                             \
193   product(intx, Tier3BackEdgeThreshold,  60000,                             \
194           "Back edge threshold at which tier 3 OSR compilation is invoked") \
195           range(0, max_jint)                                                \
196                                                                             \
197   product(intx, Tier4InvocationThreshold, 5000,                             \
198           "Compile if number of method invocations crosses this "           \
199           "threshold")                                                      \
200           range(0, max_jint)                                                \
201                                                                             \
202   product(intx, Tier4MinInvocationThreshold, 600,                           \
203           "Minimum invocation to compile at tier 4")                        \
204           range(0, max_jint)                                                \
205                                                                             \
206   product(intx, Tier4CompileThreshold, 15000,                               \
207           "Threshold at which tier 4 compilation is invoked (invocation "   \
208           "minimum must be satisfied)")                                     \
209           range(0, max_jint)                                                \
210                                                                             \
211   product(intx, Tier4BackEdgeThreshold, 40000,                              \
212           "Back edge threshold at which tier 4 OSR compilation is invoked") \
213           range(0, max_jint)                                                \
214                                                                             \
215   product(intx, Tier0Delay, 20, DIAGNOSTIC,                                 \
216           "If C2 queue size grows over this amount per compiler thread "    \
217           "do not start profiling in the interpreter")                      \
218           range(0, max_jint)                                                \
219                                                                             \
220   product(intx, TieredOldPercentage, 1000, DIAGNOSTIC,                      \
221           "Percentage over tier 3 thresholds after which a method is "      \
222           "considered old (turns off parts of prioritization based on "     \
223           "compile queue length)")                                          \
224           range(0, max_jint)                                                \
225                                                                             \
226   product(intx, Tier3DelayOn, 5,                                            \
227           "If C2 queue size grows over this amount per compiler thread "    \
228           "stop compiling at tier 3 and start compiling at tier 2")         \
229           range(0, max_jint)                                                \
230                                                                             \
231   product(intx, Tier3DelayOff, 2,                                           \
232           "If C2 queue size is less than this amount per compiler thread "  \
233           "allow methods compiled at tier 2 transition to tier 3")          \
234           range(0, max_jint)                                                \
235                                                                             \
236   product(intx, Tier3LoadFeedback, 5,                                       \
237           "Tier 3 thresholds will increase twofold when C1 queue size "     \
238           "reaches this amount per compiler thread")                        \
239           range(0, max_jint)                                                \
240                                                                             \
241   product(intx, Tier4LoadFeedback, 3,                                       \
242           "Tier 4 thresholds will increase twofold when C2 queue size "     \
243           "reaches this amount per compiler thread")                        \
244           range(0, max_jint)                                                \
245                                                                             \
246   product(intx, TieredCompileTaskTimeout, 50,                               \
247           "Kill compile task if method was not used within "                \
248           "given timeout in milliseconds")                                  \
249           range(0, max_intx)                                                \
250                                                                             \
251   product(intx, TieredStopAtLevel, 4,                                       \
252           "Stop at given compilation level")                                \
253           range(0, 4)                                                       \
254                                                                             \
255   product(intx, Tier0ProfilingStartPercentage, 200,                         \
256           "Start profiling in interpreter if the counters exceed the "      \
257           "specified percentage of tier 3 thresholds")                      \
258           range(0, max_jint)                                                \
259                                                                             \
260   product(uintx, IncreaseFirstTierCompileThresholdAt, 50,                   \
261           "Increase the compile threshold for C1 compilation if the code "  \
262           "cache is filled by the specified percentage")                    \
263           range(0, 99)                                                      \
264                                                                             \
265   product(intx, TieredRateUpdateMinTime, 1,                                 \
266           "Minimum rate sampling interval (in milliseconds)")               \
267           range(0, max_intx)                                                \
268                                                                             \
269   product(intx, TieredRateUpdateMaxTime, 25,                                \
270           "Maximum rate sampling interval (in milliseconds)")               \
271           range(0, max_intx)                                                \
272                                                                             \
273   product(ccstr, CompilationMode, "default",                                \
274           "Compilation modes: "                                             \
275           "default: normal tiered compilation; "                            \
276           "quick-only: C1-only mode; "                                      \
277           "high-only: C2/JVMCI-only mode; "                                 \
278           "high-only-quick-internal: C2/JVMCI-only mode, "                  \
279           "with JVMCI compiler compiled with C1.")                          \
280                                                                             \
281   product(bool, PrintTieredEvents, false,                                   \
282           "Print tiered events notifications")                              \
283                                                                             \
284   product_pd(intx, OnStackReplacePercentage,                                \
285           "NON_TIERED number of method invocations/branches (expressed as " \
286           "% of CompileThreshold) before (re-)compiling OSR code")          \
287           constraint(OnStackReplacePercentageConstraintFunc, AfterErgo)     \
288                                                                             \
289   product(intx, InterpreterProfilePercentage, 33,                           \
290           "NON_TIERED number of method invocations/branches (expressed as " \
291           "% of CompileThreshold) before profiling in the interpreter")     \
292           range(0, 100)                                                     \
293                                                                             \
294   /* compiler directives */                                                 \
295                                                                             \
296   product(ccstrlist, CompileOnly, "",                                       \
297           "List of methods (pkg/class.name) to restrict compilation to")    \
298                                                                             \
299   product(ccstr, CompileCommandFile, nullptr,                               \
300           "Read compiler commands from this file [.hotspot_compiler]")      \
301                                                                             \
302   product(ccstr, CompilerDirectivesFile, nullptr, DIAGNOSTIC,               \
303           "Read compiler directives from this file")                        \
304                                                                             \
305   product(ccstrlist, CompileCommand, "",                                    \
306           "Prepend to .hotspot_compiler; e.g. log,java/lang/String.<init>") \
307                                                                             \
308   product(bool, ReplayCompiles, false, DIAGNOSTIC,                          \
309           "Enable replay of compilations from ReplayDataFile")              \
310                                                                             \
311   product(bool, ReplayReduce, false, EXPERIMENTAL,                          \
312           "Enable features to facilitate replay file reduction")            \
313                                                                             \
314   product(ccstr, ReplayDataFile, nullptr,                                   \
315           "File containing compilation replay information"                  \
316           "[default: ./replay_pid%p.log] (%p replaced with pid)")           \
317                                                                             \
318   product(ccstr, InlineDataFile, nullptr,                                   \
319           "File containing inlining replay information"                     \
320           "[default: ./inline_pid%p.log] (%p replaced with pid)")           \
321                                                                             \
322   product(intx, ReplaySuppressInitializers, 2, DIAGNOSTIC,                  \
323           "Control handling of class initialization during replay: "        \
324           "0 - don't do anything special; "                                 \
325           "1 - treat all class initializers as empty; "                     \
326           "2 - treat class initializers for application classes as empty; " \
327           "3 - allow all class initializers to run during bootstrap but "   \
328           "    pretend they are empty after starting replay")               \
329           range(0, 3)                                                       \
330                                                                             \
331   product(bool, ReplayIgnoreInitErrors, false, DIAGNOSTIC,                  \
332           "Ignore exceptions thrown during initialization for replay")      \
333                                                                             \
334   product(bool, DumpReplayDataOnError, true,                                \
335           "Record replay data for crashing compiler threads")               \
336                                                                             \
337   product(bool, CompilerDirectivesIgnoreCompileCommands, false, DIAGNOSTIC, \
338              "Disable backwards compatibility for compile commands.")       \
339                                                                             \
340   product(bool, CompilerDirectivesPrint, false, DIAGNOSTIC,                 \
341              "Print compiler directives on installation.")                  \
342                                                                             \
343   product(int,  CompilerDirectivesLimit, 50, DIAGNOSTIC,                    \
344              "Limit on number of compiler directives.")                     \
345                                                                             \
346   /* Bytecode escape analysis estimation. */                                \
347                                                                             \
348   product(bool, EstimateArgEscape, true,                                    \
349           "Analyze bytecodes to estimate escape state of arguments")        \
350                                                                             \
351   product(intx, BCEATraceLevel, 0,                                          \
352           "How much tracing to do of bytecode escape analysis estimates "   \
353           "(0-3)")                                                          \
354           range(0, 3)                                                       \
355                                                                             \
356   product(intx, MaxBCEAEstimateLevel, 5,                                    \
357           "Maximum number of nested calls that are analyzed by BC EA")      \
358           range(0, max_jint)                                                \
359                                                                             \
360   product(intx, MaxBCEAEstimateSize, 150,                                   \
361           "Maximum bytecode size of a method to be analyzed by BC EA")      \
362           range(0, max_jint)                                                \
363                                                                             \
364   /* misc compiler flags */                                                 \
365                                                                             \
366   product(bool, AbortVMOnCompilationFailure, false, DIAGNOSTIC,             \
367           "Abort VM when method had failed to compile.")                    \
368                                                                             \
369   develop(intx, OSROnlyBCI, -1,                                             \
370           "OSR only at this bci.  Negative values mean exclude that bci")   \
371                                                                             \
372   develop(intx, DesiredMethodLimit,  8000,                                  \
373           "The desired maximum method size (in bytecodes) after inlining")  \
374                                                                             \
375   product(bool, DontCompileHugeMethods, true,                               \
376           "Do not compile methods > HugeMethodLimit")                       \
377                                                                             \
378   develop(intx, HugeMethodLimit,  8000,                                     \
379           "Don't compile methods larger than this if "                      \
380           "+DontCompileHugeMethods")                                        \
381                                                                             \
382   product(bool, CaptureBailoutInformation, trueInDebug, DIAGNOSTIC,         \
383           "If compilation is stopped with an error, capture diagnostic "    \
384           "information at the bailout point")                               \
385                                                                             \
386 
387 // end of COMPILER_FLAGS
388 
389 DECLARE_FLAGS(COMPILER_FLAGS)
390 
391 #endif // SHARE_COMPILER_COMPILER_GLOBALS_HPP