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