src/share/vm/gc_implementation/g1/heapRegionSeq.hpp

Print this page


   1 /*
   2  * Copyright (c) 2001, 2009, 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 class HeapRegion;
  26 class HeapRegionClosure;
  27 
  28 class HeapRegionSeq: public CHeapObj {
  29 
  30   // _regions is kept sorted by start address order, and no two regions are
  31   // overlapping.
  32   GrowableArray<HeapRegion*> _regions;
  33 
  34   // The index in "_regions" at which to start the next allocation search.
  35   // (For efficiency only; private to obj_allocate after initialization.)
  36   int _alloc_search_start;
  37 
  38   // Attempts to allocate a block of the (assumed humongous) word_size,
  39   // starting at the region "ind".
  40   HeapWord* alloc_obj_from_region_index(int ind, size_t word_size);
  41 
  42   // Currently, we're choosing collection sets in a round-robin fashion,
  43   // starting here.
  44   int _next_rr_candidate;


  91   // instead of a given heap region.
  92   void iterate_from(int idx, HeapRegionClosure* blk);
  93 
  94   // Requires "shrink_bytes" to be a multiple of the page size and heap
  95   // region granularity.  Deletes as many "rightmost" completely free heap
  96   // regions from the sequence as comprise shrink_bytes bytes.  Returns the
  97   // MemRegion indicating the region those regions comprised, and sets
  98   // "num_regions_deleted" to the number of regions deleted.
  99   MemRegion shrink_by(size_t shrink_bytes, size_t& num_regions_deleted);
 100 
 101   // If "addr" falls within a region in the sequence, return that region,
 102   // or else NULL.
 103   HeapRegion* addr_to_region(const void* addr);
 104 
 105   void print();
 106 
 107   // Prints out runs of empty regions.
 108   void print_empty_runs();
 109 
 110 };


   1 /*
   2  * Copyright (c) 2001, 2010, 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_HEAPREGIONSEQ_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_HPP
  27 
  28 #include "gc_implementation/g1/heapRegion.hpp"
  29 #include "utilities/growableArray.hpp"
  30 
  31 class HeapRegion;
  32 class HeapRegionClosure;
  33 
  34 class HeapRegionSeq: public CHeapObj {
  35 
  36   // _regions is kept sorted by start address order, and no two regions are
  37   // overlapping.
  38   GrowableArray<HeapRegion*> _regions;
  39 
  40   // The index in "_regions" at which to start the next allocation search.
  41   // (For efficiency only; private to obj_allocate after initialization.)
  42   int _alloc_search_start;
  43 
  44   // Attempts to allocate a block of the (assumed humongous) word_size,
  45   // starting at the region "ind".
  46   HeapWord* alloc_obj_from_region_index(int ind, size_t word_size);
  47 
  48   // Currently, we're choosing collection sets in a round-robin fashion,
  49   // starting here.
  50   int _next_rr_candidate;


  97   // instead of a given heap region.
  98   void iterate_from(int idx, HeapRegionClosure* blk);
  99 
 100   // Requires "shrink_bytes" to be a multiple of the page size and heap
 101   // region granularity.  Deletes as many "rightmost" completely free heap
 102   // regions from the sequence as comprise shrink_bytes bytes.  Returns the
 103   // MemRegion indicating the region those regions comprised, and sets
 104   // "num_regions_deleted" to the number of regions deleted.
 105   MemRegion shrink_by(size_t shrink_bytes, size_t& num_regions_deleted);
 106 
 107   // If "addr" falls within a region in the sequence, return that region,
 108   // or else NULL.
 109   HeapRegion* addr_to_region(const void* addr);
 110 
 111   void print();
 112 
 113   // Prints out runs of empty regions.
 114   void print_empty_runs();
 115 
 116 };
 117 
 118 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_HPP