297 // min size. Either way, some users might have to set the region 298 // size manually for some -Xms / -Xmx combos. 299 300 region_size = MAX2(min_heap_size / TARGET_REGION_NUMBER, 301 (uintx) MIN_REGION_SIZE); 302 } 303 304 int region_size_log = log2_long((jlong) region_size); 305 // Recalculate the region size to make sure it's a power of 306 // 2. This means that region_size is the largest power of 2 that's 307 // <= what we've calculated so far. 308 region_size = ((uintx)1 << region_size_log); 309 310 // Now make sure that we don't go over or under our limits. 311 if (region_size < MIN_REGION_SIZE) { 312 region_size = MIN_REGION_SIZE; 313 } else if (region_size > MAX_REGION_SIZE) { 314 region_size = MAX_REGION_SIZE; 315 } 316 317 // And recalculate the log. 318 region_size_log = log2_long((jlong) region_size); 319 320 // Now, set up the globals. 321 guarantee(LogOfHRGrainBytes == 0, "we should only set it once"); 322 LogOfHRGrainBytes = region_size_log; 323 324 guarantee(LogOfHRGrainWords == 0, "we should only set it once"); 325 LogOfHRGrainWords = LogOfHRGrainBytes - LogHeapWordSize; 326 327 guarantee(GrainBytes == 0, "we should only set it once"); 328 // The cast to int is safe, given that we've bounded region_size by 329 // MIN_REGION_SIZE and MAX_REGION_SIZE. 330 GrainBytes = (size_t)region_size; 331 332 guarantee(GrainWords == 0, "we should only set it once"); 333 GrainWords = GrainBytes >> LogHeapWordSize; 334 guarantee((size_t) 1 << LogOfHRGrainWords == GrainWords, "sanity"); 335 336 guarantee(CardsPerRegion == 0, "we should only set it once"); | 297 // min size. Either way, some users might have to set the region 298 // size manually for some -Xms / -Xmx combos. 299 300 region_size = MAX2(min_heap_size / TARGET_REGION_NUMBER, 301 (uintx) MIN_REGION_SIZE); 302 } 303 304 int region_size_log = log2_long((jlong) region_size); 305 // Recalculate the region size to make sure it's a power of 306 // 2. This means that region_size is the largest power of 2 that's 307 // <= what we've calculated so far. 308 region_size = ((uintx)1 << region_size_log); 309 310 // Now make sure that we don't go over or under our limits. 311 if (region_size < MIN_REGION_SIZE) { 312 region_size = MIN_REGION_SIZE; 313 } else if (region_size > MAX_REGION_SIZE) { 314 region_size = MAX_REGION_SIZE; 315 } 316 317 if (region_size != G1HeapRegionSize) { 318 // Update the flag to make sure that PrintFlagsFinal logs the correct value 319 FLAG_SET_ERGO(uintx, G1HeapRegionSize, region_size); 320 } 321 322 // And recalculate the log. 323 region_size_log = log2_long((jlong) region_size); 324 325 // Now, set up the globals. 326 guarantee(LogOfHRGrainBytes == 0, "we should only set it once"); 327 LogOfHRGrainBytes = region_size_log; 328 329 guarantee(LogOfHRGrainWords == 0, "we should only set it once"); 330 LogOfHRGrainWords = LogOfHRGrainBytes - LogHeapWordSize; 331 332 guarantee(GrainBytes == 0, "we should only set it once"); 333 // The cast to int is safe, given that we've bounded region_size by 334 // MIN_REGION_SIZE and MAX_REGION_SIZE. 335 GrainBytes = (size_t)region_size; 336 337 guarantee(GrainWords == 0, "we should only set it once"); 338 GrainWords = GrainBytes >> LogHeapWordSize; 339 guarantee((size_t) 1 << LogOfHRGrainWords == GrainWords, "sanity"); 340 341 guarantee(CardsPerRegion == 0, "we should only set it once"); |