Tue, 24 Dec 2013 11:48:39 -0800
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
Summary: Copyright year updated for files modified during 2013
Reviewed-by: twisti, iveresov
jmasa@4196 | 1 | /* |
mikael@6198 | 2 | * Copyright (c) 2001, 2013, 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 | |
jmasa@4196 | 59 | using FreeList<Chunk>::assert_proper_lock_protection; |
jmasa@4196 | 60 | #ifdef ASSERT |
jmasa@4196 | 61 | using FreeList<Chunk>::protecting_lock; |
jmasa@4196 | 62 | #endif |
jmasa@4196 | 63 | using FreeList<Chunk>::count; |
jmasa@4196 | 64 | using FreeList<Chunk>::size; |
jmasa@4196 | 65 | using FreeList<Chunk>::verify_chunk_in_free_list; |
jmasa@4196 | 66 | using FreeList<Chunk>::getFirstNChunksFromList; |
jmasa@4196 | 67 | using FreeList<Chunk>::print_on; |
jmasa@4196 | 68 | void return_chunk_at_head(Chunk* fc, bool record_return); |
jmasa@4196 | 69 | void return_chunk_at_head(Chunk* fc); |
jmasa@4196 | 70 | void return_chunk_at_tail(Chunk* fc, bool record_return); |
jmasa@4196 | 71 | void return_chunk_at_tail(Chunk* fc); |
jmasa@4196 | 72 | using FreeList<Chunk>::return_chunk_at_tail; |
jmasa@4196 | 73 | using FreeList<Chunk>::remove_chunk; |
jmasa@4196 | 74 | using FreeList<Chunk>::prepend; |
jmasa@4196 | 75 | using FreeList<Chunk>::print_labels_on; |
jmasa@4196 | 76 | using FreeList<Chunk>::get_chunk_at_head; |
jmasa@4196 | 77 | |
jmasa@4196 | 78 | // Initialize. |
jmasa@4196 | 79 | void initialize(); |
jmasa@4196 | 80 | |
jmasa@4196 | 81 | // Reset the head, tail, hint, and count of a free list. |
jmasa@4196 | 82 | void reset(size_t hint); |
jmasa@4196 | 83 | |
jmasa@4196 | 84 | void assert_proper_lock_protection_work() const PRODUCT_RETURN; |
jmasa@4196 | 85 | |
jmasa@4196 | 86 | void print_on(outputStream* st, const char* c = NULL) const; |
jmasa@4196 | 87 | |
jmasa@4196 | 88 | size_t hint() const { |
jmasa@4196 | 89 | return _hint; |
jmasa@4196 | 90 | } |
jmasa@4196 | 91 | void set_hint(size_t v) { |
jmasa@4196 | 92 | assert_proper_lock_protection(); |
jmasa@4196 | 93 | assert(v == 0 || size() < v, "Bad hint"); |
jmasa@4196 | 94 | _hint = v; |
jmasa@4196 | 95 | } |
jmasa@4196 | 96 | |
jmasa@4196 | 97 | size_t get_better_size(); |
jmasa@4196 | 98 | |
jmasa@4196 | 99 | // Accessors for statistics |
jmasa@4196 | 100 | void init_statistics(bool split_birth = false); |
jmasa@4196 | 101 | |
jmasa@4196 | 102 | AllocationStats* allocation_stats() { |
jmasa@4196 | 103 | assert_proper_lock_protection(); |
jmasa@4196 | 104 | return &_allocation_stats; |
jmasa@4196 | 105 | } |
jmasa@4196 | 106 | |
jmasa@4196 | 107 | ssize_t desired() const { |
jmasa@4196 | 108 | return _allocation_stats.desired(); |
jmasa@4196 | 109 | } |
jmasa@4196 | 110 | void set_desired(ssize_t v) { |
jmasa@4196 | 111 | assert_proper_lock_protection(); |
jmasa@4196 | 112 | _allocation_stats.set_desired(v); |
jmasa@4196 | 113 | } |
jmasa@4196 | 114 | void compute_desired(float inter_sweep_current, |
jmasa@4196 | 115 | float inter_sweep_estimate, |
jmasa@4196 | 116 | float intra_sweep_estimate) { |
jmasa@4196 | 117 | assert_proper_lock_protection(); |
jmasa@4196 | 118 | _allocation_stats.compute_desired(count(), |
jmasa@4196 | 119 | inter_sweep_current, |
jmasa@4196 | 120 | inter_sweep_estimate, |
jmasa@4196 | 121 | intra_sweep_estimate); |
jmasa@4196 | 122 | } |
jmasa@4196 | 123 | ssize_t coal_desired() const { |
jmasa@4196 | 124 | return _allocation_stats.coal_desired(); |
jmasa@4196 | 125 | } |
jmasa@4196 | 126 | void set_coal_desired(ssize_t v) { |
jmasa@4196 | 127 | assert_proper_lock_protection(); |
jmasa@4196 | 128 | _allocation_stats.set_coal_desired(v); |
jmasa@4196 | 129 | } |
jmasa@4196 | 130 | |
jmasa@4196 | 131 | ssize_t surplus() const { |
jmasa@4196 | 132 | return _allocation_stats.surplus(); |
jmasa@4196 | 133 | } |
jmasa@4196 | 134 | void set_surplus(ssize_t v) { |
jmasa@4196 | 135 | assert_proper_lock_protection(); |
jmasa@4196 | 136 | _allocation_stats.set_surplus(v); |
jmasa@4196 | 137 | } |
jmasa@4196 | 138 | void increment_surplus() { |
jmasa@4196 | 139 | assert_proper_lock_protection(); |
jmasa@4196 | 140 | _allocation_stats.increment_surplus(); |
jmasa@4196 | 141 | } |
jmasa@4196 | 142 | void decrement_surplus() { |
jmasa@4196 | 143 | assert_proper_lock_protection(); |
jmasa@4196 | 144 | _allocation_stats.decrement_surplus(); |
jmasa@4196 | 145 | } |
jmasa@4196 | 146 | |
jmasa@4196 | 147 | ssize_t bfr_surp() const { |
jmasa@4196 | 148 | return _allocation_stats.bfr_surp(); |
jmasa@4196 | 149 | } |
jmasa@4196 | 150 | void set_bfr_surp(ssize_t v) { |
jmasa@4196 | 151 | assert_proper_lock_protection(); |
jmasa@4196 | 152 | _allocation_stats.set_bfr_surp(v); |
jmasa@4196 | 153 | } |
jmasa@4196 | 154 | ssize_t prev_sweep() const { |
jmasa@4196 | 155 | return _allocation_stats.prev_sweep(); |
jmasa@4196 | 156 | } |
jmasa@4196 | 157 | void set_prev_sweep(ssize_t v) { |
jmasa@4196 | 158 | assert_proper_lock_protection(); |
jmasa@4196 | 159 | _allocation_stats.set_prev_sweep(v); |
jmasa@4196 | 160 | } |
jmasa@4196 | 161 | ssize_t before_sweep() const { |
jmasa@4196 | 162 | return _allocation_stats.before_sweep(); |
jmasa@4196 | 163 | } |
jmasa@4196 | 164 | void set_before_sweep(ssize_t v) { |
jmasa@4196 | 165 | assert_proper_lock_protection(); |
jmasa@4196 | 166 | _allocation_stats.set_before_sweep(v); |
jmasa@4196 | 167 | } |
jmasa@4196 | 168 | |
jmasa@4196 | 169 | ssize_t coal_births() const { |
jmasa@4196 | 170 | return _allocation_stats.coal_births(); |
jmasa@4196 | 171 | } |
jmasa@4196 | 172 | void set_coal_births(ssize_t v) { |
jmasa@4196 | 173 | assert_proper_lock_protection(); |
jmasa@4196 | 174 | _allocation_stats.set_coal_births(v); |
jmasa@4196 | 175 | } |
jmasa@4196 | 176 | void increment_coal_births() { |
jmasa@4196 | 177 | assert_proper_lock_protection(); |
jmasa@4196 | 178 | _allocation_stats.increment_coal_births(); |
jmasa@4196 | 179 | } |
jmasa@4196 | 180 | |
jmasa@4196 | 181 | ssize_t coal_deaths() const { |
jmasa@4196 | 182 | return _allocation_stats.coal_deaths(); |
jmasa@4196 | 183 | } |
jmasa@4196 | 184 | void set_coal_deaths(ssize_t v) { |
jmasa@4196 | 185 | assert_proper_lock_protection(); |
jmasa@4196 | 186 | _allocation_stats.set_coal_deaths(v); |
jmasa@4196 | 187 | } |
jmasa@4196 | 188 | void increment_coal_deaths() { |
jmasa@4196 | 189 | assert_proper_lock_protection(); |
jmasa@4196 | 190 | _allocation_stats.increment_coal_deaths(); |
jmasa@4196 | 191 | } |
jmasa@4196 | 192 | |
jmasa@4196 | 193 | ssize_t split_births() const { |
jmasa@4196 | 194 | return _allocation_stats.split_births(); |
jmasa@4196 | 195 | } |
jmasa@4196 | 196 | void set_split_births(ssize_t v) { |
jmasa@4196 | 197 | assert_proper_lock_protection(); |
jmasa@4196 | 198 | _allocation_stats.set_split_births(v); |
jmasa@4196 | 199 | } |
jmasa@4196 | 200 | void increment_split_births() { |
jmasa@4196 | 201 | assert_proper_lock_protection(); |
jmasa@4196 | 202 | _allocation_stats.increment_split_births(); |
jmasa@4196 | 203 | } |
jmasa@4196 | 204 | |
jmasa@4196 | 205 | ssize_t split_deaths() const { |
jmasa@4196 | 206 | return _allocation_stats.split_deaths(); |
jmasa@4196 | 207 | } |
jmasa@4196 | 208 | void set_split_deaths(ssize_t v) { |
jmasa@4196 | 209 | assert_proper_lock_protection(); |
jmasa@4196 | 210 | _allocation_stats.set_split_deaths(v); |
jmasa@4196 | 211 | } |
jmasa@4196 | 212 | void increment_split_deaths() { |
jmasa@4196 | 213 | assert_proper_lock_protection(); |
jmasa@4196 | 214 | _allocation_stats.increment_split_deaths(); |
jmasa@4196 | 215 | } |
jmasa@4196 | 216 | |
jmasa@4196 | 217 | #ifndef PRODUCT |
jmasa@4196 | 218 | // For debugging. The "_returned_bytes" in all the lists are summed |
jmasa@4196 | 219 | // and compared with the total number of bytes swept during a |
jmasa@4196 | 220 | // collection. |
jmasa@4196 | 221 | size_t returned_bytes() const { return _allocation_stats.returned_bytes(); } |
jmasa@4196 | 222 | void set_returned_bytes(size_t v) { _allocation_stats.set_returned_bytes(v); } |
jmasa@4196 | 223 | void increment_returned_bytes_by(size_t v) { |
jmasa@4196 | 224 | _allocation_stats.set_returned_bytes(_allocation_stats.returned_bytes() + v); |
jmasa@4196 | 225 | } |
jmasa@4196 | 226 | // Stats verification |
jmasa@4196 | 227 | void verify_stats() const; |
jmasa@4196 | 228 | #endif // NOT PRODUCT |
jmasa@4196 | 229 | }; |
jmasa@4196 | 230 | |
jmasa@4196 | 231 | #endif // SHARE_VM_MEMORY_ADAPTIVEFREELIST_HPP |