annotate src/share/vm/runtime/arguments.cpp @ 5664:78da3894b86f

8027593: performance drop with constrained codecache starting with hs25 b111 Summary: Fixed proper sweeping of small code cache sizes Reviewed-by: kvn, iveresov
author anoll
date Tue, 12 Nov 2013 09:32:50 +0100
parents 3b3133d93fb6
children 6f206b5d258f
rev   line source
duke@0 1 /*
hseigel@4030 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1879 25 #include "precompiled.hpp"
stefank@1879 26 #include "classfile/javaAssertions.hpp"
hseigel@3842 27 #include "classfile/symbolTable.hpp"
stefank@1879 28 #include "compiler/compilerOracle.hpp"
stefank@1879 29 #include "memory/allocation.inline.hpp"
stefank@1879 30 #include "memory/cardTableRS.hpp"
tschatzl@5266 31 #include "memory/genCollectedHeap.hpp"
stefank@1879 32 #include "memory/referenceProcessor.hpp"
stefank@1879 33 #include "memory/universe.inline.hpp"
stefank@1879 34 #include "oops/oop.inline.hpp"
stefank@1879 35 #include "prims/jvmtiExport.hpp"
stefank@1879 36 #include "runtime/arguments.hpp"
stefank@1879 37 #include "runtime/globals_extension.hpp"
stefank@1879 38 #include "runtime/java.hpp"
stefank@1879 39 #include "services/management.hpp"
zgu@3465 40 #include "services/memTracker.hpp"
stefank@1879 41 #include "utilities/defaultStream.hpp"
jprovino@4107 42 #include "utilities/macros.hpp"
stefank@1879 43 #include "utilities/taskqueue.hpp"
stefank@1879 44 #ifdef TARGET_OS_FAMILY_linux
stefank@1879 45 # include "os_linux.inline.hpp"
stefank@1879 46 #endif
stefank@1879 47 #ifdef TARGET_OS_FAMILY_solaris
stefank@1879 48 # include "os_solaris.inline.hpp"
stefank@1879 49 #endif
stefank@1879 50 #ifdef TARGET_OS_FAMILY_windows
stefank@1879 51 # include "os_windows.inline.hpp"
stefank@1879 52 #endif
never@2721 53 #ifdef TARGET_OS_FAMILY_bsd
never@2721 54 # include "os_bsd.inline.hpp"
never@2721 55 #endif
jprovino@4107 56 #if INCLUDE_ALL_GCS
stefank@1879 57 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
tschatzl@5266 58 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
tschatzl@5266 59 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
jprovino@4107 60 #endif // INCLUDE_ALL_GCS
duke@0 61
ohair@2321 62 // Note: This is a special bug reporting site for the JVM
ohair@2321 63 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp"
duke@0 64 #define DEFAULT_JAVA_LAUNCHER "generic"
duke@0 65
iignatyev@5050 66 // Disable options not supported in this release, with a warning if they
iignatyev@5050 67 // were explicitly requested on the command-line
iignatyev@5050 68 #define UNSUPPORTED_OPTION(opt, description) \
iignatyev@5050 69 do { \
iignatyev@5050 70 if (opt) { \
iignatyev@5050 71 if (FLAG_IS_CMDLINE(opt)) { \
iignatyev@5050 72 warning(description " is disabled in this release."); \
iignatyev@5050 73 } \
iignatyev@5050 74 FLAG_SET_DEFAULT(opt, false); \
iignatyev@5050 75 } \
iignatyev@5050 76 } while(0)
iignatyev@5050 77
iignatyev@5050 78 #define UNSUPPORTED_GC_OPTION(gc) \
iignatyev@5050 79 do { \
iignatyev@5050 80 if (gc) { \
iignatyev@5050 81 if (FLAG_IS_CMDLINE(gc)) { \
iignatyev@5050 82 warning(#gc " is not supported in this VM. Using Serial GC."); \
iignatyev@5050 83 } \
iignatyev@5050 84 FLAG_SET_DEFAULT(gc, false); \
iignatyev@5050 85 } \
iignatyev@5050 86 } while(0)
iignatyev@5050 87
duke@0 88 char** Arguments::_jvm_flags_array = NULL;
duke@0 89 int Arguments::_num_jvm_flags = 0;
duke@0 90 char** Arguments::_jvm_args_array = NULL;
duke@0 91 int Arguments::_num_jvm_args = 0;
duke@0 92 char* Arguments::_java_command = NULL;
duke@0 93 SystemProperty* Arguments::_system_properties = NULL;
duke@0 94 const char* Arguments::_gc_log_filename = NULL;
duke@0 95 bool Arguments::_has_profile = false;
tschatzl@5266 96 size_t Arguments::_conservative_max_heap_alignment = 0;
duke@0 97 uintx Arguments::_min_heap_size = 0;
duke@0 98 Arguments::Mode Arguments::_mode = _mixed;
duke@0 99 bool Arguments::_java_compiler = false;
duke@0 100 bool Arguments::_xdebug_mode = false;
duke@0 101 const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG;
duke@0 102 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
duke@0 103 int Arguments::_sun_java_launcher_pid = -1;
sla@2149 104 bool Arguments::_created_by_gamma_launcher = false;
duke@0 105
duke@0 106 // These parameters are reset in method parse_vm_init_args(JavaVMInitArgs*)
duke@0 107 bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
duke@0 108 bool Arguments::_UseOnStackReplacement = UseOnStackReplacement;
duke@0 109 bool Arguments::_BackgroundCompilation = BackgroundCompilation;
duke@0 110 bool Arguments::_ClipInlining = ClipInlining;
duke@0 111
duke@0 112 char* Arguments::SharedArchivePath = NULL;
duke@0 113
duke@0 114 AgentLibraryList Arguments::_libraryList;
duke@0 115 AgentLibraryList Arguments::_agentList;
duke@0 116
duke@0 117 abort_hook_t Arguments::_abort_hook = NULL;
duke@0 118 exit_hook_t Arguments::_exit_hook = NULL;
duke@0 119 vfprintf_hook_t Arguments::_vfprintf_hook = NULL;
duke@0 120
duke@0 121
duke@0 122 SystemProperty *Arguments::_java_ext_dirs = NULL;
duke@0 123 SystemProperty *Arguments::_java_endorsed_dirs = NULL;
duke@0 124 SystemProperty *Arguments::_sun_boot_library_path = NULL;
duke@0 125 SystemProperty *Arguments::_java_library_path = NULL;
duke@0 126 SystemProperty *Arguments::_java_home = NULL;
duke@0 127 SystemProperty *Arguments::_java_class_path = NULL;
duke@0 128 SystemProperty *Arguments::_sun_boot_class_path = NULL;
duke@0 129
duke@0 130 char* Arguments::_meta_index_path = NULL;
duke@0 131 char* Arguments::_meta_index_dir = NULL;
duke@0 132
duke@0 133 // Check if head of 'option' matches 'name', and sets 'tail' remaining part of option string
duke@0 134
duke@0 135 static bool match_option(const JavaVMOption *option, const char* name,
duke@0 136 const char** tail) {
duke@0 137 int len = (int)strlen(name);
duke@0 138 if (strncmp(option->optionString, name, len) == 0) {
duke@0 139 *tail = option->optionString + len;
duke@0 140 return true;
duke@0 141 } else {
duke@0 142 return false;
duke@0 143 }
duke@0 144 }
duke@0 145
duke@0 146 static void logOption(const char* opt) {
duke@0 147 if (PrintVMOptions) {
duke@0 148 jio_fprintf(defaultStream::output_stream(), "VM option '%s'\n", opt);
duke@0 149 }
duke@0 150 }
duke@0 151
duke@0 152 // Process java launcher properties.
duke@0 153 void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
duke@0 154 // See if sun.java.launcher or sun.java.launcher.pid is defined.
duke@0 155 // Must do this before setting up other system properties,
duke@0 156 // as some of them may depend on launcher type.
duke@0 157 for (int index = 0; index < args->nOptions; index++) {
duke@0 158 const JavaVMOption* option = args->options + index;
duke@0 159 const char* tail;
duke@0 160
duke@0 161 if (match_option(option, "-Dsun.java.launcher=", &tail)) {
duke@0 162 process_java_launcher_argument(tail, option->extraInfo);
duke@0 163 continue;
duke@0 164 }
duke@0 165 if (match_option(option, "-Dsun.java.launcher.pid=", &tail)) {
duke@0 166 _sun_java_launcher_pid = atoi(tail);
duke@0 167 continue;
duke@0 168 }
duke@0 169 }
duke@0 170 }
duke@0 171
duke@0 172 // Initialize system properties key and value.
duke@0 173 void Arguments::init_system_properties() {
duke@0 174
duke@0 175 PropertyList_add(&_system_properties, new SystemProperty("java.vm.specification.name",
duke@0 176 "Java Virtual Machine Specification", false));
duke@0 177 PropertyList_add(&_system_properties, new SystemProperty("java.vm.version", VM_Version::vm_release(), false));
duke@0 178 PropertyList_add(&_system_properties, new SystemProperty("java.vm.name", VM_Version::vm_name(), false));
duke@0 179 PropertyList_add(&_system_properties, new SystemProperty("java.vm.info", VM_Version::vm_info_string(), true));
duke@0 180
duke@0 181 // following are JVMTI agent writeable properties.
duke@0 182 // Properties values are set to NULL and they are
duke@0 183 // os specific they are initialized in os::init_system_properties_values().
duke@0 184 _java_ext_dirs = new SystemProperty("java.ext.dirs", NULL, true);
duke@0 185 _java_endorsed_dirs = new SystemProperty("java.endorsed.dirs", NULL, true);
duke@0 186 _sun_boot_library_path = new SystemProperty("sun.boot.library.path", NULL, true);
duke@0 187 _java_library_path = new SystemProperty("java.library.path", NULL, true);
duke@0 188 _java_home = new SystemProperty("java.home", NULL, true);
duke@0 189 _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL, true);
duke@0 190
duke@0 191 _java_class_path = new SystemProperty("java.class.path", "", true);
duke@0 192
duke@0 193 // Add to System Property list.
duke@0 194 PropertyList_add(&_system_properties, _java_ext_dirs);
duke@0 195 PropertyList_add(&_system_properties, _java_endorsed_dirs);
duke@0 196 PropertyList_add(&_system_properties, _sun_boot_library_path);
duke@0 197 PropertyList_add(&_system_properties, _java_library_path);
duke@0 198 PropertyList_add(&_system_properties, _java_home);
duke@0 199 PropertyList_add(&_system_properties, _java_class_path);
duke@0 200 PropertyList_add(&_system_properties, _sun_boot_class_path);
duke@0 201
duke@0 202 // Set OS specific system properties values
duke@0 203 os::init_system_properties_values();
duke@0 204 }
duke@0 205
zgu@1784 206
zgu@1784 207 // Update/Initialize System properties after JDK version number is known
zgu@1784 208 void Arguments::init_version_specific_system_properties() {
kamg@1863 209 enum { bufsz = 16 };
kamg@1863 210 char buffer[bufsz];
kamg@1863 211 const char* spec_vendor = "Sun Microsystems Inc.";
kamg@1863 212 uint32_t spec_version = 0;
kamg@1863 213
kamg@1863 214 if (JDK_Version::is_gte_jdk17x_version()) {
kamg@1863 215 spec_vendor = "Oracle Corporation";
kamg@1863 216 spec_version = JDK_Version::current().major_version();
kamg@1863 217 }
kamg@1863 218 jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version);
kamg@1863 219
kamg@1863 220 PropertyList_add(&_system_properties,
kamg@1863 221 new SystemProperty("java.vm.specification.vendor", spec_vendor, false));
kamg@1863 222 PropertyList_add(&_system_properties,
kamg@1863 223 new SystemProperty("java.vm.specification.version", buffer, false));
kamg@1863 224 PropertyList_add(&_system_properties,
kamg@1863 225 new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(), false));
zgu@1784 226 }
zgu@1784 227
kamg@242 228 /**
kamg@242 229 * Provide a slightly more user-friendly way of eliminating -XX flags.
kamg@242 230 * When a flag is eliminated, it can be added to this list in order to
kamg@242 231 * continue accepting this flag on the command-line, while issuing a warning
kamg@242 232 * and ignoring the value. Once the JDK version reaches the 'accept_until'
kamg@242 233 * limit, we flatly refuse to admit the existence of the flag. This allows
kamg@242 234 * a flag to die correctly over JDK releases using HSX.
kamg@242 235 */
kamg@242 236 typedef struct {
kamg@242 237 const char* name;
kamg@242 238 JDK_Version obsoleted_in; // when the flag went away
kamg@242 239 JDK_Version accept_until; // which version to start denying the existence
kamg@242 240 } ObsoleteFlag;
duke@0 241
kamg@242 242 static ObsoleteFlag obsolete_jvm_flags[] = {
kamg@242 243 { "UseTrainGC", JDK_Version::jdk(5), JDK_Version::jdk(7) },
kamg@242 244 { "UseSpecialLargeObjectHandling", JDK_Version::jdk(5), JDK_Version::jdk(7) },
kamg@242 245 { "UseOversizedCarHandling", JDK_Version::jdk(5), JDK_Version::jdk(7) },
kamg@242 246 { "TraceCarAllocation", JDK_Version::jdk(5), JDK_Version::jdk(7) },
kamg@242 247 { "PrintTrainGCProcessingStats", JDK_Version::jdk(5), JDK_Version::jdk(7) },
kamg@242 248 { "LogOfCarSpaceSize", JDK_Version::jdk(5), JDK_Version::jdk(7) },
kamg@242 249 { "OversizedCarThreshold", JDK_Version::jdk(5), JDK_Version::jdk(7) },
kamg@242 250 { "MinTickInterval", JDK_Version::jdk(5), JDK_Version::jdk(7) },
kamg@242 251 { "DefaultTickInterval", JDK_Version::jdk(5), JDK_Version::jdk(7) },
kamg@242 252 { "MaxTickInterval", JDK_Version::jdk(5), JDK_Version::jdk(7) },
kamg@242 253 { "DelayTickAdjustment", JDK_Version::jdk(5), JDK_Version::jdk(7) },
kamg@242 254 { "ProcessingToTenuringRatio", JDK_Version::jdk(5), JDK_Version::jdk(7) },
kamg@242 255 { "MinTrainLength", JDK_Version::jdk(5), JDK_Version::jdk(7) },
kamg@242 256 { "AppendRatio", JDK_Version::jdk_update(6,10), JDK_Version::jdk(7) },
phh@1064 257 { "DefaultMaxRAM", JDK_Version::jdk_update(6,18), JDK_Version::jdk(7) },
phh@1064 258 { "DefaultInitialRAMFraction",
phh@1064 259 JDK_Version::jdk_update(6,18), JDK_Version::jdk(7) },
tonyp@1626 260 { "UseDepthFirstScavengeOrder",
tonyp@1626 261 JDK_Version::jdk_update(6,22), JDK_Version::jdk(7) },
ysr@1808 262 { "HandlePromotionFailure",
ysr@1808 263 JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
ysr@1808 264 { "MaxLiveObjectEvacuationRatio",
ysr@1808 265 JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
jcoomes@2209 266 { "ForceSharedSpaces", JDK_Version::jdk_update(6,25), JDK_Version::jdk(8) },
jcoomes@2348 267 { "UseParallelOldGCCompacting",
jcoomes@2348 268 JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
jcoomes@2348 269 { "UseParallelDensePrefixUpdate",
jcoomes@2348 270 JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
jcoomes@2348 271 { "UseParallelOldGCDensePrefix",
jcoomes@2348 272 JDK_Version::jdk_update(6,27), JDK_Version::jdk(8) },
jrose@2307 273 { "AllowTransitionalJSR292", JDK_Version::jdk(7), JDK_Version::jdk(8) },
jcoomes@2559 274 { "UseCompressedStrings", JDK_Version::jdk(7), JDK_Version::jdk(8) },
coleenp@3602 275 { "CMSPermGenPrecleaningEnabled", JDK_Version::jdk(8), JDK_Version::jdk(9) },
coleenp@3602 276 { "CMSTriggerPermRatio", JDK_Version::jdk(8), JDK_Version::jdk(9) },
coleenp@3602 277 { "CMSInitiatingPermOccupancyFraction", JDK_Version::jdk(8), JDK_Version::jdk(9) },
coleenp@3602 278 { "AdaptivePermSizeWeight", JDK_Version::jdk(8), JDK_Version::jdk(9) },
coleenp@3602 279 { "PermGenPadding", JDK_Version::jdk(8), JDK_Version::jdk(9) },
coleenp@3602 280 { "PermMarkSweepDeadRatio", JDK_Version::jdk(8), JDK_Version::jdk(9) },
coleenp@3602 281 { "PermSize", JDK_Version::jdk(8), JDK_Version::jdk(9) },
coleenp@3602 282 { "MaxPermSize", JDK_Version::jdk(8), JDK_Version::jdk(9) },
coleenp@3602 283 { "MinPermHeapExpansion", JDK_Version::jdk(8), JDK_Version::jdk(9) },
coleenp@3602 284 { "MaxPermHeapExpansion", JDK_Version::jdk(8), JDK_Version::jdk(9) },
coleenp@3602 285 { "CMSRevisitStackSize", JDK_Version::jdk(8), JDK_Version::jdk(9) },
coleenp@3602 286 { "PrintRevisitStats", JDK_Version::jdk(8), JDK_Version::jdk(9) },
coleenp@3792 287 { "UseVectoredExceptions", JDK_Version::jdk(8), JDK_Version::jdk(9) },
hseigel@4384 288 { "UseSplitVerifier", JDK_Version::jdk(8), JDK_Version::jdk(9) },
anoll@4949 289 { "UseISM", JDK_Version::jdk(8), JDK_Version::jdk(9) },
anoll@4949 290 { "UsePermISM", JDK_Version::jdk(8), JDK_Version::jdk(9) },
anoll@4949 291 { "UseMPSS", JDK_Version::jdk(8), JDK_Version::jdk(9) },
ccheung@4992 292 { "UseStringCache", JDK_Version::jdk(8), JDK_Version::jdk(9) },
jcoomes@2559 293 #ifdef PRODUCT
jcoomes@2559 294 { "DesiredMethodLimit",
jcoomes@2559 295 JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) },
jcoomes@2559 296 #endif // PRODUCT
kamg@242 297 { NULL, JDK_Version(0), JDK_Version(0) }
kamg@242 298 };
kamg@242 299
kamg@242 300 // Returns true if the flag is obsolete and fits into the range specified
kamg@242 301 // for being ignored. In the case that the flag is ignored, the 'version'
kamg@242 302 // value is filled in with the version number when the flag became
kamg@242 303 // obsolete so that that value can be displayed to the user.
kamg@242 304 bool Arguments::is_newly_obsolete(const char *s, JDK_Version* version) {
duke@0 305 int i = 0;
kamg@242 306 assert(version != NULL, "Must provide a version buffer");
kamg@242 307 while (obsolete_jvm_flags[i].name != NULL) {
kamg@242 308 const ObsoleteFlag& flag_status = obsolete_jvm_flags[i];
duke@0 309 // <flag>=xxx form
duke@0 310 // [-|+]<flag> form
kamg@242 311 if ((strncmp(flag_status.name, s, strlen(flag_status.name)) == 0) ||
duke@0 312 ((s[0] == '+' || s[0] == '-') &&
kamg@242 313 (strncmp(flag_status.name, &s[1], strlen(flag_status.name)) == 0))) {
kamg@242 314 if (JDK_Version::current().compare(flag_status.accept_until) == -1) {
kamg@242 315 *version = flag_status.obsoleted_in;
kamg@242 316 return true;
kamg@242 317 }
duke@0 318 }
duke@0 319 i++;
duke@0 320 }
duke@0 321 return false;
duke@0 322 }
duke@0 323
duke@0 324 // Constructs the system class path (aka boot class path) from the following
duke@0 325 // components, in order:
duke@0 326 //
duke@0 327 // prefix // from -Xbootclasspath/p:...
duke@0 328 // endorsed // the expansion of -Djava.endorsed.dirs=...
duke@0 329 // base // from os::get_system_properties() or -Xbootclasspath=
duke@0 330 // suffix // from -Xbootclasspath/a:...
duke@0 331 //
duke@0 332 // java.endorsed.dirs is a list of directories; any jar or zip files in the
duke@0 333 // directories are added to the sysclasspath just before the base.
duke@0 334 //
duke@0 335 // This could be AllStatic, but it isn't needed after argument processing is
duke@0 336 // complete.
duke@0 337 class SysClassPath: public StackObj {
duke@0 338 public:
duke@0 339 SysClassPath(const char* base);
duke@0 340 ~SysClassPath();
duke@0 341
duke@0 342 inline void set_base(const char* base);
duke@0 343 inline void add_prefix(const char* prefix);
phh@531 344 inline void add_suffix_to_prefix(const char* suffix);
duke@0 345 inline void add_suffix(const char* suffix);
duke@0 346 inline void reset_path(const char* base);
duke@0 347
duke@0 348 // Expand the jar/zip files in each directory listed by the java.endorsed.dirs
duke@0 349 // property. Must be called after all command-line arguments have been
duke@0 350 // processed (in particular, -Djava.endorsed.dirs=...) and before calling
duke@0 351 // combined_path().
duke@0 352 void expand_endorsed();
duke@0 353
duke@0 354 inline const char* get_base() const { return _items[_scp_base]; }
duke@0 355 inline const char* get_prefix() const { return _items[_scp_prefix]; }
duke@0 356 inline const char* get_suffix() const { return _items[_scp_suffix]; }
duke@0 357 inline const char* get_endorsed() const { return _items[_scp_endorsed]; }
duke@0 358
duke@0 359 // Combine all the components into a single c-heap-allocated string; caller
duke@0 360 // must free the string if/when no longer needed.
duke@0 361 char* combined_path();
duke@0 362
duke@0 363 private:
duke@0 364 // Utility routines.
duke@0 365 static char* add_to_path(const char* path, const char* str, bool prepend);
duke@0 366 static char* add_jars_to_path(char* path, const char* directory);
duke@0 367
duke@0 368 inline void reset_item_at(int index);
duke@0 369
duke@0 370 // Array indices for the items that make up the sysclasspath. All except the
duke@0 371 // base are allocated in the C heap and freed by this class.
duke@0 372 enum {
duke@0 373 _scp_prefix, // from -Xbootclasspath/p:...
duke@0 374 _scp_endorsed, // the expansion of -Djava.endorsed.dirs=...
duke@0 375 _scp_base, // the default sysclasspath
duke@0 376 _scp_suffix, // from -Xbootclasspath/a:...
duke@0 377 _scp_nitems // the number of items, must be last.
duke@0 378 };
duke@0 379
duke@0 380 const char* _items[_scp_nitems];
duke@0 381 DEBUG_ONLY(bool _expansion_done;)
duke@0 382 };
duke@0 383
duke@0 384 SysClassPath::SysClassPath(const char* base) {
duke@0 385 memset(_items, 0, sizeof(_items));
duke@0 386 _items[_scp_base] = base;
duke@0 387 DEBUG_ONLY(_expansion_done = false;)
duke@0 388 }
duke@0 389
duke@0 390 SysClassPath::~SysClassPath() {
duke@0 391 // Free everything except the base.
duke@0 392 for (int i = 0; i < _scp_nitems; ++i) {
duke@0 393 if (i != _scp_base) reset_item_at(i);
duke@0 394 }
duke@0 395 DEBUG_ONLY(_expansion_done = false;)
duke@0 396 }
duke@0 397
duke@0 398 inline void SysClassPath::set_base(const char* base) {
duke@0 399 _items[_scp_base] = base;
duke@0 400 }
duke@0 401
duke@0 402 inline void SysClassPath::add_prefix(const char* prefix) {
duke@0 403 _items[_scp_prefix] = add_to_path(_items[_scp_prefix], prefix, true);
duke@0 404 }
duke@0 405
phh@531 406 inline void SysClassPath::add_suffix_to_prefix(const char* suffix) {
phh@531 407 _items[_scp_prefix] = add_to_path(_items[_scp_prefix], suffix, false);
phh@531 408 }
phh@531 409
duke@0 410 inline void SysClassPath::add_suffix(const char* suffix) {
duke@0 411 _items[_scp_suffix] = add_to_path(_items[_scp_suffix], suffix, false);
duke@0 412 }
duke@0 413
duke@0 414 inline void SysClassPath::reset_item_at(int index) {
duke@0 415 assert(index < _scp_nitems && index != _scp_base, "just checking");
duke@0 416 if (_items[index] != NULL) {
zgu@3465 417 FREE_C_HEAP_ARRAY(char, _items[index], mtInternal);
duke@0 418 _items[index] = NULL;
duke@0 419 }
duke@0 420 }
duke@0 421
duke@0 422 inline void SysClassPath::reset_path(const char* base) {
duke@0 423 // Clear the prefix and suffix.
duke@0 424 reset_item_at(_scp_prefix);
duke@0 425 reset_item_at(_scp_suffix);
duke@0 426 set_base(base);
duke@0 427 }
duke@0 428
duke@0 429 //------------------------------------------------------------------------------
duke@0 430
duke@0 431 void SysClassPath::expand_endorsed() {
duke@0 432 assert(_items[_scp_endorsed] == NULL, "can only be called once.");
duke@0 433
duke@0 434 const char* path = Arguments::get_property("java.endorsed.dirs");
duke@0 435 if (path == NULL) {
duke@0 436 path = Arguments::get_endorsed_dir();
duke@0 437 assert(path != NULL, "no default for java.endorsed.dirs");
duke@0 438 }
duke@0 439
duke@0 440 char* expanded_path = NULL;
duke@0 441 const char separator = *os::path_separator();
duke@0 442 const char* const end = path + strlen(path);
duke@0 443 while (path < end) {
duke@0 444 const char* tmp_end = strchr(path, separator);
duke@0 445 if (tmp_end == NULL) {
duke@0 446 expanded_path = add_jars_to_path(expanded_path, path);
duke@0 447 path = end;
duke@0 448 } else {
zgu@3465 449 char* dirpath = NEW_C_HEAP_ARRAY(char, tmp_end - path + 1, mtInternal);
duke@0 450 memcpy(dirpath, path, tmp_end - path);
duke@0 451 dirpath[tmp_end - path] = '\0';
duke@0 452 expanded_path = add_jars_to_path(expanded_path, dirpath);
zgu@3465 453 FREE_C_HEAP_ARRAY(char, dirpath, mtInternal);
duke@0 454 path = tmp_end + 1;
duke@0 455 }
duke@0 456 }
duke@0 457 _items[_scp_endorsed] = expanded_path;
duke@0 458 DEBUG_ONLY(_expansion_done = true;)
duke@0 459 }
duke@0 460
duke@0 461 // Combine the bootclasspath elements, some of which may be null, into a single
duke@0 462 // c-heap-allocated string.
duke@0 463 char* SysClassPath::combined_path() {
duke@0 464 assert(_items[_scp_base] != NULL, "empty default sysclasspath");
duke@0 465 assert(_expansion_done, "must call expand_endorsed() first.");
duke@0 466
duke@0 467 size_t lengths[_scp_nitems];
duke@0 468 size_t total_len = 0;
duke@0 469
duke@0 470 const char separator = *os::path_separator();
duke@0 471
duke@0 472 // Get the lengths.
duke@0 473 int i;
duke@0 474 for (i = 0; i < _scp_nitems; ++i) {
duke@0 475 if (_items[i] != NULL) {
duke@0 476 lengths[i] = strlen(_items[i]);
duke@0 477 // Include space for the separator char (or a NULL for the last item).
duke@0 478 total_len += lengths[i] + 1;
duke@0 479 }
duke@0 480 }
duke@0 481 assert(total_len > 0, "empty sysclasspath not allowed");
duke@0 482
duke@0 483 // Copy the _items to a single string.
zgu@3465 484 char* cp = NEW_C_HEAP_ARRAY(char, total_len, mtInternal);
duke@0 485 char* cp_tmp = cp;
duke@0 486 for (i = 0; i < _scp_nitems; ++i) {
duke@0 487 if (_items[i] != NULL) {
duke@0 488 memcpy(cp_tmp, _items[i], lengths[i]);
duke@0 489 cp_tmp += lengths[i];
duke@0 490 *cp_tmp++ = separator;
duke@0 491 }
duke@0 492 }
duke@0 493 *--cp_tmp = '\0'; // Replace the extra separator.
duke@0 494 return cp;
duke@0 495 }
duke@0 496
duke@0 497 // Note: path must be c-heap-allocated (or NULL); it is freed if non-null.
duke@0 498 char*
duke@0 499 SysClassPath::add_to_path(const char* path, const char* str, bool prepend) {
duke@0 500 char *cp;
duke@0 501
duke@0 502 assert(str != NULL, "just checking");
duke@0 503 if (path == NULL) {
duke@0 504 size_t len = strlen(str) + 1;
zgu@3465 505 cp = NEW_C_HEAP_ARRAY(char, len, mtInternal);
duke@0 506 memcpy(cp, str, len); // copy the trailing null
duke@0 507 } else {
duke@0 508 const char separator = *os::path_separator();
duke@0 509 size_t old_len = strlen(path);
duke@0 510 size_t str_len = strlen(str);
duke@0 511 size_t len = old_len + str_len + 2;
duke@0 512
duke@0 513 if (prepend) {
zgu@3465 514 cp = NEW_C_HEAP_ARRAY(char, len, mtInternal);
duke@0 515 char* cp_tmp = cp;
duke@0 516 memcpy(cp_tmp, str, str_len);
duke@0 517 cp_tmp += str_len;
duke@0 518 *cp_tmp = separator;
duke@0 519 memcpy(++cp_tmp, path, old_len + 1); // copy the trailing null
zgu@3465 520 FREE_C_HEAP_ARRAY(char, path, mtInternal);
duke@0 521 } else {
zgu@3465 522 cp = REALLOC_C_HEAP_ARRAY(char, path, len, mtInternal);
duke@0 523 char* cp_tmp = cp + old_len;
duke@0 524 *cp_tmp = separator;
duke@0 525 memcpy(++cp_tmp, str, str_len + 1); // copy the trailing null
duke@0 526 }
duke@0 527 }
duke@0 528 return cp;
duke@0 529 }
duke@0 530
duke@0 531 // Scan the directory and append any jar or zip files found to path.
duke@0 532 // Note: path must be c-heap-allocated (or NULL); it is freed if non-null.
duke@0 533 char* SysClassPath::add_jars_to_path(char* path, const char* directory) {
duke@0 534 DIR* dir = os::opendir(directory);
duke@0 535 if (dir == NULL) return path;
duke@0 536
duke@0 537 char dir_sep[2] = { '\0', '\0' };
duke@0 538 size_t directory_len = strlen(directory);
duke@0 539 const char fileSep = *os::file_separator();
duke@0 540 if (directory[directory_len - 1] != fileSep) dir_sep[0] = fileSep;
duke@0 541
duke@0 542 /* Scan the directory for jars/zips, appending them to path. */
duke@0 543 struct dirent *entry;
zgu@3465 544 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal);
duke@0 545 while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
duke@0 546 const char* name = entry->d_name;
duke@0 547 const char* ext = name + strlen(name) - 4;
duke@0 548 bool isJarOrZip = ext > name &&
duke@0 549 (os::file_name_strcmp(ext, ".jar") == 0 ||
duke@0 550 os::file_name_strcmp(ext, ".zip") == 0);
duke@0 551 if (isJarOrZip) {
zgu@3465 552 char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtInternal);
duke@0 553 sprintf(jarpath, "%s%s%s", directory, dir_sep, name);
duke@0 554 path = add_to_path(path, jarpath, false);
zgu@3465 555 FREE_C_HEAP_ARRAY(char, jarpath, mtInternal);
duke@0 556 }
duke@0 557 }
zgu@3465 558 FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
duke@0 559 os::closedir(dir);
duke@0 560 return path;
duke@0 561 }
duke@0 562
duke@0 563 // Parses a memory size specification string.
swamyv@489 564 static bool atomull(const char *s, julong* result) {
swamyv@489 565 julong n = 0;
hseigel@4030 566 int args_read = sscanf(s, JULONG_FORMAT, &n);
duke@0 567 if (args_read != 1) {
duke@0 568 return false;
duke@0 569 }
duke@0 570 while (*s != '\0' && isdigit(*s)) {
duke@0 571 s++;
duke@0 572 }
duke@0 573 // 4705540: illegal if more characters are found after the first non-digit
duke@0 574 if (strlen(s) > 1) {
duke@0 575 return false;
duke@0 576 }
duke@0 577 switch (*s) {
duke@0 578 case 'T': case 't':
duke@0 579 *result = n * G * K;
swamyv@489 580 // Check for overflow.
swamyv@489 581 if (*result/((julong)G * K) != n) return false;
duke@0 582 return true;
duke@0 583 case 'G': case 'g':
duke@0 584 *result = n * G;
swamyv@489 585 if (*result/G != n) return false;
duke@0 586 return true;
duke@0 587 case 'M': case 'm':
duke@0 588 *result = n * M;
swamyv@489 589 if (*result/M != n) return false;
duke@0 590 return true;
duke@0 591 case 'K': case 'k':
duke@0 592 *result = n * K;
swamyv@489 593 if (*result/K != n) return false;
duke@0 594 return true;
duke@0 595 case '\0':
duke@0 596 *result = n;
duke@0 597 return true;
duke@0 598 default:
duke@0 599 return false;
duke@0 600 }
duke@0 601 }
duke@0 602
swamyv@489 603 Arguments::ArgsRange Arguments::check_memory_size(julong size, julong min_size) {
duke@0 604 if (size < min_size) return arg_too_small;
duke@0 605 // Check that size will fit in a size_t (only relevant on 32-bit)
swamyv@489 606 if (size > max_uintx) return arg_too_big;
duke@0 607 return arg_in_range;
duke@0 608 }
duke@0 609
duke@0 610 // Describe an argument out of range error
duke@0 611 void Arguments::describe_range_error(ArgsRange errcode) {
duke@0 612 switch(errcode) {
duke@0 613 case arg_too_big:
duke@0 614 jio_fprintf(defaultStream::error_stream(),
duke@0 615 "The specified size exceeds the maximum "
duke@0 616 "representable size.\n");
duke@0 617 break;
duke@0 618 case arg_too_small:
duke@0 619 case arg_unreadable:
duke@0 620 case arg_in_range:
duke@0 621 // do nothing for now
duke@0 622 break;
duke@0 623 default:
duke@0 624 ShouldNotReachHere();
duke@0 625 }
duke@0 626 }
duke@0 627
twisti@5355 628 static bool set_bool_flag(char* name, bool value, Flag::Flags origin) {
duke@0 629 return CommandLineFlags::boolAtPut(name, &value, origin);
duke@0 630 }
duke@0 631
twisti@5355 632 static bool set_fp_numeric_flag(char* name, char* value, Flag::Flags origin) {
duke@0 633 double v;
duke@0 634 if (sscanf(value, "%lf", &v) != 1) {
duke@0 635 return false;
duke@0 636 }
duke@0 637
duke@0 638 if (CommandLineFlags::doubleAtPut(name, &v, origin)) {
duke@0 639 return true;
duke@0 640 }
duke@0 641 return false;
duke@0 642 }
duke@0 643
twisti@5355 644 static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) {
swamyv@489 645 julong v;
duke@0 646 intx intx_v;
duke@0 647 bool is_neg = false;
swamyv@489 648 // Check the sign first since atomull() parses only unsigned values.
duke@0 649 if (*value == '-') {
duke@0 650 if (!CommandLineFlags::intxAt(name, &intx_v)) {
duke@0 651 return false;
duke@0 652 }
duke@0 653 value++;
duke@0 654 is_neg = true;
duke@0 655 }
swamyv@489 656 if (!atomull(value, &v)) {
duke@0 657 return false;
duke@0 658 }
duke@0 659 intx_v = (intx) v;
duke@0 660 if (is_neg) {
duke@0 661 intx_v = -intx_v;
duke@0 662 }
duke@0 663 if (CommandLineFlags::intxAtPut(name, &intx_v, origin)) {
duke@0 664 return true;
duke@0 665 }
duke@0 666 uintx uintx_v = (uintx) v;
duke@0 667 if (!is_neg && CommandLineFlags::uintxAtPut(name, &uintx_v, origin)) {
duke@0 668 return true;
duke@0 669 }
phh@1064 670 uint64_t uint64_t_v = (uint64_t) v;
phh@1064 671 if (!is_neg && CommandLineFlags::uint64_tAtPut(name, &uint64_t_v, origin)) {
phh@1064 672 return true;
phh@1064 673 }
duke@0 674 return false;
duke@0 675 }
duke@0 676
twisti@5355 677 static bool set_string_flag(char* name, const char* value, Flag::Flags origin) {
duke@0 678 if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false;
duke@0 679 // Contract: CommandLineFlags always returns a pointer that needs freeing.
zgu@3465 680 FREE_C_HEAP_ARRAY(char, value, mtInternal);
duke@0 681 return true;
duke@0 682 }
duke@0 683
twisti@5355 684 static bool append_to_string_flag(char* name, const char* new_value, Flag::Flags origin) {
duke@0 685 const char* old_value = "";
duke@0 686 if (!CommandLineFlags::ccstrAt(name, &old_value)) return false;
duke@0 687 size_t old_len = old_value != NULL ? strlen(old_value) : 0;
duke@0 688 size_t new_len = strlen(new_value);
duke@0 689 const char* value;
duke@0 690 char* free_this_too = NULL;
duke@0 691 if (old_len == 0) {
duke@0 692 value = new_value;
duke@0 693 } else if (new_len == 0) {
duke@0 694 value = old_value;
duke@0 695 } else {
zgu@3465 696 char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtInternal);
duke@0 697 // each new setting adds another LINE to the switch:
duke@0 698 sprintf(buf, "%s\n%s", old_value, new_value);
duke@0 699 value = buf;
duke@0 700 free_this_too = buf;
duke@0 701 }
duke@0 702 (void) CommandLineFlags::ccstrAtPut(name, &value, origin);
duke@0 703 // CommandLineFlags always returns a pointer that needs freeing.
zgu@3465 704 FREE_C_HEAP_ARRAY(char, value, mtInternal);
duke@0 705 if (free_this_too != NULL) {
duke@0 706 // CommandLineFlags made its own copy, so I must delete my own temp. buffer.
zgu@3465 707 FREE_C_HEAP_ARRAY(char, free_this_too, mtInternal);
duke@0 708 }
duke@0 709 return true;
duke@0 710 }
duke@0 711
twisti@5355 712 bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
duke@0 713
duke@0 714 // range of acceptable characters spelled out for portability reasons
duke@0 715 #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
duke@0 716 #define BUFLEN 255
duke@0 717 char name[BUFLEN+1];
duke@0 718 char dummy;
duke@0 719
duke@0 720 if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
duke@0 721 return set_bool_flag(name, false, origin);
duke@0 722 }
duke@0 723 if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
duke@0 724 return set_bool_flag(name, true, origin);
duke@0 725 }
duke@0 726
duke@0 727 char punct;
duke@0 728 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
duke@0 729 const char* value = strchr(arg, '=') + 1;
duke@0 730 Flag* flag = Flag::find_flag(name, strlen(name));
duke@0 731 if (flag != NULL && flag->is_ccstr()) {
duke@0 732 if (flag->ccstr_accumulates()) {
duke@0 733 return append_to_string_flag(name, value, origin);
duke@0 734 } else {
duke@0 735 if (value[0] == '\0') {
duke@0 736 value = NULL;
duke@0 737 }
duke@0 738 return set_string_flag(name, value, origin);
duke@0 739 }
duke@0 740 }
duke@0 741 }
duke@0 742
duke@0 743 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE ":%c", name, &punct) == 2 && punct == '=') {
duke@0 744 const char* value = strchr(arg, '=') + 1;
duke@0 745 // -XX:Foo:=xxx will reset the string flag to the given value.
duke@0 746 if (value[0] == '\0') {
duke@0 747 value = NULL;
duke@0 748 }
duke@0 749 return set_string_flag(name, value, origin);
duke@0 750 }
duke@0 751
duke@0 752 #define SIGNED_FP_NUMBER_RANGE "[-0123456789.]"
duke@0 753 #define SIGNED_NUMBER_RANGE "[-0123456789]"
duke@0 754 #define NUMBER_RANGE "[0123456789]"
duke@0 755 char value[BUFLEN + 1];
duke@0 756 char value2[BUFLEN + 1];
duke@0 757 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) {
duke@0 758 // Looks like a floating-point number -- try again with more lenient format string
duke@0 759 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) {
duke@0 760 return set_fp_numeric_flag(name, value, origin);
duke@0 761 }
duke@0 762 }
duke@0 763
duke@0 764 #define VALUE_RANGE "[-kmgtKMGT0123456789]"
duke@0 765 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) VALUE_RANGE "%c", name, value, &dummy) == 2) {
duke@0 766 return set_numeric_flag(name, value, origin);
duke@0 767 }
duke@0 768
duke@0 769 return false;
duke@0 770 }
duke@0 771
duke@0 772 void Arguments::add_string(char*** bldarray, int* count, const char* arg) {
duke@0 773 assert(bldarray != NULL, "illegal argument");
duke@0 774
duke@0 775 if (arg == NULL) {
duke@0 776 return;
duke@0 777 }
duke@0 778
brutisso@4635 779 int new_count = *count + 1;
duke@0 780
duke@0 781 // expand the array and add arg to the last element
duke@0 782 if (*bldarray == NULL) {
brutisso@4635 783 *bldarray = NEW_C_HEAP_ARRAY(char*, new_count, mtInternal);
duke@0 784 } else {
brutisso@4635 785 *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, new_count, mtInternal);
duke@0 786 }
brutisso@4635 787 (*bldarray)[*count] = strdup(arg);
brutisso@4635 788 *count = new_count;
duke@0 789 }
duke@0 790
duke@0 791 void Arguments::build_jvm_args(const char* arg) {
duke@0 792 add_string(&_jvm_args_array, &_num_jvm_args, arg);
duke@0 793 }
duke@0 794
duke@0 795 void Arguments::build_jvm_flags(const char* arg) {
duke@0 796 add_string(&_jvm_flags_array, &_num_jvm_flags, arg);
duke@0 797 }
duke@0 798
duke@0 799 // utility function to return a string that concatenates all
duke@0 800 // strings in a given char** array
duke@0 801 const char* Arguments::build_resource_string(char** args, int count) {
duke@0 802 if (args == NULL || count == 0) {
duke@0 803 return NULL;
duke@0 804 }
duke@0 805 size_t length = strlen(args[0]) + 1; // add 1 for the null terminator
duke@0 806 for (int i = 1; i < count; i++) {
duke@0 807 length += strlen(args[i]) + 1; // add 1 for a space
duke@0 808 }
duke@0 809 char* s = NEW_RESOURCE_ARRAY(char, length);
duke@0 810 strcpy(s, args[0]);
duke@0 811 for (int j = 1; j < count; j++) {
duke@0 812 strcat(s, " ");
duke@0 813 strcat(s, args[j]);
duke@0 814 }
duke@0 815 return (const char*) s;
duke@0 816 }
duke@0 817
duke@0 818 void Arguments::print_on(outputStream* st) {
duke@0 819 st->print_cr("VM Arguments:");
duke@0 820 if (num_jvm_flags() > 0) {
duke@0 821 st->print("jvm_flags: "); print_jvm_flags_on(st);
duke@0 822 }
duke@0 823 if (num_jvm_args() > 0) {
duke@0 824 st->print("jvm_args: "); print_jvm_args_on(st);
duke@0 825 }
duke@0 826 st->print_cr("java_command: %s", java_command() ? java_command() : "<unknown>");
coleenp@3755 827 if (_java_class_path != NULL) {
coleenp@3755 828 char* path = _java_class_path->value();
coleenp@3755 829 st->print_cr("java_class_path (initial): %s", strlen(path) == 0 ? "<not set>" : path );
coleenp@3755 830 }
duke@0 831 st->print_cr("Launcher Type: %s", _sun_java_launcher);
duke@0 832 }
duke@0 833
duke@0 834 void Arguments::print_jvm_flags_on(outputStream* st) {
duke@0 835 if (_num_jvm_flags > 0) {
duke@0 836 for (int i=0; i < _num_jvm_flags; i++) {
duke@0 837 st->print("%s ", _jvm_flags_array[i]);
duke@0 838 }
duke@0 839 st->print_cr("");
duke@0 840 }
duke@0 841 }
duke@0 842
duke@0 843 void Arguments::print_jvm_args_on(outputStream* st) {
duke@0 844 if (_num_jvm_args > 0) {
duke@0 845 for (int i=0; i < _num_jvm_args; i++) {
duke@0 846 st->print("%s ", _jvm_args_array[i]);
duke@0 847 }
duke@0 848 st->print_cr("");
duke@0 849 }
duke@0 850 }
duke@0 851
kamg@242 852 bool Arguments::process_argument(const char* arg,
twisti@5355 853 jboolean ignore_unrecognized, Flag::Flags origin) {
kamg@242 854
kamg@242 855 JDK_Version since = JDK_Version();
duke@0 856
jcoomes@2347 857 if (parse_argument(arg, origin) || ignore_unrecognized) {
jcoomes@2347 858 return true;
duke@0 859 }
jcoomes@2347 860
hseigel@4067 861 bool has_plus_minus = (*arg == '+' || *arg == '-');
hseigel@4067 862 const char* const argname = has_plus_minus ? arg + 1 : arg;
jcoomes@2347 863 if (is_newly_obsolete(arg, &since)) {
jcoomes@2347 864 char version[256];
jcoomes@2347 865 since.to_string(version, sizeof(version));
jcoomes@2347 866 warning("ignoring option %s; support was removed in %s", argname, version);
jcoomes@2347 867 return true;
jcoomes@2347 868 }
jcoomes@2347 869
jmelvin@3215 870 // For locked flags, report a custom error message if available.
jmelvin@3215 871 // Otherwise, report the standard unrecognized VM option.
jmelvin@3215 872
hseigel@4067 873 size_t arg_len;
hseigel@4067 874 const char* equal_sign = strchr(argname, '=');
hseigel@4067 875 if (equal_sign == NULL) {
hseigel@4067 876 arg_len = strlen(argname);
hseigel@4067 877 } else {
hseigel@4067 878 arg_len = equal_sign - argname;
hseigel@4067 879 }
hseigel@4067 880
tamao@4908 881 Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true);
hseigel@4067 882 if (found_flag != NULL) {
jmelvin@3215 883 char locked_message_buf[BUFLEN];
hseigel@4067 884 found_flag->get_locked_message(locked_message_buf, BUFLEN);
jmelvin@3215 885 if (strlen(locked_message_buf) == 0) {
hseigel@4067 886 if (found_flag->is_bool() && !has_plus_minus) {
hseigel@4067 887 jio_fprintf(defaultStream::error_stream(),
hseigel@4067 888 "Missing +/- setting for VM option '%s'\n", argname);
hseigel@4067 889 } else if (!found_flag->is_bool() && has_plus_minus) {
hseigel@4067 890 jio_fprintf(defaultStream::error_stream(),
hseigel@4067 891 "Unexpected +/- setting in VM option '%s'\n", argname);
hseigel@4067 892 } else {
hseigel@4067 893 jio_fprintf(defaultStream::error_stream(),
hseigel@4067 894 "Improperly specified VM option '%s'\n", argname);
hseigel@4067 895 }
jmelvin@3215 896 } else {
jmelvin@3215 897 jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf);
jmelvin@3215 898 }
kevinw@3286 899 } else {
kevinw@3286 900 jio_fprintf(defaultStream::error_stream(),
kevinw@3286 901 "Unrecognized VM option '%s'\n", argname);
tamao@4908 902 Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true);
tamao@4908 903 if (fuzzy_matched != NULL) {
tamao@4908 904 jio_fprintf(defaultStream::error_stream(),
tamao@4908 905 "Did you mean '%s%s%s'?\n",
tamao@4908 906 (fuzzy_matched->is_bool()) ? "(+/-)" : "",
twisti@5355 907 fuzzy_matched->_name,
tamao@4908 908 (fuzzy_matched->is_bool()) ? "" : "=<value>");
tamao@4908 909 }
jmelvin@3215 910 }
jmelvin@3215 911
jcoomes@2347 912 // allow for commandline "commenting out" options like -XX:#+Verbose
jcoomes@2347 913 return arg[0] == '#';
duke@0 914 }
duke@0 915
duke@0 916 bool Arguments::process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized) {
duke@0 917 FILE* stream = fopen(file_name, "rb");
duke@0 918 if (stream == NULL) {
duke@0 919 if (should_exist) {
duke@0 920 jio_fprintf(defaultStream::error_stream(),
duke@0 921 "Could not open settings file %s\n", file_name);
duke@0 922 return false;
duke@0 923 } else {
duke@0 924 return true;
duke@0 925 }
duke@0 926 }
duke@0 927
duke@0 928 char token[1024];
duke@0 929 int pos = 0;
duke@0 930
duke@0 931 bool in_white_space = true;
duke@0 932 bool in_comment = false;
duke@0 933 bool in_quote = false;
duke@0 934 char quote_c = 0;
duke@0 935 bool result = true;
duke@0 936
duke@0 937 int c = getc(stream);
kamg@3777 938 while(c != EOF && pos < (int)(sizeof(token)-1)) {
duke@0 939 if (in_white_space) {
duke@0 940 if (in_comment) {
duke@0 941 if (c == '\n') in_comment = false;
duke@0 942 } else {
duke@0 943 if (c == '#') in_comment = true;
duke@0 944 else if (!isspace(c)) {
duke@0 945 in_white_space = false;
duke@0 946 token[pos++] = c;
duke@0 947 }
duke@0 948 }
duke@0 949 } else {
duke@0 950 if (c == '\n' || (!in_quote && isspace(c))) {
duke@0 951 // token ends at newline, or at unquoted whitespace
duke@0 952 // this allows a way to include spaces in string-valued options
duke@0 953 token[pos] = '\0';
duke@0 954 logOption(token);
twisti@5355 955 result &= process_argument(token, ignore_unrecognized, Flag::CONFIG_FILE);
duke@0 956 build_jvm_flags(token);
duke@0 957 pos = 0;
duke@0 958 in_white_space = true;
duke@0 959 in_quote = false;
duke@0 960 } else if (!in_quote && (c == '\'' || c == '"')) {
duke@0 961 in_quote = true;
duke@0 962 quote_c = c;
duke@0 963 } else if (in_quote && (c == quote_c)) {
duke@0 964 in_quote = false;
duke@0 965 } else {
duke@0 966 token[pos++] = c;
duke@0 967 }
duke@0 968 }
duke@0 969 c = getc(stream);
duke@0 970 }
duke@0 971 if (pos > 0) {
duke@0 972 token[pos] = '\0';
twisti@5355 973 result &= process_argument(token, ignore_unrecognized, Flag::CONFIG_FILE);
duke@0 974 build_jvm_flags(token);
duke@0 975 }
duke@0 976 fclose(stream);
duke@0 977 return result;
duke@0 978 }
duke@0 979
duke@0 980 //=============================================================================================================
duke@0 981 // Parsing of properties (-D)
duke@0 982
duke@0 983 const char* Arguments::get_property(const char* key) {
duke@0 984 return PropertyList_get_value(system_properties(), key);
duke@0 985 }
duke@0 986
duke@0 987 bool Arguments::add_property(const char* prop) {
duke@0 988 const char* eq = strchr(prop, '=');
duke@0 989 char* key;
duke@0 990 // ns must be static--its address may be stored in a SystemProperty object.
duke@0 991 const static char ns[1] = {0};
duke@0 992 char* value = (char *)ns;
duke@0 993
duke@0 994 size_t key_len = (eq == NULL) ? strlen(prop) : (eq - prop);
zgu@3465 995 key = AllocateHeap(key_len + 1, mtInternal);
duke@0 996 strncpy(key, prop, key_len);
duke@0 997 key[key_len] = '\0';
duke@0 998
duke@0 999 if (eq != NULL) {
duke@0 1000 size_t value_len = strlen(prop) - key_len - 1;
zgu@3465 1001 value = AllocateHeap(value_len + 1, mtInternal);
duke@0 1002 strncpy(value, &prop[key_len + 1], value_len + 1);
duke@0 1003 }
duke@0 1004
duke@0 1005 if (strcmp(key, "java.compiler") == 0) {
duke@0 1006 process_java_compiler_argument(value);
duke@0 1007 FreeHeap(key);
duke@0 1008 if (eq != NULL) {
duke@0 1009 FreeHeap(value);
duke@0 1010 }
duke@0 1011 return true;
phh@691 1012 } else if (strcmp(key, "sun.java.command") == 0) {
duke@0 1013 _java_command = value;
duke@0 1014
kevinw@2014 1015 // Record value in Arguments, but let it get passed to Java.
phh@691 1016 } else if (strcmp(key, "sun.java.launcher.pid") == 0) {
duke@0 1017 // launcher.pid property is private and is processed
duke@0 1018 // in process_sun_java_launcher_properties();
duke@0 1019 // the sun.java.launcher property is passed on to the java application
duke@0 1020 FreeHeap(key);
duke@0 1021 if (eq != NULL) {
duke@0 1022 FreeHeap(value);
duke@0 1023 }
duke@0 1024 return true;
phh@691 1025 } else if (strcmp(key, "java.vendor.url.bug") == 0) {
duke@0 1026 // save it in _java_vendor_url_bug, so JVM fatal error handler can access
duke@0 1027 // its value without going through the property list or making a Java call.
duke@0 1028 _java_vendor_url_bug = value;
phh@691 1029 } else if (strcmp(key, "sun.boot.library.path") == 0) {
phh@691 1030 PropertyList_unique_add(&_system_properties, key, value, true);
phh@691 1031 return true;
duke@0 1032 }
duke@0 1033 // Create new property and add at the end of the list
duke@0 1034 PropertyList_unique_add(&_system_properties, key, value);
duke@0 1035 return true;
duke@0 1036 }
duke@0 1037
duke@0 1038 //===========================================================================================================
duke@0 1039 // Setting int/mixed/comp mode flags
duke@0 1040
duke@0 1041 void Arguments::set_mode_flags(Mode mode) {
duke@0 1042 // Set up default values for all flags.
duke@0 1043 // If you add a flag to any of the branches below,
duke@0 1044 // add a default value for it here.
duke@0 1045 set_java_compiler(false);
duke@0 1046 _mode = mode;
duke@0 1047
duke@0 1048 // Ensure Agent_OnLoad has the correct initial values.
duke@0 1049 // This may not be the final mode; mode may change later in onload phase.
duke@0 1050 PropertyList_unique_add(&_system_properties, "java.vm.info",
dholmes@2423 1051 (char*)VM_Version::vm_info_string(), false);
duke@0 1052
duke@0 1053 UseInterpreter = true;
duke@0 1054 UseCompiler = true;
duke@0 1055 UseLoopCounter = true;
duke@0 1056
never@2305 1057 #ifndef ZERO
never@2305 1058 // Turn these off for mixed and comp. Leave them on for Zero.
never@2305 1059 if (FLAG_IS_DEFAULT(UseFastAccessorMethods)) {
never@2438 1060 UseFastAccessorMethods = (mode == _int);
never@2305 1061 }
never@2305 1062 if (FLAG_IS_DEFAULT(UseFastEmptyMethods)) {
never@2438 1063 UseFastEmptyMethods = (mode == _int);
never@2305 1064 }
never@2305 1065 #endif
never@2305 1066
duke@0 1067 // Default values may be platform/compiler dependent -
duke@0 1068 // use the saved values
duke@0 1069 ClipInlining = Arguments::_ClipInlining;
duke@0 1070 AlwaysCompileLoopMethods = Arguments::_AlwaysCompileLoopMethods;
duke@0 1071 UseOnStackReplacement = Arguments::_UseOnStackReplacement;
duke@0 1072 BackgroundCompilation = Arguments::_BackgroundCompilation;
duke@0 1073
duke@0 1074 // Change from defaults based on mode
duke@0 1075 switch (mode) {
duke@0 1076 default:
duke@0 1077 ShouldNotReachHere();
duke@0 1078 break;
duke@0 1079 case _int:
duke@0 1080 UseCompiler = false;
duke@0 1081 UseLoopCounter = false;
duke@0 1082 AlwaysCompileLoopMethods = false;
duke@0 1083 UseOnStackReplacement = false;
duke@0 1084 break;
duke@0 1085 case _mixed:
duke@0 1086 // same as default
duke@0 1087 break;
duke@0 1088 case _comp:
duke@0 1089 UseInterpreter = false;
duke@0 1090 BackgroundCompilation = false;
duke@0 1091 ClipInlining = false;
iveresov@2952 1092 // Be much more aggressive in tiered mode with -Xcomp and exercise C2 more.
iveresov@2952 1093 // We will first compile a level 3 version (C1 with full profiling), then do one invocation of it and
iveresov@2952 1094 // compile a level 4 (C2) and then continue executing it.
iveresov@2952 1095 if (TieredCompilation) {
iveresov@2952 1096 Tier3InvokeNotifyFreqLog = 0;
iveresov@2952 1097 Tier4InvocationThreshold = 0;
iveresov@2952 1098 }
duke@0 1099 break;
duke@0 1100 }
duke@0 1101 }
duke@0 1102
hseigel@5313 1103 #if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS
duke@0 1104 // Conflict: required to use shared spaces (-Xshare:on), but
duke@0 1105 // incompatible command line options were chosen.
duke@0 1106
duke@0 1107 static void no_shared_spaces() {
duke@0 1108 if (RequireSharedSpaces) {
duke@0 1109 jio_fprintf(defaultStream::error_stream(),
duke@0 1110 "Class data sharing is inconsistent with other specified options.\n");
duke@0 1111 vm_exit_during_initialization("Unable to use shared archive.", NULL);
duke@0 1112 } else {
duke@0 1113 FLAG_SET_DEFAULT(UseSharedSpaces, false);
duke@0 1114 }
duke@0 1115 }
hseigel@5313 1116 #endif
duke@0 1117
iveresov@1703 1118 void Arguments::set_tiered_flags() {
iveresov@2195 1119 // With tiered, set default policy to AdvancedThresholdPolicy, which is 3.
iveresov@1703 1120 if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) {
iveresov@2195 1121 FLAG_SET_DEFAULT(CompilationPolicyChoice, 3);
iveresov@1703 1122 }
iveresov@1703 1123 if (CompilationPolicyChoice < 2) {
iveresov@1703 1124 vm_exit_during_initialization(
iveresov@1703 1125 "Incompatible compilation policy selected", NULL);
iveresov@1703 1126 }
iveresov@1811 1127 // Increase the code cache size - tiered compiles a lot more.
iveresov@1703 1128 if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
morris@4149 1129 FLAG_SET_DEFAULT(ReservedCodeCacheSize, ReservedCodeCacheSize * 5);
iveresov@1703 1130 }
kvn@4675 1131 if (!UseInterpreter) { // -Xcomp
kvn@4675 1132 Tier3InvokeNotifyFreqLog = 0;
kvn@4675 1133 Tier4InvocationThreshold = 0;
kvn@4675 1134 }
iveresov@1703 1135 }
iveresov@1703 1136
jprovino@4107 1137 #if INCLUDE_ALL_GCS
jcoomes@3030 1138 static void disable_adaptive_size_policy(const char* collector_name) {
jcoomes@3030 1139 if (UseAdaptiveSizePolicy) {
jcoomes@3030 1140 if (FLAG_IS_CMDLINE(UseAdaptiveSizePolicy)) {
jcoomes@3030 1141 warning("disabling UseAdaptiveSizePolicy; it is incompatible with %s.",
jcoomes@3030 1142 collector_name);
jcoomes@3030 1143 }
jcoomes@3030 1144 FLAG_SET_DEFAULT(UseAdaptiveSizePolicy, false);
jcoomes@3030 1145 }
jcoomes@3030 1146 }
jcoomes@3030 1147
duke@0 1148 void Arguments::set_parnew_gc_flags() {
phh@1064 1149 assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC,
ysr@342 1150 "control point invariant");
ysr@342 1151 assert(UseParNewGC, "Error");
duke@0 1152
jcoomes@3030 1153 // Turn off AdaptiveSizePolicy for parnew until it is complete.
jcoomes@3030 1154 disable_adaptive_size_policy("UseParNewGC");
jmasa@10 1155
brutisso@3952 1156 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
brutisso@3952 1157 FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
brutisso@3952 1158 assert(ParallelGCThreads > 0, "We should always have at least one thread by default");
brutisso@3952 1159 } else if (ParallelGCThreads == 0) {
brutisso@3952 1160 jio_fprintf(defaultStream::error_stream(),
brutisso@3952 1161 "The ParNew GC can not be combined with -XX:ParallelGCThreads=0\n");
brutisso@3952 1162 vm_exit(1);
brutisso@3952 1163 }
brutisso@3952 1164
brutisso@3952 1165 // By default YoungPLABSize and OldPLABSize are set to 4096 and 1024 respectively,
brutisso@3952 1166 // these settings are default for Parallel Scavenger. For ParNew+Tenured configuration
brutisso@3952 1167 // we set them to 1024 and 1024.
brutisso@3952 1168 // See CR 6362902.
brutisso@3952 1169 if (FLAG_IS_DEFAULT(YoungPLABSize)) {
brutisso@3952 1170 FLAG_SET_DEFAULT(YoungPLABSize, (intx)1024);
brutisso@3952 1171 }
brutisso@3952 1172 if (FLAG_IS_DEFAULT(OldPLABSize)) {
brutisso@3952 1173 FLAG_SET_DEFAULT(OldPLABSize, (intx)1024);
brutisso@3952 1174 }
brutisso@3952 1175
brutisso@3952 1176 // AlwaysTenure flag should make ParNew promote all at first collection.
brutisso@3952 1177 // See CR 6362902.
brutisso@3952 1178 if (AlwaysTenure) {
brutisso@3952 1179 FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0);
brutisso@3952 1180 }
brutisso@3952 1181 // When using compressed oops, we use local overflow stacks,
brutisso@3952 1182 // rather than using a global overflow list chained through
brutisso@3952 1183 // the klass word of the object's pre-image.
brutisso@3952 1184 if (UseCompressedOops && !ParGCUseLocalOverflow) {
brutisso@3952 1185 if (!FLAG_IS_DEFAULT(ParGCUseLocalOverflow)) {
brutisso@3952 1186 warning("Forcing +ParGCUseLocalOverflow: needed if using compressed references");
duke@0 1187 }
brutisso@3952 1188 FLAG_SET_DEFAULT(ParGCUseLocalOverflow, true);
duke@0 1189 }
brutisso@3952 1190 assert(ParGCUseLocalOverflow || !UseCompressedOops, "Error");
duke@0 1191 }
duke@0 1192
duke@0 1193 // Adjust some sizes to suit CMS and/or ParNew needs; these work well on
duke@0 1194 // sparc/solaris for certain applications, but would gain from
duke@0 1195 // further optimization and tuning efforts, and would almost
duke@0 1196 // certainly gain from analysis of platform and environment.
duke@0 1197 void Arguments::set_cms_and_parnew_gc_flags() {
phh@1064 1198 assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC, "Error");
jmasa@10 1199 assert(UseConcMarkSweepGC, "CMS is expected to be on here");
jmasa@10 1200
duke@0 1201 // If we are using CMS, we prefer to UseParNewGC,
duke@0 1202 // unless explicitly forbidden.
ysr@342 1203 if (FLAG_IS_DEFAULT(UseParNewGC)) {
jmasa@10 1204 FLAG_SET_ERGO(bool, UseParNewGC, true);
duke@0 1205 }
duke@0 1206
jprovino@3730 1207 // Turn off AdaptiveSizePolicy by default for cms until it is complete.
jcoomes@3030 1208 disable_adaptive_size_policy("UseConcMarkSweepGC");
duke@0 1209
duke@0 1210 // In either case, adjust ParallelGCThreads and/or UseParNewGC
duke@0 1211 // as needed.
jmasa@10 1212 if (UseParNewGC) {
jmasa@10 1213 set_parnew_gc_flags();
duke@0 1214 }
duke@0 1215
ysr@2215 1216 size_t max_heap = align_size_down(MaxHeapSize,
ysr@2215 1217 CardTableRS::ct_max_alignment_constraint());
ysr@2215 1218
duke@0 1219 // Now make adjustments for CMS
ysr@2215 1220 intx tenuring_default = (intx)6;
ysr@2215 1221 size_t young_gen_per_worker = CMSYoungGenPerWorker;
ysr@2215 1222
ysr@2215 1223 // Preferred young gen size for "short" pauses:
ysr@2215 1224 // upper bound depends on # of threads and NewRatio.
duke@0 1225 const uintx parallel_gc_threads =
duke@0 1226 (ParallelGCThreads == 0 ? 1 : ParallelGCThreads);
duke@0 1227 const size_t preferred_max_new_size_unaligned =
ysr@2215 1228 MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * parallel_gc_threads));
ysr@2215 1229 size_t preferred_max_new_size =
duke@0 1230 align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
duke@0 1231
duke@0 1232 // Unless explicitly requested otherwise, size young gen
ysr@2215 1233 // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
jmasa@886 1234
jmasa@886 1235 // If either MaxNewSize or NewRatio is set on the command line,
jmasa@886 1236 // assume the user is trying to set the size of the young gen.
jmasa@886 1237 if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
jmasa@886 1238
jmasa@886 1239 // Set MaxNewSize to our calculated preferred_max_new_size unless
jmasa@886 1240 // NewSize was set on the command line and it is larger than
jmasa@886 1241 // preferred_max_new_size.
duke@0 1242 if (!FLAG_IS_DEFAULT(NewSize)) { // NewSize explicitly set at command-line
jmasa@13 1243 FLAG_SET_ERGO(uintx, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
duke@0 1244 } else {
jmasa@13 1245 FLAG_SET_ERGO(uintx, MaxNewSize, preferred_max_new_size);
duke@0 1246 }
phh@1064 1247 if (PrintGCDetails && Verbose) {
jmasa@13 1248 // Too early to use gclog_or_tty
ysr@2215 1249 tty->print_cr("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
jmasa@886 1250 }
jmasa@886 1251
jmasa@886 1252 // Code along this path potentially sets NewSize and OldSize
phh@1064 1253 if (PrintGCDetails && Verbose) {
jmasa@13 1254 // Too early to use gclog_or_tty
jmasa@13 1255 tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT
jmasa@13 1256 " initial_heap_size: " SIZE_FORMAT
jmasa@13 1257 " max_heap: " SIZE_FORMAT,
phh@1064 1258 min_heap_size(), InitialHeapSize, max_heap);
jmasa@13 1259 }
ysr@2215 1260 size_t min_new = preferred_max_new_size;
ysr@2215 1261 if (FLAG_IS_CMDLINE(NewSize)) {
ysr@2215 1262 min_new = NewSize;
ysr@2215 1263 }
ysr@2215 1264 if (max_heap > min_new && min_heap_size() > min_new) {
duke@0 1265 // Unless explicitly requested otherwise, make young gen
duke@0 1266 // at least min_new, and at most preferred_max_new_size.
duke@0 1267 if (FLAG_IS_DEFAULT(NewSize)) {
jmasa@13 1268 FLAG_SET_ERGO(uintx, NewSize, MAX2(NewSize, min_new));
jmasa@13 1269 FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, NewSize));
phh@1064 1270 if (PrintGCDetails && Verbose) {
jmasa@13 1271 // Too early to use gclog_or_tty
ysr@2215 1272 tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
jmasa@13 1273 }
duke@0 1274 }
duke@0 1275 // Unless explicitly requested otherwise, size old gen
ysr@2215 1276 // so it's NewRatio x of NewSize.
duke@0 1277 if (FLAG_IS_DEFAULT(OldSize)) {
duke@0 1278 if (max_heap > NewSize) {
ysr@2215 1279 FLAG_SET_ERGO(uintx, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
phh@1064 1280 if (PrintGCDetails && Verbose) {
jmasa@13 1281 // Too early to use gclog_or_tty
ysr@2215 1282 tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
jmasa@13 1283 }
duke@0 1284 }
duke@0 1285 }
duke@0 1286 }
duke@0 1287 }
duke@0 1288 // Unless explicitly requested otherwise, definitely
duke@0 1289 // promote all objects surviving "tenuring_default" scavenges.
duke@0 1290 if (FLAG_IS_DEFAULT(MaxTenuringThreshold) &&
duke@0 1291 FLAG_IS_DEFAULT(SurvivorRatio)) {
jwilhelm@3694 1292 FLAG_SET_ERGO(uintx, MaxTenuringThreshold, tenuring_default);
duke@0 1293 }
duke@0 1294 // If we decided above (or user explicitly requested)
duke@0 1295 // `promote all' (via MaxTenuringThreshold := 0),
duke@0 1296 // prefer minuscule survivor spaces so as not to waste
duke@0 1297 // space for (non-existent) survivors
duke@0 1298 if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) {
jwilhelm@4141 1299 FLAG_SET_ERGO(uintx, SurvivorRatio, MAX2((uintx)1024, SurvivorRatio));
duke@0 1300 }
duke@0 1301 // If OldPLABSize is set and CMSParPromoteBlocksToClaim is not,
duke@0 1302 // set CMSParPromoteBlocksToClaim equal to OldPLABSize.
duke@0 1303 // This is done in order to make ParNew+CMS configuration to work
duke@0 1304 // with YoungPLABSize and OldPLABSize options.
duke@0 1305 // See CR 6362902.
duke@0 1306 if (!FLAG_IS_DEFAULT(OldPLABSize)) {
duke@0 1307 if (FLAG_IS_DEFAULT(CMSParPromoteBlocksToClaim)) {
jmasa@13 1308 // OldPLABSize is not the default value but CMSParPromoteBlocksToClaim
jmasa@13 1309 // is. In this situtation let CMSParPromoteBlocksToClaim follow
jmasa@13 1310 // the value (either from the command line or ergonomics) of
jmasa@13 1311 // OldPLABSize. Following OldPLABSize is an ergonomics decision.
jmasa@13 1312 FLAG_SET_ERGO(uintx, CMSParPromoteBlocksToClaim, OldPLABSize);
ysr@1145 1313 } else {
duke@0 1314 // OldPLABSize and CMSParPromoteBlocksToClaim are both set.
duke@0 1315 // CMSParPromoteBlocksToClaim is a collector-specific flag, so
duke@0 1316 // we'll let it to take precedence.
duke@0 1317 jio_fprintf(defaultStream::error_stream(),
jmasa@886 1318 "Both OldPLABSize and CMSParPromoteBlocksToClaim"
jmasa@886 1319 " options are specified for the CMS collector."
jmasa@886 1320 " CMSParPromoteBlocksToClaim will take precedence.\n");
duke@0 1321 }
duke@0 1322 }
ysr@1145 1323 if (!FLAG_IS_DEFAULT(ResizeOldPLAB) && !ResizeOldPLAB) {
ysr@1145 1324 // OldPLAB sizing manually turned off: Use a larger default setting,
ysr@1145 1325 // unless it was manually specified. This is because a too-low value
ysr@1145 1326 // will slow down scavenges.
ysr@1145 1327 if (FLAG_IS_DEFAULT(CMSParPromoteBlocksToClaim)) {
ysr@1145 1328 FLAG_SET_ERGO(uintx, CMSParPromoteBlocksToClaim, 50); // default value before 6631166
ysr@1145 1329 }
ysr@1145 1330 }
ysr@1145 1331 // Overwrite OldPLABSize which is the variable we will internally use everywhere.
ysr@1145 1332 FLAG_SET_ERGO(uintx, OldPLABSize, CMSParPromoteBlocksToClaim);
ysr@1145 1333 // If either of the static initialization defaults have changed, note this
ysr@1145 1334 // modification.
ysr@1145 1335 if (!FLAG_IS_DEFAULT(CMSParPromoteBlocksToClaim) || !FLAG_IS_DEFAULT(OldPLABWeight)) {
ysr@1145 1336 CFLS_LAB::modify_initialization(OldPLABSize, OldPLABWeight);
ysr@1145 1337 }
jmasa@1284 1338 if (PrintGCDetails && Verbose) {
jmasa@1284 1339 tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
jmasa@1284 1340 MarkStackSize / K, MarkStackSizeMax / K);
jmasa@1284 1341 tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
jmasa@1284 1342 }
duke@0 1343 }
jprovino@4107 1344 #endif // INCLUDE_ALL_GCS
duke@0 1345
kvn@1491 1346 void set_object_alignment() {
kvn@1491 1347 // Object alignment.
kvn@1491 1348 assert(is_power_of_2(ObjectAlignmentInBytes), "ObjectAlignmentInBytes must be power of 2");
kvn@1491 1349 MinObjAlignmentInBytes = ObjectAlignmentInBytes;
kvn@1491 1350 assert(MinObjAlignmentInBytes >= HeapWordsPerLong * HeapWordSize, "ObjectAlignmentInBytes value is too small");
kvn@1491 1351 MinObjAlignment = MinObjAlignmentInBytes / HeapWordSize;
kvn@1491 1352 assert(MinObjAlignmentInBytes == MinObjAlignment * HeapWordSize, "ObjectAlignmentInBytes value is incorrect");
kvn@1491 1353 MinObjAlignmentInBytesMask = MinObjAlignmentInBytes - 1;
kvn@1491 1354
kvn@1491 1355 LogMinObjAlignmentInBytes = exact_log2(ObjectAlignmentInBytes);
kvn@1491 1356 LogMinObjAlignment = LogMinObjAlignmentInBytes - LogHeapWordSize;
kvn@1491 1357
kvn@1491 1358 // Oop encoding heap max
kvn@1491 1359 OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes;
kvn@1491 1360
jprovino@4107 1361 #if INCLUDE_ALL_GCS
kvn@1491 1362 // Set CMS global values
kvn@1491 1363 CompactibleFreeListSpace::set_cms_values();
jprovino@4107 1364 #endif // INCLUDE_ALL_GCS
kvn@1491 1365 }
kvn@1491 1366
kvn@1491 1367 bool verify_object_alignment() {
kvn@1491 1368 // Object alignment.
kvn@1491 1369 if (!is_power_of_2(ObjectAlignmentInBytes)) {
kvn@1491 1370 jio_fprintf(defaultStream::error_stream(),
kvn@1749 1371 "error: ObjectAlignmentInBytes=%d must be power of 2\n",
kvn@1749 1372 (int)ObjectAlignmentInBytes);
kvn@1491 1373 return false;
kvn@1491 1374 }
kvn@1491 1375 if ((int)ObjectAlignmentInBytes < BytesPerLong) {
kvn@1491 1376 jio_fprintf(defaultStream::error_stream(),
kvn@1749 1377 "error: ObjectAlignmentInBytes=%d must be greater or equal %d\n",
kvn@1749 1378 (int)ObjectAlignmentInBytes, BytesPerLong);
kvn@1749 1379 return false;
kvn@1749 1380 }
kvn@1749 1381 // It does not make sense to have big object alignment
kvn@1749 1382 // since a space lost due to alignment will be greater
kvn@1749 1383 // then a saved space from compressed oops.
kvn@1749 1384 if ((int)ObjectAlignmentInBytes > 256) {
kvn@1749 1385 jio_fprintf(defaultStream::error_stream(),
hseigel@3962 1386 "error: ObjectAlignmentInBytes=%d must not be greater than 256\n",
kvn@1749 1387 (int)ObjectAlignmentInBytes);
kvn@1749 1388 return false;
kvn@1749 1389 }
kvn@1749 1390 // In case page size is very small.
kvn@1749 1391 if ((int)ObjectAlignmentInBytes >= os::vm_page_size()) {
kvn@1749 1392 jio_fprintf(defaultStream::error_stream(),
hseigel@3962 1393 "error: ObjectAlignmentInBytes=%d must be less than page size %d\n",
kvn@1749 1394 (int)ObjectAlignmentInBytes, os::vm_page_size());
kvn@1491 1395 return false;
kvn@1491 1396 }
kvn@1491 1397 return true;
kvn@1491 1398 }
kvn@1491 1399
tschatzl@5266 1400 uintx Arguments::max_heap_for_compressed_oops() {
kvn@1870 1401 // Avoid sign flip.
hseigel@5093 1402 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
tschatzl@5266 1403 // We need to fit both the NULL page and the heap into the memory budget, while
tschatzl@5266 1404 // keeping alignment constraints of the heap. To guarantee the latter, as the
tschatzl@5266 1405 // NULL page is located before the heap, we pad the NULL page to the conservative
tschatzl@5266 1406 // maximum alignment that the GC may ever impose upon the heap.
tschatzl@5266 1407 size_t displacement_due_to_null_page = align_size_up_(os::vm_page_size(),
tschatzl@5266 1408 Arguments::conservative_max_heap_alignment());
tschatzl@5266 1409
tschatzl@5266 1410 LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page);
phh@1064 1411 NOT_LP64(ShouldNotReachHere(); return 0);
coleenp@135 1412 }
coleenp@135 1413
duke@0 1414 bool Arguments::should_auto_select_low_pause_collector() {
duke@0 1415 if (UseAutoGCSelectPolicy &&
duke@0 1416 !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
duke@0 1417 (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
duke@0 1418 if (PrintGCDetails) {
duke@0 1419 // Cannot use gclog_or_tty yet.
duke@0 1420 tty->print_cr("Automatic selection of the low pause collector"
duke@0 1421 " based on pause goal of %d (ms)", MaxGCPauseMillis);
duke@0 1422 }
duke@0 1423 return true;
duke@0 1424 }
duke@0 1425 return false;
duke@0 1426 }
duke@0 1427
brutisso@4306 1428 void Arguments::set_use_compressed_oops() {
brutisso@4306 1429 #ifndef ZERO
brutisso@4306 1430 #ifdef _LP64
brutisso@4306 1431 // MaxHeapSize is not set up properly at this point, but
brutisso@4306 1432 // the only value that can override MaxHeapSize if we are
brutisso@4306 1433 // to use UseCompressedOops is InitialHeapSize.
brutisso@4306 1434 size_t max_heap_size = MAX2(MaxHeapSize, InitialHeapSize);
brutisso@4306 1435
brutisso@4306 1436 if (max_heap_size <= max_heap_for_compressed_oops()) {
brutisso@4306 1437 #if !defined(COMPILER1) || defined(TIERED)
brutisso@4306 1438 if (FLAG_IS_DEFAULT(UseCompressedOops)) {
brutisso@4306 1439 FLAG_SET_ERGO(bool, UseCompressedOops, true);
brutisso@4306 1440 }
brutisso@4306 1441 #endif
brutisso@4306 1442 #ifdef _WIN64
brutisso@4306 1443 if (UseLargePages && UseCompressedOops) {
brutisso@4306 1444 // Cannot allocate guard pages for implicit checks in indexed addressing
brutisso@4306 1445 // mode, when large pages are specified on windows.
brutisso@4306 1446 // This flag could be switched ON if narrow oop base address is set to 0,
brutisso@4306 1447 // see code in Universe::initialize_heap().
brutisso@4306 1448 Universe::set_narrow_oop_use_implicit_null_checks(false);
brutisso@4306 1449 }
brutisso@4306 1450 #endif // _WIN64
brutisso@4306 1451 } else {
brutisso@4306 1452 if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
brutisso@4306 1453 warning("Max heap size too large for Compressed Oops");
brutisso@4306 1454 FLAG_SET_DEFAULT(UseCompressedOops, false);
ehelin@5259 1455 FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
brutisso@4306 1456 }
brutisso@4306 1457 }
brutisso@4306 1458 #endif // _LP64
brutisso@4306 1459 #endif // ZERO
brutisso@4306 1460 }
brutisso@4306 1461
hseigel@5093 1462
hseigel@5093 1463 // NOTE: set_use_compressed_klass_ptrs() must be called after calling
hseigel@5093 1464 // set_use_compressed_oops().
hseigel@5093 1465 void Arguments::set_use_compressed_klass_ptrs() {
hseigel@5093 1466 #ifndef ZERO
hseigel@5093 1467 #ifdef _LP64
ehelin@5259 1468 // UseCompressedOops must be on for UseCompressedClassPointers to be on.
hseigel@5093 1469 if (!UseCompressedOops) {
ehelin@5259 1470 if (UseCompressedClassPointers) {
ehelin@5259 1471 warning("UseCompressedClassPointers requires UseCompressedOops");
hseigel@5093 1472 }
ehelin@5259 1473 FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
hseigel@5093 1474 } else {
ehelin@5259 1475 // Turn on UseCompressedClassPointers too
ehelin@5259 1476 if (FLAG_IS_DEFAULT(UseCompressedClassPointers)) {
ehelin@5259 1477 FLAG_SET_ERGO(bool, UseCompressedClassPointers, true);
hseigel@5093 1478 }
ehelin@5259 1479 // Check the CompressedClassSpaceSize to make sure we use compressed klass ptrs.
ehelin@5259 1480 if (UseCompressedClassPointers) {
ehelin@5259 1481 if (CompressedClassSpaceSize > KlassEncodingMetaspaceMax) {
ehelin@5259 1482 warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
ehelin@5259 1483 FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
hseigel@5093 1484 }
hseigel@5093 1485 }
hseigel@5093 1486 }
hseigel@5093 1487 #endif // _LP64
hseigel@5093 1488 #endif // !ZERO
hseigel@5093 1489 }
hseigel@5093 1490
tschatzl@5266 1491 void Arguments::set_conservative_max_heap_alignment() {
tschatzl@5266 1492 // The conservative maximum required alignment for the heap is the maximum of
tschatzl@5266 1493 // the alignments imposed by several sources: any requirements from the heap
tschatzl@5266 1494 // itself, the collector policy and the maximum page size we may run the VM
tschatzl@5266 1495 // with.
tschatzl@5266 1496 size_t heap_alignment = GenCollectedHeap::conservative_max_heap_alignment();
tschatzl@5266 1497 #if INCLUDE_ALL_GCS
tschatzl@5266 1498 if (UseParallelGC) {
tschatzl@5266 1499 heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment();
tschatzl@5266 1500 } else if (UseG1GC) {
tschatzl@5266 1501 heap_alignment = G1CollectedHeap::conservative_max_heap_alignment();
tschatzl@5266 1502 }
tschatzl@5266 1503 #endif // INCLUDE_ALL_GCS
tschatzl@5266 1504 _conservative_max_heap_alignment = MAX3(heap_alignment, os::max_page_size(),
tschatzl@5266 1505 CollectorPolicy::compute_max_alignment());
tschatzl@5266 1506 }
tschatzl@5266 1507
duke@0 1508 void Arguments::set_ergonomics_flags() {
duke@0 1509
iveresov@3138 1510 if (os::is_server_class_machine()) {
duke@0 1511 // If no other collector is requested explicitly,
duke@0 1512 // let the VM select the collector based on
duke@0 1513 // machine class and automatic selection policy.
duke@0 1514 if (!UseSerialGC &&
duke@0 1515 !UseConcMarkSweepGC &&
ysr@342 1516 !UseG1GC &&
duke@0 1517 !UseParNewGC &&
duke@0 1518 FLAG_IS_DEFAULT(UseParallelGC)) {
duke@0 1519 if (should_auto_select_low_pause_collector()) {
duke@0 1520 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
duke@0 1521 } else {
duke@0 1522 FLAG_SET_ERGO(bool, UseParallelGC, true);
duke@0 1523 }
coleenp@3602 1524 }
duke@0 1525 }
hseigel@5313 1526 #ifdef COMPILER2
hseigel@5313 1527 // Shared spaces work fine with other GCs but causes bytecode rewriting
hseigel@5313 1528 // to be disabled, which hurts interpreter performance and decreases
hseigel@5313 1529 // server performance. When -server is specified, keep the default off
hseigel@5313 1530 // unless it is asked for. Future work: either add bytecode rewriting
hseigel@5313 1531 // at link time, or rewrite bytecodes in non-shared methods.
hseigel@5313 1532 if (!DumpSharedSpaces && !RequireSharedSpaces &&
hseigel@5313 1533 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
hseigel@5313 1534 no_shared_spaces();
hseigel@5313 1535 }
hseigel@5313 1536 #endif
coleenp@113 1537
tschatzl@5266 1538 set_conservative_max_heap_alignment();
tschatzl@5266 1539
never@1010 1540 #ifndef ZERO
coleenp@113 1541 #ifdef _LP64
brutisso@4306 1542 set_use_compressed_oops();
hseigel@5093 1543
hseigel@5093 1544 // set_use_compressed_klass_ptrs() must be called after calling
hseigel@5093 1545 // set_use_compressed_oops().
hseigel@5093 1546 set_use_compressed_klass_ptrs();
hseigel@5093 1547
coleenp@113 1548 // Also checks that certain machines are slower with compressed oops
coleenp@113 1549 // in vm_version initialization code.
coleenp@113 1550 #endif // _LP64
never@1010 1551 #endif // !ZERO
duke@0 1552 }
duke@0 1553
duke@0 1554 void Arguments::set_parallel_gc_flags() {
ysr@342 1555 assert(UseParallelGC || UseParallelOldGC, "Error");
jcoomes@3071 1556 // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
jcoomes@3071 1557 if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
jcoomes@3071 1558 FLAG_SET_DEFAULT(UseParallelOldGC, true);
duke@0 1559 }
jcoomes@3071 1560 FLAG_SET_DEFAULT(UseParallelGC, true);
duke@0 1561
duke@0 1562 // If no heap maximum was requested explicitly, use some reasonable fraction
duke@0 1563 // of the physical memory, up to a maximum of 1GB.
brutisso@3972 1564 FLAG_SET_DEFAULT(ParallelGCThreads,
brutisso@3972 1565 Abstract_VM_Version::parallel_worker_threads());
brutisso@3972 1566 if (ParallelGCThreads == 0) {
brutisso@3972 1567 jio_fprintf(defaultStream::error_stream(),
brutisso@3972 1568 "The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
brutisso@3972 1569 vm_exit(1);
brutisso@3972 1570 }
brutisso@3972 1571
brutisso@3972 1572
brutisso@3972 1573 // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
brutisso@3972 1574 // SurvivorRatio has been set, reset their default values to SurvivorRatio +
brutisso@3972 1575 // 2. By doing this we make SurvivorRatio also work for Parallel Scavenger.
brutisso@3972 1576 // See CR 6362902 for details.
brutisso@3972 1577 if (!FLAG_IS_DEFAULT(SurvivorRatio)) {
brutisso@3972 1578 if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
brutisso@3972 1579 FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
duke@0 1580 }
brutisso@3972 1581 if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
brutisso@3972 1582 FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
brutisso@3972 1583 }
brutisso@3972 1584 }
brutisso@3972 1585
brutisso@3972 1586 if (UseParallelOldGC) {
brutisso@3972 1587 // Par compact uses lower default values since they are treated as
brutisso@3972 1588 // minimums. These are different defaults because of the different
brutisso@3972 1589 // interpretation and are not ergonomically set.
brutisso@3972 1590 if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
brutisso@3972 1591 FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
duke@0 1592 }
duke@0 1593 }
duke@0 1594 }
duke@0 1595
ysr@342 1596 void Arguments::set_g1_gc_flags() {
ysr@342 1597 assert(UseG1GC, "Error");
ysr@342 1598 #ifdef COMPILER1
ysr@342 1599 FastTLABRefill = false;
ysr@342 1600 #endif
ysr@342 1601 FLAG_SET_DEFAULT(ParallelGCThreads,
ysr@342 1602 Abstract_VM_Version::parallel_worker_threads());
ysr@342 1603 if (ParallelGCThreads == 0) {
ysr@342 1604 FLAG_SET_DEFAULT(ParallelGCThreads,
johnc@751 1605 Abstract_VM_Version::parallel_worker_threads());
ysr@342 1606 }
johnc@751 1607
johnc@3898 1608 // MarkStackSize will be set (if it hasn't been set by the user)
johnc@3898 1609 // when concurrent marking is initialized.
johnc@3898 1610 // Its value will be based upon the number of parallel marking threads.
johnc@3898 1611 // But we do set the maximum mark stack size here.
johnc@3898 1612 if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
johnc@3898 1613 FLAG_SET_DEFAULT(MarkStackSizeMax, 128 * TASKQUEUE_SIZE);
jmasa@1284 1614 }
tonyp@1356 1615
tonyp@1356 1616 if (FLAG_IS_DEFAULT(GCTimeRatio) || GCTimeRatio == 0) {
tonyp@1356 1617 // In G1, we want the default GC overhead goal to be higher than
tonyp@1356 1618 // say in PS. So we set it here to 10%. Otherwise the heap might
tonyp@1356 1619 // be expanded more aggressively than we would like it to. In
tonyp@1356 1620 // fact, even 10% seems to not be high enough in some cases
tonyp@1356 1621 // (especially small GC stress tests that the main thing they do
tonyp@1356 1622 // is allocation). We might consider increase it further.
tonyp@1356 1623 FLAG_SET_DEFAULT(GCTimeRatio, 9);
tonyp@1356 1624 }
johnc@3898 1625
johnc@3898 1626 if (PrintGCDetails && Verbose) {
johnc@3898 1627 tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
johnc@3898 1628 MarkStackSize / K, MarkStackSizeMax / K);
johnc@3898 1629 tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
johnc@3898 1630 }
ysr@342 1631 }
ysr@342 1632
tschatzl@4419 1633 julong Arguments::limit_by_allocatable_memory(julong limit) {
tschatzl@4419 1634 julong max_allocatable;
tschatzl@4419 1635 julong result = limit;
tschatzl@4419 1636 if (os::has_allocatable_memory_limit(&max_allocatable)) {
tschatzl@4419 1637 result = MIN2(result, max_allocatable / MaxVirtMemFraction);
tschatzl@4419 1638 }
tschatzl@4419 1639 return result;
tschatzl@4419 1640 }
tschatzl@4419 1641
phh@1064 1642 void Arguments::set_heap_size() {
phh@1064 1643 if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
phh@1064 1644 // Deprecated flag
phh@1064 1645 FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
phh@1064 1646 }
phh@1064 1647
phh@1064 1648 const julong phys_mem =
phh@1064 1649 FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
phh@1064 1650 : (julong)MaxRAM;
phh@1064 1651
phh@1064 1652 // If the maximum heap size has not been set with -Xmx,
phh@1064 1653 // then set it as fraction of the size of physical memory,
phh@1064 1654 // respecting the maximum and minimum sizes of the heap.
ysr@342 1655 if (FLAG_IS_DEFAULT(MaxHeapSize)) {
phh@1064 1656 julong reasonable_max = phys_mem / MaxRAMFraction;
phh@1064 1657
phh@1064 1658 if (phys_mem <= MaxHeapSize * MinRAMFraction) {
phh@1064 1659 // Small physical memory, so use a minimum fraction of it for the heap
phh@1064 1660 reasonable_max = phys_mem / MinRAMFraction;
phh@1064 1661 } else {
phh@1064 1662 // Not-small physical memory, so require a heap at least
phh@1064 1663 // as large as MaxHeapSize
phh@1064 1664 reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
ysr@342 1665 }
phh@1064 1666 if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
phh@1064 1667 // Limit the heap size to ErgoHeapSizeLimit
phh@1064 1668 reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
phh@1064 1669 }
phh@1064 1670 if (UseCompressedOops) {
phh@1064 1671 // Limit the heap size to the maximum possible when using compressed oops
kvn@1870 1672 julong max_coop_heap = (julong)max_heap_for_compressed_oops();
kvn@1870 1673 if (HeapBaseMinAddress + MaxHeapSize < max_coop_heap) {
kvn@1870 1674 // Heap should be above HeapBaseMinAddress to get zero based compressed oops
kvn@1870 1675 // but it should be not less than default MaxHeapSize.
kvn@1870 1676 max_coop_heap -= HeapBaseMinAddress;
kvn@1870 1677 }
kvn@1870 1678 reasonable_max = MIN2(reasonable_max, max_coop_heap);
phh@1064 1679 }
tschatzl@4419 1680 reasonable_max = limit_by_allocatable_memory(reasonable_max);
phh@1064 1681
phh@1064 1682 if (!FLAG_IS_DEFAULT(InitialHeapSize)) {
phh@1064 1683 // An initial heap size was specified on the command line,
phh@1064 1684 // so be sure that the maximum size is consistent. Done
tschatzl@4419 1685 // after call to limit_by_allocatable_memory because that
phh@1064 1686 // method might reduce the allocation size.
phh@1064 1687 reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
phh@1064 1688 }
phh@1064 1689
ysr@342 1690 if (PrintGCDetails && Verbose) {
ysr@342 1691 // Cannot use gclog_or_tty yet.
phh@1064 1692 tty->print_cr(" Maximum heap size " SIZE_FORMAT, reasonable_max);
ysr@342 1693 }
phh@1064 1694 FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx)reasonable_max);
phh@1064 1695 }
phh@1064 1696
tschatzl@4638 1697 // If the minimum or initial heap_size have not been set or requested to be set
tschatzl@4638 1698 // ergonomically, set them accordingly.
tschatzl@4638 1699 if (InitialHeapSize == 0 || min_heap_size() == 0) {
phh@1074 1700 julong reasonable_minimum = (julong)(OldSize + NewSize);
phh@1074 1701
phh@1074 1702 reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
phh@1074 1703
tschatzl@4419 1704 reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum);
phh@1074 1705
tschatzl@4638 1706 if (InitialHeapSize == 0) {
tschatzl@4638 1707 julong reasonable_initial = phys_mem / InitialRAMFraction;
tschatzl@4638 1708
tschatzl@4638 1709 reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size());
tschatzl@4638 1710 reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
tschatzl@4638 1711
tschatzl@4638 1712 reasonable_initial = limit_by_allocatable_memory(reasonable_initial);
tschatzl@4638 1713
tschatzl@4638 1714 if (PrintGCDetails && Verbose) {
tschatzl@4638 1715 // Cannot use gclog_or_tty yet.
tschatzl@4638 1716 tty->print_cr(" Initial heap size " SIZE_FORMAT, (uintx)reasonable_initial);
tschatzl@4638 1717 }
tschatzl@4638 1718 FLAG_SET_ERGO(uintx, InitialHeapSize, (uintx)reasonable_initial);
ysr@342 1719 }
tschatzl@4638 1720 // If the minimum heap size has not been set (via -Xms),
tschatzl@4638 1721 // synchronize with InitialHeapSize to avoid errors with the default value.
tschatzl@4638 1722 if (min_heap_size() == 0) {
tschatzl@4638 1723 set_min_heap_size(MIN2((uintx)reasonable_minimum, InitialHeapSize));
tschatzl@4638 1724 if (PrintGCDetails && Verbose) {
tschatzl@4638 1725 // Cannot use gclog_or_tty yet.
tschatzl@4638 1726 tty->print_cr(" Minimum heap size " SIZE_FORMAT, min_heap_size());
tschatzl@4638 1727 }
tschatzl@4638 1728 }
ysr@342 1729 }
ysr@342 1730 }
ysr@342 1731
duke@0 1732 // This must be called after ergonomics because we want bytecode rewriting
duke@0 1733 // if the server compiler is used, or if UseSharedSpaces is disabled.
duke@0 1734 void Arguments::set_bytecode_flags() {
duke@0 1735 // Better not attempt to store into a read-only space.
duke@0 1736 if (UseSharedSpaces) {
duke@0 1737 FLAG_SET_DEFAULT(RewriteBytecodes, false);
duke@0 1738 FLAG_SET_DEFAULT(RewriteFrequentPairs, false);
duke@0 1739 }
duke@0 1740
duke@0 1741 if (!RewriteBytecodes) {
duke@0 1742 FLAG_SET_DEFAULT(RewriteFrequentPairs, false);
duke@0 1743 }
duke@0 1744 }
duke@0 1745
duke@0 1746 // Aggressive optimization flags -XX:+AggressiveOpts
duke@0 1747 void Arguments::set_aggressive_opts_flags() {
never@17 1748 #ifdef COMPILER2
kvn@4675 1749 if (AggressiveUnboxing) {
kvn@4675 1750 if (FLAG_IS_DEFAULT(EliminateAutoBox)) {
kvn@4675 1751 FLAG_SET_DEFAULT(EliminateAutoBox, true);
kvn@4675 1752 } else if (!EliminateAutoBox) {
kvn@4675 1753 // warning("AggressiveUnboxing is disabled because EliminateAutoBox is disabled");
kvn@4675 1754 AggressiveUnboxing = false;
kvn@4675 1755 }
kvn@4675 1756 if (FLAG_IS_DEFAULT(DoEscapeAnalysis)) {
kvn@4675 1757 FLAG_SET_DEFAULT(DoEscapeAnalysis, true);
kvn@4675 1758 } else if (!DoEscapeAnalysis) {
kvn@4675 1759 // warning("AggressiveUnboxing is disabled because DoEscapeAnalysis is disabled");
kvn@4675 1760 AggressiveUnboxing = false;
kvn@4675 1761 }
kvn@4675 1762 }
never@17 1763 if (AggressiveOpts || !FLAG_IS_DEFAULT(AutoBoxCacheMax)) {
never@17 1764 if (FLAG_IS_DEFAULT(EliminateAutoBox)) {
never@17 1765 FLAG_SET_DEFAULT(EliminateAutoBox, true);
never@17 1766 }
never@17 1767 if (FLAG_IS_DEFAULT(AutoBoxCacheMax)) {
never@17 1768 FLAG_SET_DEFAULT(AutoBoxCacheMax, 20000);
never@17 1769 }
never@17 1770
never@17 1771 // Feed the cache size setting into the JDK
never@17 1772 char buffer[1024];
xlu@513 1773 sprintf(buffer, "java.lang.Integer.IntegerCache.high=" INTX_FORMAT, AutoBoxCacheMax);
never@17 1774 add_property(buffer);
never@17 1775 }
never@416 1776 if (AggressiveOpts && FLAG_IS_DEFAULT(BiasedLockingStartupDelay)) {
never@416 1777 FLAG_SET_DEFAULT(BiasedLockingStartupDelay, 500);
never@416 1778 }
never@17 1779 #endif
never@17 1780
duke@0 1781 if (AggressiveOpts) {
sbohne@61 1782 // Sample flag setting code
sbohne@61 1783 // if (FLAG_IS_DEFAULT(EliminateZeroing)) {
sbohne@61 1784 // FLAG_SET_DEFAULT(EliminateZeroing, true);
sbohne@61 1785 // }
duke@0 1786 }
duke@0 1787 }
duke@0 1788
duke@0 1789 //===========================================================================================================
duke@0 1790 // Parsing of java.compiler property
duke@0 1791
duke@0 1792 void Arguments::process_java_compiler_argument(char* arg) {
duke@0 1793 // For backwards compatibility, Djava.compiler=NONE or ""
duke@0 1794 // causes us to switch to -Xint mode UNLESS -Xdebug
duke@0 1795 // is also specified.
duke@0 1796 if (strlen(arg) == 0 || strcasecmp(arg, "NONE") == 0) {
duke@0 1797 set_java_compiler(true); // "-Djava.compiler[=...]" most recently seen.
duke@0 1798 }
duke@0 1799 }
duke@0 1800
duke@0 1801 void Arguments::process_java_launcher_argument(const char* launcher, void* extra_info) {
duke@0 1802 _sun_java_launcher = strdup(launcher);
sla@2149 1803 if (strcmp("gamma", _sun_java_launcher) == 0) {
sla@2149 1804 _created_by_gamma_launcher = true;
sla@2149 1805 }
duke@0 1806 }
duke@0 1807
duke@0 1808 bool Arguments::created_by_java_launcher() {
duke@0 1809 assert(_sun_java_launcher != NULL, "property must have value");
duke@0 1810 return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
duke@0 1811 }
duke@0 1812
sla@2149 1813 bool Arguments::created_by_gamma_launcher() {
sla@2149 1814 return _created_by_gamma_launcher;
sla@2149 1815 }
sla@2149 1816
duke@0 1817 //===========================================================================================================
duke@0 1818 // Parsing of main arguments
duke@0 1819
johnc@1244 1820 bool Arguments::verify_interval(uintx val, uintx min,
johnc@1244 1821 uintx max, const char* name) {
johnc@1244 1822 // Returns true iff value is in the inclusive interval [min..max]
johnc@1244 1823 // false, otherwise.
johnc@1244 1824 if (val >= min && val <= max) {
johnc@1244 1825 return true;
johnc@1244 1826 }
johnc@1244 1827 jio_fprintf(defaultStream::error_stream(),
johnc@1244 1828 "%s of " UINTX_FORMAT " is invalid; must be between " UINTX_FORMAT
johnc@1244 1829 " and " UINTX_FORMAT "\n",
johnc@1244 1830 name, val, min, max);
johnc@1244 1831 return false;
johnc@1244 1832 }
johnc@1244 1833
ptisnovs@1664 1834 bool Arguments::verify_min_value(intx val, intx min, const char* name) {
jwilhelm@2213 1835 // Returns true if given value is at least specified min threshold
ptisnovs@1664 1836 // false, otherwise.
ptisnovs@1664 1837 if (val >= min ) {
ptisnovs@1664 1838 return true;
ptisnovs@1664 1839 }
ptisnovs@1664 1840 jio_fprintf(defaultStream::error_stream(),
jwilhelm@2213 1841 "%s of " INTX_FORMAT " is invalid; must be at least " INTX_FORMAT "\n",
ptisnovs@1664 1842 name, val, min);
ptisnovs@1664 1843 return false;
ptisnovs@1664 1844 }
ptisnovs@1664 1845
duke@0 1846 bool Arguments::verify_percentage(uintx value, const char* name) {
duke@0 1847 if (value <= 100) {
duke@0 1848 return true;
duke@0 1849 }
duke@0 1850 jio_fprintf(defaultStream::error_stream(),
duke@0 1851 "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n",
duke@0 1852 name, value);
duke@0 1853 return false;
duke@0 1854 }
duke@0 1855
mikael@4454 1856 #if !INCLUDE_ALL_GCS
mikael@4454 1857 #ifdef ASSERT
duke@0 1858 static bool verify_serial_gc_flags() {
duke@0 1859 return (UseSerialGC &&
ysr@945 1860 !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
ysr@342 1861 UseParallelGC || UseParallelOldGC));
duke@0 1862 }
mikael@4454 1863 #endif // ASSERT
mikael@4454 1864 #endif // INCLUDE_ALL_GCS
duke@0 1865
minqi@2529 1866 // check if do gclog rotation
minqi@2529 1867 // +UseGCLogFileRotation is a must,
minqi@2529 1868 // no gc log rotation when log file not supplied or
minqi@2529 1869 // NumberOfGCLogFiles is 0, or GCLogFileSize is 0
minqi@2529 1870 void check_gclog_consistency() {
minqi@2529 1871 if (UseGCLogFileRotation) {
minqi@2529 1872 if ((Arguments::gc_log_filename() == NULL) ||
minqi@2529 1873 (NumberOfGCLogFiles == 0) ||
minqi@2529 1874 (GCLogFileSize == 0)) {
minqi@2529 1875 jio_fprintf(defaultStream::output_stream(),
minqi@5248 1876 "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files> -XX:GCLogFileSize=<num_of_size>[k|K|m|M|g|G]\n"
minqi@2529 1877 "where num_of_file > 0 and num_of_size > 0\n"
minqi@2529 1878 "GC log rotation is turned off\n");
minqi@2529 1879 UseGCLogFileRotation = false;
minqi@2529 1880 }
minqi@2529 1881 }
minqi@2529 1882
minqi@2529 1883 if (UseGCLogFileRotation && GCLogFileSize < 8*K) {
minqi@2529 1884 FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K);
minqi@2529 1885 jio_fprintf(defaultStream::output_stream(),
minqi@2529 1886 "GCLogFileSize changed to minimum 8K\n");
minqi@2529 1887 }
minqi@2529 1888 }
minqi@2529 1889
minqi@5248 1890 // This function is called for -Xloggc:<filename>, it can be used
minqi@5248 1891 // to check if a given file name(or string) conforms to the following
minqi@5248 1892 // specification:
minqi@5248 1893 // A valid string only contains "[A-Z][a-z][0-9].-_%[p|t]"
minqi@5248 1894 // %p and %t only allowed once. We only limit usage of filename not path
minqi@5248 1895 bool is_filename_valid(const char *file_name) {
minqi@5248 1896 const char* p = file_name;
minqi@5248 1897 char file_sep = os::file_separator()[0];
minqi@5248 1898 const char* cp;
minqi@5248 1899 // skip prefix path
minqi@5248 1900 for (cp = file_name; *cp != '\0'; cp++) {
minqi@5248 1901 if (*cp == '/' || *cp == file_sep) {
minqi@5248 1902 p = cp + 1;
minqi@5248 1903 }
minqi@5248 1904 }
minqi@5248 1905
minqi@5248 1906 int count_p = 0;
minqi@5248 1907 int count_t = 0;
minqi@5248 1908 while (*p != '\0') {
minqi@5248 1909 if ((*p >= '0' && *p <= '9') ||
minqi@5248 1910 (*p >= 'A' && *p <= 'Z') ||
minqi@5248 1911 (*p >= 'a' && *p <= 'z') ||
minqi@5248 1912 *p == '-' ||
minqi@5248 1913 *p == '_' ||
minqi@5248 1914 *p == '.') {
minqi@5248 1915 p++;
minqi@5248 1916 continue;
minqi@5248 1917 }
minqi@5248 1918 if (*p == '%') {
minqi@5248 1919 if(*(p + 1) == 'p') {
minqi@5248 1920 p += 2;
minqi@5248 1921 count_p ++;
minqi@5248 1922 continue;
minqi@5248 1923 }
minqi@5248 1924 if (*(p + 1) == 't') {
minqi@5248 1925 p += 2;
minqi@5248 1926 count_t ++;
minqi@5248 1927 continue;
minqi@5248 1928 }
minqi@5248 1929 }
minqi@5248 1930 return false;
minqi@5248 1931 }
minqi@5248 1932 return count_p < 2 && count_t < 2;
minqi@5248 1933 }
minqi@5248 1934
jmasa@10 1935 // Check consistency of GC selection
jmasa@10 1936 bool Arguments::check_gc_consistency() {
minqi@2529 1937 check_gclog_consistency();
jmasa@10 1938 bool status = true;
jmasa@10 1939 // Ensure that the user has not selected conflicting sets
jmasa@10 1940 // of collectors. [Note: this check is merely a user convenience;
jmasa@10 1941 // collectors over-ride each other so that only a non-conflicting
jmasa@10 1942 // set is selected; however what the user gets is not what they
jmasa@10 1943 // may have expected from the combination they asked for. It's
jmasa@10 1944 // better to reduce user confusion by not allowing them to
jmasa@10 1945 // select conflicting combinations.
jmasa@10 1946 uint i = 0;
jmasa@10 1947 if (UseSerialGC) i++;
jmasa@10 1948 if (UseConcMarkSweepGC || UseParNewGC) i++;
jmasa@10 1949 if (UseParallelGC || UseParallelOldGC) i++;
ysr@845 1950 if (UseG1GC) i++;
jmasa@10 1951 if (i > 1) {
jmasa@10 1952 jio_fprintf(defaultStream::error_stream(),
jmasa@10 1953 "Conflicting collector combinations in option list; "
jmasa@10 1954 "please refer to the release notes for the combinations "
jmasa@10 1955 "allowed\n");
jmasa@10 1956 status = false;
jmasa@10 1957 }
jmasa@10 1958 return status;
jmasa@10 1959 }
jmasa@10 1960
brutisso@3953 1961 void Arguments::check_deprecated_gcs() {
brutisso@3953 1962 if (UseConcMarkSweepGC && !UseParNewGC) {
brutisso@3953 1963 warning("Using the DefNew young collector with the CMS collector is deprecated "
brutisso@3953 1964 "and will likely be removed in a future release");
brutisso@3953 1965 }
brutisso@3953 1966
brutisso@3953 1967 if (UseParNewGC && !UseConcMarkSweepGC) {
brutisso@3953 1968 // !UseConcMarkSweepGC means that we are using serial old gc. Unfortunately we don't
brutisso@3953 1969 // set up UseSerialGC properly, so that can't be used in the check here.
brutisso@3953 1970 warning("Using the ParNew young collector with the Serial old collector is deprecated "
brutisso@3953 1971 "and will likely be removed in a future release");
brutisso@3953 1972 }
brutisso@3954 1973
brutisso@3954 1974 if (CMSIncrementalMode) {
brutisso@3954 1975 warning("Using incremental CMS is deprecated and will likely be removed in a future release");
brutisso@3954 1976 }
brutisso@3953 1977 }
brutisso@3953 1978
tamao@4299 1979 void Arguments::check_deprecated_gc_flags() {
tamao@4299 1980 if (FLAG_IS_CMDLINE(MaxGCMinorPauseMillis)) {
tamao@4299 1981 warning("Using MaxGCMinorPauseMillis as minor pause goal is deprecated"
tamao@4299 1982 "and will likely be removed in future release");
tamao@4299 1983 }
brutisso@5028 1984 if (FLAG_IS_CMDLINE(DefaultMaxRAMFraction)) {
brutisso@5028 1985 warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. "
brutisso@5028 1986 "Use MaxRAMFraction instead.");
brutisso@5028 1987 }
brutisso@5602 1988 if (FLAG_IS_CMDLINE(UseCMSCompactAtFullCollection)) {
brutisso@5602 1989 warning("UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.");
brutisso@5602 1990 }
brutisso@5602 1991 if (FLAG_IS_CMDLINE(CMSFullGCsBeforeCompaction)) {
brutisso@5602 1992 warning("CMSFullGCsBeforeCompaction is deprecated and will likely be removed in a future release.");
brutisso@5602 1993 }
brutisso@5602 1994 if (FLAG_IS_CMDLINE(UseCMSCollectionPassing)) {
brutisso@5602 1995 warning("UseCMSCollectionPassing is deprecated and will likely be removed in a future release.");
brutisso@5602 1996 }
tamao@4299 1997 }
tamao@4299 1998
ptisnovs@1664 1999 // Check stack pages settings
ptisnovs@1664 2000 bool Arguments::check_stack_pages()
ptisnovs@1664 2001 {
ptisnovs@1664 2002 bool status = true;
ptisnovs@1664 2003 status = status && verify_min_value(StackYellowPages, 1, "StackYellowPages");
ptisnovs@1664 2004 status = status && verify_min_value(StackRedPages, 1, "StackRedPages");
coleenp@1787 2005 // greater stack shadow pages can't generate instruction to bang stack
coleenp@1787 2006 status = status && verify_interval(StackShadowPages, 1, 50, "StackShadowPages");
ptisnovs@1664 2007 return status;
ptisnovs@1664 2008 }
ptisnovs@1664 2009
duke@0 2010 // Check the consistency of vm_init_args
duke@0 2011 bool Arguments::check_vm_args_consistency() {
duke@0 2012 // Method for adding checks for flag consistency.
duke@0 2013 // The intent is to warn the user of all possible conflicts,
duke@0 2014 // before returning an error.
duke@0 2015 // Note: Needs platform-dependent factoring.
duke@0 2016 bool status = true;
duke@0 2017
duke@0 2018 // Allow both -XX:-UseStackBanging and -XX:-UseBoundThreads in non-product
duke@0 2019 // builds so the cost of stack banging can be measured.
duke@0 2020 #if (defined(PRODUCT) && defined(SOLARIS))
duke@0 2021 if (!UseBoundThreads && !UseStackBanging) {
duke@0 2022 jio_fprintf(defaultStream::error_stream(),
duke@0 2023 "-UseStackBanging conflicts with -UseBoundThreads\n");
duke@0 2024
duke@0 2025 status = false;
duke@0 2026 }
duke@0 2027 #endif
duke@0 2028
duke@0 2029 if (TLABRefillWasteFraction == 0) {
duke@0 2030 jio_fprintf(defaultStream::error_stream(),
duke@0 2031 "TLABRefillWasteFraction should be a denominator, "
duke@0 2032 "not " SIZE_FORMAT "\n",
duke@0 2033 TLABRefillWasteFraction);
duke@0 2034 status = false;
duke@0 2035 }
duke@0 2036
tschatzl@4684 2037 status = status && verify_interval(AdaptiveSizePolicyWeight, 0, 100,
duke@0 2038 "AdaptiveSizePolicyWeight");
jmasa@10 2039 status = status && verify_percentage(ThresholdTolerance, "ThresholdTolerance");
jmasa@10 2040 status = status && verify_percentage(MinHeapFreeRatio, "MinHeapFreeRatio");
jmasa@10 2041 status = status && verify_percentage(MaxHeapFreeRatio, "MaxHeapFreeRatio");
duke@0 2042
hseigel@3842 2043 // Divide by bucket size to prevent a large size from causing rollover when
hseigel@3842 2044 // calculating amount of memory needed to be allocated for the String table.
hseigel@4523 2045 status = status && verify_interval(StringTableSize, minimumStringTableSize,
hseigel@3842 2046 (max_uintx / StringTable::bucket_size()), "StringTable size");
hseigel@3842 2047
kevinw@5415 2048 status = status && verify_interval(SymbolTableSize, minimumSymbolTableSize,
kevinw@5415 2049 (max_uintx / SymbolTable::bucket_size()), "SymbolTable size");
kevinw@5415 2050
duke@0 2051 if (MinHeapFreeRatio > MaxHeapFreeRatio) {
duke@0 2052 jio_fprintf(defaultStream::error_stream(),
duke@0 2053 "MinHeapFreeRatio (" UINTX_FORMAT ") must be less than or "
duke@0 2054 "equal to MaxHeapFreeRatio (" UINTX_FORMAT ")\n",
duke@0 2055 MinHeapFreeRatio, MaxHeapFreeRatio);
duke@0 2056 status = false;
duke@0 2057 }
duke@0 2058 // Keeping the heap 100% free is hard ;-) so limit it to 99%.
duke@0 2059 MinHeapFreeRatio = MIN2(MinHeapFreeRatio, (uintx) 99);
duke@0 2060
jmasa@4146 2061 // Min/MaxMetaspaceFreeRatio
jmasa@4146 2062 status = status && verify_percentage(MinMetaspaceFreeRatio, "MinMetaspaceFreeRatio");
jmasa@4146 2063 status = status && verify_percentage(MaxMetaspaceFreeRatio, "MaxMetaspaceFreeRatio");
jmasa@4146 2064
jmasa@4146 2065 if (MinMetaspaceFreeRatio > MaxMetaspaceFreeRatio) {
jmasa@4146 2066 jio_fprintf(defaultStream::error_stream(),
jmasa@4146 2067 "MinMetaspaceFreeRatio (%s" UINTX_FORMAT ") must be less than or "
jmasa@4146 2068 "equal to MaxMetaspaceFreeRatio (%s" UINTX_FORMAT ")\n",
jmasa@4146 2069 FLAG_IS_DEFAULT(MinMetaspaceFreeRatio) ? "Default: " : "",
jmasa@4146 2070 MinMetaspaceFreeRatio,
jmasa@4146 2071 FLAG_IS_DEFAULT(MaxMetaspaceFreeRatio) ? "Default: " : "",
jmasa@4146 2072 MaxMetaspaceFreeRatio);
jmasa@4146 2073 status = false;
jmasa@4146 2074 }
jmasa@4146 2075
jmasa@4146 2076 // Trying to keep 100% free is not practical
jmasa@4146 2077 MinMetaspaceFreeRatio = MIN2(MinMetaspaceFreeRatio, (uintx) 99);
jmasa@4146 2078
duke@0 2079 if (FullGCALot && FLAG_IS_DEFAULT(MarkSweepAlwaysCompactCount)) {
duke@0 2080 MarkSweepAlwaysCompactCount = 1; // Move objects every gc.
duke@0 2081 }
duke@0 2082
jcoomes@483 2083 if (UseParallelOldGC && ParallelOldGCSplitALot) {
jcoomes@483 2084 // Settings to encourage splitting.
jcoomes@483 2085 if (!FLAG_IS_CMDLINE(NewRatio)) {
jwilhelm@4141 2086 FLAG_SET_CMDLINE(uintx, NewRatio, 2);
jcoomes@483 2087 }
jcoomes@483 2088 if (!FLAG_IS_CMDLINE(ScavengeBeforeFullGC)) {
jcoomes@483 2089 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
jcoomes@483 2090 }
jcoomes@483 2091 }
jcoomes@483 2092
jmasa@10 2093 status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit");
jmasa@10 2094 status = status && verify_percentage(GCTimeLimit, "GCTimeLimit");
duke@0 2095 if (GCTimeLimit == 100) {
duke@0 2096 // Turn off gc-overhead-limit-exceeded checks
duke@0 2097 FLAG_SET_DEFAULT(UseGCOverheadLimit, false);
duke@0 2098 }
duke@0 2099
jmasa@10 2100 status = status && check_gc_consistency();
ptisnovs@1664 2101 status = status && check_stack_pages();
duke@0 2102
duke@0 2103 if (CMSIncrementalMode) {
duke@0 2104 if (!UseConcMarkSweepGC) {
duke@0 2105 jio_fprintf(defaultStream::error_stream(),
duke@0 2106 "error: invalid argument combination.\n"
duke@0 2107 "The CMS collector (-XX:+UseConcMarkSweepGC) must be "
duke@0 2108 "selected in order\nto use CMSIncrementalMode.\n");
duke@0 2109 status = false;
duke@0 2110 } else {
jmasa@10 2111 status = status && verify_percentage(CMSIncrementalDutyCycle,
duke@0 2112 "CMSIncrementalDutyCycle");
jmasa@10 2113 status = status && verify_percentage(CMSIncrementalDutyCycleMin,
duke@0 2114 "CMSIncrementalDutyCycleMin");
jmasa@10 2115 status = status && verify_percentage(CMSIncrementalSafetyFactor,
duke@0 2116 "CMSIncrementalSafetyFactor");
jmasa@10 2117 status = status && verify_percentage(CMSIncrementalOffset,
duke@0 2118 "CMSIncrementalOffset");
jmasa@10 2119 status = status && verify_percentage(CMSExpAvgFactor,
duke@0 2120 "CMSExpAvgFactor");
duke@0 2121 // If it was not set on the command line, set
duke@0 2122 // CMSInitiatingOccupancyFraction to 1 so icms can initiate cycles early.
duke@0 2123 if (CMSInitiatingOccupancyFraction < 0) {
duke@0 2124 FLAG_SET_DEFAULT(CMSInitiatingOccupancyFraction, 1);
duke@0 2125 }
duke@0 2126 }
duke@0 2127 }
duke@0 2128
duke@0 2129 // CMS space iteration, which FLSVerifyAllHeapreferences entails,
duke@0 2130 // insists that we hold the requisite locks so that the iteration is
duke@0 2131 // MT-safe. For the verification at start-up and shut-down, we don't
duke@0 2132 // yet have a good way of acquiring and releasing these locks,
duke@0 2133 // which are not visible at the CollectedHeap level. We want to
duke@0 2134 // be able to acquire these locks and then do the iteration rather
duke@0 2135 // than just disable the lock verification. This will be fixed under
duke@0 2136 // bug 4788986.
duke@0 2137 if (UseConcMarkSweepGC && FLSVerifyAllHeapReferences) {
johnc@4464 2138 if (VerifyDuringStartup) {
duke@0 2139 warning("Heap verification at start-up disabled "
duke@0 2140 "(due to current incompatibility with FLSVerifyAllHeapReferences)");
johnc@4464 2141 VerifyDuringStartup = false; // Disable verification at start-up
duke@0 2142 }
johnc@4464 2143
duke@0 2144 if (VerifyBeforeExit) {
duke@0 2145 warning("Heap verification at shutdown disabled "
duke@0 2146 "(due to current incompatibility with FLSVerifyAllHeapReferences)");
duke@0 2147 VerifyBeforeExit = false; // Disable verification at shutdown
duke@0 2148 }
duke@0 2149 }
duke@0 2150
duke@0 2151 // Note: only executed in non-PRODUCT mode
duke@0 2152 if (!UseAsyncConcMarkSweepGC &&
duke@0 2153 (ExplicitGCInvokesConcurrent ||
duke@0 2154 ExplicitGCInvokesConcurrentAndUnloadsClasses)) {
duke@0 2155 jio_fprintf(defaultStream::error_stream(),
brutisso@3580 2156 "error: +ExplicitGCInvokesConcurrent[AndUnloadsClasses] conflicts"
duke@0 2157 " with -UseAsyncConcMarkSweepGC");
duke@0 2158 status = false;
duke@0 2159 }
duke@0 2160
jwilhelm@2213 2161 status = status && verify_min_value(ParGCArrayScanChunk, 1, "ParGCArrayScanChunk");
jwilhelm@2213 2162
jprovino@4107 2163 #if INCLUDE_ALL_GCS
tonyp@1283 2164 if (UseG1GC) {
tonyp@1283 2165 status = status && verify_percentage(InitiatingHeapOccupancyPercent,
tonyp@1283 2166 "InitiatingHeapOccupancyPercent");
johnc@2059 2167 status = status && verify_min_value(G1RefProcDrainInterval, 1,
johnc@2059 2168 "G1RefProcDrainInterval");
johnc@2059 2169 status = status && verify_min_value((intx)G1ConcMarkStepDurationMillis, 1,
johnc@2059 2170 "G1ConcMarkStepDurationMillis");
johnc@4643 2171 status = status && verify_interval(G1ConcRSHotCardLimit, 0, max_jubyte,
johnc@4643 2172 "G1ConcRSHotCardLimit");
johnc@4643 2173 status = status && verify_interval(G1ConcRSLogCacheSize, 0, 31,
johnc@4643 2174 "G1ConcRSLogCacheSize");
tonyp@1283 2175 }
tschatzl@4684 2176 if (UseConcMarkSweepGC) {
tschatzl@4684 2177 status = status && verify_min_value(CMSOldPLABNumRefills, 1, "CMSOldPLABNumRefills");
tschatzl@4684 2178 status = status && verify_min_value(CMSOldPLABToleranceFactor, 1, "CMSOldPLABToleranceFactor");
tschatzl@4684 2179 status = status && verify_min_value(CMSOldPLABMax, 1, "CMSOldPLABMax");
tschatzl@4684 2180 status = status && verify_interval(CMSOldPLABMin, 1, CMSOldPLABMax, "CMSOldPLABMin");
tschatzl@4684 2181
tschatzl@4684 2182 status = status && verify_min_value(CMSYoungGenPerWorker, 1, "CMSYoungGenPerWorker");
tschatzl@4684 2183
tschatzl@4684 2184 status = status && verify_min_value(CMSSamplingGrain, 1, "CMSSamplingGrain");
tschatzl@4684 2185 status = status && verify_interval(CMS_SweepWeight, 0, 100, "CMS_SweepWeight");
tschatzl@4684 2186 status = status && verify_interval(CMS_FLSWeight, 0, 100, "CMS_FLSWeight");
tschatzl@4684 2187
tschatzl@4684 2188 status = status && verify_interval(FLSCoalescePolicy, 0, 4, "FLSCoalescePolicy");
tschatzl@4684 2189
tschatzl@4684 2190 status = status && verify_min_value(CMSRescanMultiple, 1, "CMSRescanMultiple");
tschatzl@4684 2191 status = status && verify_min_value(CMSConcMarkMultiple, 1, "CMSConcMarkMultiple");
tschatzl@4684 2192
tschatzl@4684 2193 status = status && verify_interval(CMSPrecleanIter, 0, 9, "CMSPrecleanIter");
tschatzl@4684 2194 status = status && verify_min_value(CMSPrecleanDenominator, 1, "CMSPrecleanDenominator");
tschatzl@4684 2195 status = status && verify_interval(CMSPrecleanNumerator, 0, CMSPrecleanDenominator - 1, "CMSPrecleanNumerator");
tschatzl@4684 2196
tschatzl@4684 2197 status = status && verify_percentage(CMSBootstrapOccupancy, "CMSBootstrapOccupancy");
tschatzl@4684 2198
tschatzl@4684 2199 status = status && verify_min_value(CMSPrecleanThreshold, 100, "CMSPrecleanThreshold");
tschatzl@4684 2200
tschatzl@4684 2201 status = status && verify_percentage(CMSScheduleRemarkEdenPenetration, "CMSScheduleRemarkEdenPenetration");
tschatzl@4684 2202 status = status && verify_min_value(CMSScheduleRemarkSamplingRatio, 1, "CMSScheduleRemarkSamplingRatio");
tschatzl@4684 2203 status = status && verify_min_value(CMSBitMapYieldQuantum, 1, "CMSBitMapYieldQuantum");
tschatzl@4684 2204 status = status && verify_percentage(CMSTriggerRatio, "CMSTriggerRatio");
tschatzl@4684 2205 status = status && verify_percentage(CMSIsTooFullPercentage, "CMSIsTooFullPercentage");
tschatzl@4684 2206 }
tschatzl@4684 2207
tschatzl@4684 2208 if (UseParallelGC || UseParallelOldGC) {
tschatzl@4684 2209 status = status && verify_interval(ParallelOldDeadWoodLimiterMean, 0, 100, "ParallelOldDeadWoodLimiterMean");
tschatzl@4684 2210 status = status && verify_interval(ParallelOldDeadWoodLimiterStdDev, 0, 100, "ParallelOldDeadWoodLimiterStdDev");
tschatzl@4684 2211
tschatzl@4684 2212 status = status && verify_percentage(YoungGenerationSizeIncrement, "YoungGenerationSizeIncrement");
tschatzl@4684 2213 status = status && verify_percentage(TenuredGenerationSizeIncrement, "TenuredGenerationSizeIncrement");
tschatzl@4684 2214
tschatzl@4684 2215 status = status && verify_min_value(YoungGenerationSizeSupplementDecay, 1, "YoungGenerationSizeSupplementDecay");
tschatzl@4684 2216 status = status && verify_min_value(TenuredGenerationSizeSupplementDecay, 1, "TenuredGenerationSizeSupplementDecay");
tschatzl@4684 2217
tschatzl@4684 2218 status = status && verify_min_value(ParGCCardsPerStrideChunk, 1, "ParGCCardsPerStrideChunk");
tschatzl@4684 2219
tschatzl@4684 2220 status = status && verify_min_value(ParallelOldGCSplitInterval, 0, "ParallelOldGCSplitInterval");
tschatzl@4684 2221 }
jprovino@4107 2222 #endif // INCLUDE_ALL_GCS
tonyp@1283 2223
johnc@1244 2224 status = status && verify_interval(RefDiscoveryPolicy,
johnc@1244 2225 ReferenceProcessor::DiscoveryPolicyMin,
johnc@1244 2226 ReferenceProcessor::DiscoveryPolicyMax,
johnc@1244 2227 "RefDiscoveryPolicy");
johnc@1244 2228
johnc@1244 2229 // Limit the lower bound of this flag to 1 as it is used in a division
johnc@1244 2230 // expression.
johnc@1244 2231 status = status && verify_interval(TLABWasteTargetPercent,
johnc@1244 2232 1, 100, "TLABWasteTargetPercent");
johnc@1244 2233
kvn@1491 2234 status = status && verify_object_alignment();
kvn@1491 2235
ehelin@5259 2236 status = status && verify_interval(CompressedClassSpaceSize, 1*M, 3*G,
ehelin@5259 2237 "CompressedClassSpaceSize");
coleenp@3613 2238
johnc@3898 2239 status = status && verify_interval(MarkStackSizeMax,
johnc@3898 2240 1, (max_jint - 1), "MarkStackSizeMax");
tschatzl@4684 2241 status = status && verify_interval(NUMAChunkResizeWeight, 0, 100, "NUMAChunkResizeWeight");
tschatzl@4684 2242
tschatzl@4684 2243 status = status && verify_min_value(LogEventsBufferEntries, 1, "LogEventsBufferEntries");
tschatzl@4684 2244
tschatzl@4684 2245 status = status && verify_min_value(HeapSizePerGCThread, (uintx) os::vm_page_size(), "HeapSizePerGCThread");
tschatzl@4684 2246
tschatzl@4684 2247 status = status && verify_min_value(GCTaskTimeStampEntries, 1, "GCTaskTimeStampEntries");
tschatzl@4684 2248
tschatzl@4684 2249 status = status && verify_percentage(ParallelGCBufferWastePct, "ParallelGCBufferWastePct");
tschatzl@4684 2250 status = status && verify_interval(TargetPLABWastePct, 1, 100, "TargetPLABWastePct");
tschatzl@4684 2251
tschatzl@4684 2252 status = status && verify_min_value(ParGCStridesPerThread, 1, "ParGCStridesPerThread");
tschatzl@4684 2253
tschatzl@4684 2254 status = status && verify_min_value(MinRAMFraction, 1, "MinRAMFraction");
tschatzl@4684 2255 status = status && verify_min_value(InitialRAMFraction, 1, "InitialRAMFraction");
tschatzl@4684 2256 status = status && verify_min_value(MaxRAMFraction, 1, "MaxRAMFraction");
tschatzl@4684 2257 status = status && verify_min_value(DefaultMaxRAMFraction, 1, "DefaultMaxRAMFraction");
tschatzl@4684 2258
tschatzl@4684 2259 status = status && verify_interval(AdaptiveTimeWeight, 0, 100, "AdaptiveTimeWeight");
tschatzl@4684 2260 status = status && verify_min_value(AdaptiveSizeDecrementScaleFactor, 1, "AdaptiveSizeDecrementScaleFactor");
tschatzl@4684 2261
tschatzl@4684 2262 status = status && verify_interval(TLABAllocationWeight, 0, 100, "TLABAllocationWeight");
tschatzl@4684 2263 status = status && verify_min_value(MinTLABSize, 1, "MinTLABSize");
tschatzl@4684 2264 status = status && verify_min_value(TLABRefillWasteFraction, 1, "TLABRefillWasteFraction");
tschatzl@4684 2265
tschatzl@4684 2266 status = status && verify_percentage(YoungGenerationSizeSupplement, "YoungGenerationSizeSupplement");
tschatzl@4684 2267 status = status && verify_percentage(TenuredGenerationSizeSupplement, "TenuredGenerationSizeSupplement");
tschatzl@4684 2268
tschatzl@4684 2269 // the "age" field in the oop header is 4 bits; do not want to pull in markOop.hpp
tschatzl@4684 2270 // just for that, so hardcode here.
tschatzl@4684 2271 status = status && verify_interval(MaxTenuringThreshold, 0, 15, "MaxTenuringThreshold");
tschatzl@4684 2272 status = status && verify_interval(InitialTenuringThreshold, 0, MaxTenuringThreshold, "MaxTenuringThreshold");
tschatzl@4684 2273 status = status && verify_percentage(TargetSurvivorRatio, "TargetSurvivorRatio");
tschatzl@4684 2274 status = status && verify_percentage(MarkSweepDeadRatio, "MarkSweepDeadRatio");
tschatzl@4684 2275
tschatzl@4684 2276 status = status && verify_min_value(MarkSweepAlwaysCompactCount, 1, "MarkSweepAlwaysCompactCount");
johnc@3631 2277 #ifdef SPARC
johnc@3631 2278 if (UseConcMarkSweepGC || UseG1GC) {
johnc@3631 2279 // Issue a stern warning if the user has explicitly set
johnc@3631 2280 // UseMemSetInBOT (it is known to cause issues), but allow
johnc@3631 2281 // use for experimentation and debugging.
johnc@3631 2282 if (VM_Version::is_sun4v() && UseMemSetInBOT) {
johnc@3631 2283 assert(!FLAG_IS_DEFAULT(UseMemSetInBOT), "Error");
johnc@3631 2284 warning("Experimental flag -XX:+UseMemSetInBOT is known to cause instability"
johnc@3631 2285 " on sun4v; please understand that you are using at your own risk!");
johnc@3631 2286 }
johnc@3631 2287 }
johnc@3631 2288 #endif // SPARC
johnc@3631 2289
jprovino@3730 2290 if (PrintNMTStatistics) {
jprovino@3730 2291 #if INCLUDE_NMT
jprovino@3730 2292 if (MemTracker::tracking_level() == MemTracker::NMT_off) {
jprovino@3730 2293 #endif // INCLUDE_NMT
jprovino@3730 2294 warning("PrintNMTStatistics is disabled, because native memory tracking is not enabled");
jprovino@3730 2295 PrintNMTStatistics = false;
jprovino@3730 2296 #if INCLUDE_NMT
jprovino@3730 2297 }
jprovino@3730 2298 #endif
zgu@3646 2299 }
zgu@3646 2300
dholmes@4657 2301 // Need to limit the extent of the padding to reasonable size.
dholmes@4657 2302 // 8K is well beyond the reasonable HW cache line size, even with the
dholmes@4657 2303 // aggressive prefetching, while still leaving the room for segregating
dholmes@4657 2304 // among the distinct pages.
dholmes@4657 2305 if (ContendedPaddingWidth < 0 || ContendedPaddingWidth > 8192) {
dholmes@4657 2306 jio_fprintf(defaultStream::error_stream(),
shade@5162 2307 "ContendedPaddingWidth=" INTX_FORMAT " must be in between %d and %d\n",
dholmes@4657 2308 ContendedPaddingWidth, 0, 8192);
dholmes@4657 2309 status = false;
dholmes@4657 2310 }
dholmes@4657 2311
dholmes@4657 2312 // Need to enforce the padding not to break the existing field alignments.
dholmes@4657 2313 // It is sufficient to check against the largest type size.
dholmes@4657 2314 if ((ContendedPaddingWidth % BytesPerLong) != 0) {
dholmes@4657 2315 jio_fprintf(defaultStream::error_stream(),
shade@5162 2316 "ContendedPaddingWidth=" INTX_FORMAT " must be a multiple of %d\n",
dholmes@4657 2317 ContendedPaddingWidth, BytesPerLong);
dholmes@4657 2318 status = false;
dholmes@4657 2319 }
dholmes@4657 2320
anoll@4917 2321 // Check lower bounds of the code cache
anoll@4917 2322 // Template Interpreter code is approximately 3X larger in debug builds.
anoll@4917 2323 uint min_code_cache_size = (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3)) + CodeCacheMinimumFreeSpace;
anoll@4917 2324 if (InitialCodeCacheSize < (uintx)os::vm_page_size()) {
anoll@4789 2325 jio_fprintf(defaultStream::error_stream(),
anoll@4917 2326 "Invalid InitialCodeCacheSize=%dK. Must be at least %dK.\n", InitialCodeCacheSize/K,
anoll@4917 2327 os::vm_page_size()/K);
anoll@4917 2328 status = false;
anoll@4917 2329 } else if (ReservedCodeCacheSize < InitialCodeCacheSize) {
anoll@4917 2330 jio_fprintf(defaultStream::error_stream(),
anoll@4917 2331 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n",
anoll@4789 2332 ReservedCodeCacheSize/K, InitialCodeCacheSize/K);
anoll@4789 2333 status = false;
anoll@4917 2334 } else if (ReservedCodeCacheSize < min_code_cache_size) {
anoll@4917 2335 jio_fprintf(defaultStream::error_stream(),
anoll@4917 2336 "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K,
anoll@4917 2337 min_code_cache_size/K);
anoll@4917 2338 status = false;
anoll@4947 2339 } else if (ReservedCodeCacheSize > 2*G) {
anoll@4947 2340 // Code cache size larger than MAXINT is not supported.
anoll@4947 2341 jio_fprintf(defaultStream::error_stream(),
anoll@4947 2342 "Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M,
anoll@4947 2343 (2*G)/M);
anoll@4947 2344 status = false;
anoll@4789 2345 }
anoll@5357 2346
anoll@5357 2347 status &= verify_interval(NmethodSweepFraction, 1, ReservedCodeCacheSize/K, "NmethodSweepFraction");
anoll@5357 2348 status &= verify_interval(NmethodSweepActivity, 0, 2000, "NmethodSweepActivity");
anoll@5357 2349
duke@0 2350 return status;
duke@0 2351 }
duke@0 2352
duke@0 2353 bool Arguments::is_bad_option(const JavaVMOption* option, jboolean ignore,
duke@0 2354 const char* option_type) {
duke@0 2355 if (ignore) return false;
duke@0 2356
duke@0 2357 const char* spacer = " ";
duke@0 2358 if (option_type == NULL) {
duke@0 2359 option_type = ++spacer; // Set both to the empty string.
duke@0 2360 }
duke@0 2361
duke@0 2362 if (os::obsolete_option(option)) {
duke@0 2363 jio_fprintf(defaultStream::error_stream(),
duke@0 2364 "Obsolete %s%soption: %s\n", option_type, spacer,
duke@0 2365 option->optionString);
duke@0 2366 return false;
duke@0 2367 } else {
duke@0 2368 jio_fprintf(defaultStream::error_stream(),
duke@0 2369 "Unrecognized %s%soption: %s\n", option_type, spacer,
duke@0 2370 option->optionString);
duke@0 2371 return true;
duke@0 2372 }
duke@0 2373 }
duke@0 2374
duke@0 2375 static const char* user_assertion_options[] = {
duke@0 2376 "-da", "-ea", "-disableassertions", "-enableassertions", 0
duke@0 2377 };
duke@0 2378
duke@0 2379 static const char* system_assertion_options[] = {
duke@0 2380 "-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", 0
duke@0 2381 };
duke@0 2382
duke@0 2383 // Return true if any of the strings in null-terminated array 'names' matches.
duke@0 2384 // If tail_allowed is true, then the tail must begin with a colon; otherwise,
duke@0 2385 // the option must match exactly.
duke@0 2386 static bool match_option(const JavaVMOption* option, const char** names, const char** tail,
duke@0 2387 bool tail_allowed) {
duke@0 2388 for (/* empty */; *names != NULL; ++names) {
duke@0 2389 if (match_option(option, *names, tail)) {
duke@0 2390 if (**tail == '\0' || tail_allowed && **tail == ':') {
duke@0 2391 return true;
duke@0 2392 }
duke@0 2393 }
duke@0 2394 }
duke@0 2395 return false;
duke@0 2396 }
duke@0 2397
jmasa@1284 2398 bool Arguments::parse_uintx(const char* value,
jmasa@1284 2399 uintx* uintx_arg,
jmasa@1284 2400 uintx min_size) {
jmasa@1284 2401
jmasa@1284 2402 // Check the sign first since atomull() parses only unsigned values.
jmasa@1284 2403 bool value_is_positive = !(*value == '-');
jmasa@1284 2404
jmasa@1284 2405 if (value_is_positive) {
jmasa@1284 2406 julong n;
jmasa@1284 2407 bool good_return = atomull(value, &n);
jmasa@1284 2408 if (good_return) {
jmasa@1284 2409 bool above_minimum = n >= min_size;
jmasa@1284 2410 bool value_is_too_large = n > max_uintx;
jmasa@1284 2411
jmasa@1284 2412 if (above_minimum && !value_is_too_large) {
jmasa@1284 2413 *uintx_arg = n;
jmasa@1284 2414 return true;
jmasa@1284 2415 }
jmasa@1284 2416 }
jmasa@1284 2417 }
jmasa@1284 2418 return false;
jmasa@1284 2419 }
jmasa@1284 2420
duke@0 2421 Arguments::ArgsRange Arguments::parse_memory_size(const char* s,
swamyv@489 2422 julong* long_arg,
swamyv@489 2423 julong min_size) {
swamyv@489 2424 if (!atomull(s, long_arg)) return arg_unreadable;
duke@0 2425 return check_memory_size(*long_arg, min_size);
duke@0 2426 }
duke@0 2427
duke@0 2428 // Parse JavaVMInitArgs structure
duke@0 2429
duke@0 2430 jint Arguments::parse_vm_init_args(const JavaVMInitArgs* args) {
duke@0 2431 // For components of the system classpath.
duke@0 2432 SysClassPath scp(Arguments::get_sysclasspath());
duke@0 2433 bool scp_assembly_required = false;
duke@0 2434
duke@0 2435 // Save default settings for some mode flags
duke@0 2436 Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
duke@0 2437 Arguments::_UseOnStackReplacement = UseOnStackReplacement;
duke@0 2438 Arguments::_ClipInlining = ClipInlining;
duke@0 2439 Arguments::_BackgroundCompilation = BackgroundCompilation;
duke@0 2440
never@2438 2441 // Setup flags for mixed which is the default
never@2438 2442 set_mode_flags(_mixed);
never@2438 2443
duke@0 2444 // Parse JAVA_TOOL_OPTIONS environment variable (if present)
duke@0 2445 jint result = parse_java_tool_options_environment_variable(&scp, &scp_assembly_required);
duke@0 2446 if (result != JNI_OK) {
duke@0 2447 return result;
duke@0 2448 }
duke@0 2449
duke@0 2450 // Parse JavaVMInitArgs structure passed in
twisti@5355 2451 result = parse_each_vm_init_arg(args, &scp, &scp_assembly_required, Flag::COMMAND_LINE);
duke@0 2452 if (result != JNI_OK) {
duke@0 2453 return result;
duke@0 2454 }
duke@0 2455
duke@0 2456 // Parse _JAVA_OPTIONS environment variable (if present) (mimics classic VM)
duke@0 2457 result = parse_java_options_environment_variable(&scp, &scp_assembly_required);
duke@0 2458 if (result != JNI_OK) {
duke@0 2459 return result;
duke@0 2460 }
duke@0 2461
duke@0 2462 // Do final processing now that all arguments have been parsed
duke@0 2463 result = finalize_vm_init_args(&scp, scp_assembly_required);
duke@0 2464 if (result != JNI_OK) {
duke@0 2465 return result;
duke@0 2466 }
duke@0 2467
duke@0 2468 return JNI_OK;
duke@0 2469 }
duke@0 2470
dholmes@4567 2471 // Checks if name in command-line argument -agent{lib,path}:name[=options]
dholmes@4567 2472 // represents a valid HPROF of JDWP agent. is_path==true denotes that we
dholmes@4567 2473 // are dealing with -agentpath (case where name is a path), otherwise with
dholmes@4567 2474 // -agentlib
dholmes@4567 2475 bool valid_hprof_or_jdwp_agent(char *name, bool is_path) {
dholmes@4567 2476 char *_name;
dholmes@4567 2477 const char *_hprof = "hprof", *_jdwp = "jdwp";
dholmes@4567 2478 size_t _len_hprof, _len_jdwp, _len_prefix;
dholmes@4567 2479
dholmes@4567 2480 if (is_path) {
dholmes@4567 2481 if ((_name = strrchr(name, (int) *os::file_separator())) == NULL) {
dholmes@4567 2482 return false;
dholmes@4567 2483 }
dholmes@4567 2484
dholmes@4567 2485 _name++; // skip past last path separator
dholmes@4567 2486 _len_prefix = strlen(JNI_LIB_PREFIX);
dholmes@4567 2487
dholmes@4567 2488 if (strncmp(_name, JNI_LIB_PREFIX, _len_prefix) != 0) {
dholmes@4567 2489 return false;
dholmes@4567 2490 }
dholmes@4567 2491
dholmes@4567 2492 _name += _len_prefix;
dholmes@4567 2493 _len_hprof = strlen(_hprof);
dholmes@4567 2494 _len_jdwp = strlen(_jdwp);
dholmes@4567 2495
dholmes@4567 2496 if (strncmp(_name, _hprof, _len_hprof) == 0) {
dholmes@4567 2497 _name += _len_hprof;
dholmes@4567 2498 }
dholmes@4567 2499 else if (strncmp(_name, _jdwp, _len_jdwp) == 0) {
dholmes@4567 2500 _name += _len_jdwp;
dholmes@4567 2501 }
dholmes@4567 2502 else {
dholmes@4567 2503 return false;
dholmes@4567 2504 }
dholmes@4567 2505
dholmes@4567 2506 if (strcmp(_name, JNI_LIB_SUFFIX) != 0) {
dholmes@4567 2507 return false;
dholmes@4567 2508 }
dholmes@4567 2509
dholmes@4567 2510 return true;
dholmes@4567 2511 }
dholmes@4567 2512
dholmes@4567 2513 if (strcmp(name, _hprof) == 0 || strcmp(name, _jdwp) == 0) {
dholmes@4567 2514 return true;
dholmes@4567 2515 }
dholmes@4567 2516
dholmes@4567 2517 return false;
dholmes@4567 2518 }
dholmes@4567 2519
duke@0 2520 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
duke@0 2521 SysClassPath* scp_p,
duke@0 2522 bool* scp_assembly_required_p,
twisti@5355 2523 Flag::Flags origin) {
duke@0 2524 // Remaining part of option string
duke@0 2525 const char* tail;
duke@0 2526
duke@0 2527 // iterate over arguments
duke@0 2528 for (int index = 0; index < args->nOptions; index++) {
duke@0 2529 bool is_absolute_path = false; // for -agentpath vs -agentlib
duke@0 2530
duke@0 2531 const JavaVMOption* option = args->options + index;
duke@0 2532
duke@0 2533 if (!match_option(option, "-Djava.class.path", &tail) &&
duke@0 2534 !match_option(option, "-Dsun.java.command", &tail) &&
duke@0 2535 !match_option(option, "-Dsun.java.launcher", &tail)) {
duke@0 2536
duke@0 2537 // add all jvm options to the jvm_args string. This string
duke@0 2538 // is used later to set the java.vm.args PerfData string constant.
duke@0 2539 // the -Djava.class.path and the -Dsun.java.command options are
duke@0 2540 // omitted from jvm_args string as each have their own PerfData
duke@0 2541 // string constant object.
duke@0 2542 build_jvm_args(option->optionString);
duke@0 2543 }
duke@0 2544
duke@0 2545 // -verbose:[class/gc/jni]
duke@0 2546 if (match_option(option, "-verbose", &tail)) {
duke@0 2547 if (!strcmp(tail, ":class") || !strcmp(tail, "")) {
duke@0 2548 FLAG_SET_CMDLINE(bool, TraceClassLoading, true);
duke@0 2549 FLAG_SET_CMDLINE(bool, TraceClassUnloading, true);
duke@0 2550 } else if (!strcmp(tail, ":gc")) {
duke@0 2551 FLAG_SET_CMDLINE(bool, PrintGC, true);
duke@0 2552 } else if (!strcmp(tail, ":jni")) {
duke@0 2553 FLAG_SET_CMDLINE(bool, PrintJNIResolving, true);
duke@0 2554 }
duke@0 2555 // -da / -ea / -disableassertions / -enableassertions
duke@0 2556 // These accept an optional class/package name separated by a colon, e.g.,
duke@0 2557 // -da:java.lang.Thread.
duke@0 2558 } else if (match_option(option, user_assertion_options, &tail, true)) {
duke@0 2559 bool enable = option->optionString[1] == 'e'; // char after '-' is 'e'
duke@0 2560 if (*tail == '\0') {
duke@0 2561 JavaAssertions::setUserClassDefault(enable);
duke@0 2562 } else {
duke@0 2563 assert(*tail == ':', "bogus match by match_option()");
duke@0 2564 JavaAssertions::addOption(tail + 1, enable);
duke@0 2565 }
duke@0 2566 // -dsa / -esa / -disablesystemassertions / -enablesystemassertions
duke@0 2567 } else if (match_option(option, system_assertion_options, &tail, false)) {
duke@0 2568 bool enable = option->optionString[1] == 'e'; // char after '-' is 'e'
duke@0 2569 JavaAssertions::setSystemClassDefault(enable);
duke@0 2570 // -bootclasspath:
duke@0 2571 } else if (match_option(option, "-Xbootclasspath:", &tail)) {
duke@0 2572 scp_p->reset_path(tail);
duke@0 2573 *scp_assembly_required_p = true;
duke@0 2574 // -bootclasspath/a:
duke@0 2575 } else if (match_option(option, "-Xbootclasspath/a:", &tail)) {
duke@0 2576 scp_p->add_suffix(tail);
duke@0 2577 *scp_assembly_required_p = true;
duke@0 2578 // -bootclasspath/p:
duke@0 2579 } else if (match_option(option, "-Xbootclasspath/p:", &tail)) {
duke@0 2580 scp_p->add_prefix(tail);
duke@0 2581 *scp_assembly_required_p = true;
duke@0 2582 // -Xrun
duke@0 2583 } else if (match_option(option, "-Xrun", &tail)) {
phh@531 2584 if (tail != NULL) {
duke@0 2585 const char* pos = strchr(tail, ':');
duke@0 2586 size_t len = (pos == NULL) ? strlen(tail) : pos - tail;
zgu@3465 2587 char* name = (char*)memcpy(NEW_C_HEAP_ARRAY(char, len + 1, mtInternal), tail, len);
duke@0 2588 name[len] = '\0';
duke@0 2589
duke@0 2590 char *options = NULL;
duke@0 2591 if(pos != NULL) {
duke@0 2592 size_t len2 = strlen(pos+1) + 1; // options start after ':'. Final zero must be copied.
zgu@3465 2593 options = (char*)memcpy(NEW_C_HEAP_ARRAY(char, len2, mtInternal), pos+1, len2);
duke@0 2594 }
jprovino@3730 2595 #if !INCLUDE_JVMTI
duke@0 2596 if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) {
jprovino@4285 2597 jio_fprintf(defaultStream::error_stream(),
jprovino@4285 2598 "Profiling and debugging agents are not supported in this VM\n");
jprovino@4285 2599 return JNI_ERR;
jprovino@4285 2600 }
jprovino@3730 2601 #endif // !INCLUDE_JVMTI
jprovino@4285 2602 add_init_library(name, options);
duke@0 2603 }
duke@0 2604 // -agentlib and -agentpath
duke@0 2605 } else if (match_option(option, "-agentlib:", &tail) ||
duke@0 2606 (is_absolute_path = match_option(option, "-agentpath:", &tail))) {
duke@0 2607 if(tail != NULL) {
duke@0 2608 const char* pos = strchr(tail, '=');
duke@0 2609 size_t len = (pos == NULL) ? strlen(tail) : pos - tail;
zgu@3465 2610 char* name = strncpy(NEW_C_HEAP_ARRAY(char, len + 1, mtInternal), tail, len);
duke@0 2611 name[len] = '\0';
duke@0 2612
duke@0 2613 char *options = NULL;
duke@0 2614 if(pos != NULL) {
zgu@3465 2615 options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(pos + 1) + 1, mtInternal), pos + 1);
duke@0 2616 }
jprovino@3730 2617 #if !INCLUDE_JVMTI
dholmes@4567 2618 if (valid_hprof_or_jdwp_agent(name, is_absolute_path)) {
jprovino@4285 2619 jio_fprintf(defaultStream::error_stream(),
jprovino@4285 2620 "Profiling and debugging agents are not supported in this VM\n");
jprovino@4285 2621 return JNI_ERR;
jprovino@4285 2622 }
jprovino@3730 2623 #endif // !INCLUDE_JVMTI
duke@0 2624 add_init_agent(name, options, is_absolute_path);
duke@0 2625 }
duke@0 2626 // -javaagent
duke@0 2627 } else if (match_option(option, "-javaagent:", &tail)) {
jprovino@3730 2628 #if !INCLUDE_JVMTI
jprovino@4285 2629 jio_fprintf(defaultStream::error_stream(),
jprovino@4285 2630 "Instrumentation agents are not supported in this VM\n");
jprovino@4285 2631 return JNI_ERR;
jprovino@3730 2632 #else
duke@0 2633 if(tail != NULL) {
zgu@3465 2634 char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtInternal), tail);
duke@0 2635 add_init_agent("instrument", options, false);
duke@0 2636 }
jprovino@3730 2637 #endif // !INCLUDE_JVMTI
duke@0 2638 // -Xnoclassgc
duke@0 2639 } else if (match_option(option, "-Xnoclassgc", &tail)) {
duke@0 2640 FLAG_SET_CMDLINE(bool, ClassUnloading, false);
duke@0 2641 // -Xincgc: i-CMS
duke@0 2642 } else if (match_option(option, "-Xincgc", &tail)) {
duke@0 2643 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true);
duke@0 2644 FLAG_SET_CMDLINE(bool, CMSIncrementalMode, true);
duke@0 2645 // -Xnoincgc: no i-CMS
duke@0 2646 } else if (match_option(option, "-Xnoincgc", &tail)) {
duke@0 2647 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false);
duke@0 2648 FLAG_SET_CMDLINE(bool, CMSIncrementalMode, false);
duke@0 2649 // -Xconcgc
duke@0 2650 } else if (match_option(option, "-Xconcgc", &tail)) {
duke@0 2651 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, true);
duke@0 2652 // -Xnoconcgc
duke@0 2653 } else if (match_option(option, "-Xnoconcgc", &tail)) {
duke@0 2654 FLAG_SET_CMDLINE(bool, UseConcMarkSweepGC, false);
duke@0 2655 // -Xbatch
duke@0 2656 } else if (match_option(option, "-Xbatch", &tail)) {
duke@0 2657 FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
duke@0 2658 // -Xmn for compatibility with other JVM vendors
duke@0 2659 } else if (match_option(option, "-Xmn", &tail)) {
jwilhelm@5421 2660 julong long_initial_young_size = 0;
jwilhelm@5421 2661 ArgsRange errcode = parse_memory_size(tail, &long_initial_young_size, 1);
duke@0 2662 if (errcode != arg_in_range) {
duke@0 2663 jio_fprintf(defaultStream::error_stream(),
jwilhelm@5421 2664 "Invalid initial young generation size: %s\n", option->optionString);
duke@0 2665 describe_range_error(errcode);
duke@0 2666 return JNI_EINVAL;
duke@0 2667 }
jwilhelm@5421 2668 FLAG_SET_CMDLINE(uintx, MaxNewSize, (uintx)long_initial_young_size);
jwilhelm@5421 2669 FLAG_SET_CMDLINE(uintx, NewSize, (uintx)long_initial_young_size);
duke@0 2670 // -Xms
duke@0 2671 } else if (match_option(option, "-Xms", &tail)) {
swamyv@489 2672 julong long_initial_heap_size = 0;
tschatzl@4638 2673 // an initial heap size of 0 means automatically determine
tschatzl@4638 2674 ArgsRange errcode = parse_memory_size(tail, &long_initial_heap_size, 0);
duke@0 2675 if (errcode != arg_in_range) {
duke@0 2676 jio_fprintf(defaultStream::error_stream(),
duke@0 2677 "Invalid initial heap size: %s\n", option->optionString);
duke@0 2678 describe_range_error(errcode);
duke@0 2679 return JNI_EINVAL;
duke@0 2680 }
phh@1064 2681 FLAG_SET_CMDLINE(uintx, InitialHeapSize, (uintx)long_initial_heap_size);
duke@0 2682 // Currently the minimum size and the initial heap sizes are the same.
phh@1064 2683 set_min_heap_size(InitialHeapSize);
duke@0 2684 // -Xmx
tschatzl@4638 2685 } else if (match_option(option, "-Xmx", &tail) || match_option(option, "-XX:MaxHeapSize=", &tail)) {
swamyv@489 2686 julong long_max_heap_size = 0;
duke@0 2687 ArgsRange errcode = parse_memory_size(tail, &long_max_heap_size, 1);
duke@0 2688 if (errcode != arg_in_range) {
duke@0 2689 jio_fprintf(defaultStream::error_stream(),
duke@0 2690 "Invalid maximum heap size: %s\n", option->optionString);
duke@0 2691 describe_range_error(errcode);
duke@0 2692 return JNI_EINVAL;
duke@0 2693 }
phh@1064 2694 FLAG_SET_CMDLINE(uintx, MaxHeapSize, (uintx)long_max_heap_size);
duke@0 2695 // Xmaxf
duke@0 2696 } else if (match_option(option, "-Xmaxf", &tail)) {
sjohanss@5500 2697 char* err;
sjohanss@5500 2698 int maxf = (int)(strtod(tail, &err) * 100);
sjohanss@5500 2699 if (*err != '\0' || maxf < 0 || maxf > 100) {
duke@0 2700 jio_fprintf(defaultStream::error_stream(),
duke@0 2701 "Bad max heap free percentage size: %s\n",
duke@0 2702 option->optionString);
duke@0 2703 return JNI_EINVAL;
duke@0 2704 } else {
duke@0 2705 FLAG_SET_CMDLINE(uintx, MaxHeapFreeRatio, maxf);
duke@0 2706 }
duke@0 2707 // Xminf
duke@0 2708 } else if (match_option(option, "-Xminf", &tail)) {
sjohanss@5500 2709 char* err;
sjohanss@5500 2710 int minf = (int)(strtod(tail, &err) * 100);
sjohanss@5500 2711 if (*err != '\0' || minf < 0 || minf > 100) {
duke@0 2712 jio_fprintf(defaultStream::error_stream(),
duke@0 2713 "Bad min heap free percentage size: %s\n",
duke@0 2714 option->optionString);
duke@0 2715 return JNI_EINVAL;
duke@0 2716 } else {
duke@0 2717 FLAG_SET_CMDLINE(uintx, MinHeapFreeRatio, minf);
duke@0 2718 }
duke@0 2719 // -Xss
duke@0 2720 } else if (match_option(option, "-Xss", &tail)) {
swamyv@489 2721 julong long_ThreadStackSize = 0;
duke@0 2722 ArgsRange errcode = parse_memory_size(tail, &long_ThreadStackSize, 1000);
duke@0 2723 if (errcode != arg_in_range) {
duke@0 2724 jio_fprintf(defaultStream::error_stream(),
duke@0 2725 "Invalid thread stack size: %s\n", option->optionString);
duke@0 2726 describe_range_error(errcode);
duke@0 2727 return JNI_EINVAL;
duke@0 2728 }
duke@0 2729 // Internally track ThreadStackSize in units of 1024 bytes.
duke@0 2730 FLAG_SET_CMDLINE(intx, ThreadStackSize,
duke@0 2731 round_to((int)long_ThreadStackSize, K) / K);
duke@0 2732 // -Xoss
duke@0 2733 } else if (match_option(option, "-Xoss", &tail)) {
duke@0 2734 // HotSpot does not have separate native and Java stacks, ignore silently for compatibility
anoll@4917 2735 } else if (match_option(option, "-XX:CodeCacheExpansionSize=", &tail)) {
anoll@4917 2736 julong long_CodeCacheExpansionSize = 0;
anoll@4917 2737 ArgsRange errcode = parse_memory_size(tail, &long_CodeCacheExpansionSize, os::vm_page_size());
anoll@4917 2738 if (errcode != arg_in_range) {
anoll@4917 2739 jio_fprintf(defaultStream::error_stream(),
anoll@4917 2740 "Invalid argument: %s. Must be at least %luK.\n", option->optionString,
anoll@4917 2741 os::vm_page_size()/K);
anoll@4917 2742 return JNI_EINVAL;
anoll@4917 2743 }
anoll@4917 2744 FLAG_SET_CMDLINE(uintx, CodeCacheExpansionSize, (uintx)long_CodeCacheExpansionSize);
coleenp@1983 2745 } else if (match_option(option, "-Xmaxjitcodesize", &tail) ||
coleenp@1983 2746 match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) {
swamyv@489 2747 julong long_ReservedCodeCacheSize = 0;
anoll@4917 2748
anoll@4789 2749 ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize, 1);
duke@0 2750 if (errcode != arg_in_range) {
duke@0 2751 jio_fprintf(defaultStream::error_stream(),
anoll@4789 2752 "Invalid maximum code cache size: %s.\n", option->optionString);
duke@0 2753 return JNI_EINVAL;
duke@0 2754 }
duke@0 2755 FLAG_SET_CMDLINE(uintx, ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize);
anoll@4716 2756 //-XX:IncreaseFirstTierCompileThresholdAt=
anoll@4716 2757 } else if (match_option(option, "-XX:IncreaseFirstTierCompileThresholdAt=", &tail)) {
anoll@4716 2758 uintx uint_IncreaseFirstTierCompileThresholdAt = 0;
anoll@4716 2759 if (!parse_uintx(tail, &uint_IncreaseFirstTierCompileThresholdAt, 0) || uint_IncreaseFirstTierCompileThresholdAt > 99) {
anoll@4716 2760 jio_fprintf(defaultStream::error_stream(),
anoll@4716 2761 "Invalid value for IncreaseFirstTierCompileThresholdAt: %s. Should be between 0 and 99.\n",
anoll@4716 2762 option->optionString);
anoll@4716 2763 return JNI_EINVAL;
anoll@4716 2764 }
anoll@4716 2765 FLAG_SET_CMDLINE(uintx, IncreaseFirstTierCompileThresholdAt, (uintx)uint_IncreaseFirstTierCompileThresholdAt);
duke@0 2766 // -green
duke@0 2767 } else if (match_option(option, "-green", &tail)) {
duke@0 2768 jio_fprintf(defaultStream::error_stream(),
duke@0 2769 "Green threads support not available\n");
duke@0 2770 return JNI_EINVAL;
duke@0 2771 // -native
duke@0 2772 } else if (match_option(option, "-native", &tail)) {
duke@0 2773 // HotSpot always uses native threads, ignore silently for compatibility
duke@0 2774 // -Xsqnopause
duke@0 2775 } else if (match_option(option, "-Xsqnopause", &tail)) {
duke@0 2776 // EVM option, ignore silently for compatibility
duke@0 2777 // -Xrs
duke@0 2778 } else if (match_option(option, "-Xrs", &tail)) {
duke@0 2779 // Classic/EVM option, new functionality
duke@0 2780 FLAG_SET_CMDLINE(bool, ReduceSignalUsage, true);
duke@0 2781 } else if (match_option(option, "-Xusealtsigs", &tail)) {
duke@0 2782 // change default internal VM signals used - lower case for back compat
duke@0 2783 FLAG_SET_CMDLINE(bool, UseAltSigs, true);
duke@0 2784 // -Xoptimize
duke@0 2785 } else if (match_option(option, "-Xoptimize", &tail)) {
duke@0 2786 // EVM option, ignore silently for compatibility
duke@0 2787 // -Xprof
duke@0 2788 } else if (match_option(option, "-Xprof", &tail)) {
jprovino@3730 2789 #if INCLUDE_FPROF
duke@0 2790 _has_profile = true;
jprovino@3730 2791 #else // INCLUDE_FPROF
jprovino@4285 2792 jio_fprintf(defaultStream::error_stream(),
jprovino@4285 2793 "Flat profiling is not supported in this VM.\n");
jprovino@4285 2794 return JNI_ERR;
jprovino@3730 2795 #endif // INCLUDE_FPROF
duke@0 2796 // -Xconcurrentio
duke@0 2797 } else if (match_option(option, "-Xconcurrentio", &tail)) {
duke@0 2798 FLAG_SET_CMDLINE(bool, UseLWPSynchronization, true);
duke@0 2799 FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
duke@0 2800 FLAG_SET_CMDLINE(intx, DeferThrSuspendLoopCount, 1);
duke@0 2801 FLAG_SET_CMDLINE(bool, UseTLAB, false);
duke@0 2802 FLAG_SET_CMDLINE(uintx, NewSizeThreadIncrease, 16 * K); // 20Kb per thread added to new generation
duke@0 2803
duke@0 2804 // -Xinternalversion
duke@0 2805 } else if (match_option(option, "-Xinternalversion", &tail)) {
duke@0 2806 jio_fprintf(defaultStream::output_stream(), "%s\n",
duke@0 2807 VM_Version::internal_vm_info_string());
duke@0 2808 vm_exit(0);
duke@0 2809 #ifndef PRODUCT
duke@0 2810 // -Xprintflags
duke@0 2811 } else if (match_option(option, "-Xprintflags", &tail)) {
fparain@2967 2812 CommandLineFlags::printFlags(tty, false);
duke@0 2813 vm_exit(0);
duke@0 2814 #endif
duke@0 2815 // -D
duke@0 2816 } else if (match_option(option, "-D", &tail)) {
duke@0 2817 if (!add_property(tail)) {
duke@0 2818 return JNI_ENOMEM;
duke@0 2819 }
duke@0 2820 // Out of the box management support
duke@0 2821 if (match_option(option, "-Dcom.sun.management", &tail)) {
jprovino@4187 2822 #if INCLUDE_MANAGEMENT
duke@0 2823 FLAG_SET_CMDLINE(bool, ManagementServer, true);
jprovino@4187 2824 #else
jprovino@4285 2825 jio_fprintf(defaultStream::output_stream(),
jprovino@4285 2826 "-Dcom.sun.management is not supported in this VM.\n");
jprovino@4285 2827 return JNI_ERR;
jprovino@4187 2828 #endif
duke@0 2829 }
duke@0 2830 // -Xint
duke@0 2831 } else if (match_option(option, "-Xint", &tail)) {
duke@0 2832 set_mode_flags(_int);
duke@0 2833 // -Xmixed
duke@0 2834 } else if (match_option(option, "-Xmixed", &tail)) {
duke@0 2835 set_mode_flags(_mixed);
duke@0 2836 // -Xcomp
duke@0 2837 } else if (match_option(option, "-Xcomp", &tail)) {
duke@0 2838 // for testing the compiler; turn off all flags that inhibit compilation
duke@0 2839 set_mode_flags(_comp);
duke@0 2840 // -Xshare:dump
duke@0 2841 } else if (match_option(option, "-Xshare:dump", &tail)) {
duke@0 2842 FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true);
duke@0 2843 set_mode_flags(_int); // Prevent compilation, which creates objects
duke@0 2844 // -Xshare:on
duke@0 2845 } else if (match_option(option, "-Xshare:on", &tail)) {
duke@0 2846 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
duke@0 2847 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true);
duke@0 2848 // -Xshare:auto
duke@0 2849 } else if (match_option(option, "-Xshare:auto", &tail)) {
duke@0 2850 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
duke@0 2851 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false);
duke@0 2852 // -Xshare:off
duke@0 2853 } else if (match_option(option, "-Xshare:off", &tail)) {
duke@0 2854 FLAG_SET_CMDLINE(bool, UseSharedSpaces, false);
duke@0 2855 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false);
duke@0 2856 // -Xverify
duke@0 2857 } else if (match_option(option, "-Xverify", &tail)) {
duke@0 2858 if (strcmp(tail, ":all") == 0 || strcmp(tail, "") == 0) {
duke@0 2859 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, true);
duke@0 2860 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true);
duke@0 2861 } else if (strcmp(tail, ":remote") == 0) {
duke@0 2862 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false);
duke@0 2863 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, true);
duke@0 2864 } else if (strcmp(tail, ":none") == 0) {
duke@0 2865 FLAG_SET_CMDLINE(bool, BytecodeVerificationLocal, false);
duke@0 2866 FLAG_SET_CMDLINE(bool, BytecodeVerificationRemote, false);
duke@0 2867 } else if (is_bad_option(option, args->ignoreUnrecognized, "verification")) {
duke@0 2868 return JNI_EINVAL;
duke@0 2869 }
duke@0 2870 // -Xdebug
duke@0 2871 } else if (match_option(option, "-Xdebug", &tail)) {
duke@0 2872 // note this flag has been used, then ignore
duke@0 2873 set_xdebug_mode(true);
duke@0 2874 // -Xnoagent
duke@0 2875 } else if (match_option(option, "-Xnoagent", &tail)) {
duke@0 2876 // For compatibility with classic. HotSpot refuses to load the old style agent.dll.
duke@0 2877 } else if (match_option(option, "-Xboundthreads", &tail)) {
duke@0 2878 // Bind user level threads to kernel threads (Solaris only)
duke@0 2879 FLAG_SET_CMDLINE(bool, UseBoundThreads, true);
duke@0 2880 } else if (match_option(option, "-Xloggc:", &tail)) {
duke@0 2881 // Redirect GC output to the file. -Xloggc:<filename>
duke@0 2882 // ostream_init_log(), when called will use this filename
duke@0 2883 // to initialize a fileStream.
duke@0 2884 _gc_log_filename = strdup(tail);
minqi@5248 2885 if (!is_filename_valid(_gc_log_filename)) {
minqi@5248 2886 jio_fprintf(defaultStream::output_stream(),
minqi@5248 2887 "Invalid file name for use with -Xloggc: Filename can only contain the "
minqi@5248 2888 "characters [A-Z][a-z][0-9]-_.%%[p|t] but it has been %s\n"
minqi@5248 2889 "Note %%p or %%t can only be used once\n", _gc_log_filename);
minqi@5248 2890 return JNI_EINVAL;
minqi@5248 2891 }
duke@0 2892 FLAG_SET_CMDLINE(bool, PrintGC, true);
duke@0 2893 FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true);
duke@0 2894
duke@0 2895 // JNI hooks
duke@0 2896 } else if (match_option(option, "-Xcheck", &tail)) {
duke@0 2897 if (!strcmp(tail, ":jni")) {
jprovino@3730 2898 #if !INCLUDE_JNI_CHECK
jprovino@3730 2899 warning("JNI CHECKING is not supported in this VM");
jprovino@3730 2900 #else
duke@0 2901 CheckJNICalls = true;
jprovino@3730 2902 #endif // INCLUDE_JNI_CHECK
duke@0 2903 } else if (is_bad_option(option, args->ignoreUnrecognized,
duke@0 2904 "check")) {
duke@0 2905 return JNI_EINVAL;
duke@0 2906 }
duke@0 2907 } else if (match_option(option, "vfprintf", &tail)) {
duke@0 2908 _vfprintf_hook = CAST_TO_FN_PTR(vfprintf_hook_t, option->extraInfo);
duke@0 2909 } else if (match_option(option, "exit", &tail)) {
duke@0 2910 _exit_hook = CAST_TO_FN_PTR(exit_hook_t, option->extraInfo);
duke@0 2911 } else if (match_option(option, "abort", &tail)) {
duke@0 2912 _abort_hook = CAST_TO_FN_PTR(abort_hook_t, option->extraInfo);
duke@0 2913 // -XX:+AggressiveHeap
duke@0 2914 } else if (match_option(option, "-XX:+AggressiveHeap", &tail)) {
duke@0 2915
duke@0 2916 // This option inspects the machine and attempts to set various
duke@0 2917 // parameters to be optimal for long-running, memory allocation
duke@0 2918 // intensive jobs. It is intended for machines with large
duke@0 2919 // amounts of cpu and memory.
duke@0 2920
duke@0 2921 // initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
duke@0 2922 // VM, but we may not be able to represent the total physical memory
duke@0 2923 // available (like having 8gb of memory on a box but using a 32bit VM).
duke@0 2924 // Thus, we need to make sure we're using a julong for intermediate
duke@0 2925 // calculations.
duke@0 2926 julong initHeapSize;
duke@0 2927 julong total_memory = os::physical_memory();
duke@0 2928
duke@0 2929 if (total_memory < (julong)256*M) {
duke@0 2930 jio_fprintf(defaultStream::error_stream(),
duke@0 2931 "You need at least 256mb of memory to use -XX:+AggressiveHeap\n");
duke@0 2932 vm_exit(1);
duke@0 2933 }
duke@0 2934
duke@0 2935 // The heap size is half of available memory, or (at most)
duke@0 2936 // all of possible memory less 160mb (leaving room for the OS
duke@0 2937 // when using ISM). This is the maximum; because adaptive sizing
duke@0 2938 // is turned on below, the actual space used may be smaller.
duke@0 2939
duke@0 2940 initHeapSize = MIN2(total_memory / (julong)2,
duke@0 2941 total_memory - (julong)160*M);
duke@0 2942
tschatzl@4419 2943 initHeapSize = limit_by_allocatable_memory(initHeapSize);
duke@0 2944
duke@0 2945 if (FLAG_IS_DEFAULT(MaxHeapSize)) {
duke@0 2946 FLAG_SET_CMDLINE(uintx, MaxHeapSize, initHeapSize);
phh@1064 2947 FLAG_SET_CMDLINE(uintx, InitialHeapSize, initHeapSize);
duke@0 2948 // Currently the minimum size and the initial heap sizes are the same.
phh@1064 2949 set_min_heap_size(initHeapSize);
duke@0 2950 }
duke@0 2951 if (FLAG_IS_DEFAULT(NewSize)) {
duke@0 2952 // Make the young generation 3/8ths of the total heap.
duke@0 2953 FLAG_SET_CMDLINE(uintx, NewSize,
duke@0 2954 ((julong)MaxHeapSize / (julong)8) * (julong)3);
duke@0 2955 FLAG_SET_CMDLINE(uintx, MaxNewSize, NewSize);
duke@0 2956 }
duke@0 2957
coleenp@3793 2958 #ifndef _ALLBSD_SOURCE // UseLargePages is not yet supported on BSD.
duke@0 2959 FLAG_SET_DEFAULT(UseLargePages, true);
coleenp@3793 2960 #endif
duke@0 2961
duke@0 2962 // Increase some data structure sizes for efficiency
duke@0 2963 FLAG_SET_CMDLINE(uintx, BaseFootPrintEstimate, MaxHeapSize);
duke@0 2964 FLAG_SET_CMDLINE(bool, ResizeTLAB, false);
duke@0 2965 FLAG_SET_CMDLINE(uintx, TLABSize, 256*K);
duke@0 2966
duke@0 2967 // See the OldPLABSize comment below, but replace 'after promotion'
duke@0 2968 // with 'after copying'. YoungPLABSize is the size of the survivor
duke@0 2969 // space per-gc-thread buffers. The default is 4kw.
duke@0 2970 FLAG_SET_CMDLINE(uintx, YoungPLABSize, 256*K); // Note: this is in words
duke@0 2971
duke@0 2972 // OldPLABSize is the size of the buffers in the old gen that
duke@0 2973 // UseParallelGC uses to promote live data that doesn't fit in the
duke@0 2974 // survivor spaces. At any given time, there's one for each gc thread.
duke@0 2975 // The default size is 1kw. These buffers are rarely used, since the
duke@0 2976 // survivor spaces are usually big enough. For specjbb, however, there
duke@0 2977 // are occasions when there's lots of live data in the young gen
duke@0 2978 // and we end up promoting some of it. We don't have a definite
duke@0 2979 // explanation for why bumping OldPLABSize helps, but the theory
duke@0 2980 // is that a bigger PLAB results in retaining something like the
duke@0 2981 // original allocation order after promotion, which improves mutator
duke@0 2982 // locality. A minor effect may be that larger PLABs reduce the
duke@0 2983 // number of PLAB allocation events during gc. The value of 8kw
duke@0 2984 // was arrived at by experimenting with specjbb.
duke@0 2985 FLAG_SET_CMDLINE(uintx, OldPLABSize, 8*K); // Note: this is in words
duke@0 2986
duke@0 2987 // Enable parallel GC and adaptive generation sizing
duke@0 2988 FLAG_SET_CMDLINE(bool, UseParallelGC, true);
jmasa@10 2989 FLAG_SET_DEFAULT(ParallelGCThreads,
jmasa@10 2990 Abstract_VM_Version::parallel_worker_threads());
duke@0 2991
duke@0 2992 // Encourage steady state memory management
duke@0 2993 FLAG_SET_CMDLINE(uintx, ThresholdTolerance, 100);
duke@0 2994
duke@0 2995 // This appears to improve mutator locality
duke@0 2996 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
duke@0 2997
duke@0 2998 // Get around early Solaris scheduling bug
duke@0 2999 // (affinity vs other jobs on system)
duke@0 3000 // but disallow DR and offlining (5008695).
duke@0 3001 FLAG_SET_CMDLINE(bool, BindGCTaskThreadsToCPUs, true);
duke@0 3002
duke@0 3003 } else if (match_option(option, "-XX:+NeverTenure", &tail)) {
duke@0 3004 // The last option must always win.
duke@0 3005 FLAG_SET_CMDLINE(bool, AlwaysTenure, false);
duke@0 3006 FLAG_SET_CMDLINE(bool, NeverTenure, true);
duke@0 3007 } else if (match_option(option, "-XX:+AlwaysTenure", &tail)) {
duke@0 3008 // The last option must always win.
duke@0 3009 FLAG_SET_CMDLINE(bool, NeverTenure, false);
duke@0 3010 FLAG_SET_CMDLINE(bool, AlwaysTenure, true);
duke@0 3011 } else if (match_option(option, "-XX:+CMSPermGenSweepingEnabled", &tail) ||
duke@0 3012 match_option(option, "-XX:-CMSPermGenSweepingEnabled", &tail)) {
duke@0 3013 jio_fprintf(defaultStream::error_stream(),
duke@0 3014 "Please use CMSClassUnloadingEnabled in place of "
duke@0 3015 "CMSPermGenSweepingEnabled in the future\n");
duke@0 3016 } else if (match_option(option, "-XX:+UseGCTimeLimit", &tail)) {
duke@0 3017 FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, true);
duke@0 3018 jio_fprintf(defaultStream::error_stream(),
duke@0 3019 "Please use -XX:+UseGCOverheadLimit in place of "
duke@0 3020 "-XX:+UseGCTimeLimit in the future\n");
duke@0 3021 } else if (match_option(option, "-XX:-UseGCTimeLimit", &tail)) {
duke@0 3022 FLAG_SET_CMDLINE(bool, UseGCOverheadLimit, false);
duke@0 3023 jio_fprintf(defaultStream::error_stream(),
duke@0 3024 "Please use -XX:-UseGCOverheadLimit in place of "
duke@0 3025 "-XX:-UseGCTimeLimit in the future\n");
duke@0 3026 // The TLE options are for compatibility with 1.3 and will be
duke@0 3027 // removed without notice in a future release. These options
duke@0 3028 // are not to be documented.
duke@0 3029 } else if (match_option(option, "-XX:MaxTLERatio=", &tail)) {
duke@0 3030 // No longer used.
duke@0 3031 } else if (match_option(option, "-XX:+ResizeTLE", &tail)) {
duke@0 3032 FLAG_SET_CMDLINE(bool, ResizeTLAB, true);
duke@0 3033 } else if (match_option(option, "-XX:-ResizeTLE", &tail)) {
duke@0 3034 FLAG_SET_CMDLINE(bool, ResizeTLAB, false);
duke@0 3035 } else if (match_option(option, "-XX:+PrintTLE", &tail)) {
duke@0 3036 FLAG_SET_CMDLINE(bool, PrintTLAB, true);
duke@0 3037 } else if (match_option(option, "-XX:-PrintTLE", &tail)) {
duke@0 3038 FLAG_SET_CMDLINE(bool, PrintTLAB, false);
duke@0 3039 } else if (match_option(option, "-XX:TLEFragmentationRatio=", &tail)) {
duke@0 3040 // No longer used.
duke@0 3041 } else if (match_option(option, "-XX:TLESize=", &tail)) {
swamyv@489 3042 julong long_tlab_size = 0;
duke@0 3043 ArgsRange errcode = parse_memory_size(tail, &long_tlab_size, 1);
duke@0 3044 if (errcode != arg_in_range) {
duke@0 3045 jio_fprintf(defaultStream::error_stream(),
duke@0 3046 "Invalid TLAB size: %s\n", option->optionString);
duke@0 3047 describe_range_error(errcode);
duke@0 3048 return JNI_EINVAL;
duke@0 3049 }
duke@0 3050 FLAG_SET_CMDLINE(uintx, TLABSize, long_tlab_size);
duke@0 3051 } else if (match_option(option, "-XX:TLEThreadRatio=", &tail)) {
duke@0 3052 // No longer used.
duke@0 3053 } else if (match_option(option, "-XX:+UseTLE", &tail)) {
duke@0 3054 FLAG_SET_CMDLINE(bool, UseTLAB, true);
duke@0 3055 } else if (match_option(option, "-XX:-UseTLE", &tail)) {
duke@0 3056 FLAG_SET_CMDLINE(bool, UseTLAB, false);
duke@0 3057 } else if (match_option(option, "-XX:+DisplayVMOutputToStderr", &tail)) {
duke@0 3058 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, false);
duke@0 3059 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, true);
duke@0 3060 } else if (match_option(option, "-XX:+DisplayVMOutputToStdout", &tail)) {
duke@0 3061 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStderr, false);
duke@0 3062 FLAG_SET_CMDLINE(bool, DisplayVMOutputToStdout, true);
duke@0 3063 } else if (match_option(option, "-XX:+ExtendedDTraceProbes", &tail)) {
dcubed@2767 3064 #if defined(DTRACE_ENABLED)
duke@0 3065 FLAG_SET_CMDLINE(bool, ExtendedDTraceProbes, true);
duke@0 3066 FLAG_SET_CMDLINE(bool, DTraceMethodProbes, true);
duke@0 3067 FLAG_SET_CMDLINE(bool, DTraceAllocProbes, true);
duke@0 3068 FLAG_SET_CMDLINE(bool, DTraceMonitorProbes, true);
dcubed@2767 3069 #else // defined(DTRACE_ENABLED)
duke@0 3070 jio_fprintf(defaultStream::error_stream(),
dcubed@2767 3071 "ExtendedDTraceProbes flag is not applicable for this configuration\n");
duke@0 3072 return JNI_EINVAL;
dcubed@2767 3073 #endif // defined(DTRACE_ENABLED)
duke@0 3074 #ifdef ASSERT
ysr@1145 3075 } else if (match_option(option, "-XX:+FullGCALot", &tail)) {
duke@0 3076 FLAG_SET_CMDLINE(bool, FullGCALot, true);
duke@0 3077 // disable scavenge before parallel mark-compact
duke@0 3078 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
duke@0 3079 #endif
ysr@1145 3080 } else if (match_option(option, "-XX:CMSParPromoteBlocksToClaim=", &tail)) {
duke@0 3081 julong cms_blocks_to_claim = (julong)atol(tail);
duke@0 3082 FLAG_SET_CMDLINE(uintx, CMSParPromoteBlocksToClaim, cms_blocks_to_claim);
duke@0 3083 jio_fprintf(defaultStream::error_stream(),
ysr@1145 3084 "Please use -XX:OldPLABSize in place of "
ysr@1145 3085 "-XX:CMSParPromoteBlocksToClaim in the future\n");
ysr@1145 3086 } else if (match_option(option, "-XX:ParCMSPromoteBlocksToClaim=", &tail)) {
ysr@1145 3087 julong cms_blocks_to_claim = (julong)atol(tail);
ysr@1145 3088 FLAG_SET_CMDLINE(uintx, CMSParPromoteBlocksToClaim, cms_blocks_to_claim);
ysr@1145 3089 jio_fprintf(defaultStream::error_stream(),
ysr@1145 3090 "Please use -XX:OldPLABSize in place of "
duke@0 3091 "-XX:ParCMSPromoteBlocksToClaim in the future\n");
ysr@1145 3092 } else if (match_option(option, "-XX:ParallelGCOldGenAllocBufferSize=", &tail)) {
swamyv@489 3093 julong old_plab_size = 0;
duke@0 3094 ArgsRange errcode = parse_memory_size(tail, &old_plab_size, 1);
duke@0 3095 if (errcode != arg_in_range) {
duke@0 3096 jio_fprintf(defaultStream::error_stream(),
duke@0 3097 "Invalid old PLAB size: %s\n", option->optionString);
duke@0 3098 describe_range_error(errcode);
duke@0 3099 return JNI_EINVAL;
duke@0 3100 }
swamyv@489 3101 FLAG_SET_CMDLINE(uintx, OldPLABSize, old_plab_size);
duke@0 3102 jio_fprintf(defaultStream::error_stream(),
duke@0 3103 "Please use -XX:OldPLABSize in place of "
duke@0 3104 "-XX:ParallelGCOldGenAllocBufferSize in the future\n");
ysr@1145 3105 } else if (match_option(option, "-XX:ParallelGCToSpaceAllocBufferSize=", &tail)) {
swamyv@489 3106 julong young_plab_size = 0;
duke@0 3107 ArgsRange errcode = parse_memory_size(tail, &young_plab_size, 1);
duke@0 3108 if (errcode != arg_in_range) {
duke@0 3109 jio_fprintf(defaultStream::error_stream(),
duke@0 3110 "Invalid young PLAB size: %s\n", option->optionString);
duke@0 3111 describe_range_error(errcode);
duke@0 3112 return JNI_EINVAL;
duke@0 3113 }
swamyv@489 3114 FLAG_SET_CMDLINE(uintx, YoungPLABSize, young_plab_size);
duke@0 3115 jio_fprintf(defaultStream::error_stream(),
duke@0 3116 "Please use -XX:YoungPLABSize in place of "
duke@0 3117 "-XX:ParallelGCToSpaceAllocBufferSize in the future\n");
jmasa@1284 3118 } else if (match_option(option, "-XX:CMSMarkStackSize=", &tail) ||
jmasa@1284 3119 match_option(option, "-XX:G1MarkStackSize=", &tail)) {
jmasa@1284 3120 julong stack_size = 0;
jmasa@1284 3121 ArgsRange errcode = parse_memory_size(tail, &stack_size, 1);
jmasa@1284 3122 if (errcode != arg_in_range) {
jmasa@1284 3123 jio_fprintf(defaultStream::error_stream(),
jmasa@1284 3124 "Invalid mark stack size: %s\n", option->optionString);
jmasa@1284 3125 describe_range_error(errcode);
jmasa@1284 3126 return JNI_EINVAL;
jmasa@1284 3127 }
jmasa@1284 3128 FLAG_SET_CMDLINE(uintx, MarkStackSize, stack_size);
jmasa@1284 3129 } else if (match_option(option, "-XX:CMSMarkStackSizeMax=", &tail)) {
jmasa@1284 3130 julong max_stack_size = 0;
jmasa@1284 3131 ArgsRange errcode = parse_memory_size(tail, &max_stack_size, 1);
jmasa@1284 3132 if (errcode != arg_in_range) {
jmasa@1284 3133 jio_fprintf(defaultStream::error_stream(),
jmasa@1284 3134 "Invalid maximum mark stack size: %s\n",
jmasa@1284 3135 option->optionString);
jmasa@1284 3136 describe_range_error(errcode);
jmasa@1284 3137 return JNI_EINVAL;
jmasa@1284 3138 }
jmasa@1284 3139 FLAG_SET_CMDLINE(uintx, MarkStackSizeMax, max_stack_size);
jmasa@1284 3140 } else if (match_option(option, "-XX:ParallelMarkingThreads=", &tail) ||
jmasa@1284 3141 match_option(option, "-XX:ParallelCMSThreads=", &tail)) {
jmasa@1284 3142 uintx conc_threads = 0;
jmasa@1284 3143 if (!parse_uintx(tail, &conc_threads, 1)) {
jmasa@1284 3144 jio_fprintf(defaultStream::error_stream(),
jmasa@1284 3145 "Invalid concurrent threads: %s\n", option->optionString);
jmasa@1284 3146 return JNI_EINVAL;
jmasa@1284 3147 }
jmasa@1284 3148 FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads);
dholmes@3467 3149 } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) {
dholmes@3467 3150 julong max_direct_memory_size = 0;
dholmes@3467 3151 ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0);
dholmes@3467 3152 if (errcode != arg_in_range) {
dholmes@3467 3153 jio_fprintf(defaultStream::error_stream(),
dholmes@3467 3154 "Invalid maximum direct memory size: %s\n",
dholmes@3467 3155 option->optionString);
dholmes@3467 3156 describe_range_error(errcode);
dholmes@3467 3157 return JNI_EINVAL;
dholmes@3467 3158 }
dholmes@3467 3159 FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size);
coleenp@3754 3160 } else if (match_option(option, "-XX:+UseVMInterruptibleIO", &tail)) {
coleenp@3754 3161 // NOTE! In JDK 9, the UseVMInterruptibleIO flag will completely go
coleenp@3754 3162 // away and will cause VM initialization failures!
coleenp@3754 3163 warning("-XX:+UseVMInterruptibleIO is obsolete and will be removed in a future release.");
coleenp@3754 3164 FLAG_SET_CMDLINE(bool, UseVMInterruptibleIO, true);
jprovino@4187 3165 #if !INCLUDE_MANAGEMENT
jprovino@4187 3166 } else if (match_option(option, "-XX:+ManagementServer", &tail)) {
jprovino@4285 3167 jio_fprintf(defaultStream::error_stream(),
jprovino@4285 3168 "ManagementServer is not supported in this VM.\n");
jprovino@4285 3169 return JNI_ERR;
jprovino@4187 3170 #endif // INCLUDE_MANAGEMENT
ysr@1145 3171 } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
duke@0 3172 // Skip -XX:Flags= since that case has already been handled
duke@0 3173 if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {
duke@0 3174 if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
duke@0 3175 return JNI_EINVAL;
duke@0 3176 }
duke@0 3177 }
duke@0 3178 // Unknown option
duke@0 3179 } else if (is_bad_option(option, args->ignoreUnrecognized)) {
duke@0 3180 return JNI_ERR;
duke@0 3181 }
duke@0 3182 }
minqi@2529 3183
xlu@449 3184 // Change the default value for flags which have different default values
xlu@449 3185 // when working with older JDKs.
aph@1599 3186 #ifdef LINUX
aph@1599 3187 if (JDK_Version::current().compare_major(6) <= 0 &&
aph@1599 3188 FLAG_IS_DEFAULT(UseLinuxPosixThreadCPUClocks)) {
aph@1599 3189 FLAG_SET_DEFAULT(UseLinuxPosixThreadCPUClocks, false);
aph@1599 3190 }
aph@1599 3191 #endif // LINUX
duke@0 3192 return JNI_OK;
duke@0 3193 }
duke@0 3194
duke@0 3195 jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required) {
duke@0 3196 // This must be done after all -D arguments have been processed.
duke@0 3197 scp_p->expand_endorsed();
duke@0 3198
duke@0 3199 if (scp_assembly_required || scp_p->get_endorsed() != NULL) {
duke@0 3200 // Assemble the bootclasspath elements into the final path.
duke@0 3201 Arguments::set_sysclasspath(scp_p->combined_path());
duke@0 3202 }
duke@0 3203
duke@0 3204 // This must be done after all arguments have been processed.
duke@0 3205 // java_compiler() true means set to "NONE" or empty.
duke@0 3206 if (java_compiler() && !xdebug_mode()) {
duke@0 3207 // For backwards compatibility, we switch to interpreted mode if
duke@0 3208 // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
duke@0 3209 // not specified.
duke@0 3210 set_mode_flags(_int);
duke@0 3211 }
duke@0 3212 if (CompileThreshold == 0) {
duke@0 3213 set_mode_flags(_int);
duke@0 3214 }
duke@0 3215
tschatzl@4689 3216 // eventually fix up InitialTenuringThreshold if only MaxTenuringThreshold is set
tschatzl@4689 3217 if (FLAG_IS_DEFAULT(InitialTenuringThreshold) && (InitialTenuringThreshold > MaxTenuringThreshold)) {
tschatzl@4689 3218 FLAG_SET_ERGO(uintx, InitialTenuringThreshold, MaxTenuringThreshold);
tschatzl@4689 3219 }
tschatzl@4689 3220
duke@0 3221 #ifndef COMPILER2
duke@0 3222 // Don't degrade server performance for footprint
duke@0 3223 if (FLAG_IS_DEFAULT(UseLargePages) &&
duke@0 3224 MaxHeapSize < LargePageHeapSizeThreshold) {
duke@0 3225 // No need for large granularity pages w/small heaps.
duke@0 3226 // Note that large pages are enabled/disabled for both the
duke@0 3227 // Java heap and the code cache.
duke@0 3228 FLAG_SET_DEFAULT(UseLargePages, false);
duke@0 3229 }
ysr@342 3230
duke@0 3231 #else
duke@0 3232 if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
duke@0 3233 FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
duke@0 3234 }
duke@0 3235 #endif
duke@0 3236
iignatyev@5050 3237 #ifndef TIERED
iignatyev@5050 3238 // Tiered compilation is undefined.
iignatyev@5050 3239 UNSUPPORTED_OPTION(TieredCompilation, "TieredCompilation");
iignatyev@5050 3240 #endif
iignatyev@5050 3241
bobv@1601 3242 // If we are running in a headless jre, force java.awt.headless property
bobv@1601 3243 // to be true unless the property has already been set.
bobv@1601 3244 // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
bobv@1601 3245 if (os::is_headless_jre()) {
bobv@1601 3246 const char* headless = Arguments::get_property("java.awt.headless");
bobv@1601 3247 if (headless == NULL) {
bobv@1601 3248 char envbuffer[128];
bobv@1601 3249 if (!os::getenv("JAVA_AWT_HEADLESS", envbuffer, sizeof(envbuffer))) {
bobv@1601 3250 if (!add_property("java.awt.headless=true")) {
bobv@1601 3251 return JNI_ENOMEM;
bobv@1601 3252 }
bobv@1601 3253 } else {
bobv@1601 3254 char buffer[256];
bobv@1601 3255 strcpy(buffer, "java.awt.headless=");
bobv@1601 3256 strcat(buffer, envbuffer);
bobv@1601 3257 if (!add_property(buffer)) {
bobv@1601 3258 return JNI_ENOMEM;
bobv@1601 3259 }
bobv@1601 3260 }
bobv@1601 3261 }
bobv@1601 3262 }
bobv@1601 3263
duke@0 3264 if (!check_vm_args_consistency()) {
duke@0 3265 return JNI_ERR;
duke@0 3266 }
duke@0 3267
duke@0 3268 return JNI_OK;
duke@0 3269 }
duke@0 3270
duke@0 3271 jint Arguments::parse_java_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) {
duke@0 3272 return parse_options_environment_variable("_JAVA_OPTIONS", scp_p,
duke@0 3273 scp_assembly_required_p);
duke@0 3274 }
duke@0 3275
duke@0 3276 jint Arguments::parse_java_tool_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p) {
duke@0 3277 return parse_options_environment_variable("JAVA_TOOL_OPTIONS", scp_p,
duke@0 3278 scp_assembly_required_p);
duke@0 3279 }
duke@0 3280
duke@0 3281 jint Arguments::parse_options_environment_variable(const char* name, SysClassPath* scp_p, bool* scp_assembly_required_p) {
duke@0 3282 const int N_MAX_OPTIONS = 64;
duke@0 3283 const int OPTION_BUFFER_SIZE = 1024;
duke@0 3284 char buffer[OPTION_BUFFER_SIZE];
duke@0 3285
duke@0 3286 // The variable will be ignored if it exceeds the length of the buffer.
duke@0 3287 // Don't check this variable if user has special privileges
duke@0 3288 // (e.g. unix su command).
duke@0 3289 if (os::getenv(name, buffer, sizeof(buffer)) &&
duke@0 3290 !os::have_special_privileges()) {
duke@0 3291 JavaVMOption options[N_MAX_OPTIONS]; // Construct option array
duke@0 3292 jio_fprintf(defaultStream::error_stream(),
duke@0 3293 "Picked up %s: %s\n", name, buffer);
duke@0 3294 char* rd = buffer; // pointer to the input string (rd)
duke@0 3295 int i;
duke@0 3296 for (i = 0; i < N_MAX_OPTIONS;) { // repeat for all options in the input string
duke@0 3297 while (isspace(*rd)) rd++; // skip whitespace
duke@0 3298 if (*rd == 0) break; // we re done when the input string is read completely
duke@0 3299
duke@0 3300 // The output, option string, overwrites the input string.
duke@0 3301 // Because of quoting, the pointer to the option string (wrt) may lag the pointer to
duke@0 3302 // input string (rd).
duke@0 3303 char* wrt = rd;
duke@0 3304
duke@0 3305 options[i++].optionString = wrt; // Fill in option
duke@0 3306 while (*rd != 0 && !isspace(*rd)) { // unquoted strings terminate with a space or NULL
duke@0 3307 if (*rd == '\'' || *rd == '"') { // handle a quoted string
duke@0 3308 int quote = *rd; // matching quote to look for
duke@0 3309 rd++; // don't copy open quote
duke@0 3310 while (*rd != quote) { // include everything (even spaces) up until quote
duke@0 3311 if (*rd == 0) { // string termination means unmatched string
duke@0 3312 jio_fprintf(defaultStream::error_stream(),
duke@0 3313 "Unmatched quote in %s\n", name);
duke@0 3314 return JNI_ERR;
duke@0 3315 }
duke@0 3316 *wrt++ = *rd++; // copy to option string
duke@0 3317 }
duke@0 3318 rd++; // don't copy close quote
duke@0 3319 } else {
duke@0 3320 *wrt++ = *rd++; // copy to option string
duke@0 3321 }
duke@0 3322 }
duke@0 3323 // Need to check if we're done before writing a NULL,
duke@0 3324 // because the write could be to the byte that rd is pointing to.
duke@0 3325 if (*rd++ == 0) {
duke@0 3326 *wrt = 0;
duke@0 3327 break;
duke@0 3328 }
duke@0 3329 *wrt = 0; // Zero terminate option
duke@0 3330 }
duke@0 3331 // Construct JavaVMInitArgs structure and parse as if it was part of the command line
duke@0 3332 JavaVMInitArgs vm_args;
duke@0 3333 vm_args.version = JNI_VERSION_1_2;
duke@0 3334 vm_args.options = options;
duke@0 3335 vm_args.nOptions = i;
kvn@564 3336 vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions;
duke@0 3337
duke@0 3338 if (PrintVMOptions) {
duke@0 3339 const char* tail;
duke@0 3340 for (int i = 0; i < vm_args.nOptions; i++) {
duke@0 3341 const JavaVMOption *option = vm_args.options + i;
duke@0 3342 if (match_option(option, "-XX:", &tail)) {
duke@0 3343 logOption(tail);
duke@0 3344 }
duke@0 3345 }
duke@0 3346 }
duke@0 3347
twisti@5355 3348 return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, Flag::ENVIRON_VAR));
duke@0 3349 }
duke@0 3350 return JNI_OK;
duke@0 3351 }
duke@0 3352
jcoomes@2209 3353 void Arguments::set_shared_spaces_flags() {
coleenp@3602 3354 if (DumpSharedSpaces) {
coleenp@3602 3355 if (RequireSharedSpaces) {
coleenp@3602 3356 warning("cannot dump shared archive while using shared archive");
coleenp@3602 3357 }
coleenp@3602 3358 UseSharedSpaces = false;
hseigel@5093 3359 #ifdef _LP64
ehelin@5259 3360 if (!UseCompressedOops || !UseCompressedClassPointers) {
hseigel@5093 3361 vm_exit_during_initialization(
ehelin@5259 3362 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
hseigel@5093 3363 }
hseigel@5093 3364 } else {
ehelin@5259 3365 // UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.