comparison src/share/vm/runtime/arguments.cpp @ 12355:cefad50507d8

Merge with hs25-b53
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 11 Oct 2013 10:38:03 +0200
parents 58fc8e2b7b6d 1c3486050433
children 359f7e70ae7f
comparison
equal deleted inserted replaced
12058:ccb4f2af2319 12355:cefad50507d8
26 #include "classfile/javaAssertions.hpp" 26 #include "classfile/javaAssertions.hpp"
27 #include "classfile/symbolTable.hpp" 27 #include "classfile/symbolTable.hpp"
28 #include "compiler/compilerOracle.hpp" 28 #include "compiler/compilerOracle.hpp"
29 #include "memory/allocation.inline.hpp" 29 #include "memory/allocation.inline.hpp"
30 #include "memory/cardTableRS.hpp" 30 #include "memory/cardTableRS.hpp"
31 #include "memory/genCollectedHeap.hpp"
31 #include "memory/referenceProcessor.hpp" 32 #include "memory/referenceProcessor.hpp"
32 #include "memory/universe.inline.hpp" 33 #include "memory/universe.inline.hpp"
33 #include "oops/oop.inline.hpp" 34 #include "oops/oop.inline.hpp"
34 #include "prims/jvmtiExport.hpp" 35 #include "prims/jvmtiExport.hpp"
35 #include "runtime/arguments.hpp" 36 #include "runtime/arguments.hpp"
52 #ifdef TARGET_OS_FAMILY_bsd 53 #ifdef TARGET_OS_FAMILY_bsd
53 # include "os_bsd.inline.hpp" 54 # include "os_bsd.inline.hpp"
54 #endif 55 #endif
55 #if INCLUDE_ALL_GCS 56 #if INCLUDE_ALL_GCS
56 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp" 57 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
58 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
59 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
57 #endif // INCLUDE_ALL_GCS 60 #endif // INCLUDE_ALL_GCS
58 61
59 // Note: This is a special bug reporting site for the JVM 62 // Note: This is a special bug reporting site for the JVM
60 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp" 63 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp"
61 #define DEFAULT_JAVA_LAUNCHER "generic" 64 #define DEFAULT_JAVA_LAUNCHER "generic"
92 #endif 95 #endif
93 char* Arguments::_java_command = NULL; 96 char* Arguments::_java_command = NULL;
94 SystemProperty* Arguments::_system_properties = NULL; 97 SystemProperty* Arguments::_system_properties = NULL;
95 const char* Arguments::_gc_log_filename = NULL; 98 const char* Arguments::_gc_log_filename = NULL;
96 bool Arguments::_has_profile = false; 99 bool Arguments::_has_profile = false;
100 size_t Arguments::_conservative_max_heap_alignment = 0;
97 uintx Arguments::_min_heap_size = 0; 101 uintx Arguments::_min_heap_size = 0;
98 Arguments::Mode Arguments::_mode = _mixed; 102 Arguments::Mode Arguments::_mode = _mixed;
99 bool Arguments::_java_compiler = false; 103 bool Arguments::_java_compiler = false;
100 bool Arguments::_xdebug_mode = false; 104 bool Arguments::_xdebug_mode = false;
101 const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG; 105 const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG;
623 default: 627 default:
624 ShouldNotReachHere(); 628 ShouldNotReachHere();
625 } 629 }
626 } 630 }
627 631
628 static bool set_bool_flag(char* name, bool value, FlagValueOrigin origin) { 632 static bool set_bool_flag(char* name, bool value, Flag::Flags origin) {
629 return CommandLineFlags::boolAtPut(name, &value, origin); 633 return CommandLineFlags::boolAtPut(name, &value, origin);
630 } 634 }
631 635
632 static bool set_fp_numeric_flag(char* name, char* value, FlagValueOrigin origin) { 636 static bool set_fp_numeric_flag(char* name, char* value, Flag::Flags origin) {
633 double v; 637 double v;
634 if (sscanf(value, "%lf", &v) != 1) { 638 if (sscanf(value, "%lf", &v) != 1) {
635 return false; 639 return false;
636 } 640 }
637 641
639 return true; 643 return true;
640 } 644 }
641 return false; 645 return false;
642 } 646 }
643 647
644 static bool set_numeric_flag(char* name, char* value, FlagValueOrigin origin) { 648 static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) {
645 julong v; 649 julong v;
646 intx intx_v; 650 intx intx_v;
647 bool is_neg = false; 651 bool is_neg = false;
648 // Check the sign first since atomull() parses only unsigned values. 652 // Check the sign first since atomull() parses only unsigned values.
649 if (*value == '-') { 653 if (*value == '-') {
672 return true; 676 return true;
673 } 677 }
674 return false; 678 return false;
675 } 679 }
676 680
677 static bool set_string_flag(char* name, const char* value, FlagValueOrigin origin) { 681 static bool set_string_flag(char* name, const char* value, Flag::Flags origin) {
678 if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false; 682 if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false;
679 // Contract: CommandLineFlags always returns a pointer that needs freeing. 683 // Contract: CommandLineFlags always returns a pointer that needs freeing.
680 FREE_C_HEAP_ARRAY(char, value, mtInternal); 684 FREE_C_HEAP_ARRAY(char, value, mtInternal);
681 return true; 685 return true;
682 } 686 }
683 687
684 static bool append_to_string_flag(char* name, const char* new_value, FlagValueOrigin origin) { 688 static bool append_to_string_flag(char* name, const char* new_value, Flag::Flags origin) {
685 const char* old_value = ""; 689 const char* old_value = "";
686 if (!CommandLineFlags::ccstrAt(name, &old_value)) return false; 690 if (!CommandLineFlags::ccstrAt(name, &old_value)) return false;
687 size_t old_len = old_value != NULL ? strlen(old_value) : 0; 691 size_t old_len = old_value != NULL ? strlen(old_value) : 0;
688 size_t new_len = strlen(new_value); 692 size_t new_len = strlen(new_value);
689 const char* value; 693 const char* value;
707 FREE_C_HEAP_ARRAY(char, free_this_too, mtInternal); 711 FREE_C_HEAP_ARRAY(char, free_this_too, mtInternal);
708 } 712 }
709 return true; 713 return true;
710 } 714 }
711 715
712 bool Arguments::parse_argument(const char* arg, FlagValueOrigin origin) { 716 bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
713 717
714 // range of acceptable characters spelled out for portability reasons 718 // range of acceptable characters spelled out for portability reasons
715 #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]" 719 #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
716 #define BUFLEN 255 720 #define BUFLEN 255
717 char name[BUFLEN+1]; 721 char name[BUFLEN+1];
853 st->print_cr(""); 857 st->print_cr("");
854 } 858 }
855 } 859 }
856 860
857 bool Arguments::process_argument(const char* arg, 861 bool Arguments::process_argument(const char* arg,
858 jboolean ignore_unrecognized, FlagValueOrigin origin) { 862 jboolean ignore_unrecognized, Flag::Flags origin) {
859 863
860 JDK_Version since = JDK_Version(); 864 JDK_Version since = JDK_Version();
861 865
862 if (parse_argument(arg, origin) || ignore_unrecognized) { 866 if (parse_argument(arg, origin) || ignore_unrecognized) {
863 return true; 867 return true;
907 Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true); 911 Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true);
908 if (fuzzy_matched != NULL) { 912 if (fuzzy_matched != NULL) {
909 jio_fprintf(defaultStream::error_stream(), 913 jio_fprintf(defaultStream::error_stream(),
910 "Did you mean '%s%s%s'?\n", 914 "Did you mean '%s%s%s'?\n",
911 (fuzzy_matched->is_bool()) ? "(+/-)" : "", 915 (fuzzy_matched->is_bool()) ? "(+/-)" : "",
912 fuzzy_matched->name, 916 fuzzy_matched->_name,
913 (fuzzy_matched->is_bool()) ? "" : "=<value>"); 917 (fuzzy_matched->is_bool()) ? "" : "=<value>");
914 } 918 }
915 } 919 }
916 920
917 // allow for commandline "commenting out" options like -XX:#+Verbose 921 // allow for commandline "commenting out" options like -XX:#+Verbose
955 if (c == '\n' || (!in_quote && isspace(c))) { 959 if (c == '\n' || (!in_quote && isspace(c))) {
956 // token ends at newline, or at unquoted whitespace 960 // token ends at newline, or at unquoted whitespace
957 // this allows a way to include spaces in string-valued options 961 // this allows a way to include spaces in string-valued options
958 token[pos] = '\0'; 962 token[pos] = '\0';
959 logOption(token); 963 logOption(token);
960 result &= process_argument(token, ignore_unrecognized, CONFIG_FILE); 964 result &= process_argument(token, ignore_unrecognized, Flag::CONFIG_FILE);
961 build_jvm_flags(token); 965 build_jvm_flags(token);
962 pos = 0; 966 pos = 0;
963 in_white_space = true; 967 in_white_space = true;
964 in_quote = false; 968 in_quote = false;
965 } else if (!in_quote && (c == '\'' || c == '"')) { 969 } else if (!in_quote && (c == '\'' || c == '"')) {
973 } 977 }
974 c = getc(stream); 978 c = getc(stream);
975 } 979 }
976 if (pos > 0) { 980 if (pos > 0) {
977 token[pos] = '\0'; 981 token[pos] = '\0';
978 result &= process_argument(token, ignore_unrecognized, CONFIG_FILE); 982 result &= process_argument(token, ignore_unrecognized, Flag::CONFIG_FILE);
979 build_jvm_flags(token); 983 build_jvm_flags(token);
980 } 984 }
981 fclose(stream); 985 fclose(stream);
982 return result; 986 return result;
983 } 987 }
1103 } 1107 }
1104 break; 1108 break;
1105 } 1109 }
1106 } 1110 }
1107 1111
1112 #if defined(COMPILER2) || defined(GRAAL) || defined(_LP64) || !INCLUDE_CDS
1108 // Conflict: required to use shared spaces (-Xshare:on), but 1113 // Conflict: required to use shared spaces (-Xshare:on), but
1109 // incompatible command line options were chosen. 1114 // incompatible command line options were chosen.
1110 1115
1111 static void no_shared_spaces() { 1116 static void no_shared_spaces() {
1112 if (RequireSharedSpaces) { 1117 if (RequireSharedSpaces) {
1115 vm_exit_during_initialization("Unable to use shared archive.", NULL); 1120 vm_exit_during_initialization("Unable to use shared archive.", NULL);
1116 } else { 1121 } else {
1117 FLAG_SET_DEFAULT(UseSharedSpaces, false); 1122 FLAG_SET_DEFAULT(UseSharedSpaces, false);
1118 } 1123 }
1119 } 1124 }
1125 #endif
1120 1126
1121 void Arguments::set_tiered_flags() { 1127 void Arguments::set_tiered_flags() {
1122 // With tiered, set default policy to AdvancedThresholdPolicy, which is 3. 1128 // With tiered, set default policy to AdvancedThresholdPolicy, which is 3.
1123 if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) { 1129 if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) {
1124 FLAG_SET_DEFAULT(CompilationPolicyChoice, 3); 1130 FLAG_SET_DEFAULT(CompilationPolicyChoice, 3);
1132 FLAG_SET_DEFAULT(ReservedCodeCacheSize, ReservedCodeCacheSize * 5); 1138 FLAG_SET_DEFAULT(ReservedCodeCacheSize, ReservedCodeCacheSize * 5);
1133 } 1139 }
1134 if (!UseInterpreter) { // -Xcomp 1140 if (!UseInterpreter) { // -Xcomp
1135 Tier3InvokeNotifyFreqLog = 0; 1141 Tier3InvokeNotifyFreqLog = 0;
1136 Tier4InvocationThreshold = 0; 1142 Tier4InvocationThreshold = 0;
1143 }
1144 if (FLAG_IS_DEFAULT(NmethodSweepFraction)) {
1145 FLAG_SET_DEFAULT(NmethodSweepFraction, 1 + ReservedCodeCacheSize / (16 * M));
1137 } 1146 }
1138 } 1147 }
1139 1148
1140 #if INCLUDE_ALL_GCS 1149 #if INCLUDE_ALL_GCS
1141 static void disable_adaptive_size_policy(const char* collector_name) { 1150 static void disable_adaptive_size_policy(const char* collector_name) {
1398 return false; 1407 return false;
1399 } 1408 }
1400 return true; 1409 return true;
1401 } 1410 }
1402 1411
1403 inline uintx max_heap_for_compressed_oops() { 1412 uintx Arguments::max_heap_for_compressed_oops() {
1404 // Avoid sign flip. 1413 // Avoid sign flip.
1405 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size"); 1414 assert(OopEncodingHeapMax > (uint64_t)os::vm_page_size(), "Unusual page size");
1406 LP64_ONLY(return OopEncodingHeapMax - os::vm_page_size()); 1415 // We need to fit both the NULL page and the heap into the memory budget, while
1416 // keeping alignment constraints of the heap. To guarantee the latter, as the
1417 // NULL page is located before the heap, we pad the NULL page to the conservative
1418 // maximum alignment that the GC may ever impose upon the heap.
1419 size_t displacement_due_to_null_page = align_size_up_(os::vm_page_size(),
1420 Arguments::conservative_max_heap_alignment());
1421
1422 LP64_ONLY(return OopEncodingHeapMax - displacement_due_to_null_page);
1407 NOT_LP64(ShouldNotReachHere(); return 0); 1423 NOT_LP64(ShouldNotReachHere(); return 0);
1408 } 1424 }
1409 1425
1410 bool Arguments::should_auto_select_low_pause_collector() { 1426 bool Arguments::should_auto_select_low_pause_collector() {
1411 if (UseAutoGCSelectPolicy && 1427 if (UseAutoGCSelectPolicy &&
1446 #endif // _WIN64 1462 #endif // _WIN64
1447 } else { 1463 } else {
1448 if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) { 1464 if (UseCompressedOops && !FLAG_IS_DEFAULT(UseCompressedOops)) {
1449 warning("Max heap size too large for Compressed Oops"); 1465 warning("Max heap size too large for Compressed Oops");
1450 FLAG_SET_DEFAULT(UseCompressedOops, false); 1466 FLAG_SET_DEFAULT(UseCompressedOops, false);
1451 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false); 1467 FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1452 } 1468 }
1453 } 1469 }
1454 #endif // _LP64 1470 #endif // _LP64
1455 #endif // ZERO 1471 #endif // ZERO
1456 } 1472 }
1459 // NOTE: set_use_compressed_klass_ptrs() must be called after calling 1475 // NOTE: set_use_compressed_klass_ptrs() must be called after calling
1460 // set_use_compressed_oops(). 1476 // set_use_compressed_oops().
1461 void Arguments::set_use_compressed_klass_ptrs() { 1477 void Arguments::set_use_compressed_klass_ptrs() {
1462 #ifndef ZERO 1478 #ifndef ZERO
1463 #ifdef _LP64 1479 #ifdef _LP64
1464 // UseCompressedOops must be on for UseCompressedKlassPointers to be on. 1480 // UseCompressedOops must be on for UseCompressedClassPointers to be on.
1465 if (!UseCompressedOops) { 1481 if (!UseCompressedOops) {
1466 if (UseCompressedKlassPointers) { 1482 if (UseCompressedClassPointers) {
1467 warning("UseCompressedKlassPointers requires UseCompressedOops"); 1483 warning("UseCompressedClassPointers requires UseCompressedOops");
1468 } 1484 }
1469 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false); 1485 FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1470 } else { 1486 } else {
1471 // Turn on UseCompressedKlassPointers too 1487 // Turn on UseCompressedClassPointers too
1472 if (FLAG_IS_DEFAULT(UseCompressedKlassPointers)) { 1488 if (FLAG_IS_DEFAULT(UseCompressedClassPointers)) {
1473 FLAG_SET_ERGO(bool, UseCompressedKlassPointers, true); 1489 FLAG_SET_ERGO(bool, UseCompressedClassPointers, true);
1474 } 1490 }
1475 // Check the ClassMetaspaceSize to make sure we use compressed klass ptrs. 1491 // Check the CompressedClassSpaceSize to make sure we use compressed klass ptrs.
1476 if (UseCompressedKlassPointers) { 1492 if (UseCompressedClassPointers) {
1477 if (ClassMetaspaceSize > KlassEncodingMetaspaceMax) { 1493 if (CompressedClassSpaceSize > KlassEncodingMetaspaceMax) {
1478 warning("Class metaspace size is too large for UseCompressedKlassPointers"); 1494 warning("CompressedClassSpaceSize is too large for UseCompressedClassPointers");
1479 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false); 1495 FLAG_SET_DEFAULT(UseCompressedClassPointers, false);
1480 } 1496 }
1481 } 1497 }
1482 } 1498 }
1483 #endif // _LP64 1499 #endif // _LP64
1484 #endif // !ZERO 1500 #endif // !ZERO
1501 }
1502
1503 void Arguments::set_conservative_max_heap_alignment() {
1504 // The conservative maximum required alignment for the heap is the maximum of
1505 // the alignments imposed by several sources: any requirements from the heap
1506 // itself, the collector policy and the maximum page size we may run the VM
1507 // with.
1508 size_t heap_alignment = GenCollectedHeap::conservative_max_heap_alignment();
1509 #if INCLUDE_ALL_GCS
1510 if (UseParallelGC) {
1511 heap_alignment = ParallelScavengeHeap::conservative_max_heap_alignment();
1512 } else if (UseG1GC) {
1513 heap_alignment = G1CollectedHeap::conservative_max_heap_alignment();
1514 }
1515 #endif // INCLUDE_ALL_GCS
1516 _conservative_max_heap_alignment = MAX3(heap_alignment, os::max_page_size(),
1517 CollectorPolicy::compute_max_alignment());
1485 } 1518 }
1486 1519
1487 void Arguments::set_ergonomics_flags() { 1520 void Arguments::set_ergonomics_flags() {
1488 1521
1489 if (os::is_server_class_machine()) { 1522 if (os::is_server_class_machine()) {
1499 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true); 1532 FLAG_SET_ERGO(bool, UseConcMarkSweepGC, true);
1500 } else { 1533 } else {
1501 FLAG_SET_ERGO(bool, UseParallelGC, true); 1534 FLAG_SET_ERGO(bool, UseParallelGC, true);
1502 } 1535 }
1503 } 1536 }
1504 // Shared spaces work fine with other GCs but causes bytecode rewriting 1537 }
1505 // to be disabled, which hurts interpreter performance and decreases 1538 #if defined(COMPILER2) || defined(GRAAL)
1506 // server performance. On server class machines, keep the default 1539 // Shared spaces work fine with other GCs but causes bytecode rewriting
1507 // off unless it is asked for. Future work: either add bytecode rewriting 1540 // to be disabled, which hurts interpreter performance and decreases
1508 // at link time, or rewrite bytecodes in non-shared methods. 1541 // server performance. When -server is specified, keep the default off
1509 if (!DumpSharedSpaces && !RequireSharedSpaces && 1542 // unless it is asked for. Future work: either add bytecode rewriting
1510 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) { 1543 // at link time, or rewrite bytecodes in non-shared methods.
1511 no_shared_spaces(); 1544 if (!DumpSharedSpaces && !RequireSharedSpaces &&
1512 } 1545 (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
1513 } 1546 no_shared_spaces();
1547 }
1548 #endif
1549
1550 set_conservative_max_heap_alignment();
1514 1551
1515 #ifndef ZERO 1552 #ifndef ZERO
1516 #ifdef _LP64 1553 #ifdef _LP64
1517 set_use_compressed_oops(); 1554 set_use_compressed_oops();
1518 1555
1612 result = MIN2(result, max_allocatable / MaxVirtMemFraction); 1649 result = MIN2(result, max_allocatable / MaxVirtMemFraction);
1613 } 1650 }
1614 return result; 1651 return result;
1615 } 1652 }
1616 1653
1617 void Arguments::set_heap_base_min_address() {
1618 if (FLAG_IS_DEFAULT(HeapBaseMinAddress) && UseG1GC && HeapBaseMinAddress < 1*G) {
1619 // By default HeapBaseMinAddress is 2G on all platforms except Solaris x86.
1620 // G1 currently needs a lot of C-heap, so on Solaris we have to give G1
1621 // some extra space for the C-heap compared to other collectors.
1622 // Use FLAG_SET_DEFAULT here rather than FLAG_SET_ERGO to make sure that
1623 // code that checks for default values work correctly.
1624 FLAG_SET_DEFAULT(HeapBaseMinAddress, 1*G);
1625 }
1626 }
1627
1628 void Arguments::set_heap_size() { 1654 void Arguments::set_heap_size() {
1629 if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) { 1655 if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
1630 // Deprecated flag 1656 // Deprecated flag
1631 FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction); 1657 FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
1632 } 1658 }
1857 if (UseGCLogFileRotation) { 1883 if (UseGCLogFileRotation) {
1858 if ((Arguments::gc_log_filename() == NULL) || 1884 if ((Arguments::gc_log_filename() == NULL) ||
1859 (NumberOfGCLogFiles == 0) || 1885 (NumberOfGCLogFiles == 0) ||
1860 (GCLogFileSize == 0)) { 1886 (GCLogFileSize == 0)) {
1861 jio_fprintf(defaultStream::output_stream(), 1887 jio_fprintf(defaultStream::output_stream(),
1862 "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files> -XX:GCLogFileSize=<num_of_size>\n" 1888 "To enable GC log rotation, use -Xloggc:<filename> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<num_of_files> -XX:GCLogFileSize=<num_of_size>[k|K|m|M|g|G]\n"
1863 "where num_of_file > 0 and num_of_size > 0\n" 1889 "where num_of_file > 0 and num_of_size > 0\n"
1864 "GC log rotation is turned off\n"); 1890 "GC log rotation is turned off\n");
1865 UseGCLogFileRotation = false; 1891 UseGCLogFileRotation = false;
1866 } 1892 }
1867 } 1893 }
1869 if (UseGCLogFileRotation && GCLogFileSize < 8*K) { 1895 if (UseGCLogFileRotation && GCLogFileSize < 8*K) {
1870 FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K); 1896 FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K);
1871 jio_fprintf(defaultStream::output_stream(), 1897 jio_fprintf(defaultStream::output_stream(),
1872 "GCLogFileSize changed to minimum 8K\n"); 1898 "GCLogFileSize changed to minimum 8K\n");
1873 } 1899 }
1900 }
1901
1902 // This function is called for -Xloggc:<filename>, it can be used
1903 // to check if a given file name(or string) conforms to the following
1904 // specification:
1905 // A valid string only contains "[A-Z][a-z][0-9].-_%[p|t]"
1906 // %p and %t only allowed once. We only limit usage of filename not path
1907 bool is_filename_valid(const char *file_name) {
1908 const char* p = file_name;
1909 char file_sep = os::file_separator()[0];
1910 const char* cp;
1911 // skip prefix path
1912 for (cp = file_name; *cp != '\0'; cp++) {
1913 if (*cp == '/' || *cp == file_sep) {
1914 p = cp + 1;
1915 }
1916 }
1917
1918 int count_p = 0;
1919 int count_t = 0;
1920 while (*p != '\0') {
1921 if ((*p >= '0' && *p <= '9') ||
1922 (*p >= 'A' && *p <= 'Z') ||
1923 (*p >= 'a' && *p <= 'z') ||
1924 *p == '-' ||
1925 *p == '_' ||
1926 *p == '.') {
1927 p++;
1928 continue;
1929 }
1930 if (*p == '%') {
1931 if(*(p + 1) == 'p') {
1932 p += 2;
1933 count_p ++;
1934 continue;
1935 }
1936 if (*(p + 1) == 't') {
1937 p += 2;
1938 count_t ++;
1939 continue;
1940 }
1941 }
1942 return false;
1943 }
1944 return count_p < 2 && count_t < 2;
1874 } 1945 }
1875 1946
1876 // Check consistency of GC selection 1947 // Check consistency of GC selection
1877 bool Arguments::check_gc_consistency() { 1948 bool Arguments::check_gc_consistency() {
1878 check_gclog_consistency(); 1949 check_gclog_consistency();
2166 status = status && verify_interval(TLABWasteTargetPercent, 2237 status = status && verify_interval(TLABWasteTargetPercent,
2167 1, 100, "TLABWasteTargetPercent"); 2238 1, 100, "TLABWasteTargetPercent");
2168 2239
2169 status = status && verify_object_alignment(); 2240 status = status && verify_object_alignment();
2170 2241
2171 status = status && verify_interval(ClassMetaspaceSize, 1*M, 3*G, 2242 status = status && verify_interval(CompressedClassSpaceSize, 1*M, 3*G,
2172 "ClassMetaspaceSize"); 2243 "CompressedClassSpaceSize");
2173 2244
2174 status = status && verify_interval(MarkStackSizeMax, 2245 status = status && verify_interval(MarkStackSizeMax,
2175 1, (max_jint - 1), "MarkStackSizeMax"); 2246 1, (max_jint - 1), "MarkStackSizeMax");
2176 status = status && verify_interval(NUMAChunkResizeWeight, 0, 100, "NUMAChunkResizeWeight"); 2247 status = status && verify_interval(NUMAChunkResizeWeight, 0, 100, "NUMAChunkResizeWeight");
2177 2248
2254 // 8K is well beyond the reasonable HW cache line size, even with the 2325 // 8K is well beyond the reasonable HW cache line size, even with the
2255 // aggressive prefetching, while still leaving the room for segregating 2326 // aggressive prefetching, while still leaving the room for segregating
2256 // among the distinct pages. 2327 // among the distinct pages.
2257 if (ContendedPaddingWidth < 0 || ContendedPaddingWidth > 8192) { 2328 if (ContendedPaddingWidth < 0 || ContendedPaddingWidth > 8192) {
2258 jio_fprintf(defaultStream::error_stream(), 2329 jio_fprintf(defaultStream::error_stream(),
2259 "ContendedPaddingWidth=" INTX_FORMAT " must be the between %d and %d\n", 2330 "ContendedPaddingWidth=" INTX_FORMAT " must be in between %d and %d\n",
2260 ContendedPaddingWidth, 0, 8192); 2331 ContendedPaddingWidth, 0, 8192);
2261 status = false; 2332 status = false;
2262 } 2333 }
2263 2334
2264 // Need to enforce the padding not to break the existing field alignments. 2335 // Need to enforce the padding not to break the existing field alignments.
2265 // It is sufficient to check against the largest type size. 2336 // It is sufficient to check against the largest type size.
2266 if ((ContendedPaddingWidth % BytesPerLong) != 0) { 2337 if ((ContendedPaddingWidth % BytesPerLong) != 0) {
2267 jio_fprintf(defaultStream::error_stream(), 2338 jio_fprintf(defaultStream::error_stream(),
2268 "ContendedPaddingWidth=" INTX_FORMAT " must be the multiple of %d\n", 2339 "ContendedPaddingWidth=" INTX_FORMAT " must be a multiple of %d\n",
2269 ContendedPaddingWidth, BytesPerLong); 2340 ContendedPaddingWidth, BytesPerLong);
2270 status = false; 2341 status = false;
2271 } 2342 }
2272 2343
2273 // Check lower bounds of the code cache 2344 // Check lower bounds of the code cache
2294 "Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M, 2365 "Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M,
2295 (2*G)/M); 2366 (2*G)/M);
2296 status = false; 2367 status = false;
2297 } 2368 }
2298 2369
2370 status &= verify_interval(NmethodSweepFraction, 1, ReservedCodeCacheSize/K, "NmethodSweepFraction");
2371 status &= verify_interval(NmethodSweepActivity, 0, 2000, "NmethodSweepActivity");
2372
2299 return status; 2373 return status;
2300 } 2374 }
2301 2375
2302 bool Arguments::is_bad_option(const JavaVMOption* option, jboolean ignore, 2376 bool Arguments::is_bad_option(const JavaVMOption* option, jboolean ignore,
2303 const char* option_type) { 2377 const char* option_type) {
2395 if (result != JNI_OK) { 2469 if (result != JNI_OK) {
2396 return result; 2470 return result;
2397 } 2471 }
2398 2472
2399 // Parse JavaVMInitArgs structure passed in 2473 // Parse JavaVMInitArgs structure passed in
2400 result = parse_each_vm_init_arg(args, &scp, &scp_assembly_required, COMMAND_LINE); 2474 result = parse_each_vm_init_arg(args, &scp, &scp_assembly_required, Flag::COMMAND_LINE);
2401 if (result != JNI_OK) { 2475 if (result != JNI_OK) {
2402 return result; 2476 return result;
2403 }
2404
2405 if (AggressiveOpts) {
2406 // Insert alt-rt.jar between user-specified bootclasspath
2407 // prefix and the default bootclasspath. os::set_boot_path()
2408 // uses meta_index_dir as the default bootclasspath directory.
2409 const char* altclasses_jar = "alt-rt.jar";
2410 size_t altclasses_path_len = strlen(get_meta_index_dir()) + 1 +
2411 strlen(altclasses_jar);
2412 char* altclasses_path = NEW_C_HEAP_ARRAY(char, altclasses_path_len, mtInternal);
2413 strcpy(altclasses_path, get_meta_index_dir());
2414 strcat(altclasses_path, altclasses_jar);
2415 scp.add_suffix_to_prefix(altclasses_path);
2416 scp_assembly_required = true;
2417 FREE_C_HEAP_ARRAY(char, altclasses_path, mtInternal);
2418 } 2477 }
2419 2478
2420 // Parse _JAVA_OPTIONS environment variable (if present) (mimics classic VM) 2479 // Parse _JAVA_OPTIONS environment variable (if present) (mimics classic VM)
2421 result = parse_java_options_environment_variable(&scp, &scp_assembly_required); 2480 result = parse_java_options_environment_variable(&scp, &scp_assembly_required);
2422 if (result != JNI_OK) { 2481 if (result != JNI_OK) {
2482 } 2541 }
2483 2542
2484 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, 2543 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
2485 SysClassPath* scp_p, 2544 SysClassPath* scp_p,
2486 bool* scp_assembly_required_p, 2545 bool* scp_assembly_required_p,
2487 FlagValueOrigin origin) { 2546 Flag::Flags origin) {
2488 // Remaining part of option string 2547 // Remaining part of option string
2489 const char* tail; 2548 const char* tail;
2490 2549
2491 // iterate over arguments 2550 // iterate over arguments
2492 for (int index = 0; index < args->nOptions; index++) { 2551 for (int index = 0; index < args->nOptions; index++) {
2842 } else if (match_option(option, "-Xloggc:", &tail)) { 2901 } else if (match_option(option, "-Xloggc:", &tail)) {
2843 // Redirect GC output to the file. -Xloggc:<filename> 2902 // Redirect GC output to the file. -Xloggc:<filename>
2844 // ostream_init_log(), when called will use this filename 2903 // ostream_init_log(), when called will use this filename
2845 // to initialize a fileStream. 2904 // to initialize a fileStream.
2846 _gc_log_filename = strdup(tail); 2905 _gc_log_filename = strdup(tail);
2906 if (!is_filename_valid(_gc_log_filename)) {
2907 jio_fprintf(defaultStream::output_stream(),
2908 "Invalid file name for use with -Xloggc: Filename can only contain the "
2909 "characters [A-Z][a-z][0-9]-_.%%[p|t] but it has been %s\n"
2910 "Note %%p or %%t can only be used once\n", _gc_log_filename);
2911 return JNI_EINVAL;
2912 }
2847 FLAG_SET_CMDLINE(bool, PrintGC, true); 2913 FLAG_SET_CMDLINE(bool, PrintGC, true);
2848 FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true); 2914 FLAG_SET_CMDLINE(bool, PrintGCTimeStamps, true);
2849 2915
2850 // JNI hooks 2916 // JNI hooks
2851 } else if (match_option(option, "-Xcheck", &tail)) { 2917 } else if (match_option(option, "-Xcheck", &tail)) {
3309 logOption(tail); 3375 logOption(tail);
3310 } 3376 }
3311 } 3377 }
3312 } 3378 }
3313 3379
3314 return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, ENVIRON_VAR)); 3380 return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, Flag::ENVIRON_VAR));
3315 } 3381 }
3316 return JNI_OK; 3382 return JNI_OK;
3317 } 3383 }
3318 3384
3319 void Arguments::set_shared_spaces_flags() { 3385 void Arguments::set_shared_spaces_flags() {
3321 if (RequireSharedSpaces) { 3387 if (RequireSharedSpaces) {
3322 warning("cannot dump shared archive while using shared archive"); 3388 warning("cannot dump shared archive while using shared archive");
3323 } 3389 }
3324 UseSharedSpaces = false; 3390 UseSharedSpaces = false;
3325 #ifdef _LP64 3391 #ifdef _LP64
3326 if (!UseCompressedOops || !UseCompressedKlassPointers) { 3392 if (!UseCompressedOops || !UseCompressedClassPointers) {
3327 vm_exit_during_initialization( 3393 vm_exit_during_initialization(
3328 "Cannot dump shared archive when UseCompressedOops or UseCompressedKlassPointers is off.", NULL); 3394 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3329 } 3395 }
3330 } else { 3396 } else {
3331 // UseCompressedOops and UseCompressedKlassPointers must be on for UseSharedSpaces. 3397 // UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.
3332 if (!UseCompressedOops || !UseCompressedKlassPointers) { 3398 if (!UseCompressedOops || !UseCompressedClassPointers) {
3333 no_shared_spaces(); 3399 no_shared_spaces();
3334 } 3400 }
3335 #endif 3401 #endif
3336 } 3402 }
3337 } 3403 }
3373 } 3439 }
3374 } 3440 }
3375 return shared_archive_path; 3441 return shared_archive_path;
3376 } 3442 }
3377 3443
3444 #ifndef PRODUCT
3445 // Determine whether LogVMOutput should be implicitly turned on.
3446 static bool use_vm_log() {
3447 if (LogCompilation || !FLAG_IS_DEFAULT(LogFile) ||
3448 PrintCompilation || PrintInlining || PrintDependencies || PrintNativeNMethods ||
3449 PrintDebugInfo || PrintRelocations || PrintNMethods || PrintExceptionHandlers ||
3450 PrintAssembly || TraceDeoptimization || TraceDependencies ||
3451 (VerifyDependencies && FLAG_IS_CMDLINE(VerifyDependencies))) {
3452 return true;
3453 }
3454
3455 #ifdef COMPILER1
3456 if (PrintC1Statistics) {
3457 return true;
3458 }
3459 #endif // COMPILER1
3460
3461 #ifdef COMPILER2
3462 if (PrintOptoAssembly || PrintOptoStatistics) {
3463 return true;
3464 }
3465 #endif // COMPILER2
3466
3467 return false;
3468 }
3469 #endif // PRODUCT
3470
3378 // Parse entry point called from JNI_CreateJavaVM 3471 // Parse entry point called from JNI_CreateJavaVM
3379 3472
3380 jint Arguments::parse(const JavaVMInitArgs* args) { 3473 jint Arguments::parse(const JavaVMInitArgs* args) {
3381 3474
3382 // Remaining part of option string 3475 // Remaining part of option string
3553 FLAG_SET_DEFAULT(PrintSharedSpaces, false); 3646 FLAG_SET_DEFAULT(PrintSharedSpaces, false);
3554 } 3647 }
3555 no_shared_spaces(); 3648 no_shared_spaces();
3556 #endif // INCLUDE_CDS 3649 #endif // INCLUDE_CDS
3557 3650
3651 return JNI_OK;
3652 }
3653
3654 jint Arguments::apply_ergo() {
3655
3558 // Set flags based on ergonomics. 3656 // Set flags based on ergonomics.
3559 set_ergonomics_flags(); 3657 set_ergonomics_flags();
3560 3658
3561 set_shared_spaces_flags(); 3659 set_shared_spaces_flags();
3562 3660
3567 3665
3568 if (TieredCompilation) { 3666 if (TieredCompilation) {
3569 set_tiered_flags(); 3667 set_tiered_flags();
3570 } else { 3668 } else {
3571 // Check if the policy is valid. Policies 0 and 1 are valid for non-tiered setup. 3669 // Check if the policy is valid. Policies 0 and 1 are valid for non-tiered setup.
3572 if (CompilationPolicyChoice >= 2 && CompilationPolicyChoice < 4) { 3670 if (CompilationPolicyChoice >= 2 GRAAL_ONLY(&& CompilationPolicyChoice < 4)) {
3573 vm_exit_during_initialization( 3671 vm_exit_during_initialization(
3574 "Incompatible compilation policy selected", NULL); 3672 "Incompatible compilation policy selected", NULL);
3575 } 3673 }
3576 } 3674 }
3577
3578 set_heap_base_min_address();
3579 3675
3580 // Set heap size based on available physical memory 3676 // Set heap size based on available physical memory
3581 set_heap_size(); 3677 set_heap_size();
3582 3678
3583 #if INCLUDE_ALL_GCS 3679 #if INCLUDE_ALL_GCS
3633 #ifdef CC_INTERP 3729 #ifdef CC_INTERP
3634 // Clear flags not supported by the C++ interpreter 3730 // Clear flags not supported by the C++ interpreter
3635 FLAG_SET_DEFAULT(ProfileInterpreter, false); 3731 FLAG_SET_DEFAULT(ProfileInterpreter, false);
3636 FLAG_SET_DEFAULT(UseBiasedLocking, false); 3732 FLAG_SET_DEFAULT(UseBiasedLocking, false);
3637 LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedOops, false)); 3733 LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedOops, false));
3638 LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedKlassPointers, false)); 3734 LP64_ONLY(FLAG_SET_DEFAULT(UseCompressedClassPointers, false));
3639 #endif // CC_INTERP 3735 #endif // CC_INTERP
3640 3736
3641 #ifdef COMPILER2 3737 #ifdef COMPILER2
3642 if (!UseBiasedLocking || EmitSync != 0) { 3738 if (!UseBiasedLocking || EmitSync != 0) {
3643 UseOptoBiasInlining = false; 3739 UseOptoBiasInlining = false;
3660 #endif 3756 #endif
3661 3757
3662 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) { 3758 if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
3663 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output"); 3759 warning("PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output");
3664 DebugNonSafepoints = true; 3760 DebugNonSafepoints = true;
3761 }
3762
3763 if (FLAG_IS_CMDLINE(CompressedClassSpaceSize) && !UseCompressedClassPointers) {
3764 warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used");
3665 } 3765 }
3666 3766
3667 #ifndef PRODUCT 3767 #ifndef PRODUCT
3668 if (CompileTheWorld) { 3768 if (CompileTheWorld) {
3669 // Force NmethodSweeper to sweep whole CodeCache each time. 3769 // Force NmethodSweeper to sweep whole CodeCache each time.
3670 if (FLAG_IS_DEFAULT(NmethodSweepFraction)) { 3770 if (FLAG_IS_DEFAULT(NmethodSweepFraction)) {
3671 NmethodSweepFraction = 1; 3771 NmethodSweepFraction = 1;
3672 } 3772 }
3673 } 3773 }
3674 #endif 3774
3775 if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) {
3776 if (use_vm_log()) {
3777 LogVMOutput = true;
3778 }
3779 }
3780 #endif // PRODUCT
3675 3781
3676 if (PrintCommandLineFlags) { 3782 if (PrintCommandLineFlags) {
3677 CommandLineFlags::printSetFlags(tty); 3783 CommandLineFlags::printSetFlags(tty);
3678 } 3784 }
3679 3785