comparison src/share/vm/runtime/arguments.cpp @ 2491:0654ee04b214

Merge with OpenJDK.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 22 Apr 2011 15:30:53 +0200
parents 29246b1d2d3c 3449f5e02cc4
children 62feb6fd69a9
comparison
equal deleted inserted replaced
2490:29246b1d2d3c 2491:0654ee04b214
57 #endif 57 #endif
58 #ifndef SERIALGC 58 #ifndef SERIALGC
59 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp" 59 #include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
60 #endif 60 #endif
61 61
62 #define DEFAULT_VENDOR_URL_BUG "http://java.sun.com/webapps/bugreport/crash.jsp" 62 // Note: This is a special bug reporting site for the JVM
63 #define DEFAULT_VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/crash.jsp"
63 #define DEFAULT_JAVA_LAUNCHER "generic" 64 #define DEFAULT_JAVA_LAUNCHER "generic"
64 65
65 char** Arguments::_jvm_flags_array = NULL; 66 char** Arguments::_jvm_flags_array = NULL;
66 int Arguments::_num_jvm_flags = 0; 67 int Arguments::_num_jvm_flags = 0;
67 char** Arguments::_jvm_args_array = NULL; 68 char** Arguments::_jvm_args_array = NULL;
78 bool Arguments::_java_compiler = false; 79 bool Arguments::_java_compiler = false;
79 bool Arguments::_xdebug_mode = false; 80 bool Arguments::_xdebug_mode = false;
80 const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG; 81 const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG;
81 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER; 82 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
82 int Arguments::_sun_java_launcher_pid = -1; 83 int Arguments::_sun_java_launcher_pid = -1;
84 bool Arguments::_created_by_gamma_launcher = false;
83 85
84 // These parameters are reset in method parse_vm_init_args(JavaVMInitArgs*) 86 // These parameters are reset in method parse_vm_init_args(JavaVMInitArgs*)
85 bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods; 87 bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
86 bool Arguments::_UseOnStackReplacement = UseOnStackReplacement; 88 bool Arguments::_UseOnStackReplacement = UseOnStackReplacement;
87 bool Arguments::_BackgroundCompilation = BackgroundCompilation; 89 bool Arguments::_BackgroundCompilation = BackgroundCompilation;
241 JDK_Version::jdk_update(6,22), JDK_Version::jdk(7) }, 243 JDK_Version::jdk_update(6,22), JDK_Version::jdk(7) },
242 { "HandlePromotionFailure", 244 { "HandlePromotionFailure",
243 JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) }, 245 JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
244 { "MaxLiveObjectEvacuationRatio", 246 { "MaxLiveObjectEvacuationRatio",
245 JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) }, 247 JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
248 { "ForceSharedSpaces", JDK_Version::jdk_update(6,25), JDK_Version::jdk(8) },
249 { "AllowTransitionalJSR292", JDK_Version::jdk(7), JDK_Version::jdk(8) },
246 { NULL, JDK_Version(0), JDK_Version(0) } 250 { NULL, JDK_Version(0), JDK_Version(0) }
247 }; 251 };
248 252
249 // Returns true if the flag is obsolete and fits into the range specified 253 // Returns true if the flag is obsolete and fits into the range specified
250 // for being ignored. In the case that the flag is ignored, the 'version' 254 // for being ignored. In the case that the flag is ignored, the 'version'
964 968
965 UseInterpreter = true; 969 UseInterpreter = true;
966 UseCompiler = true; 970 UseCompiler = true;
967 UseLoopCounter = true; 971 UseLoopCounter = true;
968 972
973 #ifndef ZERO
974 // Turn these off for mixed and comp. Leave them on for Zero.
975 if (FLAG_IS_DEFAULT(UseFastAccessorMethods)) {
976 UseFastAccessorMethods = mode == _int;
977 }
978 if (FLAG_IS_DEFAULT(UseFastEmptyMethods)) {
979 UseFastEmptyMethods = mode == _int;
980 }
981 #endif
982
969 // Default values may be platform/compiler dependent - 983 // Default values may be platform/compiler dependent -
970 // use the saved values 984 // use the saved values
971 ClipInlining = Arguments::_ClipInlining; 985 ClipInlining = Arguments::_ClipInlining;
972 AlwaysCompileLoopMethods = Arguments::_AlwaysCompileLoopMethods; 986 AlwaysCompileLoopMethods = Arguments::_AlwaysCompileLoopMethods;
973 UseOnStackReplacement = Arguments::_UseOnStackReplacement; 987 UseOnStackReplacement = Arguments::_UseOnStackReplacement;
1006 } else { 1020 } else {
1007 FLAG_SET_DEFAULT(UseSharedSpaces, false); 1021 FLAG_SET_DEFAULT(UseSharedSpaces, false);
1008 } 1022 }
1009 } 1023 }
1010 1024
1011 void Arguments::check_compressed_oops_compat() {
1012 #ifdef _LP64
1013 assert(UseCompressedOops, "Precondition");
1014 // Is it on by default or set on ergonomically
1015 bool is_on_by_default = FLAG_IS_DEFAULT(UseCompressedOops) || FLAG_IS_ERGO(UseCompressedOops);
1016
1017 // If dumping an archive or forcing its use, disable compressed oops if possible
1018 if (DumpSharedSpaces || RequireSharedSpaces) {
1019 if (is_on_by_default) {
1020 FLAG_SET_DEFAULT(UseCompressedOops, false);
1021 return;
1022 } else {
1023 vm_exit_during_initialization(
1024 "Class Data Sharing is not supported with compressed oops yet", NULL);
1025 }
1026 } else if (UseSharedSpaces) {
1027 // UseSharedSpaces is on by default. With compressed oops, we turn it off.
1028 FLAG_SET_DEFAULT(UseSharedSpaces, false);
1029 }
1030 #endif
1031 }
1032
1033 void Arguments::set_tiered_flags() { 1025 void Arguments::set_tiered_flags() {
1026 // With tiered, set default policy to AdvancedThresholdPolicy, which is 3.
1034 if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) { 1027 if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) {
1035 FLAG_SET_DEFAULT(CompilationPolicyChoice, 2); 1028 FLAG_SET_DEFAULT(CompilationPolicyChoice, 3);
1036 } 1029 }
1037 if (CompilationPolicyChoice < 2) { 1030 if (CompilationPolicyChoice < 2) {
1038 vm_exit_during_initialization( 1031 vm_exit_during_initialization(
1039 "Incompatible compilation policy selected", NULL); 1032 "Incompatible compilation policy selected", NULL);
1040 } 1033 }
1125 // as needed. 1118 // as needed.
1126 if (UseParNewGC) { 1119 if (UseParNewGC) {
1127 set_parnew_gc_flags(); 1120 set_parnew_gc_flags();
1128 } 1121 }
1129 1122
1123 // MaxHeapSize is aligned down in collectorPolicy
1124 size_t max_heap = align_size_down(MaxHeapSize,
1125 CardTableRS::ct_max_alignment_constraint());
1126
1130 // Now make adjustments for CMS 1127 // Now make adjustments for CMS
1131 size_t young_gen_per_worker; 1128 intx tenuring_default = (intx)6;
1132 intx new_ratio; 1129 size_t young_gen_per_worker = CMSYoungGenPerWorker;
1133 size_t min_new_default; 1130
1134 intx tenuring_default; 1131 // Preferred young gen size for "short" pauses:
1135 if (CMSUseOldDefaults) { // old defaults: "old" as of 6.0 1132 // upper bound depends on # of threads and NewRatio.
1136 if FLAG_IS_DEFAULT(CMSYoungGenPerWorker) {
1137 FLAG_SET_ERGO(intx, CMSYoungGenPerWorker, 4*M);
1138 }
1139 young_gen_per_worker = 4*M;
1140 new_ratio = (intx)15;
1141 min_new_default = 4*M;
1142 tenuring_default = (intx)0;
1143 } else { // new defaults: "new" as of 6.0
1144 young_gen_per_worker = CMSYoungGenPerWorker;
1145 new_ratio = (intx)7;
1146 min_new_default = 16*M;
1147 tenuring_default = (intx)4;
1148 }
1149
1150 // Preferred young gen size for "short" pauses
1151 const uintx parallel_gc_threads = 1133 const uintx parallel_gc_threads =
1152 (ParallelGCThreads == 0 ? 1 : ParallelGCThreads); 1134 (ParallelGCThreads == 0 ? 1 : ParallelGCThreads);
1153 const size_t preferred_max_new_size_unaligned = 1135 const size_t preferred_max_new_size_unaligned =
1154 ScaleForWordSize(young_gen_per_worker * parallel_gc_threads); 1136 MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * parallel_gc_threads));
1155 const size_t preferred_max_new_size = 1137 size_t preferred_max_new_size =
1156 align_size_up(preferred_max_new_size_unaligned, os::vm_page_size()); 1138 align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
1157 1139
1158 // Unless explicitly requested otherwise, size young gen 1140 // Unless explicitly requested otherwise, size young gen
1159 // for "short" pauses ~ 4M*ParallelGCThreads 1141 // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
1160 1142
1161 // If either MaxNewSize or NewRatio is set on the command line, 1143 // If either MaxNewSize or NewRatio is set on the command line,
1162 // assume the user is trying to set the size of the young gen. 1144 // assume the user is trying to set the size of the young gen.
1163
1164 if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) { 1145 if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
1165 1146
1166 // Set MaxNewSize to our calculated preferred_max_new_size unless 1147 // Set MaxNewSize to our calculated preferred_max_new_size unless
1167 // NewSize was set on the command line and it is larger than 1148 // NewSize was set on the command line and it is larger than
1168 // preferred_max_new_size. 1149 // preferred_max_new_size.
1171 } else { 1152 } else {
1172 FLAG_SET_ERGO(uintx, MaxNewSize, preferred_max_new_size); 1153 FLAG_SET_ERGO(uintx, MaxNewSize, preferred_max_new_size);
1173 } 1154 }
1174 if (PrintGCDetails && Verbose) { 1155 if (PrintGCDetails && Verbose) {
1175 // Too early to use gclog_or_tty 1156 // Too early to use gclog_or_tty
1176 tty->print_cr("Ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize); 1157 tty->print_cr("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
1177 } 1158 }
1178
1179 // Unless explicitly requested otherwise, prefer a large
1180 // Old to Young gen size so as to shift the collection load
1181 // to the old generation concurrent collector
1182
1183 // If this is only guarded by FLAG_IS_DEFAULT(NewRatio)
1184 // then NewSize and OldSize may be calculated. That would
1185 // generally lead to some differences with ParNewGC for which
1186 // there was no obvious reason. Also limit to the case where
1187 // MaxNewSize has not been set.
1188
1189 FLAG_SET_ERGO(intx, NewRatio, MAX2(NewRatio, new_ratio));
1190 1159
1191 // Code along this path potentially sets NewSize and OldSize 1160 // Code along this path potentially sets NewSize and OldSize
1192 1161
1193 // Calculate the desired minimum size of the young gen but if 1162 assert(max_heap >= InitialHeapSize, "Error");
1194 // NewSize has been set on the command line, use it here since 1163 assert(max_heap >= NewSize, "Error");
1195 // it should be the final value.
1196 size_t min_new;
1197 if (FLAG_IS_DEFAULT(NewSize)) {
1198 min_new = align_size_up(ScaleForWordSize(min_new_default),
1199 os::vm_page_size());
1200 } else {
1201 min_new = NewSize;
1202 }
1203 size_t prev_initial_size = InitialHeapSize;
1204 if (prev_initial_size != 0 && prev_initial_size < min_new + OldSize) {
1205 FLAG_SET_ERGO(uintx, InitialHeapSize, min_new + OldSize);
1206 // Currently minimum size and the initial heap sizes are the same.
1207 set_min_heap_size(InitialHeapSize);
1208 if (PrintGCDetails && Verbose) {
1209 warning("Initial heap size increased to " SIZE_FORMAT " M from "
1210 SIZE_FORMAT " M; use -XX:NewSize=... for finer control.",
1211 InitialHeapSize/M, prev_initial_size/M);
1212 }
1213 }
1214
1215 // MaxHeapSize is aligned down in collectorPolicy
1216 size_t max_heap =
1217 align_size_down(MaxHeapSize,
1218 CardTableRS::ct_max_alignment_constraint());
1219 1164
1220 if (PrintGCDetails && Verbose) { 1165 if (PrintGCDetails && Verbose) {
1221 // Too early to use gclog_or_tty 1166 // Too early to use gclog_or_tty
1222 tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT 1167 tty->print_cr("CMS set min_heap_size: " SIZE_FORMAT
1223 " initial_heap_size: " SIZE_FORMAT 1168 " initial_heap_size: " SIZE_FORMAT
1224 " max_heap: " SIZE_FORMAT, 1169 " max_heap: " SIZE_FORMAT,
1225 min_heap_size(), InitialHeapSize, max_heap); 1170 min_heap_size(), InitialHeapSize, max_heap);
1226 } 1171 }
1227 if (max_heap > min_new) { 1172 size_t min_new = preferred_max_new_size;
1173 if (FLAG_IS_CMDLINE(NewSize)) {
1174 min_new = NewSize;
1175 }
1176 if (max_heap > min_new && min_heap_size() > min_new) {
1228 // Unless explicitly requested otherwise, make young gen 1177 // Unless explicitly requested otherwise, make young gen
1229 // at least min_new, and at most preferred_max_new_size. 1178 // at least min_new, and at most preferred_max_new_size.
1230 if (FLAG_IS_DEFAULT(NewSize)) { 1179 if (FLAG_IS_DEFAULT(NewSize)) {
1231 FLAG_SET_ERGO(uintx, NewSize, MAX2(NewSize, min_new)); 1180 FLAG_SET_ERGO(uintx, NewSize, MAX2(NewSize, min_new));
1232 FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, NewSize)); 1181 FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, NewSize));
1233 if (PrintGCDetails && Verbose) { 1182 if (PrintGCDetails && Verbose) {
1234 // Too early to use gclog_or_tty 1183 // Too early to use gclog_or_tty
1235 tty->print_cr("Ergo set NewSize: " SIZE_FORMAT, NewSize); 1184 tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
1236 } 1185 }
1237 } 1186 }
1238 // Unless explicitly requested otherwise, size old gen 1187 // Unless explicitly requested otherwise, size old gen
1239 // so that it's at least 3X of NewSize to begin with; 1188 // so it's NewRatio x of NewSize.
1240 // later NewRatio will decide how it grows; see above.
1241 if (FLAG_IS_DEFAULT(OldSize)) { 1189 if (FLAG_IS_DEFAULT(OldSize)) {
1242 if (max_heap > NewSize) { 1190 if (max_heap > NewSize) {
1243 FLAG_SET_ERGO(uintx, OldSize, MIN2(3*NewSize, max_heap - NewSize)); 1191 FLAG_SET_ERGO(uintx, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
1244 if (PrintGCDetails && Verbose) { 1192 if (PrintGCDetails && Verbose) {
1245 // Too early to use gclog_or_tty 1193 // Too early to use gclog_or_tty
1246 tty->print_cr("Ergo set OldSize: " SIZE_FORMAT, OldSize); 1194 tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
1247 } 1195 }
1248 } 1196 }
1249 } 1197 }
1250 } 1198 }
1251 } 1199 }
1385 } 1333 }
1386 1334
1387 void Arguments::set_ergonomics_flags() { 1335 void Arguments::set_ergonomics_flags() {
1388 // Parallel GC is not compatible with sharing. If one specifies 1336 // Parallel GC is not compatible with sharing. If one specifies
1389 // that they want sharing explicitly, do not set ergonomics flags. 1337 // that they want sharing explicitly, do not set ergonomics flags.
1390 if (DumpSharedSpaces || ForceSharedSpaces) { 1338 if (DumpSharedSpaces || RequireSharedSpaces) {
1391 return; 1339 return;
1392 } 1340 }
1393 1341
1394 if (os::is_server_class_machine() && !force_client_mode ) { 1342 if (os::is_server_class_machine() && !force_client_mode ) {
1395 // If no other collector is requested explicitly, 1343 // If no other collector is requested explicitly,
1660 } 1608 }
1661 } 1609 }
1662 1610
1663 void Arguments::process_java_launcher_argument(const char* launcher, void* extra_info) { 1611 void Arguments::process_java_launcher_argument(const char* launcher, void* extra_info) {
1664 _sun_java_launcher = strdup(launcher); 1612 _sun_java_launcher = strdup(launcher);
1613 if (strcmp("gamma", _sun_java_launcher) == 0) {
1614 _created_by_gamma_launcher = true;
1615 }
1665 } 1616 }
1666 1617
1667 bool Arguments::created_by_java_launcher() { 1618 bool Arguments::created_by_java_launcher() {
1668 assert(_sun_java_launcher != NULL, "property must have value"); 1619 assert(_sun_java_launcher != NULL, "property must have value");
1669 return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0; 1620 return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
1621 }
1622
1623 bool Arguments::created_by_gamma_launcher() {
1624 return _created_by_gamma_launcher;
1670 } 1625 }
1671 1626
1672 //=========================================================================================================== 1627 //===========================================================================================================
1673 // Parsing of main arguments 1628 // Parsing of main arguments
1674 1629
1685 name, val, min, max); 1640 name, val, min, max);
1686 return false; 1641 return false;
1687 } 1642 }
1688 1643
1689 bool Arguments::verify_min_value(intx val, intx min, const char* name) { 1644 bool Arguments::verify_min_value(intx val, intx min, const char* name) {
1690 // Returns true if given value is greater than specified min threshold 1645 // Returns true if given value is at least specified min threshold
1691 // false, otherwise. 1646 // false, otherwise.
1692 if (val >= min ) { 1647 if (val >= min ) {
1693 return true; 1648 return true;
1694 } 1649 }
1695 jio_fprintf(defaultStream::error_stream(), 1650 jio_fprintf(defaultStream::error_stream(),
1696 "%s of " INTX_FORMAT " is invalid; must be greater than " INTX_FORMAT "\n", 1651 "%s of " INTX_FORMAT " is invalid; must be at least " INTX_FORMAT "\n",
1697 name, val, min); 1652 name, val, min);
1698 return false; 1653 return false;
1699 } 1654 }
1700 1655
1701 bool Arguments::verify_percentage(uintx value, const char* name) { 1656 bool Arguments::verify_percentage(uintx value, const char* name) {
1840 // Turn off gc-overhead-limit-exceeded checks 1795 // Turn off gc-overhead-limit-exceeded checks
1841 FLAG_SET_DEFAULT(UseGCOverheadLimit, false); 1796 FLAG_SET_DEFAULT(UseGCOverheadLimit, false);
1842 } 1797 }
1843 1798
1844 status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit"); 1799 status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit");
1845
1846 // Check whether user-specified sharing option conflicts with GC or page size.
1847 // Both sharing and large pages are enabled by default on some platforms;
1848 // large pages override sharing only if explicitly set on the command line.
1849 const bool cannot_share = UseConcMarkSweepGC || CMSIncrementalMode ||
1850 UseG1GC || UseParNewGC || UseParallelGC || UseParallelOldGC ||
1851 UseLargePages && FLAG_IS_CMDLINE(UseLargePages);
1852 if (cannot_share) {
1853 // Either force sharing on by forcing the other options off, or
1854 // force sharing off.
1855 if (DumpSharedSpaces || ForceSharedSpaces) {
1856 jio_fprintf(defaultStream::error_stream(),
1857 "Using Serial GC and default page size because of %s\n",
1858 ForceSharedSpaces ? "-Xshare:on" : "-Xshare:dump");
1859 force_serial_gc();
1860 FLAG_SET_DEFAULT(UseLargePages, false);
1861 } else {
1862 if (UseSharedSpaces && Verbose) {
1863 jio_fprintf(defaultStream::error_stream(),
1864 "Turning off use of shared archive because of "
1865 "choice of garbage collector or large pages\n");
1866 }
1867 no_shared_spaces();
1868 }
1869 } else if (UseLargePages && (UseSharedSpaces || DumpSharedSpaces)) {
1870 FLAG_SET_DEFAULT(UseLargePages, false);
1871 }
1872 1800
1873 status = status && check_gc_consistency(); 1801 status = status && check_gc_consistency();
1874 status = status && check_stack_pages(); 1802 status = status && check_stack_pages();
1875 1803
1876 if (_has_alloc_profile) { 1804 if (_has_alloc_profile) {
1944 jio_fprintf(defaultStream::error_stream(), 1872 jio_fprintf(defaultStream::error_stream(),
1945 "error: +ExplictGCInvokesConcurrent[AndUnloadsClasses] conflicts" 1873 "error: +ExplictGCInvokesConcurrent[AndUnloadsClasses] conflicts"
1946 " with -UseAsyncConcMarkSweepGC"); 1874 " with -UseAsyncConcMarkSweepGC");
1947 status = false; 1875 status = false;
1948 } 1876 }
1877
1878 status = status && verify_min_value(ParGCArrayScanChunk, 1, "ParGCArrayScanChunk");
1949 1879
1950 #ifndef SERIALGC 1880 #ifndef SERIALGC
1951 if (UseG1GC) { 1881 if (UseG1GC) {
1952 status = status && verify_percentage(InitiatingHeapOccupancyPercent, 1882 status = status && verify_percentage(InitiatingHeapOccupancyPercent,
1953 "InitiatingHeapOccupancyPercent"); 1883 "InitiatingHeapOccupancyPercent");
2408 #endif 2338 #endif
2409 // -Xshare:on 2339 // -Xshare:on
2410 } else if (match_option(option, "-Xshare:on", &tail)) { 2340 } else if (match_option(option, "-Xshare:on", &tail)) {
2411 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); 2341 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
2412 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true); 2342 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true);
2413 #ifdef TIERED
2414 FLAG_SET_CMDLINE(bool, ForceSharedSpaces, true);
2415 #endif // TIERED
2416 // -Xshare:auto 2343 // -Xshare:auto
2417 } else if (match_option(option, "-Xshare:auto", &tail)) { 2344 } else if (match_option(option, "-Xshare:auto", &tail)) {
2418 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true); 2345 FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
2419 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false); 2346 FLAG_SET_CMDLINE(bool, RequireSharedSpaces, false);
2420 // -Xshare:off 2347 // -Xshare:off
2830 TieredCompilation = false; 2757 TieredCompilation = false;
2831 #else 2758 #else
2832 if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) { 2759 if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
2833 FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1); 2760 FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
2834 } 2761 }
2835 // Temporary disable bulk zeroing reduction with G1. See CR 6627983.
2836 if (UseG1GC) {
2837 FLAG_SET_DEFAULT(ReduceBulkZeroing, false);
2838 }
2839 #endif 2762 #endif
2840 2763
2841 // If we are running in a headless jre, force java.awt.headless property 2764 // If we are running in a headless jre, force java.awt.headless property
2842 // to be true unless the property has already been set. 2765 // to be true unless the property has already been set.
2843 // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state. 2766 // Also allow the OS environment variable JAVA_AWT_HEADLESS to set headless state.
2947 return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, ENVIRON_VAR)); 2870 return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, ENVIRON_VAR));
2948 } 2871 }
2949 return JNI_OK; 2872 return JNI_OK;
2950 } 2873 }
2951 2874
2875 void Arguments::set_shared_spaces_flags() {
2876 const bool must_share = DumpSharedSpaces || RequireSharedSpaces;
2877 const bool might_share = must_share || UseSharedSpaces;
2878
2879 // The string table is part of the shared archive so the size must match.
2880 if (!FLAG_IS_DEFAULT(StringTableSize)) {
2881 // Disable sharing.
2882 if (must_share) {
2883 warning("disabling shared archive %s because of non-default "
2884 "StringTableSize", DumpSharedSpaces ? "creation" : "use");
2885 }
2886 if (might_share) {
2887 FLAG_SET_DEFAULT(DumpSharedSpaces, false);
2888 FLAG_SET_DEFAULT(RequireSharedSpaces, false);
2889 FLAG_SET_DEFAULT(UseSharedSpaces, false);
2890 }
2891 return;
2892 }
2893
2894 // Check whether class data sharing settings conflict with GC, compressed oops
2895 // or page size, and fix them up. Explicit sharing options override other
2896 // settings.
2897 const bool cannot_share = UseConcMarkSweepGC || CMSIncrementalMode ||
2898 UseG1GC || UseParNewGC || UseParallelGC || UseParallelOldGC ||
2899 UseCompressedOops || UseLargePages && FLAG_IS_CMDLINE(UseLargePages);
2900 if (cannot_share) {
2901 if (must_share) {
2902 warning("selecting serial gc and disabling large pages %s"
2903 "because of %s", "" LP64_ONLY("and compressed oops "),
2904 DumpSharedSpaces ? "-Xshare:dump" : "-Xshare:on");
2905 force_serial_gc();
2906 FLAG_SET_CMDLINE(bool, UseLargePages, false);
2907 LP64_ONLY(FLAG_SET_CMDLINE(bool, UseCompressedOops, false));
2908 } else {
2909 if (UseSharedSpaces && Verbose) {
2910 warning("turning off use of shared archive because of "
2911 "choice of garbage collector or large pages");
2912 }
2913 no_shared_spaces();
2914 }
2915 } else if (UseLargePages && might_share) {
2916 // Disable large pages to allow shared spaces. This is sub-optimal, since
2917 // there may not even be a shared archive to use.
2918 FLAG_SET_DEFAULT(UseLargePages, false);
2919 }
2920 }
2952 2921
2953 // Parse entry point called from JNI_CreateJavaVM 2922 // Parse entry point called from JNI_CreateJavaVM
2954 2923
2955 jint Arguments::parse(const JavaVMInitArgs* args) { 2924 jint Arguments::parse(const JavaVMInitArgs* args) {
2956 2925
3057 UseCounterDecay = false; 3026 UseCounterDecay = false;
3058 } 3027 }
3059 } 3028 }
3060 #endif // PRODUCT 3029 #endif // PRODUCT
3061 3030
3062 if (EnableInvokeDynamic && !EnableMethodHandles) { 3031 // Transitional
3063 if (!FLAG_IS_DEFAULT(EnableMethodHandles)) { 3032 if (EnableMethodHandles || AnonymousClasses) {
3064 warning("forcing EnableMethodHandles true because EnableInvokeDynamic is true"); 3033 if (!EnableInvokeDynamic && !FLAG_IS_DEFAULT(EnableInvokeDynamic)) {
3065 } 3034 warning("EnableMethodHandles and AnonymousClasses are obsolete. Keeping EnableInvokeDynamic disabled.");
3066 EnableMethodHandles = true; 3035 } else {
3067 } 3036 EnableInvokeDynamic = true;
3068 if (EnableMethodHandles && !AnonymousClasses) { 3037 }
3069 if (!FLAG_IS_DEFAULT(AnonymousClasses)) { 3038 }
3070 warning("forcing AnonymousClasses true because EnableMethodHandles is true"); 3039
3071 } 3040 // JSR 292 is not supported before 1.7
3072 AnonymousClasses = true; 3041 if (!JDK_Version::is_gte_jdk17x_version()) {
3073 } 3042 if (EnableInvokeDynamic) {
3074 if ((EnableMethodHandles || AnonymousClasses) && ScavengeRootsInCode == 0) { 3043 if (!FLAG_IS_DEFAULT(EnableInvokeDynamic)) {
3044 warning("JSR 292 is not supported before 1.7. Disabling support.");
3045 }
3046 EnableInvokeDynamic = false;
3047 }
3048 }
3049
3050 if (EnableInvokeDynamic && ScavengeRootsInCode == 0) {
3075 if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) { 3051 if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
3076 warning("forcing ScavengeRootsInCode non-zero because EnableMethodHandles or AnonymousClasses is true"); 3052 warning("forcing ScavengeRootsInCode non-zero because EnableInvokeDynamic is true");
3053 }
3054 ScavengeRootsInCode = 1;
3055 }
3056 if (!JavaObjectsInPerm && ScavengeRootsInCode == 0) {
3057 if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
3058 warning("forcing ScavengeRootsInCode non-zero because JavaObjectsInPerm is false");
3077 } 3059 }
3078 ScavengeRootsInCode = 1; 3060 ScavengeRootsInCode = 1;
3079 } 3061 }
3080 3062
3081 if (PrintGCDetails) { 3063 if (PrintGCDetails) {
3094 #endif // KERNEL 3076 #endif // KERNEL
3095 3077
3096 // Set flags based on ergonomics. 3078 // Set flags based on ergonomics.
3097 set_ergonomics_flags(); 3079 set_ergonomics_flags();
3098 3080
3099 if (UseCompressedOops) { 3081 set_shared_spaces_flags();
3100 check_compressed_oops_compat();
3101 }
3102 3082
3103 // Check the GC selections again. 3083 // Check the GC selections again.
3104 if (!check_gc_consistency()) { 3084 if (!check_gc_consistency()) {
3105 return JNI_EINVAL; 3085 return JNI_EINVAL;
3106 } 3086 }
3114 "Incompatible compilation policy selected", NULL); 3094 "Incompatible compilation policy selected", NULL);
3115 } 3095 }
3116 } 3096 }
3117 3097
3118 #ifndef KERNEL 3098 #ifndef KERNEL
3119 if (UseConcMarkSweepGC) { 3099 // Set heap size based on available physical memory
3120 // Set flags for CMS and ParNew. Check UseConcMarkSweep first 3100 set_heap_size();
3121 // to ensure that when both UseConcMarkSweepGC and UseParNewGC 3101 // Set per-collector flags
3122 // are true, we don't call set_parnew_gc_flags() as well. 3102 if (UseParallelGC || UseParallelOldGC) {
3103 set_parallel_gc_flags();
3104 } else if (UseConcMarkSweepGC) { // should be done before ParNew check below
3123 set_cms_and_parnew_gc_flags(); 3105 set_cms_and_parnew_gc_flags();
3124 } else { 3106 } else if (UseParNewGC) { // skipped if CMS is set above
3125 // Set heap size based on available physical memory 3107 set_parnew_gc_flags();
3126 set_heap_size(); 3108 } else if (UseG1GC) {
3127 // Set per-collector flags 3109 set_g1_gc_flags();
3128 if (UseParallelGC || UseParallelOldGC) {
3129 set_parallel_gc_flags();
3130 } else if (UseParNewGC) {
3131 set_parnew_gc_flags();
3132 } else if (UseG1GC) {
3133 set_g1_gc_flags();
3134 }
3135 } 3110 }
3136 #endif // KERNEL 3111 #endif // KERNEL
3137 3112
3138 #ifdef SERIALGC 3113 #ifdef SERIALGC
3139 assert(verify_serial_gc_flags(), "SerialGC unset"); 3114 assert(verify_serial_gc_flags(), "SerialGC unset");
3146 set_aggressive_opts_flags(); 3121 set_aggressive_opts_flags();
3147 3122
3148 // Turn off biased locking for locking debug mode flags, 3123 // Turn off biased locking for locking debug mode flags,
3149 // which are subtlely different from each other but neither works with 3124 // which are subtlely different from each other but neither works with
3150 // biased locking. 3125 // biased locking.
3151 if (!UseFastLocking || UseHeavyMonitors) { 3126 if (UseHeavyMonitors
3127 #ifdef COMPILER1
3128 || !UseFastLocking
3129 #endif // COMPILER1
3130 ) {
3152 if (!FLAG_IS_DEFAULT(UseBiasedLocking) && UseBiasedLocking) { 3131 if (!FLAG_IS_DEFAULT(UseBiasedLocking) && UseBiasedLocking) {
3153 // flag set to true on command line; warn the user that they 3132 // flag set to true on command line; warn the user that they
3154 // can't enable biased locking here 3133 // can't enable biased locking here
3155 warning("Biased Locking is not supported with locking debug flags" 3134 warning("Biased Locking is not supported with locking debug flags"
3156 "; ignoring UseBiasedLocking flag." ); 3135 "; ignoring UseBiasedLocking flag." );
3192 // Apply CPU specific policy for the BiasedLocking 3171 // Apply CPU specific policy for the BiasedLocking
3193 if (UseBiasedLocking) { 3172 if (UseBiasedLocking) {
3194 if (!VM_Version::use_biased_locking() && 3173 if (!VM_Version::use_biased_locking() &&
3195 !(FLAG_IS_CMDLINE(UseBiasedLocking))) { 3174 !(FLAG_IS_CMDLINE(UseBiasedLocking))) {
3196 UseBiasedLocking = false; 3175 UseBiasedLocking = false;
3176 }
3177 }
3178
3179 // set PauseAtExit if the gamma launcher was used and a debugger is attached
3180 // but only if not already set on the commandline
3181 if (Arguments::created_by_gamma_launcher() && os::is_debugger_attached()) {
3182 bool set = false;
3183 CommandLineFlags::wasSetOnCmdline("PauseAtExit", &set);
3184 if (!set) {
3185 FLAG_SET_DEFAULT(PauseAtExit, true);
3197 } 3186 }
3198 } 3187 }
3199 3188
3200 return JNI_OK; 3189 return JNI_OK;
3201 } 3190 }