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

Tue, 19 May 2009 04:05:31 -0700

author
apetrusenko
date
Tue, 19 May 2009 04:05:31 -0700
changeset 1231
29e7d79232b9
parent 1112
96b229c54d1e
child 1279
bd02caa94611
permissions
-rw-r--r--

6819065: G1: eliminate high serial card table clearing time
Reviewed-by: iveresov, tonyp

     1 /*
     2  * Copyright 2001-2008 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 class HeapRegion;
    26 class HeapRegionClosure;
    28 class HeapRegionSeq: public CHeapObj {
    30   // _regions is kept sorted by start address order, and no two regions are
    31   // overlapping.
    32   GrowableArray<HeapRegion*> _regions;
    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;
    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);
    42   // Currently, we're choosing collection sets in a round-robin fashion,
    43   // starting here.
    44   int _next_rr_candidate;
    46   // The bottom address of the bottom-most region, or else NULL if there
    47   // are no regions in the sequence.
    48   char* _seq_bottom;
    50  public:
    51   // Initializes "this" to the empty sequence of regions.
    52   HeapRegionSeq(const size_t max_size);
    54   // Adds "hr" to "this" sequence.  Requires "hr" not to overlap with
    55   // any region already in "this".  (Will perform better if regions are
    56   // inserted in ascending address order.)
    57   void insert(HeapRegion* hr);
    59   // Given a HeapRegion*, returns its index within _regions,
    60   // or returns -1 if not found.
    61   int find(HeapRegion* hr);
    63   // Requires the index to be valid, and return the region at the index.
    64   HeapRegion* at(size_t i) { return _regions.at((int)i); }
    66   // Return the number of regions in the sequence.
    67   size_t length();
    69   // Returns the number of contiguous regions at the end of the sequence
    70   // that are available for allocation.
    71   size_t free_suffix();
    73   // Requires "word_size" to be humongous (in the technical sense).  If
    74   // possible, allocates a contiguous subsequence of the heap regions to
    75   // satisfy the allocation, and returns the address of the beginning of
    76   // that sequence, otherwise returns NULL.
    77   HeapWord* obj_allocate(size_t word_size);
    79   // Apply the "doHeapRegion" method of "blk" to all regions in "this",
    80   // in address order, terminating the iteration early
    81   // if the "doHeapRegion" method returns "true".
    82   void iterate(HeapRegionClosure* blk);
    84   // Apply the "doHeapRegion" method of "blk" to all regions in "this",
    85   // starting at "r" (or first region, if "r" is NULL), in a circular
    86   // manner, terminating the iteration early if the "doHeapRegion" method
    87   // returns "true".
    88   void iterate_from(HeapRegion* r, HeapRegionClosure* blk);
    90   // As above, but start from a given index in the sequence
    91   // instead of a given heap region.
    92   void iterate_from(int idx, HeapRegionClosure* blk);
    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);
   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);
   105   void print();
   107   // Prints out runs of empty regions.
   108   void print_empty_runs();
   110 };

mercurial