src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp

changeset 1720
a1c410de27e4
parent 1718
1c72304f1885
child 1791
56507bcd639e
     1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Feb 24 07:00:33 2010 -0800
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Feb 24 14:56:20 2010 -0500
     1.3 @@ -292,10 +292,37 @@
     1.4    CollectorPolicy::initialize_flags();
     1.5  }
     1.6  
     1.7 +// The easiest way to deal with the parsing of the NewSize /
     1.8 +// MaxNewSize / etc. parameteres is to re-use the code in the
     1.9 +// TwoGenerationCollectorPolicy class. This is similar to what
    1.10 +// ParallelScavenge does with its GenerationSizer class (see
    1.11 +// ParallelScavengeHeap::initialize()). We might change this in the
    1.12 +// future, but it's a good start.
    1.13 +class G1YoungGenSizer : public TwoGenerationCollectorPolicy {
    1.14 +  size_t size_to_region_num(size_t byte_size) {
    1.15 +    return MAX2((size_t) 1, byte_size / HeapRegion::GrainBytes);
    1.16 +  }
    1.17 +
    1.18 +public:
    1.19 +  G1YoungGenSizer() {
    1.20 +    initialize_flags();
    1.21 +    initialize_size_info();
    1.22 +  }
    1.23 +
    1.24 +  size_t min_young_region_num() {
    1.25 +    return size_to_region_num(_min_gen0_size);
    1.26 +  }
    1.27 +  size_t initial_young_region_num() {
    1.28 +    return size_to_region_num(_initial_gen0_size);
    1.29 +  }
    1.30 +  size_t max_young_region_num() {
    1.31 +    return size_to_region_num(_max_gen0_size);
    1.32 +  }
    1.33 +};
    1.34 +
    1.35  void G1CollectorPolicy::init() {
    1.36    // Set aside an initial future to_space.
    1.37    _g1 = G1CollectedHeap::heap();
    1.38 -  size_t regions = Universe::heap()->capacity() / HeapRegion::GrainBytes;
    1.39  
    1.40    assert(Heap_lock->owned_by_self(), "Locking discipline.");
    1.41  
    1.42 @@ -304,12 +331,15 @@
    1.43    if (G1Gen) {
    1.44      _in_young_gc_mode = true;
    1.45  
    1.46 -    if (G1YoungGenSize == 0) {
    1.47 +    G1YoungGenSizer sizer;
    1.48 +    size_t initial_region_num = sizer.initial_young_region_num();
    1.49 +
    1.50 +    if (UseAdaptiveSizePolicy) {
    1.51        set_adaptive_young_list_length(true);
    1.52        _young_list_fixed_length = 0;
    1.53      } else {
    1.54        set_adaptive_young_list_length(false);
    1.55 -      _young_list_fixed_length = (G1YoungGenSize / HeapRegion::GrainBytes);
    1.56 +      _young_list_fixed_length = initial_region_num;
    1.57      }
    1.58       _free_regions_at_end_of_collection = _g1->free_regions();
    1.59       _scan_only_regions_at_end_of_collection = 0;

mercurial