comparison src/share/vm/runtime/arguments.cpp @ 8506:c3657d00e343

-Merge with tip
author Christos Kotselidis <christos.kotselidis@oracle.com>
date Thu, 21 Mar 2013 14:11:13 +0100
parents 86b4965f0c9a 0e2c530885d1
children c92949b1ec8a
comparison
equal deleted inserted replaced
8505:dee7c8b578c7 8506:c3657d00e343
36 #include "runtime/globals_extension.hpp" 36 #include "runtime/globals_extension.hpp"
37 #include "runtime/java.hpp" 37 #include "runtime/java.hpp"
38 #include "services/management.hpp" 38 #include "services/management.hpp"
39 #include "services/memTracker.hpp" 39 #include "services/memTracker.hpp"
40 #include "utilities/defaultStream.hpp" 40 #include "utilities/defaultStream.hpp"
41 #include "utilities/macros.hpp"
41 #include "utilities/taskqueue.hpp" 42 #include "utilities/taskqueue.hpp"
42 #ifdef TARGET_OS_FAMILY_linux 43 #ifdef TARGET_OS_FAMILY_linux
43 # include "os_linux.inline.hpp" 44 # include "os_linux.inline.hpp"
44 #endif 45 #endif
45 #ifdef TARGET_OS_FAMILY_solaris 46 #ifdef TARGET_OS_FAMILY_solaris
49 # include "os_windows.inline.hpp" 50 # include "os_windows.inline.hpp"
50 #endif 51 #endif
51 #ifdef TARGET_OS_FAMILY_bsd 52 #ifdef TARGET_OS_FAMILY_bsd
52 # include "os_bsd.inline.hpp" 53 # include "os_bsd.inline.hpp"
53 #endif 54 #endif
54 #ifndef SERIALGC 55 #if INCLUDE_ALL_GCS
55 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp" 56 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
56 #endif 57 #endif // INCLUDE_ALL_GCS
57 58
58 // Note: This is a special bug reporting site for the JVM 59 // Note: This is a special bug reporting site for the JVM
59 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp" 60 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp"
60 #define DEFAULT_JAVA_LAUNCHER "generic" 61 #define DEFAULT_JAVA_LAUNCHER "generic"
61 62
102 SystemProperty *Arguments::_sun_boot_library_path = NULL; 103 SystemProperty *Arguments::_sun_boot_library_path = NULL;
103 SystemProperty *Arguments::_java_library_path = NULL; 104 SystemProperty *Arguments::_java_library_path = NULL;
104 SystemProperty *Arguments::_java_home = NULL; 105 SystemProperty *Arguments::_java_home = NULL;
105 SystemProperty *Arguments::_java_class_path = NULL; 106 SystemProperty *Arguments::_java_class_path = NULL;
106 SystemProperty *Arguments::_sun_boot_class_path = NULL; 107 SystemProperty *Arguments::_sun_boot_class_path = NULL;
107 #ifdef GRAAL
108 SystemProperty *Arguments::_compiler_class_path = NULL;
109 #endif
110 108
111 char* Arguments::_meta_index_path = NULL; 109 char* Arguments::_meta_index_path = NULL;
112 char* Arguments::_meta_index_dir = NULL; 110 char* Arguments::_meta_index_dir = NULL;
113 111
114 // Check if head of 'option' matches 'name', and sets 'tail' remaining part of option string 112 // Check if head of 'option' matches 'name', and sets 'tail' remaining part of option string
166 _java_endorsed_dirs = new SystemProperty("java.endorsed.dirs", NULL, true); 164 _java_endorsed_dirs = new SystemProperty("java.endorsed.dirs", NULL, true);
167 _sun_boot_library_path = new SystemProperty("sun.boot.library.path", NULL, true); 165 _sun_boot_library_path = new SystemProperty("sun.boot.library.path", NULL, true);
168 _java_library_path = new SystemProperty("java.library.path", NULL, true); 166 _java_library_path = new SystemProperty("java.library.path", NULL, true);
169 _java_home = new SystemProperty("java.home", NULL, true); 167 _java_home = new SystemProperty("java.home", NULL, true);
170 _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL, true); 168 _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL, true);
171 #ifdef GRAAL
172 _compiler_class_path = new SystemProperty("compiler.class.path", NULL, true);
173 #endif
174 169
175 _java_class_path = new SystemProperty("java.class.path", "", true); 170 _java_class_path = new SystemProperty("java.class.path", "", true);
176 171
177 // Add to System Property list. 172 // Add to System Property list.
178 PropertyList_add(&_system_properties, _java_ext_dirs); 173 PropertyList_add(&_system_properties, _java_ext_dirs);
180 PropertyList_add(&_system_properties, _sun_boot_library_path); 175 PropertyList_add(&_system_properties, _sun_boot_library_path);
181 PropertyList_add(&_system_properties, _java_library_path); 176 PropertyList_add(&_system_properties, _java_library_path);
182 PropertyList_add(&_system_properties, _java_home); 177 PropertyList_add(&_system_properties, _java_home);
183 PropertyList_add(&_system_properties, _java_class_path); 178 PropertyList_add(&_system_properties, _java_class_path);
184 PropertyList_add(&_system_properties, _sun_boot_class_path); 179 PropertyList_add(&_system_properties, _sun_boot_class_path);
185 #ifdef GRAAL
186 PropertyList_add(&_system_properties, _compiler_class_path);
187 #endif
188 180
189 // Set OS specific system properties values 181 // Set OS specific system properties values
190 os::init_system_properties_values(); 182 os::init_system_properties_values();
191 } 183 }
192 184
843 835
844 if (parse_argument(arg, origin) || ignore_unrecognized) { 836 if (parse_argument(arg, origin) || ignore_unrecognized) {
845 return true; 837 return true;
846 } 838 }
847 839
848 const char * const argname = *arg == '+' || *arg == '-' ? arg + 1 : arg; 840 bool has_plus_minus = (*arg == '+' || *arg == '-');
841 const char* const argname = has_plus_minus ? arg + 1 : arg;
849 if (is_newly_obsolete(arg, &since)) { 842 if (is_newly_obsolete(arg, &since)) {
850 char version[256]; 843 char version[256];
851 since.to_string(version, sizeof(version)); 844 since.to_string(version, sizeof(version));
852 warning("ignoring option %s; support was removed in %s", argname, version); 845 warning("ignoring option %s; support was removed in %s", argname, version);
853 return true; 846 return true;
854 } 847 }
855 848
856 // For locked flags, report a custom error message if available. 849 // For locked flags, report a custom error message if available.
857 // Otherwise, report the standard unrecognized VM option. 850 // Otherwise, report the standard unrecognized VM option.
858 851
859 Flag* locked_flag = Flag::find_flag((char*)argname, strlen(argname), true); 852 size_t arg_len;
860 if (locked_flag != NULL) { 853 const char* equal_sign = strchr(argname, '=');
854 if (equal_sign == NULL) {
855 arg_len = strlen(argname);
856 } else {
857 arg_len = equal_sign - argname;
858 }
859
860 Flag* found_flag = Flag::find_flag((char*)argname, arg_len, true);
861 if (found_flag != NULL) {
861 char locked_message_buf[BUFLEN]; 862 char locked_message_buf[BUFLEN];
862 locked_flag->get_locked_message(locked_message_buf, BUFLEN); 863 found_flag->get_locked_message(locked_message_buf, BUFLEN);
863 if (strlen(locked_message_buf) == 0) { 864 if (strlen(locked_message_buf) == 0) {
864 jio_fprintf(defaultStream::error_stream(), 865 if (found_flag->is_bool() && !has_plus_minus) {
865 "Unrecognized VM option '%s'\n", argname); 866 jio_fprintf(defaultStream::error_stream(),
867 "Missing +/- setting for VM option '%s'\n", argname);
868 } else if (!found_flag->is_bool() && has_plus_minus) {
869 jio_fprintf(defaultStream::error_stream(),
870 "Unexpected +/- setting in VM option '%s'\n", argname);
871 } else {
872 jio_fprintf(defaultStream::error_stream(),
873 "Improperly specified VM option '%s'\n", argname);
874 }
866 } else { 875 } else {
867 jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf); 876 jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf);
868 } 877 }
869 } else { 878 } else {
870 jio_fprintf(defaultStream::error_stream(), 879 jio_fprintf(defaultStream::error_stream(),
1084 vm_exit_during_initialization( 1093 vm_exit_during_initialization(
1085 "Incompatible compilation policy selected", NULL); 1094 "Incompatible compilation policy selected", NULL);
1086 } 1095 }
1087 // Increase the code cache size - tiered compiles a lot more. 1096 // Increase the code cache size - tiered compiles a lot more.
1088 if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) { 1097 if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
1089 FLAG_SET_DEFAULT(ReservedCodeCacheSize, ReservedCodeCacheSize * 2); 1098 FLAG_SET_DEFAULT(ReservedCodeCacheSize, ReservedCodeCacheSize * 5);
1090 } 1099 }
1091 } 1100 }
1092 1101
1093 #if INCLUDE_ALTERNATE_GCS 1102 #if INCLUDE_ALL_GCS
1094 static void disable_adaptive_size_policy(const char* collector_name) { 1103 static void disable_adaptive_size_policy(const char* collector_name) {
1095 if (UseAdaptiveSizePolicy) { 1104 if (UseAdaptiveSizePolicy) {
1096 if (FLAG_IS_CMDLINE(UseAdaptiveSizePolicy)) { 1105 if (FLAG_IS_CMDLINE(UseAdaptiveSizePolicy)) {
1097 warning("disabling UseAdaptiveSizePolicy; it is incompatible with %s.", 1106 warning("disabling UseAdaptiveSizePolicy; it is incompatible with %s.",
1098 collector_name); 1107 collector_name);
1255 // If we decided above (or user explicitly requested) 1264 // If we decided above (or user explicitly requested)
1256 // `promote all' (via MaxTenuringThreshold := 0), 1265 // `promote all' (via MaxTenuringThreshold := 0),
1257 // prefer minuscule survivor spaces so as not to waste 1266 // prefer minuscule survivor spaces so as not to waste
1258 // space for (non-existent) survivors 1267 // space for (non-existent) survivors
1259 if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) { 1268 if (FLAG_IS_DEFAULT(SurvivorRatio) && MaxTenuringThreshold == 0) {
1260 FLAG_SET_ERGO(intx, SurvivorRatio, MAX2((intx)1024, SurvivorRatio)); 1269 FLAG_SET_ERGO(uintx, SurvivorRatio, MAX2((uintx)1024, SurvivorRatio));
1261 } 1270 }
1262 // If OldPLABSize is set and CMSParPromoteBlocksToClaim is not, 1271 // If OldPLABSize is set and CMSParPromoteBlocksToClaim is not,
1263 // set CMSParPromoteBlocksToClaim equal to OldPLABSize. 1272 // set CMSParPromoteBlocksToClaim equal to OldPLABSize.
1264 // This is done in order to make ParNew+CMS configuration to work 1273 // This is done in order to make ParNew+CMS configuration to work
1265 // with YoungPLABSize and OldPLABSize options. 1274 // with YoungPLABSize and OldPLABSize options.
1300 tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk", 1309 tty->print_cr("MarkStackSize: %uk MarkStackSizeMax: %uk",
1301 MarkStackSize / K, MarkStackSizeMax / K); 1310 MarkStackSize / K, MarkStackSizeMax / K);
1302 tty->print_cr("ConcGCThreads: %u", ConcGCThreads); 1311 tty->print_cr("ConcGCThreads: %u", ConcGCThreads);
1303 } 1312 }
1304 } 1313 }
1305 #endif // INCLUDE_ALTERNATE_GCS 1314 #endif // INCLUDE_ALL_GCS
1306 1315
1307 void set_object_alignment() { 1316 void set_object_alignment() {
1308 // Object alignment. 1317 // Object alignment.
1309 assert(is_power_of_2(ObjectAlignmentInBytes), "ObjectAlignmentInBytes must be power of 2"); 1318 assert(is_power_of_2(ObjectAlignmentInBytes), "ObjectAlignmentInBytes must be power of 2");
1310 MinObjAlignmentInBytes = ObjectAlignmentInBytes; 1319 MinObjAlignmentInBytes = ObjectAlignmentInBytes;
1317 LogMinObjAlignment = LogMinObjAlignmentInBytes - LogHeapWordSize; 1326 LogMinObjAlignment = LogMinObjAlignmentInBytes - LogHeapWordSize;
1318 1327
1319 // Oop encoding heap max 1328 // Oop encoding heap max
1320 OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes; 1329 OopEncodingHeapMax = (uint64_t(max_juint) + 1) << LogMinObjAlignmentInBytes;
1321 1330
1322 #if INCLUDE_ALTERNATE_GCS 1331 #if INCLUDE_ALL_GCS
1323 // Set CMS global values 1332 // Set CMS global values
1324 CompactibleFreeListSpace::set_cms_values(); 1333 CompactibleFreeListSpace::set_cms_values();
1325 #endif // INCLUDE_ALTERNATE_GCS 1334 #endif // INCLUDE_ALL_GCS
1326 } 1335 }
1327 1336
1328 bool verify_object_alignment() { 1337 bool verify_object_alignment() {
1329 // Object alignment. 1338 // Object alignment.
1330 if (!is_power_of_2(ObjectAlignmentInBytes)) { 1339 if (!is_power_of_2(ObjectAlignmentInBytes)) {
1445 if (FLAG_IS_DEFAULT(UseCompressedKlassPointers)) { 1454 if (FLAG_IS_DEFAULT(UseCompressedKlassPointers)) {
1446 FLAG_SET_ERGO(bool, UseCompressedKlassPointers, true); 1455 FLAG_SET_ERGO(bool, UseCompressedKlassPointers, true);
1447 } 1456 }
1448 // Set the ClassMetaspaceSize to something that will not need to be 1457 // Set the ClassMetaspaceSize to something that will not need to be
1449 // expanded, since it cannot be expanded. 1458 // expanded, since it cannot be expanded.
1450 if (UseCompressedKlassPointers && FLAG_IS_DEFAULT(ClassMetaspaceSize)) { 1459 if (UseCompressedKlassPointers) {
1451 // 100,000 classes seems like a good size, so 100M assumes around 1K 1460 if (ClassMetaspaceSize > KlassEncodingMetaspaceMax) {
1452 // per klass. The vtable and oopMap is embedded so we don't have a fixed 1461 warning("Class metaspace size is too large for UseCompressedKlassPointers");
1453 // size per klass. Eventually, this will be parameterized because it 1462 FLAG_SET_DEFAULT(UseCompressedKlassPointers, false);
1454 // would also be useful to determine the optimal size of the 1463 } else if (FLAG_IS_DEFAULT(ClassMetaspaceSize)) {
1455 // systemDictionary. 1464 // 100,000 classes seems like a good size, so 100M assumes around 1K
1456 FLAG_SET_ERGO(uintx, ClassMetaspaceSize, 100*M); 1465 // per klass. The vtable and oopMap is embedded so we don't have a fixed
1466 // size per klass. Eventually, this will be parameterized because it
1467 // would also be useful to determine the optimal size of the
1468 // systemDictionary.
1469 FLAG_SET_ERGO(uintx, ClassMetaspaceSize, 100*M);
1470 }
1457 } 1471 }
1458 } 1472 }
1459 // Also checks that certain machines are slower with compressed oops 1473 // Also checks that certain machines are slower with compressed oops
1460 // in vm_version initialization code. 1474 // in vm_version initialization code.
1461 #endif // _LP64 1475 #endif // _LP64
1729 } 1743 }
1730 jio_fprintf(defaultStream::error_stream(), 1744 jio_fprintf(defaultStream::error_stream(),
1731 "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n", 1745 "%s of " UINTX_FORMAT " is invalid; must be between 0 and 100\n",
1732 name, value); 1746 name, value);
1733 return false; 1747 return false;
1734 }
1735
1736 static void force_serial_gc() {
1737 FLAG_SET_DEFAULT(UseSerialGC, true);
1738 FLAG_SET_DEFAULT(UseParNewGC, false);
1739 FLAG_SET_DEFAULT(UseConcMarkSweepGC, false);
1740 FLAG_SET_DEFAULT(CMSIncrementalMode, false); // special CMS suboption
1741 FLAG_SET_DEFAULT(UseParallelGC, false);
1742 FLAG_SET_DEFAULT(UseParallelOldGC, false);
1743 FLAG_SET_DEFAULT(UseG1GC, false);
1744 } 1748 }
1745 1749
1746 static bool verify_serial_gc_flags() { 1750 static bool verify_serial_gc_flags() {
1747 return (UseSerialGC && 1751 return (UseSerialGC &&
1748 !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC || 1752 !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC ||
1890 status = false; 1894 status = false;
1891 } 1895 }
1892 // Keeping the heap 100% free is hard ;-) so limit it to 99%. 1896 // Keeping the heap 100% free is hard ;-) so limit it to 99%.
1893 MinHeapFreeRatio = MIN2(MinHeapFreeRatio, (uintx) 99); 1897 MinHeapFreeRatio = MIN2(MinHeapFreeRatio, (uintx) 99);
1894 1898
1899 // Min/MaxMetaspaceFreeRatio
1900 status = status && verify_percentage(MinMetaspaceFreeRatio, "MinMetaspaceFreeRatio");
1901 status = status && verify_percentage(MaxMetaspaceFreeRatio, "MaxMetaspaceFreeRatio");
1902
1903 if (MinMetaspaceFreeRatio > MaxMetaspaceFreeRatio) {
1904 jio_fprintf(defaultStream::error_stream(),
1905 "MinMetaspaceFreeRatio (%s" UINTX_FORMAT ") must be less than or "
1906 "equal to MaxMetaspaceFreeRatio (%s" UINTX_FORMAT ")\n",
1907 FLAG_IS_DEFAULT(MinMetaspaceFreeRatio) ? "Default: " : "",
1908 MinMetaspaceFreeRatio,
1909 FLAG_IS_DEFAULT(MaxMetaspaceFreeRatio) ? "Default: " : "",
1910 MaxMetaspaceFreeRatio);
1911 status = false;
1912 }
1913
1914 // Trying to keep 100% free is not practical
1915 MinMetaspaceFreeRatio = MIN2(MinMetaspaceFreeRatio, (uintx) 99);
1916
1895 if (FullGCALot && FLAG_IS_DEFAULT(MarkSweepAlwaysCompactCount)) { 1917 if (FullGCALot && FLAG_IS_DEFAULT(MarkSweepAlwaysCompactCount)) {
1896 MarkSweepAlwaysCompactCount = 1; // Move objects every gc. 1918 MarkSweepAlwaysCompactCount = 1; // Move objects every gc.
1897 } 1919 }
1898 1920
1899 if (UseParallelOldGC && ParallelOldGCSplitALot) { 1921 if (UseParallelOldGC && ParallelOldGCSplitALot) {
1900 // Settings to encourage splitting. 1922 // Settings to encourage splitting.
1901 if (!FLAG_IS_CMDLINE(NewRatio)) { 1923 if (!FLAG_IS_CMDLINE(NewRatio)) {
1902 FLAG_SET_CMDLINE(intx, NewRatio, 2); 1924 FLAG_SET_CMDLINE(uintx, NewRatio, 2);
1903 } 1925 }
1904 if (!FLAG_IS_CMDLINE(ScavengeBeforeFullGC)) { 1926 if (!FLAG_IS_CMDLINE(ScavengeBeforeFullGC)) {
1905 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false); 1927 FLAG_SET_CMDLINE(bool, ScavengeBeforeFullGC, false);
1906 } 1928 }
1907 } 1929 }
1992 status = false; 2014 status = false;
1993 } 2015 }
1994 2016
1995 status = status && verify_min_value(ParGCArrayScanChunk, 1, "ParGCArrayScanChunk"); 2017 status = status && verify_min_value(ParGCArrayScanChunk, 1, "ParGCArrayScanChunk");
1996 2018
1997 #ifndef SERIALGC 2019 #if INCLUDE_ALL_GCS
1998 if (UseG1GC) { 2020 if (UseG1GC) {
1999 status = status && verify_percentage(InitiatingHeapOccupancyPercent, 2021 status = status && verify_percentage(InitiatingHeapOccupancyPercent,
2000 "InitiatingHeapOccupancyPercent"); 2022 "InitiatingHeapOccupancyPercent");
2001 status = status && verify_min_value(G1RefProcDrainInterval, 1, 2023 status = status && verify_min_value(G1RefProcDrainInterval, 1,
2002 "G1RefProcDrainInterval"); 2024 "G1RefProcDrainInterval");
2003 status = status && verify_min_value((intx)G1ConcMarkStepDurationMillis, 1, 2025 status = status && verify_min_value((intx)G1ConcMarkStepDurationMillis, 1,
2004 "G1ConcMarkStepDurationMillis"); 2026 "G1ConcMarkStepDurationMillis");
2005 } 2027 }
2006 #endif 2028 #endif // INCLUDE_ALL_GCS
2007 2029
2008 status = status && verify_interval(RefDiscoveryPolicy, 2030 status = status && verify_interval(RefDiscoveryPolicy,
2009 ReferenceProcessor::DiscoveryPolicyMin, 2031 ReferenceProcessor::DiscoveryPolicyMin,
2010 ReferenceProcessor::DiscoveryPolicyMax, 2032 ReferenceProcessor::DiscoveryPolicyMax,
2011 "RefDiscoveryPolicy"); 2033 "RefDiscoveryPolicy");
2046 } 2068 }
2047 #endif 2069 #endif
2048 } 2070 }
2049 #ifdef GRAAL 2071 #ifdef GRAAL
2050 if (UseCompressedOops) { 2072 if (UseCompressedOops) {
2051 jio_fprintf(defaultStream::error_stream(), 2073 if (IgnoreUnrecognizedVMOptions) {
2074 warning("UseCompressedOops is disabled, because it is not supported by Graal");
2075 FLAG_SET_CMDLINE(bool, UseCompressedOops, false);
2076 } else {
2077 jio_fprintf(defaultStream::error_stream(),
2052 "CompressedOops are not supported in Graal at the moment\n"); 2078 "CompressedOops are not supported in Graal at the moment\n");
2053 status = false; 2079 status = false;
2080 }
2054 } else { 2081 } else {
2055 // This prevents the flag being set to true by set_ergonomics_flags() 2082 // This prevents the flag being set to true by set_ergonomics_flags()
2056 FLAG_SET_CMDLINE(bool, UseCompressedOops, false); 2083 FLAG_SET_CMDLINE(bool, UseCompressedOops, false);
2057 } 2084 }
2058 2085
2059 if (UseCompressedKlassPointers) { 2086 if (UseCompressedKlassPointers) {
2060 jio_fprintf(defaultStream::error_stream(), 2087 if (IgnoreUnrecognizedVMOptions) {
2088 warning("UseCompressedKlassPointers is disabled, because it is not supported by Graal");
2089 FLAG_SET_CMDLINE(bool, UseCompressedKlassPointers, false);
2090 } else {
2091 jio_fprintf(defaultStream::error_stream(),
2061 "UseCompressedKlassPointers are not supported in Graal at the moment\n"); 2092 "UseCompressedKlassPointers are not supported in Graal at the moment\n");
2062 status = false; 2093 status = false;
2094 }
2063 } else { 2095 } else {
2064 // This prevents the flag being set to true by set_ergonomics_flags() 2096 // This prevents the flag being set to true by set_ergonomics_flags()
2065 FLAG_SET_CMDLINE(bool, UseCompressedKlassPointers, false); 2097 FLAG_SET_CMDLINE(bool, UseCompressedKlassPointers, false);
2066 } 2098 }
2067 2099
2148 if (!atomull(s, long_arg)) return arg_unreadable; 2180 if (!atomull(s, long_arg)) return arg_unreadable;
2149 return check_memory_size(*long_arg, min_size); 2181 return check_memory_size(*long_arg, min_size);
2150 } 2182 }
2151 2183
2152 // Parse JavaVMInitArgs structure 2184 // Parse JavaVMInitArgs structure
2153 #ifdef GRAAL
2154 static void prepend_to_graal_classpath(SysClassPath &cp, const char* path) {
2155 cp.add_prefix(path);
2156 }
2157
2158 static void prepend_to_graal_classpath(SysClassPath &cp, const char* graal_dir, const char* project) {
2159 const int BUFFER_SIZE = 1024;
2160 char path[BUFFER_SIZE];
2161
2162 const char fileSep = *os::file_separator();
2163 sprintf(path, "%s%c%s%cbin", graal_dir, fileSep, project, fileSep);
2164
2165 DIR* dir = os::opendir(path);
2166 if (dir == NULL) {
2167 jio_fprintf(defaultStream::output_stream(), "Error while starting Graal VM: The Graal class directory %s could not be opened.\n", path);
2168 vm_exit(1);
2169 }
2170 os::closedir(dir);
2171 prepend_to_graal_classpath(cp, path);
2172 }
2173
2174 // Walk up the directory hierarchy starting from JAVA_HOME looking
2175 // for a directory named "graal". If found, then the full path to
2176 // this directory is returned in graal_dir.
2177 static bool find_graal_dir(char* graal_dir) {
2178 strcpy(graal_dir, Arguments::get_java_home());
2179 char* end = graal_dir + strlen(graal_dir);
2180 const char fileSep = *os::file_separator();
2181 while (end != graal_dir) {
2182 if (fileSep == '/')
2183 strcat(graal_dir, "/graal");
2184 else {
2185 assert(fileSep == '\\', "unexpected separator char");
2186 strcat(graal_dir, "\\graal");
2187 }
2188 DIR* dir = os::opendir(graal_dir);
2189 if (dir != NULL) {
2190 os::closedir(dir);
2191 return true;
2192 }
2193 *end = 0;
2194 while (end != graal_dir) {
2195 if (*end == fileSep) {
2196 *end = 0;
2197 break;
2198 }
2199 end--;
2200 }
2201 }
2202 return false;
2203 }
2204 #endif
2205 2185
2206 jint Arguments::parse_vm_init_args(const JavaVMInitArgs* args) { 2186 jint Arguments::parse_vm_init_args(const JavaVMInitArgs* args) {
2207 // For components of the system classpath. 2187 // For components of the system classpath.
2208 SysClassPath scp(Arguments::get_sysclasspath()); 2188 SysClassPath scp(Arguments::get_sysclasspath());
2209 bool scp_assembly_required = false; 2189 bool scp_assembly_required = false;
2226 // Parse JavaVMInitArgs structure passed in 2206 // Parse JavaVMInitArgs structure passed in
2227 result = parse_each_vm_init_arg(args, &scp, &scp_assembly_required, COMMAND_LINE); 2207 result = parse_each_vm_init_arg(args, &scp, &scp_assembly_required, COMMAND_LINE);
2228 if (result != JNI_OK) { 2208 if (result != JNI_OK) {
2229 return result; 2209 return result;
2230 } 2210 }
2231
2232 #ifdef GRAAL
2233 if (PrintVMOptions) {
2234 tty->print_cr("Running Graal VM... ");
2235 }
2236
2237 SysClassPath scp_compiler("");
2238
2239 if (GraalClassPath != NULL) {
2240 prepend_to_graal_classpath(scp_compiler, GraalClassPath);
2241 } else {
2242 const int BUFFER_SIZE = 1024;
2243 char graal_dir[BUFFER_SIZE];
2244 if (!os::getenv("GRAAL", graal_dir, sizeof(graal_dir))) {
2245 if (find_graal_dir(graal_dir) == false) {
2246 jio_fprintf(defaultStream::output_stream(), "Error while starting Graal VM: The GRAAL environment variable needs to point to the directory containing the Graal projects.\n");
2247 vm_exit(0);
2248 }
2249 }
2250 if (PrintVMOptions) tty->print_cr("GRAAL=%s", graal_dir);
2251
2252 // this declaration is checked for correctness by 'mx build' - only
2253 // modify its entries, not its name or shape
2254 const char* graal_projects[] = {
2255 #ifdef AMD64
2256 "com.oracle.graal.amd64",
2257 "com.oracle.graal.asm.amd64",
2258 "com.oracle.graal.lir.amd64",
2259 "com.oracle.graal.compiler.amd64",
2260 "com.oracle.graal.hotspot.amd64",
2261 #endif
2262 "com.oracle.graal.api.runtime",
2263 "com.oracle.graal.api.meta",
2264 "com.oracle.graal.api.code",
2265 "com.oracle.graal.hotspot",
2266 "com.oracle.graal.asm",
2267 "com.oracle.graal.alloc",
2268 "com.oracle.graal.word",
2269 "com.oracle.graal.snippets",
2270 "com.oracle.graal.compiler",
2271 "com.oracle.graal.loop",
2272 "com.oracle.graal.phases",
2273 "com.oracle.graal.phases.common",
2274 "com.oracle.graal.virtual",
2275 "com.oracle.graal.nodes",
2276 "com.oracle.graal.printer",
2277 "com.oracle.graal.debug",
2278 "com.oracle.graal.graph",
2279 "com.oracle.graal.lir",
2280 "com.oracle.graal.bytecode",
2281 "com.oracle.graal.java"
2282 };
2283
2284 const int len = sizeof(graal_projects) / sizeof(char*);
2285 for (int i = 0; i < len; i++) {
2286 if (PrintVMOptions) {
2287 tty->print_cr("Adding project directory %s to bootclasspath", graal_projects[i]);
2288 }
2289 prepend_to_graal_classpath(scp_compiler, graal_dir, graal_projects[i]);
2290 }
2291 }
2292
2293 scp_compiler.expand_endorsed();
2294 Arguments::set_compilerclasspath(scp_compiler.combined_path());
2295
2296 #endif
2297 2211
2298 if (AggressiveOpts) { 2212 if (AggressiveOpts) {
2299 // Insert alt-rt.jar between user-specified bootclasspath 2213 // Insert alt-rt.jar between user-specified bootclasspath
2300 // prefix and the default bootclasspath. os::set_boot_path() 2214 // prefix and the default bootclasspath. os::set_boot_path()
2301 // uses meta_index_dir as the default bootclasspath directory. 2215 // uses meta_index_dir as the default bootclasspath directory.
2306 strcpy(altclasses_path, get_meta_index_dir()); 2220 strcpy(altclasses_path, get_meta_index_dir());
2307 strcat(altclasses_path, altclasses_jar); 2221 strcat(altclasses_path, altclasses_jar);
2308 scp.add_suffix_to_prefix(altclasses_path); 2222 scp.add_suffix_to_prefix(altclasses_path);
2309 scp_assembly_required = true; 2223 scp_assembly_required = true;
2310 FREE_C_HEAP_ARRAY(char, altclasses_path, mtInternal); 2224 FREE_C_HEAP_ARRAY(char, altclasses_path, mtInternal);
2311 }
2312
2313 if (WhiteBoxAPI) {
2314 // Append wb.jar to bootclasspath if enabled
2315 const char* wb_jar = "wb.jar";
2316 size_t wb_path_len = strlen(get_meta_index_dir()) + 1 +
2317 strlen(wb_jar);
2318 char* wb_path = NEW_C_HEAP_ARRAY(char, wb_path_len, mtInternal);
2319 strcpy(wb_path, get_meta_index_dir());
2320 strcat(wb_path, wb_jar);
2321 scp.add_suffix(wb_path);
2322 scp_assembly_required = true;
2323 FREE_C_HEAP_ARRAY(char, wb_path, mtInternal);
2324 } 2225 }
2325 2226
2326 // Parse _JAVA_OPTIONS environment variable (if present) (mimics classic VM) 2227 // Parse _JAVA_OPTIONS environment variable (if present) (mimics classic VM)
2327 result = parse_java_options_environment_variable(&scp, &scp_assembly_required); 2228 result = parse_java_options_environment_variable(&scp, &scp_assembly_required);
2328 if (result != JNI_OK) { 2229 if (result != JNI_OK) {
2615 if (!add_property(tail)) { 2516 if (!add_property(tail)) {
2616 return JNI_ENOMEM; 2517 return JNI_ENOMEM;
2617 } 2518 }
2618 // Out of the box management support 2519 // Out of the box management support
2619 if (match_option(option, "-Dcom.sun.management", &tail)) { 2520 if (match_option(option, "-Dcom.sun.management", &tail)) {
2521 #if INCLUDE_MANAGEMENT
2620 FLAG_SET_CMDLINE(bool, ManagementServer, true); 2522 FLAG_SET_CMDLINE(bool, ManagementServer, true);
2523 #else
2524 vm_exit_during_initialization(
2525 "-Dcom.sun.management is not supported in this VM.", NULL);
2526 #endif
2621 } 2527 }
2622 // -Xint 2528 // -Xint
2623 } else if (match_option(option, "-Xint", &tail)) { 2529 } else if (match_option(option, "-Xint", &tail)) {
2624 set_mode_flags(_int); 2530 set_mode_flags(_int);
2625 // -Xmixed 2531 // -Xmixed
2630 // for testing the compiler; turn off all flags that inhibit compilation 2536 // for testing the compiler; turn off all flags that inhibit compilation
2631 set_mode_flags(_comp); 2537 set_mode_flags(_comp);
2632 2538
2633 // -Xshare:dump 2539 // -Xshare:dump
2634 } else if (match_option(option, "-Xshare:dump", &tail)) { 2540 } else if (match_option(option, "-Xshare:dump", &tail)) {
2635 #if defined(KERNEL) 2541 #if !INCLUDE_CDS
2636 vm_exit_during_initialization(
2637 "Dumping a shared archive is not supported on the Kernel JVM.", NULL);
2638 #elif !INCLUDE_CDS
2639 vm_exit_during_initialization( 2542 vm_exit_during_initialization(
2640 "Dumping a shared archive is not supported in this VM.", NULL); 2543 "Dumping a shared archive is not supported in this VM.", NULL);
2641 #else 2544 #else
2642 FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true); 2545 FLAG_SET_CMDLINE(bool, DumpSharedSpaces, true);
2643 set_mode_flags(_int); // Prevent compilation, which creates objects 2546 set_mode_flags(_int); // Prevent compilation, which creates objects
2964 } else if (match_option(option, "-XX:+UseVMInterruptibleIO", &tail)) { 2867 } else if (match_option(option, "-XX:+UseVMInterruptibleIO", &tail)) {
2965 // NOTE! In JDK 9, the UseVMInterruptibleIO flag will completely go 2868 // NOTE! In JDK 9, the UseVMInterruptibleIO flag will completely go
2966 // away and will cause VM initialization failures! 2869 // away and will cause VM initialization failures!
2967 warning("-XX:+UseVMInterruptibleIO is obsolete and will be removed in a future release."); 2870 warning("-XX:+UseVMInterruptibleIO is obsolete and will be removed in a future release.");
2968 FLAG_SET_CMDLINE(bool, UseVMInterruptibleIO, true); 2871 FLAG_SET_CMDLINE(bool, UseVMInterruptibleIO, true);
2872 #if !INCLUDE_MANAGEMENT
2873 } else if (match_option(option, "-XX:+ManagementServer", &tail)) {
2874 vm_exit_during_initialization(
2875 "ManagementServer is not supported in this VM.", NULL);
2876 #endif // INCLUDE_MANAGEMENT
2969 } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx 2877 } else if (match_option(option, "-XX:", &tail)) { // -XX:xxxx
2970 // Skip -XX:Flags= since that case has already been handled 2878 // Skip -XX:Flags= since that case has already been handled
2971 if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) { 2879 if (strncmp(tail, "Flags=", strlen("Flags=")) != 0) {
2972 if (!process_argument(tail, args->ignoreUnrecognized, origin)) { 2880 if (!process_argument(tail, args->ignoreUnrecognized, origin)) {
2973 return JNI_EINVAL; 2881 return JNI_EINVAL;
3203 } \ 3111 } \
3204 FLAG_SET_DEFAULT(opt, false); \ 3112 FLAG_SET_DEFAULT(opt, false); \
3205 } \ 3113 } \
3206 } while(0) 3114 } while(0)
3207 3115
3116
3117 #define UNSUPPORTED_GC_OPTION(gc) \
3118 do { \
3119 if (gc) { \
3120 if (FLAG_IS_CMDLINE(gc)) { \
3121 warning(#gc " is not supported in this VM. Using Serial GC."); \
3122 } \
3123 FLAG_SET_DEFAULT(gc, false); \
3124 } \
3125 } while(0)
3126
3127 static void force_serial_gc() {
3128 FLAG_SET_DEFAULT(UseSerialGC, true);
3129 FLAG_SET_DEFAULT(CMSIncrementalMode, false); // special CMS suboption
3130 UNSUPPORTED_GC_OPTION(UseG1GC);
3131 UNSUPPORTED_GC_OPTION(UseParallelGC);
3132 UNSUPPORTED_GC_OPTION(UseParallelOldGC);
3133 UNSUPPORTED_GC_OPTION(UseConcMarkSweepGC);
3134 UNSUPPORTED_GC_OPTION(UseParNewGC);
3135 }
3136
3208 // Parse entry point called from JNI_CreateJavaVM 3137 // Parse entry point called from JNI_CreateJavaVM
3209 3138
3210 jint Arguments::parse(const JavaVMInitArgs* args) { 3139 jint Arguments::parse(const JavaVMInitArgs* args) {
3211 3140
3212 // Sharing support 3141 // Sharing support
3318 warning("%s file is present but has been ignored. " 3247 warning("%s file is present but has been ignored. "
3319 "Run with -XX:Flags=%s to load the file.", 3248 "Run with -XX:Flags=%s to load the file.",
3320 hotspotrc, hotspotrc); 3249 hotspotrc, hotspotrc);
3321 } 3250 }
3322 3251
3323 #if (defined JAVASE_EMBEDDED || defined ARM)
3324 UNSUPPORTED_OPTION(UseG1GC, "G1 GC");
3325 #endif
3326
3327 #ifdef _ALLBSD_SOURCE // UseLargePages is not yet supported on BSD. 3252 #ifdef _ALLBSD_SOURCE // UseLargePages is not yet supported on BSD.
3328 UNSUPPORTED_OPTION(UseLargePages, "-XX:+UseLargePages"); 3253 UNSUPPORTED_OPTION(UseLargePages, "-XX:+UseLargePages");
3329 #endif 3254 #endif
3330 3255
3331 #if !INCLUDE_ALTERNATE_GCS 3256 #if INCLUDE_ALL_GCS
3332 if (UseParallelGC) { 3257 #if (defined JAVASE_EMBEDDED || defined ARM)
3333 warning("Parallel GC is not supported in this VM. Using Serial GC."); 3258 UNSUPPORTED_OPTION(UseG1GC, "G1 GC");
3334 } 3259 #endif
3335 if (UseParallelOldGC) { 3260 #endif
3336 warning("Parallel Old GC is not supported in this VM. Using Serial GC.");
3337 }
3338 if (UseConcMarkSweepGC) {
3339 warning("Concurrent Mark Sweep GC is not supported in this VM. Using Serial GC.");
3340 }
3341 if (UseParNewGC) {
3342 warning("Par New GC is not supported in this VM. Using Serial GC.");
3343 }
3344 #endif // INCLUDE_ALTERNATE_GCS
3345 3261
3346 #ifndef PRODUCT 3262 #ifndef PRODUCT
3347 if (TraceBytecodesAt != 0) { 3263 if (TraceBytecodesAt != 0) {
3348 TraceBytecodes = true; 3264 TraceBytecodes = true;
3349 } 3265 }
3386 } 3302 }
3387 3303
3388 // Set object alignment values. 3304 // Set object alignment values.
3389 set_object_alignment(); 3305 set_object_alignment();
3390 3306
3391 #ifdef SERIALGC 3307 #if !INCLUDE_ALL_GCS
3392 force_serial_gc(); 3308 force_serial_gc();
3393 #endif // SERIALGC 3309 #endif // INCLUDE_ALL_GCS
3394 #if !INCLUDE_CDS 3310 #if !INCLUDE_CDS
3395 no_shared_spaces(); 3311 no_shared_spaces();
3396 #endif // INCLUDE_CDS 3312 #endif // INCLUDE_CDS
3397 3313
3398 // Set flags based on ergonomics. 3314 // Set flags based on ergonomics.
3416 } 3332 }
3417 3333
3418 // Set heap size based on available physical memory 3334 // Set heap size based on available physical memory
3419 set_heap_size(); 3335 set_heap_size();
3420 3336
3421 #if INCLUDE_ALTERNATE_GCS 3337 #if INCLUDE_ALL_GCS
3422 // Set per-collector flags 3338 // Set per-collector flags
3423 if (UseParallelGC || UseParallelOldGC) { 3339 if (UseParallelGC || UseParallelOldGC) {
3424 set_parallel_gc_flags(); 3340 set_parallel_gc_flags();
3425 } else if (UseConcMarkSweepGC) { // should be done before ParNew check below 3341 } else if (UseConcMarkSweepGC) { // should be done before ParNew check below
3426 set_cms_and_parnew_gc_flags(); 3342 set_cms_and_parnew_gc_flags();
3428 set_parnew_gc_flags(); 3344 set_parnew_gc_flags();
3429 } else if (UseG1GC) { 3345 } else if (UseG1GC) {
3430 set_g1_gc_flags(); 3346 set_g1_gc_flags();
3431 } 3347 }
3432 check_deprecated_gcs(); 3348 check_deprecated_gcs();
3433 #endif // INCLUDE_ALTERNATE_GCS 3349 #else // INCLUDE_ALL_GCS
3434
3435 #ifdef SERIALGC
3436 assert(verify_serial_gc_flags(), "SerialGC unset"); 3350 assert(verify_serial_gc_flags(), "SerialGC unset");
3437 #endif // SERIALGC 3351 #endif // INCLUDE_ALL_GCS
3438 3352
3439 // Set bytecode rewriting flags 3353 // Set bytecode rewriting flags
3440 set_bytecode_flags(); 3354 set_bytecode_flags();
3441 3355
3442 // Set flags if Aggressive optimization flags (-XX:+AggressiveOpts) enabled. 3356 // Set flags if Aggressive optimization flags (-XX:+AggressiveOpts) enabled.
3529 3443
3530 return JNI_OK; 3444 return JNI_OK;
3531 } 3445 }
3532 3446
3533 jint Arguments::adjust_after_os() { 3447 jint Arguments::adjust_after_os() {
3534 #if INCLUDE_ALTERNATE_GCS 3448 #if INCLUDE_ALL_GCS
3535 if (UseParallelGC || UseParallelOldGC) { 3449 if (UseParallelGC || UseParallelOldGC) {
3536 if (UseNUMA) { 3450 if (UseNUMA) {
3537 if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) { 3451 if (FLAG_IS_DEFAULT(MinHeapDeltaBytes)) {
3538 FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M); 3452 FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M);
3539 } 3453 }
3540 // For those collectors or operating systems (eg, Windows) that do 3454 // For those collectors or operating systems (eg, Windows) that do
3541 // not support full UseNUMA, we will map to UseNUMAInterleaving for now 3455 // not support full UseNUMA, we will map to UseNUMAInterleaving for now
3542 UseNUMAInterleaving = true; 3456 UseNUMAInterleaving = true;
3543 } 3457 }
3544 } 3458 }
3545 #endif 3459 #endif // INCLUDE_ALL_GCS
3546 return JNI_OK; 3460 return JNI_OK;
3547 } 3461 }
3548 3462
3549 int Arguments::PropertyList_count(SystemProperty* pl) { 3463 int Arguments::PropertyList_count(SystemProperty* pl) {
3550 int count = 0; 3464 int count = 0;
3634 } 3548 }
3635 } 3549 }
3636 3550
3637 PropertyList_add(plist, k, v); 3551 PropertyList_add(plist, k, v);
3638 } 3552 }
3639
3640 #ifdef KERNEL
3641 char *Arguments::get_kernel_properties() {
3642 // Find properties starting with kernel and append them to string
3643 // We need to find out how long they are first because the URL's that they
3644 // might point to could get long.
3645 int length = 0;
3646 SystemProperty* prop;
3647 for (prop = _system_properties; prop != NULL; prop = prop->next()) {
3648 if (strncmp(prop->key(), "kernel.", 7 ) == 0) {
3649 length += (strlen(prop->key()) + strlen(prop->value()) + 5); // "-D ="
3650 }
3651 }
3652 // Add one for null terminator.
3653 char *props = AllocateHeap(length + 1, mtInternal);
3654 if (length != 0) {
3655 int pos = 0;
3656 for (prop = _system_properties; prop != NULL; prop = prop->next()) {
3657 if (strncmp(prop->key(), "kernel.", 7 ) == 0) {
3658 jio_snprintf(&props[pos], length-pos,
3659 "-D%s=%s ", prop->key(), prop->value());
3660 pos = strlen(props);
3661 }
3662 }
3663 }
3664 // null terminate props in case of null
3665 props[length] = '\0';
3666 return props;
3667 }
3668 #endif // KERNEL
3669 3553
3670 // Copies src into buf, replacing "%%" with "%" and "%p" with pid 3554 // Copies src into buf, replacing "%%" with "%" and "%p" with pid
3671 // Returns true if all of the source pointed by src has been copied over to 3555 // Returns true if all of the source pointed by src has been copied over to
3672 // the destination buffer pointed by buf. Otherwise, returns false. 3556 // the destination buffer pointed by buf. Otherwise, returns false.
3673 // Notes: 3557 // Notes: