src/share/vm/gc_implementation/concurrentMarkSweep/adaptiveFreeList.hpp

Tue, 27 Nov 2012 07:57:57 -0800

author
mikael
date
Tue, 27 Nov 2012 07:57:57 -0800
changeset 4290
7c15faa95ce7
parent 4196
685df3c6f84b
child 5166
7c5a1b62f53d
permissions
-rw-r--r--

8003879: Duplicate definitions in vmStructs
Summary: Removed duplicate entries
Reviewed-by: dholmes, sspitsyn

jmasa@4196 1 /*
jmasa@4196 2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
jmasa@4196 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jmasa@4196 4 *
jmasa@4196 5 * This code is free software; you can redistribute it and/or modify it
jmasa@4196 6 * under the terms of the GNU General Public License version 2 only, as
jmasa@4196 7 * published by the Free Software Foundation.
jmasa@4196 8 *
jmasa@4196 9 * This code is distributed in the hope that it will be useful, but WITHOUT
jmasa@4196 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jmasa@4196 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jmasa@4196 12 * version 2 for more details (a copy is included in the LICENSE file that
jmasa@4196 13 * accompanied this code).
jmasa@4196 14 *
jmasa@4196 15 * You should have received a copy of the GNU General Public License version
jmasa@4196 16 * 2 along with this work; if not, write to the Free Software Foundation,
jmasa@4196 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jmasa@4196 18 *
jmasa@4196 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jmasa@4196 20 * or visit www.oracle.com if you need additional information or have any
jmasa@4196 21 * questions.
jmasa@4196 22 *
jmasa@4196 23 */
jmasa@4196 24
jmasa@4196 25 #ifndef SHARE_VM_MEMORY_ADAPTIVEFREELIST_HPP
jmasa@4196 26 #define SHARE_VM_MEMORY_ADAPTIVEFREELIST_HPP
jmasa@4196 27
jmasa@4196 28 #include "memory/freeList.hpp"
jmasa@4196 29 #include "gc_implementation/shared/allocationStats.hpp"
jmasa@4196 30
jmasa@4196 31 class CompactibleFreeListSpace;
jmasa@4196 32
jmasa@4196 33 // A class for maintaining a free list of Chunk's. The FreeList
jmasa@4196 34 // maintains a the structure of the list (head, tail, etc.) plus
jmasa@4196 35 // statistics for allocations from the list. The links between items
jmasa@4196 36 // are not part of FreeList. The statistics are
jmasa@4196 37 // used to make decisions about coalescing Chunk's when they
jmasa@4196 38 // are swept during collection.
jmasa@4196 39 //
jmasa@4196 40 // See the corresponding .cpp file for a description of the specifics
jmasa@4196 41 // for that implementation.
jmasa@4196 42
jmasa@4196 43 class Mutex;
jmasa@4196 44
jmasa@4196 45 template <class Chunk>
jmasa@4196 46 class AdaptiveFreeList : public FreeList<Chunk> {
jmasa@4196 47 friend class CompactibleFreeListSpace;
jmasa@4196 48 friend class VMStructs;
jmasa@4196 49 // friend class PrintTreeCensusClosure<Chunk, FreeList_t>;
jmasa@4196 50
jmasa@4196 51 size_t _hint; // next larger size list with a positive surplus
jmasa@4196 52
jmasa@4196 53 AllocationStats _allocation_stats; // allocation-related statistics
jmasa@4196 54
jmasa@4196 55 public:
jmasa@4196 56
jmasa@4196 57 AdaptiveFreeList();
jmasa@4196 58 AdaptiveFreeList(Chunk* fc);
jmasa@4196 59
jmasa@4196 60 using FreeList<Chunk>::assert_proper_lock_protection;
jmasa@4196 61 #ifdef ASSERT
jmasa@4196 62 using FreeList<Chunk>::protecting_lock;
jmasa@4196 63 #endif
jmasa@4196 64 using FreeList<Chunk>::count;
jmasa@4196 65 using FreeList<Chunk>::size;
jmasa@4196 66 using FreeList<Chunk>::verify_chunk_in_free_list;
jmasa@4196 67 using FreeList<Chunk>::getFirstNChunksFromList;
jmasa@4196 68 using FreeList<Chunk>::print_on;
jmasa@4196 69 void return_chunk_at_head(Chunk* fc, bool record_return);
jmasa@4196 70 void return_chunk_at_head(Chunk* fc);
jmasa@4196 71 void return_chunk_at_tail(Chunk* fc, bool record_return);
jmasa@4196 72 void return_chunk_at_tail(Chunk* fc);
jmasa@4196 73 using FreeList<Chunk>::return_chunk_at_tail;
jmasa@4196 74 using FreeList<Chunk>::remove_chunk;
jmasa@4196 75 using FreeList<Chunk>::prepend;
jmasa@4196 76 using FreeList<Chunk>::print_labels_on;
jmasa@4196 77 using FreeList<Chunk>::get_chunk_at_head;
jmasa@4196 78
jmasa@4196 79 // Initialize.
jmasa@4196 80 void initialize();
jmasa@4196 81
jmasa@4196 82 // Reset the head, tail, hint, and count of a free list.
jmasa@4196 83 void reset(size_t hint);
jmasa@4196 84
jmasa@4196 85 void assert_proper_lock_protection_work() const PRODUCT_RETURN;
jmasa@4196 86
jmasa@4196 87 void print_on(outputStream* st, const char* c = NULL) const;
jmasa@4196 88
jmasa@4196 89 size_t hint() const {
jmasa@4196 90 return _hint;
jmasa@4196 91 }
jmasa@4196 92 void set_hint(size_t v) {
jmasa@4196 93 assert_proper_lock_protection();
jmasa@4196 94 assert(v == 0 || size() < v, "Bad hint");
jmasa@4196 95 _hint = v;
jmasa@4196 96 }
jmasa@4196 97
jmasa@4196 98 size_t get_better_size();
jmasa@4196 99
jmasa@4196 100 // Accessors for statistics
jmasa@4196 101 void init_statistics(bool split_birth = false);
jmasa@4196 102
jmasa@4196 103 AllocationStats* allocation_stats() {
jmasa@4196 104 assert_proper_lock_protection();
jmasa@4196 105 return &_allocation_stats;
jmasa@4196 106 }
jmasa@4196 107
jmasa@4196 108 ssize_t desired() const {
jmasa@4196 109 return _allocation_stats.desired();
jmasa@4196 110 }
jmasa@4196 111 void set_desired(ssize_t v) {
jmasa@4196 112 assert_proper_lock_protection();
jmasa@4196 113 _allocation_stats.set_desired(v);
jmasa@4196 114 }
jmasa@4196 115 void compute_desired(float inter_sweep_current,
jmasa@4196 116 float inter_sweep_estimate,
jmasa@4196 117 float intra_sweep_estimate) {
jmasa@4196 118 assert_proper_lock_protection();
jmasa@4196 119 _allocation_stats.compute_desired(count(),
jmasa@4196 120 inter_sweep_current,
jmasa@4196 121 inter_sweep_estimate,
jmasa@4196 122 intra_sweep_estimate);
jmasa@4196 123 }
jmasa@4196 124 ssize_t coal_desired() const {
jmasa@4196 125 return _allocation_stats.coal_desired();
jmasa@4196 126 }
jmasa@4196 127 void set_coal_desired(ssize_t v) {
jmasa@4196 128 assert_proper_lock_protection();
jmasa@4196 129 _allocation_stats.set_coal_desired(v);
jmasa@4196 130 }
jmasa@4196 131
jmasa@4196 132 ssize_t surplus() const {
jmasa@4196 133 return _allocation_stats.surplus();
jmasa@4196 134 }
jmasa@4196 135 void set_surplus(ssize_t v) {
jmasa@4196 136 assert_proper_lock_protection();
jmasa@4196 137 _allocation_stats.set_surplus(v);
jmasa@4196 138 }
jmasa@4196 139 void increment_surplus() {
jmasa@4196 140 assert_proper_lock_protection();
jmasa@4196 141 _allocation_stats.increment_surplus();
jmasa@4196 142 }
jmasa@4196 143 void decrement_surplus() {
jmasa@4196 144 assert_proper_lock_protection();
jmasa@4196 145 _allocation_stats.decrement_surplus();
jmasa@4196 146 }
jmasa@4196 147
jmasa@4196 148 ssize_t bfr_surp() const {
jmasa@4196 149 return _allocation_stats.bfr_surp();
jmasa@4196 150 }
jmasa@4196 151 void set_bfr_surp(ssize_t v) {
jmasa@4196 152 assert_proper_lock_protection();
jmasa@4196 153 _allocation_stats.set_bfr_surp(v);
jmasa@4196 154 }
jmasa@4196 155 ssize_t prev_sweep() const {
jmasa@4196 156 return _allocation_stats.prev_sweep();
jmasa@4196 157 }
jmasa@4196 158 void set_prev_sweep(ssize_t v) {
jmasa@4196 159 assert_proper_lock_protection();
jmasa@4196 160 _allocation_stats.set_prev_sweep(v);
jmasa@4196 161 }
jmasa@4196 162 ssize_t before_sweep() const {
jmasa@4196 163 return _allocation_stats.before_sweep();
jmasa@4196 164 }
jmasa@4196 165 void set_before_sweep(ssize_t v) {
jmasa@4196 166 assert_proper_lock_protection();
jmasa@4196 167 _allocation_stats.set_before_sweep(v);
jmasa@4196 168 }
jmasa@4196 169
jmasa@4196 170 ssize_t coal_births() const {
jmasa@4196 171 return _allocation_stats.coal_births();
jmasa@4196 172 }
jmasa@4196 173 void set_coal_births(ssize_t v) {
jmasa@4196 174 assert_proper_lock_protection();
jmasa@4196 175 _allocation_stats.set_coal_births(v);
jmasa@4196 176 }
jmasa@4196 177 void increment_coal_births() {
jmasa@4196 178 assert_proper_lock_protection();
jmasa@4196 179 _allocation_stats.increment_coal_births();
jmasa@4196 180 }
jmasa@4196 181
jmasa@4196 182 ssize_t coal_deaths() const {
jmasa@4196 183 return _allocation_stats.coal_deaths();
jmasa@4196 184 }
jmasa@4196 185 void set_coal_deaths(ssize_t v) {
jmasa@4196 186 assert_proper_lock_protection();
jmasa@4196 187 _allocation_stats.set_coal_deaths(v);
jmasa@4196 188 }
jmasa@4196 189 void increment_coal_deaths() {
jmasa@4196 190 assert_proper_lock_protection();
jmasa@4196 191 _allocation_stats.increment_coal_deaths();
jmasa@4196 192 }
jmasa@4196 193
jmasa@4196 194 ssize_t split_births() const {
jmasa@4196 195 return _allocation_stats.split_births();
jmasa@4196 196 }
jmasa@4196 197 void set_split_births(ssize_t v) {
jmasa@4196 198 assert_proper_lock_protection();
jmasa@4196 199 _allocation_stats.set_split_births(v);
jmasa@4196 200 }
jmasa@4196 201 void increment_split_births() {
jmasa@4196 202 assert_proper_lock_protection();
jmasa@4196 203 _allocation_stats.increment_split_births();
jmasa@4196 204 }
jmasa@4196 205
jmasa@4196 206 ssize_t split_deaths() const {
jmasa@4196 207 return _allocation_stats.split_deaths();
jmasa@4196 208 }
jmasa@4196 209 void set_split_deaths(ssize_t v) {
jmasa@4196 210 assert_proper_lock_protection();
jmasa@4196 211 _allocation_stats.set_split_deaths(v);
jmasa@4196 212 }
jmasa@4196 213 void increment_split_deaths() {
jmasa@4196 214 assert_proper_lock_protection();
jmasa@4196 215 _allocation_stats.increment_split_deaths();
jmasa@4196 216 }
jmasa@4196 217
jmasa@4196 218 #ifndef PRODUCT
jmasa@4196 219 // For debugging. The "_returned_bytes" in all the lists are summed
jmasa@4196 220 // and compared with the total number of bytes swept during a
jmasa@4196 221 // collection.
jmasa@4196 222 size_t returned_bytes() const { return _allocation_stats.returned_bytes(); }
jmasa@4196 223 void set_returned_bytes(size_t v) { _allocation_stats.set_returned_bytes(v); }
jmasa@4196 224 void increment_returned_bytes_by(size_t v) {
jmasa@4196 225 _allocation_stats.set_returned_bytes(_allocation_stats.returned_bytes() + v);
jmasa@4196 226 }
jmasa@4196 227 // Stats verification
jmasa@4196 228 void verify_stats() const;
jmasa@4196 229 #endif // NOT PRODUCT
jmasa@4196 230 };
jmasa@4196 231
jmasa@4196 232 #endif // SHARE_VM_MEMORY_ADAPTIVEFREELIST_HPP

mercurial