< prev index next >

hotspot/src/share/vm/gc_implementation/g1/heapRegionManager.hpp

Print this page
rev 7369 : 8061715: gc/g1/TestShrinkAuxiliaryData15.java fails with java.lang.RuntimeException: heap decommit failed - after > before
Summary: added WhiteBox methods to count regions and exact aux data sizes
Reviewed-by: jwilhelm, brutisso
   1 /*
   2  * Copyright (c) 2001, 2013, 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 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONMANAGER_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONMANAGER_HPP
  27 
  28 #include "gc_implementation/g1/g1BiasedArray.hpp"
  29 #include "gc_implementation/g1/g1RegionToSpaceMapper.hpp"
  30 #include "gc_implementation/g1/heapRegionSet.hpp"

  31 
  32 class HeapRegion;
  33 class HeapRegionClosure;
  34 class FreeRegionList;
  35 
  36 class G1HeapRegionTable : public G1BiasedMappedArray<HeapRegion*> {
  37  protected:
  38   virtual HeapRegion* default_value() const { return NULL; }
  39 };
  40 
  41 // This class keeps track of the actual heap memory, auxiliary data
  42 // and its metadata (i.e., HeapRegion instances) and the list of free regions.
  43 //
  44 // This allows maximum flexibility for deciding what to commit or uncommit given
  45 // a request from outside.
  46 //
  47 // HeapRegions are kept in the _regions array in address order. A region's
  48 // index in the array corresponds to its index in the heap (i.e., 0 is the
  49 // region at the bottom of the heap, 1 is the one after it, etc.). Two
  50 // regions that are consecutive in the array should also be adjacent in the


 180   }
 181 
 182   // Return the number of committed free regions in the heap.
 183   uint num_free_regions() const {
 184     return _free_list.length();
 185   }
 186 
 187   size_t total_capacity_bytes() const {
 188     return num_free_regions() * HeapRegion::GrainBytes;
 189   }
 190 
 191   // Return the number of available (uncommitted) regions.
 192   uint available() const { return max_length() - length(); }
 193 
 194   // Return the number of regions that have been committed in the heap.
 195   uint length() const { return _num_committed; }
 196 
 197   // Return the maximum number of regions in the heap.
 198   uint max_length() const { return (uint)_regions.length(); }
 199 


 200   MemRegion reserved() const { return MemRegion(heap_bottom(), heap_end()); }
 201 
 202   // Expand the sequence to reflect that the heap has grown. Either create new
 203   // HeapRegions, or re-use existing ones. Returns the number of regions the
 204   // sequence was expanded by. If a HeapRegion allocation fails, the resulting
 205   // number of regions might be smaller than what's desired.
 206   uint expand_by(uint num_regions);
 207 
 208   // Makes sure that the regions from start to start+num_regions-1 are available
 209   // for allocation. Returns the number of regions that were committed to achieve
 210   // this.
 211   uint expand_at(uint start, uint num_regions);
 212 
 213   // Find a contiguous set of empty regions of length num. Returns the start index of
 214   // that set, or G1_NO_HRM_INDEX.
 215   uint find_contiguous_only_empty(size_t num) { return find_contiguous(num, true); }
 216   // Find a contiguous set of empty or unavailable regions of length num. Returns the
 217   // start index of that set, or G1_NO_HRM_INDEX.
 218   uint find_contiguous_empty_or_unavailable(size_t num) { return find_contiguous(num, false); }
 219 
   1 /*
   2  * Copyright (c) 2001, 2015, 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 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONMANAGER_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONMANAGER_HPP
  27 
  28 #include "gc_implementation/g1/g1BiasedArray.hpp"
  29 #include "gc_implementation/g1/g1RegionToSpaceMapper.hpp"
  30 #include "gc_implementation/g1/heapRegionSet.hpp"
  31 #include "services/memoryUsage.hpp"
  32 
  33 class HeapRegion;
  34 class HeapRegionClosure;
  35 class FreeRegionList;
  36 
  37 class G1HeapRegionTable : public G1BiasedMappedArray<HeapRegion*> {
  38  protected:
  39   virtual HeapRegion* default_value() const { return NULL; }
  40 };
  41 
  42 // This class keeps track of the actual heap memory, auxiliary data
  43 // and its metadata (i.e., HeapRegion instances) and the list of free regions.
  44 //
  45 // This allows maximum flexibility for deciding what to commit or uncommit given
  46 // a request from outside.
  47 //
  48 // HeapRegions are kept in the _regions array in address order. A region's
  49 // index in the array corresponds to its index in the heap (i.e., 0 is the
  50 // region at the bottom of the heap, 1 is the one after it, etc.). Two
  51 // regions that are consecutive in the array should also be adjacent in the


 181   }
 182 
 183   // Return the number of committed free regions in the heap.
 184   uint num_free_regions() const {
 185     return _free_list.length();
 186   }
 187 
 188   size_t total_capacity_bytes() const {
 189     return num_free_regions() * HeapRegion::GrainBytes;
 190   }
 191 
 192   // Return the number of available (uncommitted) regions.
 193   uint available() const { return max_length() - length(); }
 194 
 195   // Return the number of regions that have been committed in the heap.
 196   uint length() const { return _num_committed; }
 197 
 198   // Return the maximum number of regions in the heap.
 199   uint max_length() const { return (uint)_regions.length(); }
 200 
 201   MemoryUsage get_auxiliary_data_memory_usage() const;
 202 
 203   MemRegion reserved() const { return MemRegion(heap_bottom(), heap_end()); }
 204 
 205   // Expand the sequence to reflect that the heap has grown. Either create new
 206   // HeapRegions, or re-use existing ones. Returns the number of regions the
 207   // sequence was expanded by. If a HeapRegion allocation fails, the resulting
 208   // number of regions might be smaller than what's desired.
 209   uint expand_by(uint num_regions);
 210 
 211   // Makes sure that the regions from start to start+num_regions-1 are available
 212   // for allocation. Returns the number of regions that were committed to achieve
 213   // this.
 214   uint expand_at(uint start, uint num_regions);
 215 
 216   // Find a contiguous set of empty regions of length num. Returns the start index of
 217   // that set, or G1_NO_HRM_INDEX.
 218   uint find_contiguous_only_empty(size_t num) { return find_contiguous(num, true); }
 219   // Find a contiguous set of empty or unavailable regions of length num. Returns the
 220   // start index of that set, or G1_NO_HRM_INDEX.
 221   uint find_contiguous_empty_or_unavailable(size_t num) { return find_contiguous(num, false); }
 222 
< prev index next >