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(double, Tier0ProfileDelayFactor, 100.0, DIAGNOSTIC,               \
273           "Delay profiling/compiling of methods that were "                 \
274           "observed to be lukewarm")                                        \
275                                                                             \
276   product(double, Tier2ProfileDelayFactor, 250.0, DIAGNOSTIC,               \
277           "Delay profiling of methods that were observed to be lukewarm")   \
278                                                                             \
279   product(bool, SkipTier2IfPossible, false, DIAGNOSTIC,                     \
280           "Compile at tier 4 instead of tier 2 in training replay "         \
281           "mode if posssible")                                              \
282                                                                             \
283   product(ccstr, CompilationMode, "default",                                \
284           "Compilation modes: "                                             \
285           "default: normal tiered compilation; "                            \
286           "quick-only: C1-only mode; "                                      \
287           "high-only: C2/JVMCI-only mode; "                                 \
288           "high-only-quick-internal: C2/JVMCI-only mode, "                  \
289           "with JVMCI compiler compiled with C1.")                          \
290                                                                             \
291   product(bool, PrintTieredEvents, false,                                   \
292           "Print tiered events notifications")                              \
293                                                                             \
294   product_pd(intx, OnStackReplacePercentage,                                \
295           "NON_TIERED number of method invocations/branches (expressed as " \
296           "% of CompileThreshold) before (re-)compiling OSR code")          \
297           constraint(OnStackReplacePercentageConstraintFunc, AfterErgo)     \
298                                                                             \
299   product(intx, InterpreterProfilePercentage, 33,                           \
300           "NON_TIERED number of method invocations/branches (expressed as " \
301           "% of CompileThreshold) before profiling in the interpreter")     \
302           range(0, 100)                                                     \
303                                                                             \
304   /* compiler directives */                                                 \
305                                                                             \
306   product(ccstrlist, CompileOnly, "",                                       \
307           "List of methods (pkg/class.name) to restrict compilation to")    \
308                                                                             \
309   product(ccstr, CompileCommandFile, nullptr,                               \
310           "Read compiler commands from this file [.hotspot_compiler]")      \
311                                                                             \
312   product(ccstr, CompilerDirectivesFile, nullptr, DIAGNOSTIC,               \
313           "Read compiler directives from this file")                        \
314                                                                             \
315   product(ccstrlist, CompileCommand, "",                                    \
316           "Prepend to .hotspot_compiler; e.g. log,java/lang/String.<init>") \
317                                                                             \
318   product(bool, ReplayCompiles, false, DIAGNOSTIC,                          \
319           "Enable replay of compilations from ReplayDataFile")              \
320                                                                             \
321   product(bool, ReplayReduce, false, EXPERIMENTAL,                          \
322           "Enable features to facilitate replay file reduction")            \
323                                                                             \
324   product(ccstr, ReplayDataFile, nullptr,                                   \
325           "File containing compilation replay information"                  \
326           "[default: ./replay_pid%p.log] (%p replaced with pid)")           \
327                                                                             \
328   product(ccstr, InlineDataFile, nullptr,                                   \
329           "File containing inlining replay information"                     \
330           "[default: ./inline_pid%p.log] (%p replaced with pid)")           \
331                                                                             \
332   product(intx, ReplaySuppressInitializers, 2, DIAGNOSTIC,                  \
333           "Control handling of class initialization during replay: "        \
334           "0 - don't do anything special; "                                 \
335           "1 - treat all class initializers as empty; "                     \
336           "2 - treat class initializers for application classes as empty; " \
337           "3 - allow all class initializers to run during bootstrap but "   \
338           "    pretend they are empty after starting replay")               \
339           range(0, 3)                                                       \
340                                                                             \
341   product(bool, ReplayIgnoreInitErrors, false, DIAGNOSTIC,                  \
342           "Ignore exceptions thrown during initialization for replay")      \
343                                                                             \
344   product(bool, DumpReplayDataOnError, true,                                \
345           "Record replay data for crashing compiler threads")               \
346                                                                             \
347   product(bool, CompilerDirectivesIgnoreCompileCommands, false, DIAGNOSTIC, \
348              "Disable backwards compatibility for compile commands.")       \
349                                                                             \
350   product(bool, CompilerDirectivesPrint, false, DIAGNOSTIC,                 \
351              "Print compiler directives on installation.")                  \
352                                                                             \
353   product(int,  CompilerDirectivesLimit, 50, DIAGNOSTIC,                    \
354              "Limit on number of compiler directives.")                     \
355                                                                             \
356   /* Bytecode escape analysis estimation. */                                \
357                                                                             \
358   product(bool, EstimateArgEscape, true,                                    \
359           "Analyze bytecodes to estimate escape state of arguments")        \
360                                                                             \
361   product(intx, BCEATraceLevel, 0,                                          \
362           "How much tracing to do of bytecode escape analysis estimates "   \
363           "(0-3)")                                                          \
364           range(0, 3)                                                       \
365                                                                             \
366   product(intx, MaxBCEAEstimateLevel, 5,                                    \
367           "Maximum number of nested calls that are analyzed by BC EA")      \
368           range(0, max_jint)                                                \
369                                                                             \
370   product(intx, MaxBCEAEstimateSize, 150,                                   \
371           "Maximum bytecode size of a method to be analyzed by BC EA")      \
372           range(0, max_jint)                                                \
373                                                                             \
374   /* misc compiler flags */                                                 \
375                                                                             \
376   product(bool, AbortVMOnCompilationFailure, false, DIAGNOSTIC,             \
377           "Abort VM when method had failed to compile.")                    \
378                                                                             \
379   develop(intx, OSROnlyBCI, -1,                                             \
380           "OSR only at this bci.  Negative values mean exclude that bci")   \
381                                                                             \
382   develop(intx, DesiredMethodLimit,  8000,                                  \
383           "The desired maximum method size (in bytecodes) after inlining")  \
384                                                                             \
385   product(bool, DontCompileHugeMethods, true,                               \
386           "Do not compile methods > HugeMethodLimit")                       \
387                                                                             \
388   develop(intx, HugeMethodLimit,  8000,                                     \
389           "Don't compile methods larger than this if "                      \
390           "+DontCompileHugeMethods")                                        \
391                                                                             \
392   product(bool, CaptureBailoutInformation, trueInDebug, DIAGNOSTIC,         \
393           "If compilation is stopped with an error, capture diagnostic "    \
394           "information at the bailout point")                               \
395                                                                             \
396   /* flags to control training and deployment modes  */                     \
397                                                                             \
398   product(bool, RecordTraining, false,                                      \
399           "Request output of training data for improved deployment.")       \
400                                                                             \
401   product(bool, ReplayTraining, false,                                      \
402           "Read training data, if available, for use in this execution")    \
403                                                                             \
404   product(bool, PrintTrainingInfo, false, DIAGNOSTIC,                       \
405           "Print additional information about training")                    \
406                                                                             \
407   product(ccstr, TrainingFile, nullptr,                                     \
408           "If training record or replay is enabled, store or load VM data " \
409           "to or from this file [default: ./hs_training_%p.log] "           \
410           "(_%p replaced with _pidNNN on output, empty string on input)")   \
411                                                                             \
412   product(bool, RecordOptCompilationOrder, false,                           \
413           "Record c2/jvmci nmethod temperature to guide compilation order.")\
414                                                                             \
415   product(bool, RecordOnlyTopCompilations, false,                           \
416           "Record only top compilations (non-zero counts)")                 \
417                                                                             \
418   product(int, RecordOptCompilationOrderInterval, 10,                       \
419           "Sampling interval for RecordOptCompilationOrder")                \
420                                                                             \
421   /* Code Caching flags */                                                  \
422                                                                             \
423   product(bool, UseC2asC3, false,                                           \
424           "Use C2 as 3rd compiler when other high-optimizing compiler "     \
425           "is used")                                                        \
426                                                                             \
427   product(bool, StoreCachedCode, false,                                     \
428           "Store cached compiled code")                                     \
429                                                                             \
430   product(bool, LoadCachedCode, false,                                      \
431           "Load cached compiled code")                                      \
432                                                                             \
433   product(uint, DisableCachedCode, 0,                                       \
434           "Disable cached code on some compilation levels "                 \
435           "(T1=1; T2=2; T4=4; T5/preload=8")                                \
436                                                                             \
437   product(uint, ClassInitBarrierMode, 0,                                    \
438           "Produce and use startup code which could be called "             \
439           "on first method invocation, add class initialization barriers, " \
440           "other checks and constrains if needed "                          \
441           "(0: no barriers; 1: uncommon trap; 2: full barrier)")            \
442                                                                             \
443   product(bool, StressClassInitBarriers, false, DIAGNOSTIC,                 \
444           "Force slow path in class initialization barriers")               \
445                                                                             \
446   product(bool, UseMetadataPointers, true,                                  \
447           "Store Metadata pointers in Relocation Info for cached code")     \
448                                                                             \
449   product(bool, UseCodeLoadThread, true,                                    \
450           "Use separate thread for cached code load")                       \
451                                                                             \
452   product(uint, SCLoadStart, 0,                                             \
453           "The id of the first cached code to load")                        \
454                                                                             \
455   product(uint, SCLoadStop, max_jint,                                       \
456           "The id of the last cached code to load")                         \
457                                                                             \
458   product(ccstr, CachedCodeFile, "code.jsa",                                \
459           "File with cached compiled code")                                 \
460                                                                             \
461   product(uint, CachedCodeMaxSize, 10*M,                                    \
462           "Buffer size in bytes for code caching")                          \
463                                                                             \
464   product(bool, VerifyCachedCode, false, DIAGNOSTIC,                        \
465           "Load compiled code but not publish")                             \
466                                                                             \
467   /* Recompilation flags */                                                 \
468                                                                             \
469   product(int, RecompilationLoadAverageThreshold, 5,                        \
470           "Queues load avergage after while recompilations are allowed")    \
471                                                                             \
472   product(int, RecompilationWorkUnitSize, 5,                                \
473           "Queues load avergage after while recompilations are allowed")    \
474                                                                             \
475   product(bool, UseRecompilation, false,                                    \
476           "Recompile methods for peak performance")                         \
477                                                                             \
478   product(bool, ForceRecompilation, false,                                  \
479           "Testing mode for recompilation")                                 \
480                                                                             \
481   product(double, DelayRecompilation, 0.0,                                  \
482           "Delay recompilation for given number of seconds")                \
483                                                                             \
484   product(bool, UseConcurrentTrainingReplay, true,                          \
485           "Replay training after class initialization in a separate thread")\
486                                                                             \
487   product(bool, UseGlobalCompileQueueLock, false,                           \
488           "Use a global lock for all compilation queues")                   \
489                                                                             \
490   product(bool, UseLockFreeCompileQueues, true,                             \
491           "Use lock free compile queues")                                   \
492                                                                             \
493   product(bool, PrecompileCode, false,                                      \
494           "Precompile code")                                                \
495                                                                             \
496   product(bool, PrecompileOnlyAndExit, false,                               \
497           "Exit after precompilation step is over")                         \
498 
499 // end of COMPILER_FLAGS
500 
501 DECLARE_FLAGS(COMPILER_FLAGS)
502 
503 #endif // SHARE_COMPILER_COMPILER_GLOBALS_HPP