annotate hotspot/src/share/vm/runtime/arguments.hpp @ 28838:da47c3cc5c98

8067460: G1: TestResourceManagementFlagWithCommercialBuild.java failed on embedded platform Summary: Added extension point to detect unsupported options Reviewed-by: dholmes, bdelsart
author aharlap
date Wed, 04 Feb 2015 13:14:27 -0500
parents 772aaab2582f
children 4a5f7c1e6ed7
rev   line source
duke@1 1 /*
goetz@28372 2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation.
duke@1 8 *
duke@1 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 13 * accompanied this code).
duke@1 14 *
duke@1 15 * You should have received a copy of the GNU General Public License version
duke@1 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 18 *
trims@5547 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@5547 20 * or visit www.oracle.com if you need additional information or have any
trims@5547 21 * questions.
duke@1 22 *
duke@1 23 */
duke@1 24
stefank@7397 25 #ifndef SHARE_VM_RUNTIME_ARGUMENTS_HPP
stefank@7397 26 #define SHARE_VM_RUNTIME_ARGUMENTS_HPP
stefank@7397 27
stefank@7397 28 #include "runtime/java.hpp"
goetz@25468 29 #include "runtime/os.hpp"
stefank@7397 30 #include "runtime/perfData.hpp"
jwilhelm@22555 31 #include "utilities/debug.hpp"
stefank@7397 32 #include "utilities/top.hpp"
stefank@7397 33
duke@1 34 // Arguments parses the command line and recognizes options
duke@1 35
duke@1 36 // Invocation API hook typedefs (these should really be defined in jni.hpp)
duke@1 37 extern "C" {
duke@1 38 typedef void (JNICALL *abort_hook_t)(void);
duke@1 39 typedef void (JNICALL *exit_hook_t)(jint code);
drchase@24424 40 typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args) ATTRIBUTE_PRINTF(2, 0);
duke@1 41 }
duke@1 42
duke@1 43 // Forward declarations
duke@1 44
duke@1 45 class SysClassPath;
duke@1 46
duke@1 47 // Element describing System and User (-Dkey=value flags) defined property.
duke@1 48
zgu@13195 49 class SystemProperty: public CHeapObj<mtInternal> {
duke@1 50 private:
duke@1 51 char* _key;
duke@1 52 char* _value;
duke@1 53 SystemProperty* _next;
duke@1 54 bool _writeable;
duke@1 55 bool writeable() { return _writeable; }
duke@1 56
duke@1 57 public:
duke@1 58 // Accessors
duke@1 59 const char* key() const { return _key; }
duke@1 60 char* value() const { return _value; }
duke@1 61 SystemProperty* next() const { return _next; }
duke@1 62 void set_next(SystemProperty* next) { _next = next; }
duke@1 63 bool set_value(char *value) {
duke@1 64 if (writeable()) {
duke@1 65 if (_value != NULL) {
duke@1 66 FreeHeap(_value);
duke@1 67 }
zgu@13195 68 _value = AllocateHeap(strlen(value)+1, mtInternal);
duke@1 69 if (_value != NULL) {
duke@1 70 strcpy(_value, value);
duke@1 71 }
duke@1 72 return true;
duke@1 73 }
duke@1 74 return false;
duke@1 75 }
duke@1 76
duke@1 77 void append_value(const char *value) {
duke@1 78 char *sp;
duke@1 79 size_t len = 0;
duke@1 80 if (value != NULL) {
duke@1 81 len = strlen(value);
duke@1 82 if (_value != NULL) {
duke@1 83 len += strlen(_value);
duke@1 84 }
zgu@13195 85 sp = AllocateHeap(len+2, mtInternal);
duke@1 86 if (sp != NULL) {
duke@1 87 if (_value != NULL) {
duke@1 88 strcpy(sp, _value);
duke@1 89 strcat(sp, os::path_separator());
duke@1 90 strcat(sp, value);
duke@1 91 FreeHeap(_value);
duke@1 92 } else {
duke@1 93 strcpy(sp, value);
duke@1 94 }
duke@1 95 _value = sp;
duke@1 96 }
duke@1 97 }
duke@1 98 }
duke@1 99
duke@1 100 // Constructor
duke@1 101 SystemProperty(const char* key, const char* value, bool writeable) {
duke@1 102 if (key == NULL) {
duke@1 103 _key = NULL;
duke@1 104 } else {
zgu@13195 105 _key = AllocateHeap(strlen(key)+1, mtInternal);
duke@1 106 strcpy(_key, key);
duke@1 107 }
duke@1 108 if (value == NULL) {
duke@1 109 _value = NULL;
duke@1 110 } else {
zgu@13195 111 _value = AllocateHeap(strlen(value)+1, mtInternal);
duke@1 112 strcpy(_value, value);
duke@1 113 }
duke@1 114 _next = NULL;
duke@1 115 _writeable = writeable;
duke@1 116 }
duke@1 117 };
duke@1 118
duke@1 119
duke@1 120 // For use by -agentlib, -agentpath and -Xrun
zgu@13195 121 class AgentLibrary : public CHeapObj<mtInternal> {
duke@1 122 friend class AgentLibraryList;
bpittore@19553 123 public:
bpittore@19553 124 // Is this library valid or not. Don't rely on os_lib == NULL as statically
bpittore@19553 125 // linked lib could have handle of RTLD_DEFAULT which == 0 on some platforms
bpittore@19553 126 enum AgentState {
bpittore@19553 127 agent_invalid = 0,
bpittore@19553 128 agent_valid = 1
bpittore@19553 129 };
bpittore@19553 130
duke@1 131 private:
duke@1 132 char* _name;
duke@1 133 char* _options;
duke@1 134 void* _os_lib;
duke@1 135 bool _is_absolute_path;
bpittore@19553 136 bool _is_static_lib;
bpittore@19553 137 AgentState _state;
duke@1 138 AgentLibrary* _next;
duke@1 139
duke@1 140 public:
duke@1 141 // Accessors
duke@1 142 const char* name() const { return _name; }
duke@1 143 char* options() const { return _options; }
duke@1 144 bool is_absolute_path() const { return _is_absolute_path; }
duke@1 145 void* os_lib() const { return _os_lib; }
duke@1 146 void set_os_lib(void* os_lib) { _os_lib = os_lib; }
duke@1 147 AgentLibrary* next() const { return _next; }
bpittore@19553 148 bool is_static_lib() const { return _is_static_lib; }
bpittore@19973 149 void set_static_lib(bool is_static_lib) { _is_static_lib = is_static_lib; }
bpittore@19553 150 bool valid() { return (_state == agent_valid); }
bpittore@19553 151 void set_valid() { _state = agent_valid; }
bpittore@19553 152 void set_invalid() { _state = agent_invalid; }
duke@1 153
duke@1 154 // Constructor
duke@1 155 AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) {
zgu@13195 156 _name = AllocateHeap(strlen(name)+1, mtInternal);
duke@1 157 strcpy(_name, name);
duke@1 158 if (options == NULL) {
duke@1 159 _options = NULL;
duke@1 160 } else {
zgu@13195 161 _options = AllocateHeap(strlen(options)+1, mtInternal);
duke@1 162 strcpy(_options, options);
duke@1 163 }
duke@1 164 _is_absolute_path = is_absolute_path;
duke@1 165 _os_lib = os_lib;
duke@1 166 _next = NULL;
bpittore@19553 167 _state = agent_invalid;
bpittore@19553 168 _is_static_lib = false;
duke@1 169 }
duke@1 170 };
duke@1 171
duke@1 172 // maintain an order of entry list of AgentLibrary
duke@1 173 class AgentLibraryList VALUE_OBJ_CLASS_SPEC {
duke@1 174 private:
duke@1 175 AgentLibrary* _first;
duke@1 176 AgentLibrary* _last;
duke@1 177 public:
duke@1 178 bool is_empty() const { return _first == NULL; }
duke@1 179 AgentLibrary* first() const { return _first; }
duke@1 180
duke@1 181 // add to the end of the list
duke@1 182 void add(AgentLibrary* lib) {
duke@1 183 if (is_empty()) {
duke@1 184 _first = _last = lib;
duke@1 185 } else {
duke@1 186 _last->_next = lib;
duke@1 187 _last = lib;
duke@1 188 }
duke@1 189 lib->_next = NULL;
duke@1 190 }
duke@1 191
duke@1 192 // search for and remove a library known to be in the list
duke@1 193 void remove(AgentLibrary* lib) {
duke@1 194 AgentLibrary* curr;
duke@1 195 AgentLibrary* prev = NULL;
duke@1 196 for (curr = first(); curr != NULL; prev = curr, curr = curr->next()) {
duke@1 197 if (curr == lib) {
duke@1 198 break;
duke@1 199 }
duke@1 200 }
duke@1 201 assert(curr != NULL, "always should be found");
duke@1 202
duke@1 203 if (curr != NULL) {
duke@1 204 // it was found, by-pass this library
duke@1 205 if (prev == NULL) {
duke@1 206 _first = curr->_next;
duke@1 207 } else {
duke@1 208 prev->_next = curr->_next;
duke@1 209 }
duke@1 210 if (curr == _last) {
duke@1 211 _last = prev;
duke@1 212 }
duke@1 213 curr->_next = NULL;
duke@1 214 }
duke@1 215 }
duke@1 216
duke@1 217 AgentLibraryList() {
duke@1 218 _first = NULL;
duke@1 219 _last = NULL;
duke@1 220 }
duke@1 221 };
duke@1 222
duke@1 223
duke@1 224 class Arguments : AllStatic {
duke@1 225 friend class VMStructs;
duke@1 226 friend class JvmtiExport;
duke@1 227 public:
duke@1 228 // Operation modi
duke@1 229 enum Mode {
duke@1 230 _int, // corresponds to -Xint
duke@1 231 _mixed, // corresponds to -Xmixed
duke@1 232 _comp // corresponds to -Xcomp
duke@1 233 };
duke@1 234
duke@1 235 enum ArgsRange {
duke@1 236 arg_unreadable = -3,
duke@1 237 arg_too_small = -2,
duke@1 238 arg_too_big = -1,
duke@1 239 arg_in_range = 0
duke@1 240 };
duke@1 241
duke@1 242 private:
duke@1 243
duke@1 244 // an array containing all flags specified in the .hotspotrc file
duke@1 245 static char** _jvm_flags_array;
duke@1 246 static int _num_jvm_flags;
duke@1 247 // an array containing all jvm arguments specified in the command line
duke@1 248 static char** _jvm_args_array;
duke@1 249 static int _num_jvm_args;
duke@1 250 // string containing all java command (class/jarfile name and app args)
duke@1 251 static char* _java_command;
duke@1 252
duke@1 253 // Property list
duke@1 254 static SystemProperty* _system_properties;
duke@1 255
duke@1 256 // Quick accessor to System properties in the list:
duke@1 257 static SystemProperty *_sun_boot_library_path;
duke@1 258 static SystemProperty *_java_library_path;
duke@1 259 static SystemProperty *_java_home;
duke@1 260 static SystemProperty *_java_class_path;
duke@1 261 static SystemProperty *_sun_boot_class_path;
duke@1 262
duke@1 263 // Meta-index for knowing what packages are in the boot class path
duke@1 264 static char* _meta_index_path;
duke@1 265 static char* _meta_index_dir;
duke@1 266
chegar@27562 267 // temporary: to emit warning if the default ext dirs are not empty.
chegar@27562 268 // remove this variable when the warning is no longer needed.
chegar@27562 269 static char* _ext_dirs;
chegar@27562 270
duke@1 271 // java.vendor.url.bug, bug reporting URL for fatal errors.
duke@1 272 static const char* _java_vendor_url_bug;
duke@1 273
duke@1 274 // sun.java.launcher, private property to provide information about
rdurbin@22734 275 // java launcher
duke@1 276 static const char* _sun_java_launcher;
duke@1 277
duke@1 278 // sun.java.launcher.pid, private property
duke@1 279 static int _sun_java_launcher_pid;
duke@1 280
rdurbin@22734 281 // was this VM created via the -XXaltjvm=<path> option
rdurbin@22734 282 static bool _sun_java_launcher_is_altjvm;
sla@8476 283
duke@1 284 // Option flags
duke@1 285 static bool _has_profile;
duke@1 286 static const char* _gc_log_filename;
tschatzl@19986 287 // Value of the conservative maximum heap alignment needed
tschatzl@19986 288 static size_t _conservative_max_heap_alignment;
tschatzl@19986 289
jwilhelm@26824 290 static uintx _min_heap_size;
jwilhelm@26824 291
jwilhelm@26824 292 // Used to store original flag values
jwilhelm@26824 293 static uintx _min_heap_free_ratio;
jwilhelm@26824 294 static uintx _max_heap_free_ratio;
duke@1 295
duke@1 296 // -Xrun arguments
duke@1 297 static AgentLibraryList _libraryList;
duke@1 298 static void add_init_library(const char* name, char* options)
duke@1 299 { _libraryList.add(new AgentLibrary(name, options, false, NULL)); }
duke@1 300
duke@1 301 // -agentlib and -agentpath arguments
duke@1 302 static AgentLibraryList _agentList;
duke@1 303 static void add_init_agent(const char* name, char* options, bool absolute_path)
duke@1 304 { _agentList.add(new AgentLibrary(name, options, absolute_path, NULL)); }
duke@1 305
duke@1 306 // Late-binding agents not started via arguments
bpittore@19553 307 static void add_loaded_agent(AgentLibrary *agentLib)
bpittore@19553 308 { _agentList.add(agentLib); }
duke@1 309 static void add_loaded_agent(const char* name, char* options, bool absolute_path, void* os_lib)
duke@1 310 { _agentList.add(new AgentLibrary(name, options, absolute_path, os_lib)); }
duke@1 311
duke@1 312 // Operation modi
duke@1 313 static Mode _mode;
duke@1 314 static void set_mode_flags(Mode mode);
duke@1 315 static bool _java_compiler;
duke@1 316 static void set_java_compiler(bool arg) { _java_compiler = arg; }
duke@1 317 static bool java_compiler() { return _java_compiler; }
duke@1 318
duke@1 319 // -Xdebug flag
duke@1 320 static bool _xdebug_mode;
duke@1 321 static void set_xdebug_mode(bool arg) { _xdebug_mode = arg; }
duke@1 322 static bool xdebug_mode() { return _xdebug_mode; }
duke@1 323
duke@1 324 // Used to save default settings
duke@1 325 static bool _AlwaysCompileLoopMethods;
duke@1 326 static bool _UseOnStackReplacement;
duke@1 327 static bool _BackgroundCompilation;
duke@1 328 static bool _ClipInlining;
duke@1 329 static bool _CIDynamicCompilePriority;
duke@1 330
iveresov@6453 331 // Tiered
iveresov@6453 332 static void set_tiered_flags();
anoll@24437 333 static int get_min_number_of_compiler_threads();
duke@1 334 // CMS/ParNew garbage collectors
duke@1 335 static void set_parnew_gc_flags();
duke@1 336 static void set_cms_and_parnew_gc_flags();
ysr@1374 337 // UseParallel[Old]GC
duke@1 338 static void set_parallel_gc_flags();
ysr@1374 339 // Garbage-First (UseG1GC)
ysr@1374 340 static void set_g1_gc_flags();
duke@1 341 // GC ergonomics
tschatzl@19986 342 static void set_conservative_max_heap_alignment();
brutisso@15957 343 static void set_use_compressed_oops();
hseigel@19319 344 static void set_use_compressed_klass_ptrs();
jcoomes@26836 345 static void select_gc();
duke@1 346 static void set_ergonomics_flags();
jcoomes@8681 347 static void set_shared_spaces_flags();
tschatzl@16605 348 // limits the given memory size by the maximum amount of memory this process is
tschatzl@16605 349 // currently allowed to allocate or reserve.
tschatzl@16605 350 static julong limit_by_allocatable_memory(julong size);
phh@4434 351 // Setup heap size
phh@4434 352 static void set_heap_size();
duke@1 353 // Based on automatic selection criteria, should the
duke@1 354 // low pause collector be used.
duke@1 355 static bool should_auto_select_low_pause_collector();
duke@1 356
duke@1 357 // Bytecode rewriting
duke@1 358 static void set_bytecode_flags();
duke@1 359
duke@1 360 // Invocation API hooks
duke@1 361 static abort_hook_t _abort_hook;
duke@1 362 static exit_hook_t _exit_hook;
duke@1 363 static vfprintf_hook_t _vfprintf_hook;
duke@1 364
duke@1 365 // System properties
duke@1 366 static bool add_property(const char* prop);
duke@1 367
duke@1 368 // Aggressive optimization flags.
duke@1 369 static void set_aggressive_opts_flags();
duke@1 370
duke@1 371 // Argument parsing
duke@1 372 static void do_pd_flag_adjustments();
twisti@20288 373 static bool parse_argument(const char* arg, Flag::Flags origin);
twisti@20288 374 static bool process_argument(const char* arg, jboolean ignore_unrecognized, Flag::Flags origin);
duke@1 375 static void process_java_launcher_argument(const char*, void*);
duke@1 376 static void process_java_compiler_argument(char* arg);
duke@1 377 static jint parse_options_environment_variable(const char* name, SysClassPath* scp_p, bool* scp_assembly_required_p);
duke@1 378 static jint parse_java_tool_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p);
duke@1 379 static jint parse_java_options_environment_variable(SysClassPath* scp_p, bool* scp_assembly_required_p);
duke@1 380 static jint parse_vm_init_args(const JavaVMInitArgs* args);
twisti@20288 381 static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, SysClassPath* scp_p, bool* scp_assembly_required_p, Flag::Flags origin);
duke@1 382 static jint finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required);
jwilhelm@22555 383 static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type);
jwilhelm@22555 384
duke@1 385 static bool is_bad_option(const JavaVMOption* option, jboolean ignore) {
duke@1 386 return is_bad_option(option, ignore, NULL);
duke@1 387 }
jwilhelm@22555 388
jwilhelm@22555 389 static bool is_percentage(uintx val) {
jwilhelm@22555 390 return val <= 100;
jwilhelm@22555 391 }
jwilhelm@22555 392
johnc@4885 393 static bool verify_interval(uintx val, uintx min,
johnc@4885 394 uintx max, const char* name);
ptisnovs@6414 395 static bool verify_min_value(intx val, intx min, const char* name);
duke@1 396 static bool verify_percentage(uintx value, const char* name);
duke@1 397 static void describe_range_error(ArgsRange errcode);
swamyv@1676 398 static ArgsRange check_memory_size(julong size, julong min_size);
swamyv@1676 399 static ArgsRange parse_memory_size(const char* s, julong* long_arg,
swamyv@1676 400 julong min_size);
jmasa@5035 401 // Parse a string for a unsigned integer. Returns true if value
jmasa@5035 402 // is an unsigned integer greater than or equal to the minimum
jmasa@5035 403 // parameter passed and returns the value in uintx_arg. Returns
jmasa@5035 404 // false otherwise, with uintx_arg undefined.
jmasa@5035 405 static bool parse_uintx(const char* value, uintx* uintx_arg,
jmasa@5035 406 uintx min_size);
duke@1 407
duke@1 408 // methods to build strings from individual args
duke@1 409 static void build_jvm_args(const char* arg);
duke@1 410 static void build_jvm_flags(const char* arg);
duke@1 411 static void add_string(char*** bldarray, int* count, const char* arg);
duke@1 412 static const char* build_resource_string(char** args, int count);
duke@1 413
duke@1 414 static bool methodExists(
duke@1 415 char* className, char* methodName,
duke@1 416 int classesNum, char** classes, bool* allMethods,
duke@1 417 int methodsNum, char** methods, bool* allClasses
duke@1 418 );
duke@1 419
duke@1 420 static void parseOnlyLine(
duke@1 421 const char* line,
duke@1 422 short* classesNum, short* classesMax, char*** classes, bool** allMethods,
duke@1 423 short* methodsNum, short* methodsMax, char*** methods, bool** allClasses
duke@1 424 );
duke@1 425
kamg@950 426 // Returns true if the string s is in the list of flags that have recently
kamg@950 427 // been made obsolete. If we detect one of these flags on the command
kamg@950 428 // line, instead of failing we print a warning message and ignore the
kamg@950 429 // flag. This gives the user a release or so to stop using the flag.
kamg@950 430 static bool is_newly_obsolete(const char* s, JDK_Version* buffer);
duke@1 431
duke@1 432 static short CompileOnlyClassesNum;
duke@1 433 static short CompileOnlyClassesMax;
duke@1 434 static char** CompileOnlyClasses;
duke@1 435 static bool* CompileOnlyAllMethods;
duke@1 436
duke@1 437 static short CompileOnlyMethodsNum;
duke@1 438 static short CompileOnlyMethodsMax;
duke@1 439 static char** CompileOnlyMethods;
duke@1 440 static bool* CompileOnlyAllClasses;
duke@1 441
duke@1 442 static short InterpretOnlyClassesNum;
duke@1 443 static short InterpretOnlyClassesMax;
duke@1 444 static char** InterpretOnlyClasses;
duke@1 445 static bool* InterpretOnlyAllMethods;
duke@1 446
duke@1 447 static bool CheckCompileOnly;
duke@1 448
duke@1 449 static char* SharedArchivePath;
duke@1 450
duke@1 451 public:
zmajo@28650 452 // Scale compile thresholds
zmajo@28650 453 // Returns threshold scaled with CompileThresholdScaling
zmajo@28650 454 static intx scaled_compile_threshold(intx threshold, double scale);
zmajo@28650 455 static intx scaled_compile_threshold(intx threshold) {
zmajo@28650 456 return scaled_compile_threshold(threshold, CompileThresholdScaling);
zmajo@28650 457 }
zmajo@28650 458 // Returns freq_log scaled with CompileThresholdScaling
zmajo@28650 459 static intx scaled_freq_log(intx freq_log, double scale);
zmajo@28650 460 static intx scaled_freq_log(intx freq_log) {
zmajo@28650 461 return scaled_freq_log(freq_log, CompileThresholdScaling);
zmajo@28650 462 }
zmajo@28650 463
tschatzl@19986 464 // Parses the arguments, first phase
duke@1 465 static jint parse(const JavaVMInitArgs* args);
tschatzl@19986 466 // Apply ergonomics
tschatzl@19986 467 static jint apply_ergo();
brutisso@14580 468 // Adjusts the arguments after the OS have adjusted the arguments
brutisso@14580 469 static jint adjust_after_os();
jwilhelm@22555 470
jwilhelm@27892 471 static void set_gc_specific_flags();
jcoomes@26836 472 static inline bool gc_selected(); // whether a gc has been selected
jcoomes@26836 473 static void select_gc_ergonomically();
jcoomes@26836 474
jwilhelm@22555 475 // Verifies that the given value will fit as a MinHeapFreeRatio. If not, an error
jwilhelm@22555 476 // message is returned in the provided buffer.
jwilhelm@22555 477 static bool verify_MinHeapFreeRatio(FormatBuffer<80>& err_msg, uintx min_heap_free_ratio);
jwilhelm@22555 478
jwilhelm@22555 479 // Verifies that the given value will fit as a MaxHeapFreeRatio. If not, an error
jwilhelm@22555 480 // message is returned in the provided buffer.
jwilhelm@22555 481 static bool verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_heap_free_ratio);
jwilhelm@22555 482
jmasa@183 483 // Check for consistency in the selection of the garbage collector.
jcoomes@26838 484 static bool check_gc_consistency_user(); // Check user-selected gc
jcoomes@26838 485 static inline bool check_gc_consistency_ergo(); // Check ergonomic-selected gc
tamao@15950 486 static void check_deprecated_gc_flags();
jwilhelm@22551 487 // Check consistency or otherwise of VM argument settings
duke@1 488 static bool check_vm_args_consistency();
ptisnovs@6414 489 // Check stack pages settings
ptisnovs@6414 490 static bool check_stack_pages();
duke@1 491 // Used by os_solaris
duke@1 492 static bool process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized);
duke@1 493
tschatzl@19986 494 static size_t conservative_max_heap_alignment() { return _conservative_max_heap_alignment; }
tschatzl@19986 495 // Return the maximum size a heap with compressed oops can take
tschatzl@19986 496 static size_t max_heap_for_compressed_oops();
tschatzl@19986 497
duke@1 498 // return a char* array containing all options
duke@1 499 static char** jvm_flags_array() { return _jvm_flags_array; }
duke@1 500 static char** jvm_args_array() { return _jvm_args_array; }
duke@1 501 static int num_jvm_flags() { return _num_jvm_flags; }
duke@1 502 static int num_jvm_args() { return _num_jvm_args; }
duke@1 503 // return the arguments passed to the Java application
duke@1 504 static const char* java_command() { return _java_command; }
duke@1 505
duke@1 506 // print jvm_flags, jvm_args and java_command
duke@1 507 static void print_on(outputStream* st);
duke@1 508
duke@1 509 // convenient methods to obtain / print jvm_flags and jvm_args
duke@1 510 static const char* jvm_flags() { return build_resource_string(_jvm_flags_array, _num_jvm_flags); }
duke@1 511 static const char* jvm_args() { return build_resource_string(_jvm_args_array, _num_jvm_args); }
duke@1 512 static void print_jvm_flags_on(outputStream* st);
duke@1 513 static void print_jvm_args_on(outputStream* st);
duke@1 514
duke@1 515 // -Dkey=value flags
duke@1 516 static SystemProperty* system_properties() { return _system_properties; }
duke@1 517 static const char* get_property(const char* key);
duke@1 518
duke@1 519 // -Djava.vendor.url.bug
duke@1 520 static const char* java_vendor_url_bug() { return _java_vendor_url_bug; }
duke@1 521
duke@1 522 // -Dsun.java.launcher
duke@1 523 static const char* sun_java_launcher() { return _sun_java_launcher; }
duke@1 524 // Was VM created by a Java launcher?
duke@1 525 static bool created_by_java_launcher();
rdurbin@22734 526 // -Dsun.java.launcher.is_altjvm
rdurbin@22734 527 static bool sun_java_launcher_is_altjvm();
duke@1 528 // -Dsun.java.launcher.pid
duke@1 529 static int sun_java_launcher_pid() { return _sun_java_launcher_pid; }
duke@1 530
duke@1 531 // -Xloggc:<file>, if not specified will be NULL
duke@1 532 static const char* gc_log_filename() { return _gc_log_filename; }
duke@1 533
jiangli@18687 534 // -Xprof
duke@1 535 static bool has_profile() { return _has_profile; }
duke@1 536
jwilhelm@22551 537 // -Xms
duke@1 538 static uintx min_heap_size() { return _min_heap_size; }
duke@1 539 static void set_min_heap_size(uintx v) { _min_heap_size = v; }
duke@1 540
jwilhelm@26824 541 // Returns the original values of -XX:MinHeapFreeRatio and -XX:MaxHeapFreeRatio
jwilhelm@26824 542 static uintx min_heap_free_ratio() { return _min_heap_free_ratio; }
jwilhelm@26824 543 static uintx max_heap_free_ratio() { return _max_heap_free_ratio; }
jwilhelm@26824 544
duke@1 545 // -Xrun
duke@1 546 static AgentLibrary* libraries() { return _libraryList.first(); }
duke@1 547 static bool init_libraries_at_startup() { return !_libraryList.is_empty(); }
duke@1 548 static void convert_library_to_agent(AgentLibrary* lib)
duke@1 549 { _libraryList.remove(lib);
duke@1 550 _agentList.add(lib); }
duke@1 551
duke@1 552 // -agentlib -agentpath
duke@1 553 static AgentLibrary* agents() { return _agentList.first(); }
duke@1 554 static bool init_agents_at_startup() { return !_agentList.is_empty(); }
duke@1 555
duke@1 556 // abort, exit, vfprintf hooks
duke@1 557 static abort_hook_t abort_hook() { return _abort_hook; }
duke@1 558 static exit_hook_t exit_hook() { return _exit_hook; }
duke@1 559 static vfprintf_hook_t vfprintf_hook() { return _vfprintf_hook; }
duke@1 560
duke@1 561 static bool GetCheckCompileOnly () { return CheckCompileOnly; }
duke@1 562
duke@1 563 static const char* GetSharedArchivePath() { return SharedArchivePath; }
duke@1 564
duke@1 565 static bool CompileMethod(char* className, char* methodName) {
duke@1 566 return
duke@1 567 methodExists(
duke@1 568 className, methodName,
duke@1 569 CompileOnlyClassesNum, CompileOnlyClasses, CompileOnlyAllMethods,
duke@1 570 CompileOnlyMethodsNum, CompileOnlyMethods, CompileOnlyAllClasses
duke@1 571 );
duke@1 572 }
duke@1 573
duke@1 574 // Java launcher properties
duke@1 575 static void process_sun_java_launcher_properties(JavaVMInitArgs* args);
duke@1 576
duke@1 577 // System properties
duke@1 578 static void init_system_properties();
duke@1 579
zgu@6961 580 // Update/Initialize System properties after JDK version number is known
zgu@6961 581 static void init_version_specific_system_properties();
zgu@6961 582
phh@2358 583 // Property List manipulation
goetz@28372 584 static void PropertyList_add(SystemProperty *element);
duke@1 585 static void PropertyList_add(SystemProperty** plist, SystemProperty *element);
duke@1 586 static void PropertyList_add(SystemProperty** plist, const char* k, char* v);
phh@2358 587 static void PropertyList_unique_add(SystemProperty** plist, const char* k, char* v) {
phh@2358 588 PropertyList_unique_add(plist, k, v, false);
phh@2358 589 }
phh@2358 590 static void PropertyList_unique_add(SystemProperty** plist, const char* k, char* v, jboolean append);
duke@1 591 static const char* PropertyList_get_value(SystemProperty* plist, const char* key);
duke@1 592 static int PropertyList_count(SystemProperty* pl);
duke@1 593 static const char* PropertyList_get_key_at(SystemProperty* pl,int index);
duke@1 594 static char* PropertyList_get_value_at(SystemProperty* pl,int index);
duke@1 595
duke@1 596 // Miscellaneous System property value getter and setters.
duke@1 597 static void set_dll_dir(char *value) { _sun_boot_library_path->set_value(value); }
duke@1 598 static void set_java_home(char *value) { _java_home->set_value(value); }
duke@1 599 static void set_library_path(char *value) { _java_library_path->set_value(value); }
chegar@27562 600 static void set_ext_dirs(char *value) { _ext_dirs = os::strdup_check_oom(value); }
duke@1 601 static void set_sysclasspath(char *value) { _sun_boot_class_path->set_value(value); }
duke@1 602 static void append_sysclasspath(const char *value) { _sun_boot_class_path->append_value(value); }
duke@1 603 static void set_meta_index_path(char* meta_index_path, char* meta_index_dir) {
duke@1 604 _meta_index_path = meta_index_path;
duke@1 605 _meta_index_dir = meta_index_dir;
duke@1 606 }
duke@1 607
iklam@26135 608 static char* get_java_home() { return _java_home->value(); }
iklam@26135 609 static char* get_dll_dir() { return _sun_boot_library_path->value(); }
iklam@26135 610 static char* get_sysclasspath() { return _sun_boot_class_path->value(); }
duke@1 611 static char* get_meta_index_path() { return _meta_index_path; }
duke@1 612 static char* get_meta_index_dir() { return _meta_index_dir; }
chegar@27562 613 static char* get_ext_dirs() { return _ext_dirs; }
iklam@26135 614 static char* get_appclasspath() { return _java_class_path->value(); }
iklam@26135 615 static void fix_appclasspath();
duke@1 616
chegar@27562 617
duke@1 618 // Operation modi
iveresov@26585 619 static Mode mode() { return _mode; }
iveresov@26585 620 static bool is_interpreter_only() { return mode() == _int; }
iveresov@26585 621
duke@1 622
duke@1 623 // Utility: copies src into buf, replacing "%%" with "%" and "%p" with pid.
duke@1 624 static bool copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen);
duke@1 625 };
stefank@7397 626
jcoomes@26836 627 bool Arguments::gc_selected() {
brutisso@27898 628 return UseConcMarkSweepGC || UseG1GC || UseParallelGC || UseParallelOldGC || UseSerialGC;
jcoomes@26836 629 }
jcoomes@26838 630
jcoomes@26838 631 bool Arguments::check_gc_consistency_ergo() {
jcoomes@26838 632 return check_gc_consistency_user();
jcoomes@26838 633 }
jcoomes@26838 634
aharlap@28838 635 // Disable options not supported in this release, with a warning if they
aharlap@28838 636 // were explicitly requested on the command-line
aharlap@28838 637 #define UNSUPPORTED_OPTION(opt, description) \
aharlap@28838 638 do { \
aharlap@28838 639 if (opt) { \
aharlap@28838 640 if (FLAG_IS_CMDLINE(opt)) { \
aharlap@28838 641 warning(description " is disabled in this release."); \
aharlap@28838 642 } \
aharlap@28838 643 FLAG_SET_DEFAULT(opt, false); \
aharlap@28838 644 } \
aharlap@28838 645 } while(0)
aharlap@28838 646
stefank@7397 647 #endif // SHARE_VM_RUNTIME_ARGUMENTS_HPP