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