Mercurial > hg > truffle
comparison src/share/vm/runtime/arguments.cpp @ 6275:957c266d8bc5
Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 21 Aug 2012 10:39:19 +0200 |
parents | 30162e74f11f 1d7922586cf6 |
children | c5afcc2ebd3d |
comparison
equal
deleted
inserted
replaced
5891:fd8832ae511d | 6275:957c266d8bc5 |
---|---|
33 #include "prims/jvmtiExport.hpp" | 33 #include "prims/jvmtiExport.hpp" |
34 #include "runtime/arguments.hpp" | 34 #include "runtime/arguments.hpp" |
35 #include "runtime/globals_extension.hpp" | 35 #include "runtime/globals_extension.hpp" |
36 #include "runtime/java.hpp" | 36 #include "runtime/java.hpp" |
37 #include "services/management.hpp" | 37 #include "services/management.hpp" |
38 #include "services/memTracker.hpp" | |
38 #include "utilities/defaultStream.hpp" | 39 #include "utilities/defaultStream.hpp" |
39 #include "utilities/taskqueue.hpp" | 40 #include "utilities/taskqueue.hpp" |
40 #ifdef TARGET_OS_FAMILY_linux | 41 #ifdef TARGET_OS_FAMILY_linux |
41 # include "os_linux.inline.hpp" | 42 # include "os_linux.inline.hpp" |
42 #endif | 43 #endif |
379 } | 380 } |
380 | 381 |
381 inline void SysClassPath::reset_item_at(int index) { | 382 inline void SysClassPath::reset_item_at(int index) { |
382 assert(index < _scp_nitems && index != _scp_base, "just checking"); | 383 assert(index < _scp_nitems && index != _scp_base, "just checking"); |
383 if (_items[index] != NULL) { | 384 if (_items[index] != NULL) { |
384 FREE_C_HEAP_ARRAY(char, _items[index]); | 385 FREE_C_HEAP_ARRAY(char, _items[index], mtInternal); |
385 _items[index] = NULL; | 386 _items[index] = NULL; |
386 } | 387 } |
387 } | 388 } |
388 | 389 |
389 inline void SysClassPath::reset_path(const char* base) { | 390 inline void SysClassPath::reset_path(const char* base) { |
411 const char* tmp_end = strchr(path, separator); | 412 const char* tmp_end = strchr(path, separator); |
412 if (tmp_end == NULL) { | 413 if (tmp_end == NULL) { |
413 expanded_path = add_jars_to_path(expanded_path, path); | 414 expanded_path = add_jars_to_path(expanded_path, path); |
414 path = end; | 415 path = end; |
415 } else { | 416 } else { |
416 char* dirpath = NEW_C_HEAP_ARRAY(char, tmp_end - path + 1); | 417 char* dirpath = NEW_C_HEAP_ARRAY(char, tmp_end - path + 1, mtInternal); |
417 memcpy(dirpath, path, tmp_end - path); | 418 memcpy(dirpath, path, tmp_end - path); |
418 dirpath[tmp_end - path] = '\0'; | 419 dirpath[tmp_end - path] = '\0'; |
419 expanded_path = add_jars_to_path(expanded_path, dirpath); | 420 expanded_path = add_jars_to_path(expanded_path, dirpath); |
420 FREE_C_HEAP_ARRAY(char, dirpath); | 421 FREE_C_HEAP_ARRAY(char, dirpath, mtInternal); |
421 path = tmp_end + 1; | 422 path = tmp_end + 1; |
422 } | 423 } |
423 } | 424 } |
424 _items[_scp_endorsed] = expanded_path; | 425 _items[_scp_endorsed] = expanded_path; |
425 DEBUG_ONLY(_expansion_done = true;) | 426 DEBUG_ONLY(_expansion_done = true;) |
446 } | 447 } |
447 } | 448 } |
448 assert(total_len > 0, "empty sysclasspath not allowed"); | 449 assert(total_len > 0, "empty sysclasspath not allowed"); |
449 | 450 |
450 // Copy the _items to a single string. | 451 // Copy the _items to a single string. |
451 char* cp = NEW_C_HEAP_ARRAY(char, total_len); | 452 char* cp = NEW_C_HEAP_ARRAY(char, total_len, mtInternal); |
452 char* cp_tmp = cp; | 453 char* cp_tmp = cp; |
453 for (i = 0; i < _scp_nitems; ++i) { | 454 for (i = 0; i < _scp_nitems; ++i) { |
454 if (_items[i] != NULL) { | 455 if (_items[i] != NULL) { |
455 memcpy(cp_tmp, _items[i], lengths[i]); | 456 memcpy(cp_tmp, _items[i], lengths[i]); |
456 cp_tmp += lengths[i]; | 457 cp_tmp += lengths[i]; |
467 char *cp; | 468 char *cp; |
468 | 469 |
469 assert(str != NULL, "just checking"); | 470 assert(str != NULL, "just checking"); |
470 if (path == NULL) { | 471 if (path == NULL) { |
471 size_t len = strlen(str) + 1; | 472 size_t len = strlen(str) + 1; |
472 cp = NEW_C_HEAP_ARRAY(char, len); | 473 cp = NEW_C_HEAP_ARRAY(char, len, mtInternal); |
473 memcpy(cp, str, len); // copy the trailing null | 474 memcpy(cp, str, len); // copy the trailing null |
474 } else { | 475 } else { |
475 const char separator = *os::path_separator(); | 476 const char separator = *os::path_separator(); |
476 size_t old_len = strlen(path); | 477 size_t old_len = strlen(path); |
477 size_t str_len = strlen(str); | 478 size_t str_len = strlen(str); |
478 size_t len = old_len + str_len + 2; | 479 size_t len = old_len + str_len + 2; |
479 | 480 |
480 if (prepend) { | 481 if (prepend) { |
481 cp = NEW_C_HEAP_ARRAY(char, len); | 482 cp = NEW_C_HEAP_ARRAY(char, len, mtInternal); |
482 char* cp_tmp = cp; | 483 char* cp_tmp = cp; |
483 memcpy(cp_tmp, str, str_len); | 484 memcpy(cp_tmp, str, str_len); |
484 cp_tmp += str_len; | 485 cp_tmp += str_len; |
485 *cp_tmp = separator; | 486 *cp_tmp = separator; |
486 memcpy(++cp_tmp, path, old_len + 1); // copy the trailing null | 487 memcpy(++cp_tmp, path, old_len + 1); // copy the trailing null |
487 FREE_C_HEAP_ARRAY(char, path); | 488 FREE_C_HEAP_ARRAY(char, path, mtInternal); |
488 } else { | 489 } else { |
489 cp = REALLOC_C_HEAP_ARRAY(char, path, len); | 490 cp = REALLOC_C_HEAP_ARRAY(char, path, len, mtInternal); |
490 char* cp_tmp = cp + old_len; | 491 char* cp_tmp = cp + old_len; |
491 *cp_tmp = separator; | 492 *cp_tmp = separator; |
492 memcpy(++cp_tmp, str, str_len + 1); // copy the trailing null | 493 memcpy(++cp_tmp, str, str_len + 1); // copy the trailing null |
493 } | 494 } |
494 } | 495 } |
506 const char fileSep = *os::file_separator(); | 507 const char fileSep = *os::file_separator(); |
507 if (directory[directory_len - 1] != fileSep) dir_sep[0] = fileSep; | 508 if (directory[directory_len - 1] != fileSep) dir_sep[0] = fileSep; |
508 | 509 |
509 /* Scan the directory for jars/zips, appending them to path. */ | 510 /* Scan the directory for jars/zips, appending them to path. */ |
510 struct dirent *entry; | 511 struct dirent *entry; |
511 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory)); | 512 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal); |
512 while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { | 513 while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { |
513 const char* name = entry->d_name; | 514 const char* name = entry->d_name; |
514 const char* ext = name + strlen(name) - 4; | 515 const char* ext = name + strlen(name) - 4; |
515 bool isJarOrZip = ext > name && | 516 bool isJarOrZip = ext > name && |
516 (os::file_name_strcmp(ext, ".jar") == 0 || | 517 (os::file_name_strcmp(ext, ".jar") == 0 || |
517 os::file_name_strcmp(ext, ".zip") == 0); | 518 os::file_name_strcmp(ext, ".zip") == 0); |
518 if (isJarOrZip) { | 519 if (isJarOrZip) { |
519 char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name)); | 520 char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtInternal); |
520 sprintf(jarpath, "%s%s%s", directory, dir_sep, name); | 521 sprintf(jarpath, "%s%s%s", directory, dir_sep, name); |
521 path = add_to_path(path, jarpath, false); | 522 path = add_to_path(path, jarpath, false); |
522 FREE_C_HEAP_ARRAY(char, jarpath); | 523 FREE_C_HEAP_ARRAY(char, jarpath, mtInternal); |
523 } | 524 } |
524 } | 525 } |
525 FREE_C_HEAP_ARRAY(char, dbuf); | 526 FREE_C_HEAP_ARRAY(char, dbuf, mtInternal); |
526 os::closedir(dir); | 527 os::closedir(dir); |
527 return path; | 528 return path; |
528 } | 529 } |
529 | 530 |
530 // Parses a memory size specification string. | 531 // Parses a memory size specification string. |
642 } | 643 } |
643 | 644 |
644 static bool set_string_flag(char* name, const char* value, FlagValueOrigin origin) { | 645 static bool set_string_flag(char* name, const char* value, FlagValueOrigin origin) { |
645 if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false; | 646 if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false; |
646 // Contract: CommandLineFlags always returns a pointer that needs freeing. | 647 // Contract: CommandLineFlags always returns a pointer that needs freeing. |
647 FREE_C_HEAP_ARRAY(char, value); | 648 FREE_C_HEAP_ARRAY(char, value, mtInternal); |
648 return true; | 649 return true; |
649 } | 650 } |
650 | 651 |
651 static bool append_to_string_flag(char* name, const char* new_value, FlagValueOrigin origin) { | 652 static bool append_to_string_flag(char* name, const char* new_value, FlagValueOrigin origin) { |
652 const char* old_value = ""; | 653 const char* old_value = ""; |
658 if (old_len == 0) { | 659 if (old_len == 0) { |
659 value = new_value; | 660 value = new_value; |
660 } else if (new_len == 0) { | 661 } else if (new_len == 0) { |
661 value = old_value; | 662 value = old_value; |
662 } else { | 663 } else { |
663 char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1); | 664 char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtInternal); |
664 // each new setting adds another LINE to the switch: | 665 // each new setting adds another LINE to the switch: |
665 sprintf(buf, "%s\n%s", old_value, new_value); | 666 sprintf(buf, "%s\n%s", old_value, new_value); |
666 value = buf; | 667 value = buf; |
667 free_this_too = buf; | 668 free_this_too = buf; |
668 } | 669 } |
669 (void) CommandLineFlags::ccstrAtPut(name, &value, origin); | 670 (void) CommandLineFlags::ccstrAtPut(name, &value, origin); |
670 // CommandLineFlags always returns a pointer that needs freeing. | 671 // CommandLineFlags always returns a pointer that needs freeing. |
671 FREE_C_HEAP_ARRAY(char, value); | 672 FREE_C_HEAP_ARRAY(char, value, mtInternal); |
672 if (free_this_too != NULL) { | 673 if (free_this_too != NULL) { |
673 // CommandLineFlags made its own copy, so I must delete my own temp. buffer. | 674 // CommandLineFlags made its own copy, so I must delete my own temp. buffer. |
674 FREE_C_HEAP_ARRAY(char, free_this_too); | 675 FREE_C_HEAP_ARRAY(char, free_this_too, mtInternal); |
675 } | 676 } |
676 return true; | 677 return true; |
677 } | 678 } |
678 | 679 |
679 bool Arguments::parse_argument(const char* arg, FlagValueOrigin origin) { | 680 bool Arguments::parse_argument(const char* arg, FlagValueOrigin origin) { |
746 int index = *count; | 747 int index = *count; |
747 | 748 |
748 // expand the array and add arg to the last element | 749 // expand the array and add arg to the last element |
749 (*count)++; | 750 (*count)++; |
750 if (*bldarray == NULL) { | 751 if (*bldarray == NULL) { |
751 *bldarray = NEW_C_HEAP_ARRAY(char*, *count); | 752 *bldarray = NEW_C_HEAP_ARRAY(char*, *count, mtInternal); |
752 } else { | 753 } else { |
753 *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, *count); | 754 *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, *count, mtInternal); |
754 } | 755 } |
755 (*bldarray)[index] = strdup(arg); | 756 (*bldarray)[index] = strdup(arg); |
756 } | 757 } |
757 | 758 |
758 void Arguments::build_jvm_args(const char* arg) { | 759 void Arguments::build_jvm_args(const char* arg) { |
832 since.to_string(version, sizeof(version)); | 833 since.to_string(version, sizeof(version)); |
833 warning("ignoring option %s; support was removed in %s", argname, version); | 834 warning("ignoring option %s; support was removed in %s", argname, version); |
834 return true; | 835 return true; |
835 } | 836 } |
836 | 837 |
837 jio_fprintf(defaultStream::error_stream(), | 838 // For locked flags, report a custom error message if available. |
838 "Unrecognized VM option '%s'\n", argname); | 839 // Otherwise, report the standard unrecognized VM option. |
840 | |
841 Flag* locked_flag = Flag::find_flag((char*)argname, strlen(argname), true); | |
842 if (locked_flag != NULL) { | |
843 char locked_message_buf[BUFLEN]; | |
844 locked_flag->get_locked_message(locked_message_buf, BUFLEN); | |
845 if (strlen(locked_message_buf) == 0) { | |
846 jio_fprintf(defaultStream::error_stream(), | |
847 "Unrecognized VM option '%s'\n", argname); | |
848 } else { | |
849 jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf); | |
850 } | |
851 } else { | |
852 jio_fprintf(defaultStream::error_stream(), | |
853 "Unrecognized VM option '%s'\n", argname); | |
854 } | |
855 | |
839 // allow for commandline "commenting out" options like -XX:#+Verbose | 856 // allow for commandline "commenting out" options like -XX:#+Verbose |
840 return arg[0] == '#'; | 857 return arg[0] == '#'; |
841 } | 858 } |
842 | 859 |
843 bool Arguments::process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized) { | 860 bool Arguments::process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized) { |
917 // ns must be static--its address may be stored in a SystemProperty object. | 934 // ns must be static--its address may be stored in a SystemProperty object. |
918 const static char ns[1] = {0}; | 935 const static char ns[1] = {0}; |
919 char* value = (char *)ns; | 936 char* value = (char *)ns; |
920 | 937 |
921 size_t key_len = (eq == NULL) ? strlen(prop) : (eq - prop); | 938 size_t key_len = (eq == NULL) ? strlen(prop) : (eq - prop); |
922 key = AllocateHeap(key_len + 1, "add_property"); | 939 key = AllocateHeap(key_len + 1, mtInternal); |
923 strncpy(key, prop, key_len); | 940 strncpy(key, prop, key_len); |
924 key[key_len] = '\0'; | 941 key[key_len] = '\0'; |
925 | 942 |
926 if (eq != NULL) { | 943 if (eq != NULL) { |
927 size_t value_len = strlen(prop) - key_len - 1; | 944 size_t value_len = strlen(prop) - key_len - 1; |
928 value = AllocateHeap(value_len + 1, "add_property"); | 945 value = AllocateHeap(value_len + 1, mtInternal); |
929 strncpy(value, &prop[key_len + 1], value_len + 1); | 946 strncpy(value, &prop[key_len + 1], value_len + 1); |
930 } | 947 } |
931 | 948 |
932 if (strcmp(key, "java.compiler") == 0) { | 949 if (strcmp(key, "java.compiler") == 0) { |
933 process_java_compiler_argument(value); | 950 process_java_compiler_argument(value); |
2169 // prefix and the default bootclasspath. os::set_boot_path() | 2186 // prefix and the default bootclasspath. os::set_boot_path() |
2170 // uses meta_index_dir as the default bootclasspath directory. | 2187 // uses meta_index_dir as the default bootclasspath directory. |
2171 const char* altclasses_jar = "alt-rt.jar"; | 2188 const char* altclasses_jar = "alt-rt.jar"; |
2172 size_t altclasses_path_len = strlen(get_meta_index_dir()) + 1 + | 2189 size_t altclasses_path_len = strlen(get_meta_index_dir()) + 1 + |
2173 strlen(altclasses_jar); | 2190 strlen(altclasses_jar); |
2174 char* altclasses_path = NEW_C_HEAP_ARRAY(char, altclasses_path_len); | 2191 char* altclasses_path = NEW_C_HEAP_ARRAY(char, altclasses_path_len, mtInternal); |
2175 strcpy(altclasses_path, get_meta_index_dir()); | 2192 strcpy(altclasses_path, get_meta_index_dir()); |
2176 strcat(altclasses_path, altclasses_jar); | 2193 strcat(altclasses_path, altclasses_jar); |
2177 scp.add_suffix_to_prefix(altclasses_path); | 2194 scp.add_suffix_to_prefix(altclasses_path); |
2178 scp_assembly_required = true; | 2195 scp_assembly_required = true; |
2179 FREE_C_HEAP_ARRAY(char, altclasses_path); | 2196 FREE_C_HEAP_ARRAY(char, altclasses_path, mtInternal); |
2197 } | |
2198 | |
2199 if (WhiteBoxAPI) { | |
2200 // Append wb.jar to bootclasspath if enabled | |
2201 const char* wb_jar = "wb.jar"; | |
2202 size_t wb_path_len = strlen(get_meta_index_dir()) + 1 + | |
2203 strlen(wb_jar); | |
2204 char* wb_path = NEW_C_HEAP_ARRAY(char, wb_path_len, mtInternal); | |
2205 strcpy(wb_path, get_meta_index_dir()); | |
2206 strcat(wb_path, wb_jar); | |
2207 scp.add_suffix(wb_path); | |
2208 scp_assembly_required = true; | |
2209 FREE_C_HEAP_ARRAY(char, wb_path, mtInternal); | |
2180 } | 2210 } |
2181 | 2211 |
2182 // Parse _JAVA_OPTIONS environment variable (if present) (mimics classic VM) | 2212 // Parse _JAVA_OPTIONS environment variable (if present) (mimics classic VM) |
2183 result = parse_java_options_environment_variable(&scp, &scp_assembly_required); | 2213 result = parse_java_options_environment_variable(&scp, &scp_assembly_required); |
2184 if (result != JNI_OK) { | 2214 if (result != JNI_OK) { |
2259 // -Xrun | 2289 // -Xrun |
2260 } else if (match_option(option, "-Xrun", &tail)) { | 2290 } else if (match_option(option, "-Xrun", &tail)) { |
2261 if (tail != NULL) { | 2291 if (tail != NULL) { |
2262 const char* pos = strchr(tail, ':'); | 2292 const char* pos = strchr(tail, ':'); |
2263 size_t len = (pos == NULL) ? strlen(tail) : pos - tail; | 2293 size_t len = (pos == NULL) ? strlen(tail) : pos - tail; |
2264 char* name = (char*)memcpy(NEW_C_HEAP_ARRAY(char, len + 1), tail, len); | 2294 char* name = (char*)memcpy(NEW_C_HEAP_ARRAY(char, len + 1, mtInternal), tail, len); |
2265 name[len] = '\0'; | 2295 name[len] = '\0'; |
2266 | 2296 |
2267 char *options = NULL; | 2297 char *options = NULL; |
2268 if(pos != NULL) { | 2298 if(pos != NULL) { |
2269 size_t len2 = strlen(pos+1) + 1; // options start after ':'. Final zero must be copied. | 2299 size_t len2 = strlen(pos+1) + 1; // options start after ':'. Final zero must be copied. |
2270 options = (char*)memcpy(NEW_C_HEAP_ARRAY(char, len2), pos+1, len2); | 2300 options = (char*)memcpy(NEW_C_HEAP_ARRAY(char, len2, mtInternal), pos+1, len2); |
2271 } | 2301 } |
2272 #ifdef JVMTI_KERNEL | 2302 #ifdef JVMTI_KERNEL |
2273 if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) { | 2303 if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) { |
2274 warning("profiling and debugging agents are not supported with Kernel VM"); | 2304 warning("profiling and debugging agents are not supported with Kernel VM"); |
2275 } else | 2305 } else |
2280 } else if (match_option(option, "-agentlib:", &tail) || | 2310 } else if (match_option(option, "-agentlib:", &tail) || |
2281 (is_absolute_path = match_option(option, "-agentpath:", &tail))) { | 2311 (is_absolute_path = match_option(option, "-agentpath:", &tail))) { |
2282 if(tail != NULL) { | 2312 if(tail != NULL) { |
2283 const char* pos = strchr(tail, '='); | 2313 const char* pos = strchr(tail, '='); |
2284 size_t len = (pos == NULL) ? strlen(tail) : pos - tail; | 2314 size_t len = (pos == NULL) ? strlen(tail) : pos - tail; |
2285 char* name = strncpy(NEW_C_HEAP_ARRAY(char, len + 1), tail, len); | 2315 char* name = strncpy(NEW_C_HEAP_ARRAY(char, len + 1, mtInternal), tail, len); |
2286 name[len] = '\0'; | 2316 name[len] = '\0'; |
2287 | 2317 |
2288 char *options = NULL; | 2318 char *options = NULL; |
2289 if(pos != NULL) { | 2319 if(pos != NULL) { |
2290 options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(pos + 1) + 1), pos + 1); | 2320 options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(pos + 1) + 1, mtInternal), pos + 1); |
2291 } | 2321 } |
2292 #ifdef JVMTI_KERNEL | 2322 #ifdef JVMTI_KERNEL |
2293 if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) { | 2323 if ((strcmp(name, "hprof") == 0) || (strcmp(name, "jdwp") == 0)) { |
2294 warning("profiling and debugging agents are not supported with Kernel VM"); | 2324 warning("profiling and debugging agents are not supported with Kernel VM"); |
2295 } else | 2325 } else |
2298 | 2328 |
2299 } | 2329 } |
2300 // -javaagent | 2330 // -javaagent |
2301 } else if (match_option(option, "-javaagent:", &tail)) { | 2331 } else if (match_option(option, "-javaagent:", &tail)) { |
2302 if(tail != NULL) { | 2332 if(tail != NULL) { |
2303 char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1), tail); | 2333 char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtInternal), tail); |
2304 add_init_agent("instrument", options, false); | 2334 add_init_agent("instrument", options, false); |
2305 } | 2335 } |
2306 // -Xnoclassgc | 2336 // -Xnoclassgc |
2307 } else if (match_option(option, "-Xnoclassgc", &tail)) { | 2337 } else if (match_option(option, "-Xnoclassgc", &tail)) { |
2308 FLAG_SET_CMDLINE(bool, ClassUnloading, false); | 2338 FLAG_SET_CMDLINE(bool, ClassUnloading, false); |
2636 // original allocation order after promotion, which improves mutator | 2666 // original allocation order after promotion, which improves mutator |
2637 // locality. A minor effect may be that larger PLABs reduce the | 2667 // locality. A minor effect may be that larger PLABs reduce the |
2638 // number of PLAB allocation events during gc. The value of 8kw | 2668 // number of PLAB allocation events during gc. The value of 8kw |
2639 // was arrived at by experimenting with specjbb. | 2669 // was arrived at by experimenting with specjbb. |
2640 FLAG_SET_CMDLINE(uintx, OldPLABSize, 8*K); // Note: this is in words | 2670 FLAG_SET_CMDLINE(uintx, OldPLABSize, 8*K); // Note: this is in words |
2641 | |
2642 // CompilationPolicyChoice=0 causes the server compiler to adopt | |
2643 // a more conservative which-method-do-I-compile policy when one | |
2644 // of the counters maintained by the interpreter trips. The | |
2645 // result is reduced startup time and improved specjbb and | |
2646 // alacrity performance. Zero is the default, but we set it | |
2647 // explicitly here in case the default changes. | |
2648 // See runtime/compilationPolicy.*. | |
2649 FLAG_SET_CMDLINE(intx, CompilationPolicyChoice, 0); | |
2650 | 2671 |
2651 // Enable parallel GC and adaptive generation sizing | 2672 // Enable parallel GC and adaptive generation sizing |
2652 FLAG_SET_CMDLINE(bool, UseParallelGC, true); | 2673 FLAG_SET_CMDLINE(bool, UseParallelGC, true); |
2653 FLAG_SET_DEFAULT(ParallelGCThreads, | 2674 FLAG_SET_DEFAULT(ParallelGCThreads, |
2654 Abstract_VM_Version::parallel_worker_threads()); | 2675 Abstract_VM_Version::parallel_worker_threads()); |
2815 jio_fprintf(defaultStream::error_stream(), | 2836 jio_fprintf(defaultStream::error_stream(), |
2816 "Invalid concurrent threads: %s\n", option->optionString); | 2837 "Invalid concurrent threads: %s\n", option->optionString); |
2817 return JNI_EINVAL; | 2838 return JNI_EINVAL; |
2818 } | 2839 } |
2819 FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads); | 2840 FLAG_SET_CMDLINE(uintx, ConcGCThreads, conc_threads); |
2841 } else if (match_option(option, "-XX:MaxDirectMemorySize=", &tail)) { | |
2842 julong max_direct_memory_size = 0; | |
2843 ArgsRange errcode = parse_memory_size(tail, &max_direct_memory_size, 0); | |
2844 if (errcode != arg_in_range) { | |
2845 jio_fprintf(defaultStream::error_stream(), | |
2846 "Invalid maximum direct memory size: %s\n", | |
2847 option->optionString); | |
2848 describe_range_error(errcode); | |
2849 return JNI_EINVAL; | |
2850 } | |
2851 FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size); | |
2820 } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx | 2852 } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx |
2821 // Skip -XX:Flags= since that case has already been handled | 2853 // Skip -XX:Flags= since that case has already been handled |
2822 if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) { | 2854 if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) { |
2823 if (!process_argument(tail, args->ignoreUnrecognized, origin)) { | 2855 if (!process_argument(tail, args->ignoreUnrecognized, origin)) { |
2824 return JNI_EINVAL; | 2856 return JNI_EINVAL; |
3076 char jvm_path[JVM_MAXPATHLEN]; | 3108 char jvm_path[JVM_MAXPATHLEN]; |
3077 os::jvm_path(jvm_path, sizeof(jvm_path)); | 3109 os::jvm_path(jvm_path, sizeof(jvm_path)); |
3078 char *end = strrchr(jvm_path, *os::file_separator()); | 3110 char *end = strrchr(jvm_path, *os::file_separator()); |
3079 if (end != NULL) *end = '\0'; | 3111 if (end != NULL) *end = '\0'; |
3080 char *shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(jvm_path) + | 3112 char *shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(jvm_path) + |
3081 strlen(os::file_separator()) + 20); | 3113 strlen(os::file_separator()) + 20, mtInternal); |
3082 if (shared_archive_path == NULL) return JNI_ENOMEM; | 3114 if (shared_archive_path == NULL) return JNI_ENOMEM; |
3083 strcpy(shared_archive_path, jvm_path); | 3115 strcpy(shared_archive_path, jvm_path); |
3084 strcat(shared_archive_path, os::file_separator()); | 3116 strcat(shared_archive_path, os::file_separator()); |
3085 strcat(shared_archive_path, "classes"); | 3117 strcat(shared_archive_path, "classes"); |
3086 DEBUG_ONLY(strcat(shared_archive_path, "_g");) | 3118 DEBUG_ONLY(strcat(shared_archive_path, "_g");) |
3089 | 3121 |
3090 // Remaining part of option string | 3122 // Remaining part of option string |
3091 const char* tail; | 3123 const char* tail; |
3092 | 3124 |
3093 // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed. | 3125 // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed. |
3126 const char* hotspotrc = ".hotspotrc"; | |
3094 bool settings_file_specified = false; | 3127 bool settings_file_specified = false; |
3128 bool needs_hotspotrc_warning = false; | |
3129 | |
3095 const char* flags_file; | 3130 const char* flags_file; |
3096 int index; | 3131 int index; |
3097 for (index = 0; index < args->nOptions; index++) { | 3132 for (index = 0; index < args->nOptions; index++) { |
3098 const JavaVMOption *option = args->options + index; | 3133 const JavaVMOption *option = args->options + index; |
3099 if (match_option(option, "-XX:Flags=", &tail)) { | 3134 if (match_option(option, "-XX:Flags=", &tail)) { |
3114 } | 3149 } |
3115 if (match_option(option, "-XX:+PrintFlagsInitial", &tail)) { | 3150 if (match_option(option, "-XX:+PrintFlagsInitial", &tail)) { |
3116 CommandLineFlags::printFlags(tty, false); | 3151 CommandLineFlags::printFlags(tty, false); |
3117 vm_exit(0); | 3152 vm_exit(0); |
3118 } | 3153 } |
3154 if (match_option(option, "-XX:NativeMemoryTracking", &tail)) { | |
3155 MemTracker::init_tracking_options(tail); | |
3156 } | |
3157 | |
3119 | 3158 |
3120 #ifndef PRODUCT | 3159 #ifndef PRODUCT |
3121 if (match_option(option, "-XX:+PrintFlagsWithComments", &tail)) { | 3160 if (match_option(option, "-XX:+PrintFlagsWithComments", &tail)) { |
3122 CommandLineFlags::printFlags(tty, true); | 3161 CommandLineFlags::printFlags(tty, true); |
3123 vm_exit(0); | 3162 vm_exit(0); |
3133 // Parse specified settings file | 3172 // Parse specified settings file |
3134 if (settings_file_specified) { | 3173 if (settings_file_specified) { |
3135 if (!process_settings_file(flags_file, true, args->ignoreUnrecognized)) { | 3174 if (!process_settings_file(flags_file, true, args->ignoreUnrecognized)) { |
3136 return JNI_EINVAL; | 3175 return JNI_EINVAL; |
3137 } | 3176 } |
3138 } | 3177 } else { |
3139 | 3178 #ifdef ASSERT |
3140 // Parse default .hotspotrc settings file | 3179 // Parse default .hotspotrc settings file |
3141 if (!settings_file_specified) { | |
3142 if (!process_settings_file(".hotspotrc", false, args->ignoreUnrecognized)) { | 3180 if (!process_settings_file(".hotspotrc", false, args->ignoreUnrecognized)) { |
3143 return JNI_EINVAL; | 3181 return JNI_EINVAL; |
3144 } | 3182 } |
3183 #else | |
3184 struct stat buf; | |
3185 if (os::stat(hotspotrc, &buf) == 0) { | |
3186 needs_hotspotrc_warning = true; | |
3187 } | |
3188 #endif | |
3145 } | 3189 } |
3146 | 3190 |
3147 if (PrintVMOptions) { | 3191 if (PrintVMOptions) { |
3148 for (index = 0; index < args->nOptions; index++) { | 3192 for (index = 0; index < args->nOptions; index++) { |
3149 const JavaVMOption *option = args->options + index; | 3193 const JavaVMOption *option = args->options + index; |
3157 jint result = parse_vm_init_args(args); | 3201 jint result = parse_vm_init_args(args); |
3158 if (result != JNI_OK) { | 3202 if (result != JNI_OK) { |
3159 return result; | 3203 return result; |
3160 } | 3204 } |
3161 | 3205 |
3162 #ifdef JAVASE_EMBEDDED | 3206 // Delay warning until here so that we've had a chance to process |
3207 // the -XX:-PrintWarnings flag | |
3208 if (needs_hotspotrc_warning) { | |
3209 warning("%s file is present but has been ignored. " | |
3210 "Run with -XX:Flags=%s to load the file.", | |
3211 hotspotrc, hotspotrc); | |
3212 } | |
3213 | |
3214 #if (defined JAVASE_EMBEDDED || defined ARM) | |
3163 UNSUPPORTED_OPTION(UseG1GC, "G1 GC"); | 3215 UNSUPPORTED_OPTION(UseG1GC, "G1 GC"); |
3164 #endif | 3216 #endif |
3165 | 3217 |
3166 #ifndef PRODUCT | 3218 #ifndef PRODUCT |
3167 if (TraceBytecodesAt != 0) { | 3219 if (TraceBytecodesAt != 0) { |
3172 warning("UseCounterDecay disabled because CountCalls is set"); | 3224 warning("UseCounterDecay disabled because CountCalls is set"); |
3173 UseCounterDecay = false; | 3225 UseCounterDecay = false; |
3174 } | 3226 } |
3175 } | 3227 } |
3176 #endif // PRODUCT | 3228 #endif // PRODUCT |
3177 | |
3178 // Transitional | |
3179 if (EnableMethodHandles || AnonymousClasses) { | |
3180 if (!EnableInvokeDynamic && !FLAG_IS_DEFAULT(EnableInvokeDynamic)) { | |
3181 warning("EnableMethodHandles and AnonymousClasses are obsolete. Keeping EnableInvokeDynamic disabled."); | |
3182 } else { | |
3183 EnableInvokeDynamic = true; | |
3184 } | |
3185 } | |
3186 | 3229 |
3187 // JSR 292 is not supported before 1.7 | 3230 // JSR 292 is not supported before 1.7 |
3188 if (!JDK_Version::is_gte_jdk17x_version()) { | 3231 if (!JDK_Version::is_gte_jdk17x_version()) { |
3189 if (EnableInvokeDynamic) { | 3232 if (EnableInvokeDynamic) { |
3190 if (!FLAG_IS_DEFAULT(EnableInvokeDynamic)) { | 3233 if (!FLAG_IS_DEFAULT(EnableInvokeDynamic)) { |
3208 } | 3251 } |
3209 | 3252 |
3210 if (PrintGCDetails) { | 3253 if (PrintGCDetails) { |
3211 // Turn on -verbose:gc options as well | 3254 // Turn on -verbose:gc options as well |
3212 PrintGC = true; | 3255 PrintGC = true; |
3256 } | |
3257 | |
3258 if (!JDK_Version::is_gte_jdk18x_version()) { | |
3259 // To avoid changing the log format for 7 updates this flag is only | |
3260 // true by default in JDK8 and above. | |
3261 if (FLAG_IS_DEFAULT(PrintGCCause)) { | |
3262 FLAG_SET_DEFAULT(PrintGCCause, false); | |
3263 } | |
3213 } | 3264 } |
3214 | 3265 |
3215 // Set object alignment values. | 3266 // Set object alignment values. |
3216 set_object_alignment(); | 3267 set_object_alignment(); |
3217 | 3268 |
3441 if (strncmp(prop->key(), "kernel.", 7 ) == 0) { | 3492 if (strncmp(prop->key(), "kernel.", 7 ) == 0) { |
3442 length += (strlen(prop->key()) + strlen(prop->value()) + 5); // "-D =" | 3493 length += (strlen(prop->key()) + strlen(prop->value()) + 5); // "-D =" |
3443 } | 3494 } |
3444 } | 3495 } |
3445 // Add one for null terminator. | 3496 // Add one for null terminator. |
3446 char *props = AllocateHeap(length + 1, "get_kernel_properties"); | 3497 char *props = AllocateHeap(length + 1, mtInternal); |
3447 if (length != 0) { | 3498 if (length != 0) { |
3448 int pos = 0; | 3499 int pos = 0; |
3449 for (prop = _system_properties; prop != NULL; prop = prop->next()) { | 3500 for (prop = _system_properties; prop != NULL; prop = prop->next()) { |
3450 if (strncmp(prop->key(), "kernel.", 7 ) == 0) { | 3501 if (strncmp(prop->key(), "kernel.", 7 ) == 0) { |
3451 jio_snprintf(&props[pos], length-pos, | 3502 jio_snprintf(&props[pos], length-pos, |