Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp @ 1285:a1c410de27e4
6928065: G1: use existing command line parameters to set the young generation size
Summary: see synopsis
Reviewed-by: johnc, jmasa
author | tonyp |
---|---|
date | Wed, 24 Feb 2010 14:56:20 -0500 |
parents | 1c72304f1885 |
children | 56507bcd639e |
comparison
equal
deleted
inserted
replaced
1284:5f1f51edaff6 | 1285:a1c410de27e4 |
---|---|
290 vm_exit_during_initialization("Invalid survivor ratio specified"); | 290 vm_exit_during_initialization("Invalid survivor ratio specified"); |
291 } | 291 } |
292 CollectorPolicy::initialize_flags(); | 292 CollectorPolicy::initialize_flags(); |
293 } | 293 } |
294 | 294 |
295 // The easiest way to deal with the parsing of the NewSize / | |
296 // MaxNewSize / etc. parameteres is to re-use the code in the | |
297 // TwoGenerationCollectorPolicy class. This is similar to what | |
298 // ParallelScavenge does with its GenerationSizer class (see | |
299 // ParallelScavengeHeap::initialize()). We might change this in the | |
300 // future, but it's a good start. | |
301 class G1YoungGenSizer : public TwoGenerationCollectorPolicy { | |
302 size_t size_to_region_num(size_t byte_size) { | |
303 return MAX2((size_t) 1, byte_size / HeapRegion::GrainBytes); | |
304 } | |
305 | |
306 public: | |
307 G1YoungGenSizer() { | |
308 initialize_flags(); | |
309 initialize_size_info(); | |
310 } | |
311 | |
312 size_t min_young_region_num() { | |
313 return size_to_region_num(_min_gen0_size); | |
314 } | |
315 size_t initial_young_region_num() { | |
316 return size_to_region_num(_initial_gen0_size); | |
317 } | |
318 size_t max_young_region_num() { | |
319 return size_to_region_num(_max_gen0_size); | |
320 } | |
321 }; | |
322 | |
295 void G1CollectorPolicy::init() { | 323 void G1CollectorPolicy::init() { |
296 // Set aside an initial future to_space. | 324 // Set aside an initial future to_space. |
297 _g1 = G1CollectedHeap::heap(); | 325 _g1 = G1CollectedHeap::heap(); |
298 size_t regions = Universe::heap()->capacity() / HeapRegion::GrainBytes; | |
299 | 326 |
300 assert(Heap_lock->owned_by_self(), "Locking discipline."); | 327 assert(Heap_lock->owned_by_self(), "Locking discipline."); |
301 | 328 |
302 initialize_gc_policy_counters(); | 329 initialize_gc_policy_counters(); |
303 | 330 |
304 if (G1Gen) { | 331 if (G1Gen) { |
305 _in_young_gc_mode = true; | 332 _in_young_gc_mode = true; |
306 | 333 |
307 if (G1YoungGenSize == 0) { | 334 G1YoungGenSizer sizer; |
335 size_t initial_region_num = sizer.initial_young_region_num(); | |
336 | |
337 if (UseAdaptiveSizePolicy) { | |
308 set_adaptive_young_list_length(true); | 338 set_adaptive_young_list_length(true); |
309 _young_list_fixed_length = 0; | 339 _young_list_fixed_length = 0; |
310 } else { | 340 } else { |
311 set_adaptive_young_list_length(false); | 341 set_adaptive_young_list_length(false); |
312 _young_list_fixed_length = (G1YoungGenSize / HeapRegion::GrainBytes); | 342 _young_list_fixed_length = initial_region_num; |
313 } | 343 } |
314 _free_regions_at_end_of_collection = _g1->free_regions(); | 344 _free_regions_at_end_of_collection = _g1->free_regions(); |
315 _scan_only_regions_at_end_of_collection = 0; | 345 _scan_only_regions_at_end_of_collection = 0; |
316 calculate_young_list_min_length(); | 346 calculate_young_list_min_length(); |
317 guarantee( _young_list_min_length == 0, "invariant, not enough info" ); | 347 guarantee( _young_list_min_length == 0, "invariant, not enough info" ); |