annotate src/share/vm/gc_implementation/g1/heapRegionSeq.hpp @ 470:ad8c8ca4ab0f

6785258: Update copyright year Summary: Update copyright for files that have been modified starting July 2008 to Dec 2008 Reviewed-by: katleman, ohair, tbell
author xdono
date Mon, 15 Dec 2008 16:55:11 -0800
parents 078b8a0d8d7c
children 96b229c54d1e
rev   line source
ysr@342 1 /*
xdono@470 2 * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
ysr@342 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@342 4 *
ysr@342 5 * This code is free software; you can redistribute it and/or modify it
ysr@342 6 * under the terms of the GNU General Public License version 2 only, as
ysr@342 7 * published by the Free Software Foundation.
ysr@342 8 *
ysr@342 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@342 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@342 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@342 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@342 13 * accompanied this code).
ysr@342 14 *
ysr@342 15 * You should have received a copy of the GNU General Public License version
ysr@342 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@342 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@342 18 *
ysr@342 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
ysr@342 20 * CA 95054 USA or visit www.sun.com if you need additional information or
ysr@342 21 * have any questions.
ysr@342 22 *
ysr@342 23 */
ysr@342 24
ysr@342 25 class HeapRegion;
ysr@342 26 class HeapRegionClosure;
ysr@342 27
ysr@342 28 class HeapRegionSeq: public CHeapObj {
ysr@342 29
ysr@342 30 // _regions is kept sorted by start address order, and no two regions are
ysr@342 31 // overlapping.
ysr@342 32 GrowableArray<HeapRegion*> _regions;
ysr@342 33
ysr@342 34 // The index in "_regions" at which to start the next allocation search.
ysr@342 35 // (For efficiency only; private to obj_allocate after initialization.)
ysr@342 36 int _alloc_search_start;
ysr@342 37
ysr@342 38 // Attempts to allocate a block of the (assumed humongous) word_size,
ysr@342 39 // starting at the region "ind".
ysr@342 40 HeapWord* alloc_obj_from_region_index(int ind, size_t word_size);
ysr@342 41
ysr@342 42 // Currently, we're choosing collection sets in a round-robin fashion,
ysr@342 43 // starting here.
ysr@342 44 int _next_rr_candidate;
ysr@342 45
ysr@342 46 // The bottom address of the bottom-most region, or else NULL if there
ysr@342 47 // are no regions in the sequence.
ysr@342 48 char* _seq_bottom;
ysr@342 49
ysr@342 50 public:
ysr@342 51 // Initializes "this" to the empty sequence of regions.
iveresov@393 52 HeapRegionSeq(const size_t max_size);
ysr@342 53
ysr@342 54 // Adds "hr" to "this" sequence. Requires "hr" not to overlap with
ysr@342 55 // any region already in "this". (Will perform better if regions are
ysr@342 56 // inserted in ascending address order.)
ysr@342 57 void insert(HeapRegion* hr);
ysr@342 58
ysr@342 59 // Given a HeapRegion*, returns its index within _regions,
ysr@342 60 // or returns -1 if not found.
ysr@342 61 int find(HeapRegion* hr);
ysr@342 62
ysr@342 63 // Requires the index to be valid, and return the region at the index.
ysr@342 64 HeapRegion* at(size_t i) { return _regions.at((int)i); }
ysr@342 65
ysr@342 66 // Return the number of regions in the sequence.
ysr@342 67 size_t length();
ysr@342 68
ysr@342 69 // Returns the number of contiguous regions at the end of the sequence
ysr@342 70 // that are available for allocation.
ysr@342 71 size_t free_suffix();
ysr@342 72
ysr@342 73 // Requires "word_size" to be humongous (in the technical sense). If
ysr@342 74 // possible, allocates a contiguous subsequence of the heap regions to
ysr@342 75 // satisfy the allocation, and returns the address of the beginning of
ysr@342 76 // that sequence, otherwise returns NULL.
ysr@342 77 HeapWord* obj_allocate(size_t word_size);
ysr@342 78
ysr@342 79 // Apply the "doHeapRegion" method of "blk" to all regions in "this",
ysr@342 80 // in address order, terminating the iteration early
ysr@342 81 // if the "doHeapRegion" method returns "true".
ysr@342 82 void iterate(HeapRegionClosure* blk);
ysr@342 83
ysr@342 84 // Apply the "doHeapRegion" method of "blk" to all regions in "this",
ysr@342 85 // starting at "r" (or first region, if "r" is NULL), in a circular
ysr@342 86 // manner, terminating the iteration early if the "doHeapRegion" method
ysr@342 87 // returns "true".
ysr@342 88 void iterate_from(HeapRegion* r, HeapRegionClosure* blk);
ysr@342 89
ysr@342 90 // As above, but start from a given index in the sequence
ysr@342 91 // instead of a given heap region.
ysr@342 92 void iterate_from(int idx, HeapRegionClosure* blk);
ysr@342 93
ysr@342 94 // Requires "shrink_bytes" to be a multiple of the page size and heap
ysr@342 95 // region granularity. Deletes as many "rightmost" completely free heap
ysr@342 96 // regions from the sequence as comprise shrink_bytes bytes. Returns the
ysr@342 97 // MemRegion indicating the region those regions comprised, and sets
ysr@342 98 // "num_regions_deleted" to the number of regions deleted.
ysr@342 99 MemRegion shrink_by(size_t shrink_bytes, size_t& num_regions_deleted);
ysr@342 100
ysr@342 101 // If "addr" falls within a region in the sequence, return that region,
ysr@342 102 // or else NULL.
ysr@342 103 HeapRegion* addr_to_region(const void* addr);
ysr@342 104
ysr@342 105 void print();
ysr@342 106
ysr@342 107 // Prints out runs of empty regions. If the arg is "true" reserved
ysr@342 108 // (popular regions are considered "empty".
ysr@342 109 void print_empty_runs(bool reserved_are_empty);
ysr@342 110
ysr@342 111 };