1 /*
  2  * Copyright (c) 2022, 2025, 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_CDS_CDS_GLOBALS_HPP
 26 #define SHARE_CDS_CDS_GLOBALS_HPP
 27 
 28 #include "runtime/globals_shared.hpp"
 29 
 30 //
 31 // Defines all globals flags used by CDS.
 32 //
 33 
 34 #define CDS_FLAGS(develop,                                                  \
 35                   develop_pd,                                               \
 36                   product,                                                  \
 37                   product_pd,                                               \
 38                   range,                                                    \
 39                   constraint)                                               \
 40   /* Shared spaces */                                                       \
 41                                                                             \
 42   product(bool, VerifySharedSpaces, false,                                  \
 43           "Verify integrity of shared spaces")                              \
 44                                                                             \
 45   product(bool, RecordDynamicDumpInfo, false,                               \
 46           "Record class info for jcmd VM.cds dynamic_dump")                 \
 47                                                                             \
 48   product(bool, AutoCreateSharedArchive, false,                             \
 49           "Create shared archive at exit if cds mapping failed")            \
 50                                                                             \
 51   product(bool, PrintSharedArchiveAndExit, false,                           \
 52           "Print shared archive file contents")                             \
 53                                                                             \
 54   product(size_t, SharedBaseAddress, LP64_ONLY(32*G)                        \
 55           NOT_LP64(LINUX_ONLY(2*G) NOT_LINUX(0)),                           \
 56           "Address to allocate shared memory region for class data")        \
 57           range(0, SIZE_MAX)                                                \
 58                                                                             \
 59   product(ccstr, SharedArchiveConfigFile, nullptr,                          \
 60           "Data to add to the CDS archive file")                            \
 61                                                                             \
 62   product(uint, SharedSymbolTableBucketSize, 4,                             \
 63           "Average number of symbols per bucket in shared table")           \
 64           range(2, 246)                                                     \
 65                                                                             \
 66   product(bool, AllowArchivingWithJavaAgent, false, DIAGNOSTIC,             \
 67           "Allow Java agent to be run with CDS dumping (not applicable"     \
 68           " to AOT")                                                        \
 69                                                                             \
 70   develop(ccstr, ArchiveHeapTestClass, nullptr,                             \
 71           "For JVM internal testing only. The static field named "          \
 72           "\"archivedObjects\" of the specified class is stored in the "    \
 73           "CDS archive heap")                                               \
 74                                                                             \
 75   develop(ccstr, AOTInitTestClass, nullptr,                                 \
 76           "For JVM internal testing only. The specified class is stored "   \
 77           "in the initialized state in the AOT cache ")                     \
 78                                                                             \
 79   product(ccstr, DumpLoadedClassList, nullptr,                              \
 80           "Dump the names all loaded classes, that could be stored into "   \
 81           "the CDS archive, in the specified file")                         \
 82                                                                             \
 83   product(ccstr, SharedClassListFile, nullptr,                              \
 84           "Override the default CDS class list")                            \
 85                                                                             \
 86   product(ccstr, SharedArchiveFile, nullptr,                                \
 87           "Override the default location of the CDS archive file")          \
 88                                                                             \
 89   product(ccstr, ArchiveClassesAtExit, nullptr,                             \
 90           "The path and name of the dynamic archive file")                  \
 91                                                                             \
 92   product(ccstr, ExtraSharedClassListFile, nullptr,                         \
 93           "Extra classlist for building the CDS archive file")              \
 94                                                                             \
 95   product(int, ArchiveRelocationMode, 1, DIAGNOSTIC,                        \
 96            "(0) first map at preferred address, and if "                    \
 97            "unsuccessful, map at alternative address; "                     \
 98            "(1) always map at alternative address (default); "              \
 99            "(2) always map at preferred address, and if unsuccessful, "     \
100            "do not map the archive")                                        \
101            range(0, 2)                                                      \
102                                                                             \
103   /*========== New "AOT" flags =========================================*/  \
104   /* The following 3 flags are aliases of -Xshare:dump,                 */  \
105   /* -XX:SharedArchiveFile=..., etc. See CDSConfig::check_flag_aliases()*/  \
106                                                                             \
107   product(ccstr, AOTMode, nullptr,                                          \
108           "Specifies how AOTCache should be created or used. Valid values " \
109           "are: off, record, create, auto, on; the default is auto")        \
110           constraint(AOTModeConstraintFunc, AtParse)                        \
111                                                                             \
112   product(ccstr, AOTConfiguration, nullptr,                                 \
113           "The configuration file written by -XX:AOTMode=record, and "      \
114           "loaded by -XX:AOTMode=create. This file contains profiling data "\
115           "for deciding what contents should be added to AOTCache. ")       \
116           constraint(AOTConfigurationConstraintFunc, AtParse)               \
117                                                                             \
118   product(ccstr, AOTCache, nullptr,                                         \
119           "Cache for improving start up and warm up")                       \
120           constraint(AOTCacheConstraintFunc, AtParse)                       \
121                                                                             \
122   product(ccstr, AOTCacheOutput, nullptr,                                   \
123           "Specifies the file name for writing the AOT cache")              \
124                                                                             \
125   product(bool, AOTInvokeDynamicLinking, false, DIAGNOSTIC,                 \
126           "AOT-link JVM_CONSTANT_InvokeDynamic entries in cached "          \
127           "ConstantPools")                                                  \
128                                                                             \
129   product(bool, AOTClassLinking, false,                                     \
130           "Load/link all archived classes for the boot/platform/app "       \
131           "loaders before application main")                                \
132                                                                             \
133   product(bool, AOTCacheParallelRelocation, true, DIAGNOSTIC,               \
134           "Use parallel relocation code to speed up startup.")              \
135                                                                             \
136   /* flags to control training and deployment modes  */                     \
137                                                                             \
138   product(bool, AOTRecordTraining, false, DIAGNOSTIC,                       \
139           "Request output of training data for improved deployment.")       \
140                                                                             \
141   product(bool, AOTReplayTraining, false, DIAGNOSTIC,                       \
142           "Read training data, if available, for use in this execution")    \
143                                                                             \
144   product(bool, AOTPrintTrainingInfo, false, DIAGNOSTIC,                    \
145           "Print additional information about training")                    \
146                                                                             \
147   product(bool, AOTVerifyTrainingData, trueInDebug, DIAGNOSTIC,             \
148           "Verify archived training data")                                  \
149                                                                             \
150   product(bool, AOTCompileEagerly, true, DIAGNOSTIC,                        \
151           "Compile methods as soon as possible")                            \
152                                                                             \
153   product(bool, AOTRecordOptCompilationOrder, false,                        \
154           "Record c2/jvmci nmethod temperature to guide compilation order.")\
155                                                                             \
156   product(bool, AOTRecordOnlyTopCompilations, false,                        \
157           "Record only top compilations (non-zero counts)")                 \
158                                                                             \
159   product(int, AOTRecordOptCompilationOrderInterval, 10,                    \
160           "Sampling interval for RecordOptCompilationOrder")                \
161                                                                             \
162    /* Recompilation flags */                                                \
163                                                                             \
164    product(int, AOTRecompilationLoadAverageThreshold, 5,                    \
165            "Queues load avergage after while recompilations are allowed")   \
166                                                                             \
167    product(int, AOTRecompilationWorkUnitSize, 5,                            \
168            "Queues load avergage after while recompilations are allowed")   \
169                                                                             \
170    product(bool, AOTRecompilation, false,                                   \
171            "Recompile methods for peak performance")                        \
172                                                                             \
173    product(bool, AOTForceRecompilation, false,                              \
174            "Testing mode for recompilation")                                \
175                                                                             \
176    product(double, AOTDelayRecompilation, 0.0,                              \
177            "Delay recompilation for given number of seconds")               \
178                                                                             \
179   /* AOT Code flags */                                                      \
180                                                                             \
181   product(bool, AOTCodeCaching, false, DIAGNOSTIC,                          \
182           "Enable saving and restoring JIT comiled code in AOT cache")      \
183                                                                             \
184   product(bool, AOTAdapterCaching, false, DIAGNOSTIC,                       \
185           "Enable saving and restoring i2c2i adapters in AOT cache")        \
186                                                                             \
187   product(bool, AOTStubCaching, false, DIAGNOSTIC,                          \
188           "Enable saving and restoring stubs and code blobs in AOT cache")  \
189                                                                             \
190   product(uint, AOTCodeMaxSize, 512*M, DIAGNOSTIC,                          \
191           "Buffer size in bytes for AOT code caching")                      \
192           range(1*M, max_jint)                                              \
193                                                                             \
194   product(bool, AbortVMOnAOTCodeFailure, false, DIAGNOSTIC,                 \
195           "Abort VM on the first occurrence of AOT code load or store "     \
196           "failure. By default VM will continue execute without AOT code.") \
197                                                                             \
198   develop(bool, TestAOTAdapterLinkFailure, false,                           \
199           "Test failure of adapter linking when loading from AOT cache.")   \
200                                                                             \
201   /*========== New options added by Leyden =============================*/  \
202                                                                             \
203   product(ccstrlist, AOTEndTrainingOnMethodEntry, "",                       \
204           "List of methods (pkg/class.name) to trigger end of AOT "         \
205           "training run.  Optional ',count=N' where N is > 0")              \
206                                                                             \
207   product(ccstr, CacheOnlyClassesIn, nullptr,                               \
208           "If set, only classes loaded from these JAR files will be "       \
209           "stored in the AOTCache")                                         \
210                                                                             \
211   product(ccstr, CacheDataStore, nullptr,                                   \
212           "If valid, use the specified file for SharedArchiveFile; "        \
213           "otherwise the specified file is generated at program exit")      \
214                                                                             \
215   product(ccstr, CDSPreimage, nullptr,                                      \
216           "(** internal use only **) -- used by a child JVM process to "    \
217           "create the CacheDataStore final image")                          \
218                                                                             \
219   product(bool, CDSManualFinalImage, false, DIAGNOSTIC,                     \
220           "(** internal use only **) -- if false, automatically launch a "  \
221           "child process to create the final image.")                       \
222                                                                             \
223   product(bool, ArchiveDynamicProxies, false,                               \
224           "Archive classes generated for java/lang/reflect/Proxy")          \
225                                                                             \
226   product(bool, ArchiveLoaderLookupCache, false,                            \
227           "Archive app loader's positive and negative lookup cache")        \
228                                                                             \
229   product(bool, ArchivePackages, false,                                     \
230           "Archive the java.lang.ClassLoader::{packages,package2certs} "    \
231           "tables")                                                         \
232                                                                             \
233   product(bool, ArchiveProtectionDomains, false,                            \
234           "Archive the java.security.SecureClassLoader::pdcache table")     \
235                                                                             \
236   product(bool, ArchiveReflectionData, false,                               \
237           "Archive Class::reflectionData field")                            \
238                                                                             \
239   product(bool, SkipArchiveHeapVerification, false,                         \
240           "Skip verification of CDS archive heap")                          \
241 
242 // end of CDS_FLAGS
243 
244 DECLARE_FLAGS(CDS_FLAGS)
245 
246 #endif // SHARE_CDS_CDS_GLOBALS_HPP