src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp

Tue, 21 Aug 2012 14:10:39 -0700

author
johnc
date
Tue, 21 Aug 2012 14:10:39 -0700
changeset 3998
7383557659bd
parent 3957
a2f7274eb6ef
child 6385
58fc1b1523dc
permissions
-rw-r--r--

7185699: G1: Prediction model discrepancies
Summary: Correct the result value of G1CollectedHeap::pending_card_num(). Change the code that calculates the GC efficiency of a non-young heap region to use historical data from mixed GCs and the actual number of live bytes when predicting how long it would take to collect the region. Changes were also reviewed by Thomas Schatzl.
Reviewed-by: azeemj, brutisso

tonyp@2472 1 /*
tonyp@3713 2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
tonyp@2472 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
tonyp@2472 4 *
tonyp@2472 5 * This code is free software; you can redistribute it and/or modify it
tonyp@2472 6 * under the terms of the GNU General Public License version 2 only, as
tonyp@2472 7 * published by the Free Software Foundation.
tonyp@2472 8 *
tonyp@2472 9 * This code is distributed in the hope that it will be useful, but WITHOUT
tonyp@2472 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
tonyp@2472 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
tonyp@2472 12 * version 2 for more details (a copy is included in the LICENSE file that
tonyp@2472 13 * accompanied this code).
tonyp@2472 14 *
tonyp@2472 15 * You should have received a copy of the GNU General Public License version
tonyp@2472 16 * 2 along with this work; if not, write to the Free Software Foundation,
tonyp@2472 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
tonyp@2472 18 *
tonyp@2472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
tonyp@2472 20 * or visit www.oracle.com if you need additional information or have any
tonyp@2472 21 * questions.
tonyp@2472 22 *
tonyp@2472 23 */
tonyp@2472 24
tonyp@2472 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP
tonyp@2472 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP
tonyp@2472 27
tonyp@2472 28 #include "gc_implementation/g1/heapRegionSet.hpp"
tonyp@2472 29
tonyp@2472 30 //////////////////// HeapRegionSetBase ////////////////////
tonyp@2472 31
tonyp@2472 32 inline void HeapRegionSetBase::update_for_addition(HeapRegion* hr) {
tonyp@2472 33 // Assumes the caller has already verified the region.
tonyp@2472 34
tonyp@2472 35 _length += 1;
tonyp@3957 36 _region_num += hr->region_num();
tonyp@2472 37 _total_used_bytes += hr->used();
tonyp@2472 38 }
tonyp@2472 39
tonyp@2472 40 inline void HeapRegionSetBase::add_internal(HeapRegion* hr) {
tonyp@2643 41 hrs_assert_region_ok(this, hr, NULL);
tonyp@2643 42 assert(hr->next() == NULL, hrs_ext_msg(this, "should not already be linked"));
tonyp@2472 43
tonyp@2472 44 update_for_addition(hr);
tonyp@2472 45 hr->set_containing_set(this);
tonyp@2472 46 }
tonyp@2472 47
tonyp@2472 48 inline void HeapRegionSetBase::update_for_removal(HeapRegion* hr) {
tonyp@2472 49 // Assumes the caller has already verified the region.
tonyp@2643 50 assert(_length > 0, hrs_ext_msg(this, "pre-condition"));
tonyp@2472 51 _length -= 1;
tonyp@2472 52
tonyp@3957 53 uint region_num_diff = hr->region_num();
tonyp@2472 54 assert(region_num_diff <= _region_num,
tonyp@3713 55 hrs_err_msg("[%s] region's region num: %u "
tonyp@3713 56 "should be <= region num: %u",
tonyp@2472 57 name(), region_num_diff, _region_num));
tonyp@2472 58 _region_num -= region_num_diff;
tonyp@2472 59
tonyp@2472 60 size_t used_bytes = hr->used();
tonyp@2472 61 assert(used_bytes <= _total_used_bytes,
tonyp@2643 62 hrs_err_msg("[%s] region's used bytes: "SIZE_FORMAT" "
tonyp@2472 63 "should be <= used bytes: "SIZE_FORMAT,
tonyp@2472 64 name(), used_bytes, _total_used_bytes));
tonyp@2472 65 _total_used_bytes -= used_bytes;
tonyp@2472 66 }
tonyp@2472 67
tonyp@2472 68 inline void HeapRegionSetBase::remove_internal(HeapRegion* hr) {
tonyp@2643 69 hrs_assert_region_ok(this, hr, this);
tonyp@2643 70 assert(hr->next() == NULL, hrs_ext_msg(this, "should already be unlinked"));
tonyp@2472 71
tonyp@2472 72 hr->set_containing_set(NULL);
tonyp@2472 73 update_for_removal(hr);
tonyp@2472 74 }
tonyp@2472 75
tonyp@2472 76 //////////////////// HeapRegionSet ////////////////////
tonyp@2472 77
tonyp@2472 78 inline void HeapRegionSet::add(HeapRegion* hr) {
tonyp@2643 79 hrs_assert_mt_safety_ok(this);
tonyp@2472 80 // add_internal() will verify the region.
tonyp@2472 81 add_internal(hr);
tonyp@2472 82 }
tonyp@2472 83
tonyp@2472 84 inline void HeapRegionSet::remove(HeapRegion* hr) {
tonyp@2643 85 hrs_assert_mt_safety_ok(this);
tonyp@2472 86 // remove_internal() will verify the region.
tonyp@2472 87 remove_internal(hr);
tonyp@2472 88 }
tonyp@2472 89
tonyp@2472 90 inline void HeapRegionSet::remove_with_proxy(HeapRegion* hr,
tonyp@2472 91 HeapRegionSet* proxy_set) {
tonyp@2472 92 // No need to fo the MT safety check here given that this method
tonyp@2472 93 // does not update the contents of the set but instead accumulates
tonyp@2472 94 // the changes in proxy_set which is assumed to be thread-local.
tonyp@2643 95 hrs_assert_sets_match(this, proxy_set);
tonyp@2643 96 hrs_assert_region_ok(this, hr, this);
tonyp@2472 97
tonyp@2472 98 hr->set_containing_set(NULL);
tonyp@2472 99 proxy_set->update_for_addition(hr);
tonyp@2472 100 }
tonyp@2472 101
tonyp@2472 102 //////////////////// HeapRegionLinkedList ////////////////////
tonyp@2472 103
tonyp@2714 104 inline void HeapRegionLinkedList::add_as_head(HeapRegion* hr) {
tonyp@2714 105 hrs_assert_mt_safety_ok(this);
tonyp@2714 106 assert((length() == 0 && _head == NULL && _tail == NULL) ||
tonyp@2714 107 (length() > 0 && _head != NULL && _tail != NULL),
tonyp@2714 108 hrs_ext_msg(this, "invariant"));
tonyp@2714 109 // add_internal() will verify the region.
tonyp@2714 110 add_internal(hr);
tonyp@2714 111
tonyp@2714 112 // Now link the region.
tonyp@2714 113 if (_head != NULL) {
tonyp@2714 114 hr->set_next(_head);
tonyp@2714 115 } else {
tonyp@2714 116 _tail = hr;
tonyp@2714 117 }
tonyp@2714 118 _head = hr;
tonyp@2714 119 }
tonyp@2714 120
tonyp@2472 121 inline void HeapRegionLinkedList::add_as_tail(HeapRegion* hr) {
tonyp@2643 122 hrs_assert_mt_safety_ok(this);
tonyp@2472 123 assert((length() == 0 && _head == NULL && _tail == NULL) ||
tonyp@2472 124 (length() > 0 && _head != NULL && _tail != NULL),
tonyp@2643 125 hrs_ext_msg(this, "invariant"));
tonyp@2472 126 // add_internal() will verify the region.
tonyp@2472 127 add_internal(hr);
tonyp@2472 128
tonyp@2472 129 // Now link the region.
tonyp@2472 130 if (_tail != NULL) {
tonyp@2472 131 _tail->set_next(hr);
tonyp@2472 132 } else {
tonyp@2472 133 _head = hr;
tonyp@2472 134 }
tonyp@2472 135 _tail = hr;
tonyp@2472 136 }
tonyp@2472 137
tonyp@2472 138 inline HeapRegion* HeapRegionLinkedList::remove_head() {
tonyp@2643 139 hrs_assert_mt_safety_ok(this);
tonyp@2643 140 assert(!is_empty(), hrs_ext_msg(this, "the list should not be empty"));
tonyp@2472 141 assert(length() > 0 && _head != NULL && _tail != NULL,
tonyp@2643 142 hrs_ext_msg(this, "invariant"));
tonyp@2472 143
tonyp@2472 144 // We need to unlink it first.
tonyp@2472 145 HeapRegion* hr = _head;
tonyp@2472 146 _head = hr->next();
tonyp@2472 147 if (_head == NULL) {
tonyp@2472 148 _tail = NULL;
tonyp@2472 149 }
tonyp@2472 150 hr->set_next(NULL);
tonyp@2472 151
tonyp@2472 152 // remove_internal() will verify the region.
tonyp@2472 153 remove_internal(hr);
tonyp@2472 154 return hr;
tonyp@2472 155 }
tonyp@2472 156
tonyp@2472 157 inline HeapRegion* HeapRegionLinkedList::remove_head_or_null() {
tonyp@2643 158 hrs_assert_mt_safety_ok(this);
tonyp@2472 159
tonyp@2472 160 if (!is_empty()) {
tonyp@2472 161 return remove_head();
tonyp@2472 162 } else {
tonyp@2472 163 return NULL;
tonyp@2472 164 }
tonyp@2472 165 }
tonyp@2472 166
tonyp@2472 167 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSET_INLINE_HPP

mercurial