1.1 --- a/src/share/vm/runtime/arguments.cpp Wed Jun 04 13:51:09 2008 -0700 1.2 +++ b/src/share/vm/runtime/arguments.cpp Thu Jun 05 15:57:56 2008 -0700 1.3 @@ -922,18 +922,17 @@ 1.4 // UseParNewGC and not explicitly set ParallelGCThreads we 1.5 // set it, unless this is a single cpu machine. 1.6 void Arguments::set_parnew_gc_flags() { 1.7 - assert(!UseSerialGC && !UseParallelGC, "control point invariant"); 1.8 + assert(!UseSerialGC && !UseParallelGC && !UseG1GC, 1.9 + "control point invariant"); 1.10 + assert(UseParNewGC, "Error"); 1.11 1.12 // Turn off AdaptiveSizePolicy by default for parnew until it is 1.13 // complete. 1.14 - if (UseParNewGC && 1.15 - FLAG_IS_DEFAULT(UseAdaptiveSizePolicy)) { 1.16 + if (FLAG_IS_DEFAULT(UseAdaptiveSizePolicy)) { 1.17 FLAG_SET_DEFAULT(UseAdaptiveSizePolicy, false); 1.18 } 1.19 1.20 - if (FLAG_IS_DEFAULT(UseParNewGC) && ParallelGCThreads > 1) { 1.21 - FLAG_SET_DEFAULT(UseParNewGC, true); 1.22 - } else if (UseParNewGC && ParallelGCThreads == 0) { 1.23 + if (ParallelGCThreads == 0) { 1.24 FLAG_SET_DEFAULT(ParallelGCThreads, 1.25 Abstract_VM_Version::parallel_worker_threads()); 1.26 if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) { 1.27 @@ -969,15 +968,12 @@ 1.28 // further optimization and tuning efforts, and would almost 1.29 // certainly gain from analysis of platform and environment. 1.30 void Arguments::set_cms_and_parnew_gc_flags() { 1.31 - if (UseSerialGC || UseParallelGC) { 1.32 - return; 1.33 - } 1.34 - 1.35 + assert(!UseSerialGC && !UseParallelGC, "Error"); 1.36 assert(UseConcMarkSweepGC, "CMS is expected to be on here"); 1.37 1.38 // If we are using CMS, we prefer to UseParNewGC, 1.39 // unless explicitly forbidden. 1.40 - if (!UseParNewGC && FLAG_IS_DEFAULT(UseParNewGC)) { 1.41 + if (FLAG_IS_DEFAULT(UseParNewGC)) { 1.42 FLAG_SET_ERGO(bool, UseParNewGC, true); 1.43 } 1.44 1.45 @@ -1157,6 +1153,7 @@ 1.46 // machine class and automatic selection policy. 1.47 if (!UseSerialGC && 1.48 !UseConcMarkSweepGC && 1.49 + !UseG1GC && 1.50 !UseParNewGC && 1.51 !DumpSharedSpaces && 1.52 FLAG_IS_DEFAULT(UseParallelGC)) { 1.53 @@ -1174,7 +1171,7 @@ 1.54 // field offset to determine free list chunk markers. 1.55 // Check that UseCompressedOops can be set with the max heap size allocated 1.56 // by ergonomics. 1.57 - if (!UseConcMarkSweepGC && MaxHeapSize <= max_heap_for_compressed_oops()) { 1.58 + if (!UseG1GC && !UseConcMarkSweepGC && MaxHeapSize <= max_heap_for_compressed_oops()) { 1.59 if (FLAG_IS_DEFAULT(UseCompressedOops)) { 1.60 FLAG_SET_ERGO(bool, UseCompressedOops, true); 1.61 } 1.62 @@ -1183,6 +1180,8 @@ 1.63 // If specified, give a warning 1.64 if (UseConcMarkSweepGC){ 1.65 warning("Compressed Oops does not work with CMS"); 1.66 + } else if (UseG1GC) { 1.67 + warning("Compressed Oops does not work with UseG1GC"); 1.68 } else { 1.69 warning( 1.70 "Max heap size too large for Compressed Oops"); 1.71 @@ -1196,6 +1195,7 @@ 1.72 } 1.73 1.74 void Arguments::set_parallel_gc_flags() { 1.75 + assert(UseParallelGC || UseParallelOldGC, "Error"); 1.76 // If parallel old was requested, automatically enable parallel scavenge. 1.77 if (UseParallelOldGC && !UseParallelGC && FLAG_IS_DEFAULT(UseParallelGC)) { 1.78 FLAG_SET_DEFAULT(UseParallelGC, true); 1.79 @@ -1207,51 +1207,8 @@ 1.80 FLAG_SET_ERGO(uintx, ParallelGCThreads, 1.81 Abstract_VM_Version::parallel_worker_threads()); 1.82 1.83 - if (FLAG_IS_DEFAULT(MaxHeapSize)) { 1.84 - const uint64_t reasonable_fraction = 1.85 - os::physical_memory() / DefaultMaxRAMFraction; 1.86 - const uint64_t maximum_size = (uint64_t) 1.87 - (FLAG_IS_DEFAULT(DefaultMaxRAM) && UseCompressedOops ? 1.88 - MIN2(max_heap_for_compressed_oops(), DefaultMaxRAM) : 1.89 - DefaultMaxRAM); 1.90 - size_t reasonable_max = 1.91 - (size_t) os::allocatable_physical_memory(reasonable_fraction); 1.92 - if (reasonable_max > maximum_size) { 1.93 - reasonable_max = maximum_size; 1.94 - } 1.95 - if (PrintGCDetails && Verbose) { 1.96 - // Cannot use gclog_or_tty yet. 1.97 - tty->print_cr(" Max heap size for server class platform " 1.98 - SIZE_FORMAT, reasonable_max); 1.99 - } 1.100 - // If the initial_heap_size has not been set with -Xms, 1.101 - // then set it as fraction of size of physical memory 1.102 - // respecting the maximum and minimum sizes of the heap. 1.103 - if (initial_heap_size() == 0) { 1.104 - const uint64_t reasonable_initial_fraction = 1.105 - os::physical_memory() / DefaultInitialRAMFraction; 1.106 - const size_t reasonable_initial = 1.107 - (size_t) os::allocatable_physical_memory(reasonable_initial_fraction); 1.108 - const size_t minimum_size = NewSize + OldSize; 1.109 - set_initial_heap_size(MAX2(MIN2(reasonable_initial, reasonable_max), 1.110 - minimum_size)); 1.111 - // Currently the minimum size and the initial heap sizes are the same. 1.112 - set_min_heap_size(initial_heap_size()); 1.113 - if (PrintGCDetails && Verbose) { 1.114 - // Cannot use gclog_or_tty yet. 1.115 - tty->print_cr(" Initial heap size for server class platform " 1.116 - SIZE_FORMAT, initial_heap_size()); 1.117 - } 1.118 - } else { 1.119 - // An minimum size was specified on the command line. Be sure 1.120 - // that the maximum size is consistent. 1.121 - if (initial_heap_size() > reasonable_max) { 1.122 - reasonable_max = initial_heap_size(); 1.123 - } 1.124 - } 1.125 - FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx) reasonable_max); 1.126 - } 1.127 - 1.128 + // PS is a server collector, setup the heap sizes accordingly. 1.129 + set_server_heap_size(); 1.130 // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the 1.131 // SurvivorRatio has been set, reset their default values to SurvivorRatio + 1.132 // 2. By doing this we make SurvivorRatio also work for Parallel Scavenger. 1.133 @@ -1279,6 +1236,70 @@ 1.134 } 1.135 } 1.136 1.137 +void Arguments::set_g1_gc_flags() { 1.138 + assert(UseG1GC, "Error"); 1.139 + // G1 is a server collector, setup the heap sizes accordingly. 1.140 + set_server_heap_size(); 1.141 +#ifdef COMPILER1 1.142 + FastTLABRefill = false; 1.143 +#endif 1.144 + FLAG_SET_DEFAULT(ParallelGCThreads, 1.145 + Abstract_VM_Version::parallel_worker_threads()); 1.146 + if (ParallelGCThreads == 0) { 1.147 + FLAG_SET_DEFAULT(ParallelGCThreads, 1.148 + Abstract_VM_Version::parallel_worker_threads 1.149 +()); 1.150 + } 1.151 + no_shared_spaces(); 1.152 +} 1.153 + 1.154 +void Arguments::set_server_heap_size() { 1.155 + if (FLAG_IS_DEFAULT(MaxHeapSize)) { 1.156 + const uint64_t reasonable_fraction = 1.157 + os::physical_memory() / DefaultMaxRAMFraction; 1.158 + const uint64_t maximum_size = (uint64_t) 1.159 + (FLAG_IS_DEFAULT(DefaultMaxRAM) && UseCompressedOops ? 1.160 + MIN2(max_heap_for_compressed_oops(), DefaultMaxRAM) : 1.161 + DefaultMaxRAM); 1.162 + size_t reasonable_max = 1.163 + (size_t) os::allocatable_physical_memory(reasonable_fraction); 1.164 + if (reasonable_max > maximum_size) { 1.165 + reasonable_max = maximum_size; 1.166 + } 1.167 + if (PrintGCDetails && Verbose) { 1.168 + // Cannot use gclog_or_tty yet. 1.169 + tty->print_cr(" Max heap size for server class platform " 1.170 + SIZE_FORMAT, reasonable_max); 1.171 + } 1.172 + // If the initial_heap_size has not been set with -Xms, 1.173 + // then set it as fraction of size of physical memory 1.174 + // respecting the maximum and minimum sizes of the heap. 1.175 + if (initial_heap_size() == 0) { 1.176 + const uint64_t reasonable_initial_fraction = 1.177 + os::physical_memory() / DefaultInitialRAMFraction; 1.178 + const size_t reasonable_initial = 1.179 + (size_t) os::allocatable_physical_memory(reasonable_initial_fraction); 1.180 + const size_t minimum_size = NewSize + OldSize; 1.181 + set_initial_heap_size(MAX2(MIN2(reasonable_initial, reasonable_max), 1.182 + minimum_size)); 1.183 + // Currently the minimum size and the initial heap sizes are the same. 1.184 + set_min_heap_size(initial_heap_size()); 1.185 + if (PrintGCDetails && Verbose) { 1.186 + // Cannot use gclog_or_tty yet. 1.187 + tty->print_cr(" Initial heap size for server class platform " 1.188 + SIZE_FORMAT, initial_heap_size()); 1.189 + } 1.190 + } else { 1.191 + // A minimum size was specified on the command line. Be sure 1.192 + // that the maximum size is consistent. 1.193 + if (initial_heap_size() > reasonable_max) { 1.194 + reasonable_max = initial_heap_size(); 1.195 + } 1.196 + } 1.197 + FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx) reasonable_max); 1.198 + } 1.199 +} 1.200 + 1.201 // This must be called after ergonomics because we want bytecode rewriting 1.202 // if the server compiler is used, or if UseSharedSpaces is disabled. 1.203 void Arguments::set_bytecode_flags() { 1.204 @@ -1362,12 +1383,13 @@ 1.205 FLAG_SET_DEFAULT(UseConcMarkSweepGC, false); 1.206 FLAG_SET_DEFAULT(UseParallelGC, false); 1.207 FLAG_SET_DEFAULT(UseParallelOldGC, false); 1.208 + FLAG_SET_DEFAULT(UseG1GC, false); 1.209 } 1.210 1.211 static bool verify_serial_gc_flags() { 1.212 return (UseSerialGC && 1.213 - !(UseParNewGC || UseConcMarkSweepGC || UseParallelGC || 1.214 - UseParallelOldGC)); 1.215 + !(UseParNewGC || UseConcMarkSweepGC || UseG1GC || 1.216 + UseParallelGC || UseParallelOldGC)); 1.217 } 1.218 1.219 // Check consistency of GC selection 1.220 @@ -1470,8 +1492,8 @@ 1.221 status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit"); 1.222 1.223 // Check user specified sharing option conflict with Parallel GC 1.224 - bool cannot_share = (UseConcMarkSweepGC || UseParallelGC || 1.225 - UseParallelOldGC || UseParNewGC || 1.226 + bool cannot_share = (UseConcMarkSweepGC || UseG1GC || UseParNewGC || 1.227 + UseParallelGC || UseParallelOldGC || 1.228 SOLARIS_ONLY(UseISM) NOT_SOLARIS(UseLargePages)); 1.229 1.230 if (cannot_share) { 1.231 @@ -1511,11 +1533,6 @@ 1.232 "The CMS collector (-XX:+UseConcMarkSweepGC) must be " 1.233 "selected in order\nto use CMSIncrementalMode.\n"); 1.234 status = false; 1.235 - } else if (!UseTLAB) { 1.236 - jio_fprintf(defaultStream::error_stream(), 1.237 - "error: CMSIncrementalMode requires thread-local " 1.238 - "allocation buffers\n(-XX:+UseTLAB).\n"); 1.239 - status = false; 1.240 } else { 1.241 status = status && verify_percentage(CMSIncrementalDutyCycle, 1.242 "CMSIncrementalDutyCycle"); 1.243 @@ -1535,13 +1552,6 @@ 1.244 } 1.245 } 1.246 1.247 - if (UseNUMA && !UseTLAB) { 1.248 - jio_fprintf(defaultStream::error_stream(), 1.249 - "error: NUMA allocator (-XX:+UseNUMA) requires thread-local " 1.250 - "allocation\nbuffers (-XX:+UseTLAB).\n"); 1.251 - status = false; 1.252 - } 1.253 - 1.254 // CMS space iteration, which FLSVerifyAllHeapreferences entails, 1.255 // insists that we hold the requisite locks so that the iteration is 1.256 // MT-safe. For the verification at start-up and shut-down, we don't 1.257 @@ -2330,10 +2340,15 @@ 1.258 SOLARIS_ONLY(FLAG_SET_DEFAULT(UseMPSS, false)); 1.259 SOLARIS_ONLY(FLAG_SET_DEFAULT(UseISM, false)); 1.260 } 1.261 + 1.262 #else 1.263 if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) { 1.264 FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1); 1.265 } 1.266 + // Temporary disable bulk zeroing reduction with G1. See CR 6627983. 1.267 + if (UseG1GC) { 1.268 + FLAG_SET_DEFAULT(ReduceBulkZeroing, false); 1.269 + } 1.270 #endif 1.271 1.272 if (!check_vm_args_consistency()) { 1.273 @@ -2485,12 +2500,29 @@ 1.274 } 1.275 } 1.276 1.277 + 1.278 // Parse JavaVMInitArgs structure passed in, as well as JAVA_TOOL_OPTIONS and _JAVA_OPTIONS 1.279 jint result = parse_vm_init_args(args); 1.280 if (result != JNI_OK) { 1.281 return result; 1.282 } 1.283 1.284 + // These are hacks until G1 is fully supported and tested 1.285 + // but lets you force -XX:+UseG1GC in PRT and get it where it (mostly) works 1.286 + if (UseG1GC) { 1.287 + if (UseConcMarkSweepGC || UseParNewGC || UseParallelGC || UseParallelOldGC || UseSerialGC) { 1.288 +#ifndef PRODUCT 1.289 + tty->print_cr("-XX:+UseG1GC is incompatible with other collectors, using UseG1GC"); 1.290 +#endif // PRODUCT 1.291 + UseConcMarkSweepGC = false; 1.292 + UseParNewGC = false; 1.293 + UseParallelGC = false; 1.294 + UseParallelOldGC = false; 1.295 + UseSerialGC = false; 1.296 + } 1.297 + no_shared_spaces(); 1.298 + } 1.299 + 1.300 #ifndef PRODUCT 1.301 if (TraceBytecodesAt != 0) { 1.302 TraceBytecodes = true; 1.303 @@ -2536,6 +2568,12 @@ 1.304 // Set some flags for ParNew 1.305 set_parnew_gc_flags(); 1.306 } 1.307 + // Temporary; make the "if" an "else-if" before 1.308 + // we integrate G1. XXX 1.309 + if (UseG1GC) { 1.310 + // Set some flags for garbage-first, if needed. 1.311 + set_g1_gc_flags(); 1.312 + } 1.313 1.314 #ifdef SERIALGC 1.315 assert(verify_serial_gc_flags(), "SerialGC unset");