src/hotspot/share/gc/g1/g1HeterogeneousHeapYoungGenSizer.cpp
changeset 53116 bb03098c4dde
child 54678 93f09ca4a7f8
equal deleted inserted replaced
53115:b5c41404f2d1 53116:bb03098c4dde
       
     1 /*
       
     2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  *
       
    23  */
       
    24 
       
    25 #include "precompiled.hpp"
       
    26 #include "gc/g1/g1HeterogeneousCollectorPolicy.hpp"
       
    27 #include "gc/g1/g1HeterogeneousHeapYoungGenSizer.hpp"
       
    28 #include "gc/g1/heapRegion.hpp"
       
    29 
       
    30 G1HeterogeneousHeapYoungGenSizer::G1HeterogeneousHeapYoungGenSizer() : G1YoungGenSizer() {
       
    31   // will be used later when min and max young size is calculated.
       
    32   _max_young_length = (uint)(G1HeterogeneousCollectorPolicy::reasonable_max_memory_for_young() / HeapRegion::GrainBytes);
       
    33 }
       
    34 
       
    35 // Since heap is sized potentially to larger value accounting for dram + nvdimm, we need to limit
       
    36 // max young gen size to the available dram.
       
    37 // Call parent class method first and then adjust sizes based on available dram
       
    38 void G1HeterogeneousHeapYoungGenSizer::adjust_max_new_size(uint number_of_heap_regions) {
       
    39   G1YoungGenSizer::adjust_max_new_size(number_of_heap_regions);
       
    40   adjust_lengths_based_on_dram_memory();
       
    41 }
       
    42 
       
    43 void G1HeterogeneousHeapYoungGenSizer::heap_size_changed(uint new_number_of_heap_regions) {
       
    44   G1YoungGenSizer::heap_size_changed(new_number_of_heap_regions);
       
    45   adjust_lengths_based_on_dram_memory();
       
    46 }
       
    47 
       
    48 void G1HeterogeneousHeapYoungGenSizer::adjust_lengths_based_on_dram_memory() {
       
    49   _min_desired_young_length = MIN2(_min_desired_young_length, _max_young_length);
       
    50   _max_desired_young_length = MIN2(_max_desired_young_length, _max_young_length);
       
    51 }