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