Thu, 26 Sep 2013 12:18:21 +0200
Merge
coleenp@4037 | 1 | /* |
iklam@5208 | 2 | * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
coleenp@4037 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
coleenp@4037 | 4 | * |
coleenp@4037 | 5 | * This code is free software; you can redistribute it and/or modify it |
coleenp@4037 | 6 | * under the terms of the GNU General Public License version 2 only, as |
coleenp@4037 | 7 | * published by the Free Software Foundation. |
coleenp@4037 | 8 | * |
coleenp@4037 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
coleenp@4037 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
coleenp@4037 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
coleenp@4037 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
coleenp@4037 | 13 | * accompanied this code). |
coleenp@4037 | 14 | * |
coleenp@4037 | 15 | * You should have received a copy of the GNU General Public License version |
coleenp@4037 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
coleenp@4037 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
coleenp@4037 | 18 | * |
coleenp@4037 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
coleenp@4037 | 20 | * or visit www.oracle.com if you need additional information or have any |
coleenp@4037 | 21 | * questions. |
coleenp@4037 | 22 | * |
coleenp@4037 | 23 | */ |
coleenp@4037 | 24 | #ifndef SHARE_VM_MEMORY_METASPACE_HPP |
coleenp@4037 | 25 | #define SHARE_VM_MEMORY_METASPACE_HPP |
coleenp@4037 | 26 | |
coleenp@4037 | 27 | #include "memory/allocation.hpp" |
coleenp@4037 | 28 | #include "memory/memRegion.hpp" |
coleenp@4037 | 29 | #include "runtime/virtualspace.hpp" |
coleenp@4037 | 30 | #include "utilities/exceptions.hpp" |
coleenp@4037 | 31 | |
coleenp@4037 | 32 | // Metaspace |
coleenp@4037 | 33 | // |
coleenp@4037 | 34 | // Metaspaces are Arenas for the VM's metadata. |
coleenp@4037 | 35 | // They are allocated one per class loader object, and one for the null |
coleenp@4037 | 36 | // bootstrap class loader |
coleenp@4037 | 37 | // Eventually for bootstrap loader we'll have a read-only section and read-write |
coleenp@4037 | 38 | // to write for DumpSharedSpaces and read for UseSharedSpaces |
coleenp@4037 | 39 | // |
coleenp@4037 | 40 | // block X ---+ +-------------------+ |
coleenp@4037 | 41 | // | | Virtualspace | |
coleenp@4037 | 42 | // | | | |
coleenp@4037 | 43 | // | | | |
coleenp@4037 | 44 | // | |-------------------| |
coleenp@4037 | 45 | // | || Chunk | |
coleenp@4037 | 46 | // | || | |
coleenp@4037 | 47 | // | ||---------- | |
coleenp@4037 | 48 | // +------>||| block 0 | | |
coleenp@4037 | 49 | // ||---------- | |
coleenp@4037 | 50 | // ||| block 1 | | |
coleenp@4037 | 51 | // ||---------- | |
coleenp@4037 | 52 | // || | |
coleenp@4037 | 53 | // |-------------------| |
coleenp@4037 | 54 | // | | |
coleenp@4037 | 55 | // | | |
coleenp@4037 | 56 | // +-------------------+ |
coleenp@4037 | 57 | // |
coleenp@4037 | 58 | |
stefank@5771 | 59 | class ChunkManager; |
coleenp@4037 | 60 | class ClassLoaderData; |
jmasa@4196 | 61 | class Metablock; |
stefank@5771 | 62 | class Metachunk; |
coleenp@4037 | 63 | class MetaWord; |
coleenp@4037 | 64 | class Mutex; |
coleenp@4037 | 65 | class outputStream; |
coleenp@4037 | 66 | class SpaceManager; |
stefank@5771 | 67 | class VirtualSpaceList; |
coleenp@4037 | 68 | |
coleenp@4037 | 69 | // Metaspaces each have a SpaceManager and allocations |
coleenp@4037 | 70 | // are done by the SpaceManager. Allocations are done |
coleenp@4037 | 71 | // out of the current Metachunk. When the current Metachunk |
coleenp@4037 | 72 | // is exhausted, the SpaceManager gets a new one from |
coleenp@4037 | 73 | // the current VirtualSpace. When the VirtualSpace is exhausted |
coleenp@4037 | 74 | // the SpaceManager gets a new one. The SpaceManager |
coleenp@4037 | 75 | // also manages freelists of available Chunks. |
coleenp@4037 | 76 | // |
coleenp@4037 | 77 | // Currently the space manager maintains the list of |
coleenp@4037 | 78 | // virtual spaces and the list of chunks in use. Its |
coleenp@4037 | 79 | // allocate() method returns a block for use as a |
coleenp@4037 | 80 | // quantum of metadata. |
coleenp@4037 | 81 | |
coleenp@4037 | 82 | class Metaspace : public CHeapObj<mtClass> { |
coleenp@4037 | 83 | friend class VMStructs; |
coleenp@4037 | 84 | friend class SpaceManager; |
coleenp@4037 | 85 | friend class VM_CollectForMetadataAllocation; |
coleenp@4037 | 86 | friend class MetaspaceGC; |
coleenp@4037 | 87 | friend class MetaspaceAux; |
coleenp@4037 | 88 | |
coleenp@4037 | 89 | public: |
jmasa@5162 | 90 | enum MetadataType {ClassType = 0, |
jmasa@5162 | 91 | NonClassType = ClassType + 1, |
jmasa@5162 | 92 | MetadataTypeCount = ClassType + 2 |
jmasa@5162 | 93 | }; |
jmasa@4382 | 94 | enum MetaspaceType { |
jmasa@4382 | 95 | StandardMetaspaceType, |
jmasa@4382 | 96 | BootMetaspaceType, |
jmasa@4382 | 97 | ROMetaspaceType, |
jmasa@4382 | 98 | ReadWriteMetaspaceType, |
jmasa@4382 | 99 | AnonymousMetaspaceType, |
jmasa@4382 | 100 | ReflectionMetaspaceType |
jmasa@4382 | 101 | }; |
coleenp@4037 | 102 | |
coleenp@4037 | 103 | private: |
jmasa@4382 | 104 | void initialize(Mutex* lock, MetaspaceType type); |
jmasa@4382 | 105 | |
stefank@5771 | 106 | Metachunk* get_initialization_chunk(MetadataType mdtype, |
stefank@5771 | 107 | size_t chunk_word_size, |
stefank@5771 | 108 | size_t chunk_bunch); |
stefank@5771 | 109 | |
jmasa@4382 | 110 | // Align up the word size to the allocation word size |
jmasa@4382 | 111 | static size_t align_word_size_up(size_t); |
coleenp@4037 | 112 | |
hseigel@5528 | 113 | // Aligned size of the metaspace. |
hseigel@5528 | 114 | static size_t _class_metaspace_size; |
hseigel@5528 | 115 | |
hseigel@5528 | 116 | static size_t class_metaspace_size() { |
hseigel@5528 | 117 | return _class_metaspace_size; |
hseigel@5528 | 118 | } |
hseigel@5528 | 119 | static void set_class_metaspace_size(size_t metaspace_size) { |
hseigel@5528 | 120 | _class_metaspace_size = metaspace_size; |
hseigel@5528 | 121 | } |
hseigel@5528 | 122 | |
coleenp@4037 | 123 | static size_t _first_chunk_word_size; |
jmasa@4382 | 124 | static size_t _first_class_chunk_word_size; |
coleenp@4037 | 125 | |
coleenp@4037 | 126 | SpaceManager* _vsm; |
coleenp@4037 | 127 | SpaceManager* vsm() const { return _vsm; } |
coleenp@4037 | 128 | |
coleenp@4037 | 129 | SpaceManager* _class_vsm; |
coleenp@4037 | 130 | SpaceManager* class_vsm() const { return _class_vsm; } |
coleenp@4037 | 131 | |
jmasa@5015 | 132 | // Allocate space for metadata of type mdtype. This is space |
jmasa@5015 | 133 | // within a Metachunk and is used by |
jmasa@5015 | 134 | // allocate(ClassLoaderData*, size_t, bool, MetadataType, TRAPS) |
jmasa@5015 | 135 | // which returns a Metablock. |
coleenp@4037 | 136 | MetaWord* allocate(size_t word_size, MetadataType mdtype); |
coleenp@4037 | 137 | |
coleenp@4037 | 138 | // Virtual Space lists for both classes and other metadata |
coleenp@4037 | 139 | static VirtualSpaceList* _space_list; |
coleenp@4037 | 140 | static VirtualSpaceList* _class_space_list; |
coleenp@4037 | 141 | |
stefank@5771 | 142 | static ChunkManager* _chunk_manager_metadata; |
stefank@5771 | 143 | static ChunkManager* _chunk_manager_class; |
stefank@5771 | 144 | |
stefank@5771 | 145 | public: |
coleenp@4037 | 146 | static VirtualSpaceList* space_list() { return _space_list; } |
coleenp@4037 | 147 | static VirtualSpaceList* class_space_list() { return _class_space_list; } |
ehelin@5531 | 148 | static VirtualSpaceList* get_space_list(MetadataType mdtype) { |
ehelin@5531 | 149 | assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype"); |
ehelin@5531 | 150 | return mdtype == ClassType ? class_space_list() : space_list(); |
ehelin@5531 | 151 | } |
coleenp@4037 | 152 | |
stefank@5771 | 153 | static ChunkManager* chunk_manager_metadata() { return _chunk_manager_metadata; } |
stefank@5771 | 154 | static ChunkManager* chunk_manager_class() { return _chunk_manager_class; } |
stefank@5771 | 155 | static ChunkManager* get_chunk_manager(MetadataType mdtype) { |
stefank@5771 | 156 | assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype"); |
stefank@5771 | 157 | return mdtype == ClassType ? chunk_manager_class() : chunk_manager_metadata(); |
stefank@5771 | 158 | } |
stefank@5771 | 159 | |
stefank@5771 | 160 | private: |
iklam@5208 | 161 | // This is used by DumpSharedSpaces only, where only _vsm is used. So we will |
iklam@5208 | 162 | // maintain a single list for now. |
iklam@5208 | 163 | void record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size); |
iklam@5208 | 164 | |
hseigel@5528 | 165 | #ifdef _LP64 |
hseigel@5528 | 166 | static void set_narrow_klass_base_and_shift(address metaspace_base, address cds_base); |
hseigel@5528 | 167 | |
hseigel@5528 | 168 | // Returns true if can use CDS with metaspace allocated as specified address. |
hseigel@5528 | 169 | static bool can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base); |
hseigel@5528 | 170 | |
hseigel@5528 | 171 | static void allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base); |
hseigel@5528 | 172 | |
hseigel@5528 | 173 | static void initialize_class_space(ReservedSpace rs); |
hseigel@5528 | 174 | #endif |
hseigel@5528 | 175 | |
iklam@5208 | 176 | class AllocRecord : public CHeapObj<mtClass> { |
iklam@5208 | 177 | public: |
iklam@5208 | 178 | AllocRecord(address ptr, MetaspaceObj::Type type, int byte_size) |
iklam@5208 | 179 | : _next(NULL), _ptr(ptr), _type(type), _byte_size(byte_size) {} |
iklam@5208 | 180 | AllocRecord *_next; |
iklam@5208 | 181 | address _ptr; |
iklam@5208 | 182 | MetaspaceObj::Type _type; |
iklam@5208 | 183 | int _byte_size; |
iklam@5208 | 184 | }; |
iklam@5208 | 185 | |
iklam@5208 | 186 | AllocRecord * _alloc_record_head; |
iklam@5208 | 187 | AllocRecord * _alloc_record_tail; |
iklam@5208 | 188 | |
coleenp@4037 | 189 | public: |
coleenp@4037 | 190 | |
jmasa@4382 | 191 | Metaspace(Mutex* lock, MetaspaceType type); |
coleenp@4037 | 192 | ~Metaspace(); |
coleenp@4037 | 193 | |
coleenp@4037 | 194 | // Initialize globals for Metaspace |
coleenp@4037 | 195 | static void global_initialize(); |
coleenp@4037 | 196 | |
coleenp@4037 | 197 | static size_t first_chunk_word_size() { return _first_chunk_word_size; } |
jmasa@4382 | 198 | static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; } |
coleenp@4037 | 199 | |
coleenp@4037 | 200 | char* bottom() const; |
jmasa@5015 | 201 | size_t used_words_slow(MetadataType mdtype) const; |
ehelin@5703 | 202 | size_t free_words_slow(MetadataType mdtype) const; |
jmasa@5015 | 203 | size_t capacity_words_slow(MetadataType mdtype) const; |
coleenp@4037 | 204 | |
jmasa@5015 | 205 | size_t used_bytes_slow(MetadataType mdtype) const; |
jmasa@5015 | 206 | size_t capacity_bytes_slow(MetadataType mdtype) const; |
jmasa@5015 | 207 | |
iklam@5208 | 208 | static Metablock* allocate(ClassLoaderData* loader_data, size_t word_size, |
iklam@5208 | 209 | bool read_only, MetaspaceObj::Type type, TRAPS); |
jmasa@4064 | 210 | void deallocate(MetaWord* ptr, size_t byte_size, bool is_class); |
coleenp@4037 | 211 | |
jmasa@4064 | 212 | MetaWord* expand_and_allocate(size_t size, |
jmasa@4064 | 213 | MetadataType mdtype); |
coleenp@4037 | 214 | |
coleenp@4295 | 215 | static bool contains(const void *ptr); |
coleenp@4037 | 216 | void dump(outputStream* const out) const; |
coleenp@4037 | 217 | |
jmasa@5007 | 218 | // Free empty virtualspaces |
stefank@5771 | 219 | static void purge(MetadataType mdtype); |
jmasa@5007 | 220 | static void purge(); |
jmasa@5007 | 221 | |
coleenp@4037 | 222 | void print_on(outputStream* st) const; |
coleenp@4037 | 223 | // Debugging support |
coleenp@4037 | 224 | void verify(); |
iklam@5208 | 225 | |
iklam@5208 | 226 | class AllocRecordClosure : public StackObj { |
iklam@5208 | 227 | public: |
iklam@5208 | 228 | virtual void doit(address ptr, MetaspaceObj::Type type, int byte_size) = 0; |
iklam@5208 | 229 | }; |
iklam@5208 | 230 | |
iklam@5208 | 231 | void iterate(AllocRecordClosure *closure); |
hseigel@5528 | 232 | |
ehelin@5694 | 233 | // Return TRUE only if UseCompressedClassPointers is True and DumpSharedSpaces is False. |
hseigel@5528 | 234 | static bool using_class_space() { |
ehelin@5694 | 235 | return NOT_LP64(false) LP64_ONLY(UseCompressedClassPointers && !DumpSharedSpaces); |
hseigel@5528 | 236 | } |
hseigel@5528 | 237 | |
coleenp@4037 | 238 | }; |
coleenp@4037 | 239 | |
coleenp@4037 | 240 | class MetaspaceAux : AllStatic { |
ehelin@5703 | 241 | static size_t free_chunks_total_words(Metaspace::MetadataType mdtype); |
jmasa@5015 | 242 | |
jmasa@5015 | 243 | // These methods iterate over the classloader data graph |
jmasa@5015 | 244 | // for the given Metaspace type. These are slow. |
jmasa@5015 | 245 | static size_t used_bytes_slow(Metaspace::MetadataType mdtype); |
ehelin@5703 | 246 | static size_t free_bytes_slow(Metaspace::MetadataType mdtype); |
jmasa@5015 | 247 | static size_t capacity_bytes_slow(Metaspace::MetadataType mdtype); |
ehelin@5703 | 248 | static size_t capacity_bytes_slow(); |
coleenp@4037 | 249 | |
jmasa@5015 | 250 | // Running sum of space in all Metachunks that has been |
jmasa@5015 | 251 | // allocated to a Metaspace. This is used instead of |
jmasa@5162 | 252 | // iterating over all the classloaders. One for each |
jmasa@5162 | 253 | // type of Metadata |
jmasa@5162 | 254 | static size_t _allocated_capacity_words[Metaspace:: MetadataTypeCount]; |
jmasa@5015 | 255 | // Running sum of space in all Metachunks that have |
jmasa@5162 | 256 | // are being used for metadata. One for each |
jmasa@5162 | 257 | // type of Metadata. |
jmasa@5162 | 258 | static size_t _allocated_used_words[Metaspace:: MetadataTypeCount]; |
jmasa@5015 | 259 | |
jmasa@5015 | 260 | public: |
jmasa@5015 | 261 | // Decrement and increment _allocated_capacity_words |
jmasa@5162 | 262 | static void dec_capacity(Metaspace::MetadataType type, size_t words); |
jmasa@5162 | 263 | static void inc_capacity(Metaspace::MetadataType type, size_t words); |
jmasa@5015 | 264 | |
jmasa@5015 | 265 | // Decrement and increment _allocated_used_words |
jmasa@5162 | 266 | static void dec_used(Metaspace::MetadataType type, size_t words); |
jmasa@5162 | 267 | static void inc_used(Metaspace::MetadataType type, size_t words); |
jmasa@5015 | 268 | |
jmasa@5015 | 269 | // Total of space allocated to metadata in all Metaspaces. |
jmasa@5015 | 270 | // This sums the space used in each Metachunk by |
jmasa@5015 | 271 | // iterating over the classloader data graph |
jmasa@5015 | 272 | static size_t used_bytes_slow() { |
jmasa@5015 | 273 | return used_bytes_slow(Metaspace::ClassType) + |
jmasa@5015 | 274 | used_bytes_slow(Metaspace::NonClassType); |
stefank@4371 | 275 | } |
coleenp@4037 | 276 | |
jmasa@5015 | 277 | // Used by MetaspaceCounters |
ehelin@5703 | 278 | static size_t free_chunks_total_words(); |
ehelin@5703 | 279 | static size_t free_chunks_total_bytes(); |
ehelin@5703 | 280 | static size_t free_chunks_total_bytes(Metaspace::MetadataType mdtype); |
jmasa@5015 | 281 | |
jmasa@5162 | 282 | static size_t allocated_capacity_words(Metaspace::MetadataType mdtype) { |
jmasa@5162 | 283 | return _allocated_capacity_words[mdtype]; |
jmasa@5162 | 284 | } |
jmasa@5015 | 285 | static size_t allocated_capacity_words() { |
ehelin@5703 | 286 | return allocated_capacity_words(Metaspace::NonClassType) + |
ehelin@5703 | 287 | allocated_capacity_words(Metaspace::ClassType); |
jmasa@5162 | 288 | } |
jmasa@5162 | 289 | static size_t allocated_capacity_bytes(Metaspace::MetadataType mdtype) { |
jmasa@5162 | 290 | return allocated_capacity_words(mdtype) * BytesPerWord; |
jmasa@5015 | 291 | } |
jmasa@5015 | 292 | static size_t allocated_capacity_bytes() { |
jmasa@5162 | 293 | return allocated_capacity_words() * BytesPerWord; |
jmasa@5015 | 294 | } |
jmasa@5015 | 295 | |
jmasa@5162 | 296 | static size_t allocated_used_words(Metaspace::MetadataType mdtype) { |
jmasa@5162 | 297 | return _allocated_used_words[mdtype]; |
jmasa@5162 | 298 | } |
jmasa@5015 | 299 | static size_t allocated_used_words() { |
ehelin@5703 | 300 | return allocated_used_words(Metaspace::NonClassType) + |
ehelin@5703 | 301 | allocated_used_words(Metaspace::ClassType); |
jmasa@5162 | 302 | } |
jmasa@5162 | 303 | static size_t allocated_used_bytes(Metaspace::MetadataType mdtype) { |
jmasa@5162 | 304 | return allocated_used_words(mdtype) * BytesPerWord; |
jmasa@5015 | 305 | } |
jmasa@5015 | 306 | static size_t allocated_used_bytes() { |
jmasa@5162 | 307 | return allocated_used_words() * BytesPerWord; |
jmasa@5015 | 308 | } |
jmasa@5015 | 309 | |
jmasa@5015 | 310 | static size_t free_bytes(); |
ehelin@5531 | 311 | static size_t free_bytes(Metaspace::MetadataType mdtype); |
jmasa@5015 | 312 | |
ehelin@5703 | 313 | static size_t reserved_bytes(Metaspace::MetadataType mdtype); |
ehelin@5703 | 314 | static size_t reserved_bytes() { |
ehelin@5703 | 315 | return reserved_bytes(Metaspace::ClassType) + |
ehelin@5703 | 316 | reserved_bytes(Metaspace::NonClassType); |
stefank@4371 | 317 | } |
coleenp@4037 | 318 | |
stefank@5704 | 319 | static size_t committed_bytes(Metaspace::MetadataType mdtype); |
stefank@5704 | 320 | static size_t committed_bytes() { |
stefank@5704 | 321 | return committed_bytes(Metaspace::ClassType) + |
stefank@5704 | 322 | committed_bytes(Metaspace::NonClassType); |
stefank@5704 | 323 | } |
stefank@5704 | 324 | |
ehelin@5703 | 325 | static size_t min_chunk_size_words(); |
ehelin@5703 | 326 | static size_t min_chunk_size_bytes() { |
ehelin@5703 | 327 | return min_chunk_size_words() * BytesPerWord; |
stefank@4371 | 328 | } |
coleenp@4037 | 329 | |
coleenp@4037 | 330 | // Print change in used metadata. |
coleenp@4037 | 331 | static void print_metaspace_change(size_t prev_metadata_used); |
coleenp@4037 | 332 | static void print_on(outputStream * out); |
coleenp@4037 | 333 | static void print_on(outputStream * out, Metaspace::MetadataType mdtype); |
coleenp@4037 | 334 | |
hseigel@5528 | 335 | static void print_class_waste(outputStream* out); |
coleenp@4037 | 336 | static void print_waste(outputStream* out); |
coleenp@4037 | 337 | static void dump(outputStream* out); |
mgerdin@4264 | 338 | static void verify_free_chunks(); |
jmasa@5015 | 339 | // Checks that the values returned by allocated_capacity_bytes() and |
jmasa@5015 | 340 | // capacity_bytes_slow() are the same. |
jmasa@5015 | 341 | static void verify_capacity(); |
jmasa@5015 | 342 | static void verify_used(); |
jmasa@5015 | 343 | static void verify_metrics(); |
coleenp@4037 | 344 | }; |
coleenp@4037 | 345 | |
coleenp@4037 | 346 | // Metaspace are deallocated when their class loader are GC'ed. |
coleenp@4037 | 347 | // This class implements a policy for inducing GC's to recover |
coleenp@4037 | 348 | // Metaspaces. |
coleenp@4037 | 349 | |
coleenp@4037 | 350 | class MetaspaceGC : AllStatic { |
coleenp@4037 | 351 | |
coleenp@4037 | 352 | // The current high-water-mark for inducing a GC. When |
coleenp@4037 | 353 | // the capacity of all space in the virtual lists reaches this value, |
coleenp@4037 | 354 | // a GC is induced and the value is increased. This should be changed |
coleenp@4037 | 355 | // to the space actually used for allocations to avoid affects of |
coleenp@4037 | 356 | // fragmentation losses to partially used chunks. Size is in words. |
coleenp@4037 | 357 | static size_t _capacity_until_GC; |
coleenp@4037 | 358 | |
coleenp@4037 | 359 | // After a GC is done any allocation that fails should try to expand |
coleenp@4037 | 360 | // the capacity of the Metaspaces. This flag is set during attempts |
coleenp@4037 | 361 | // to allocate in the VMGCOperation that does the GC. |
coleenp@4037 | 362 | static bool _expand_after_GC; |
coleenp@4037 | 363 | |
coleenp@4037 | 364 | // For a CMS collection, signal that a concurrent collection should |
coleenp@4037 | 365 | // be started. |
coleenp@4037 | 366 | static bool _should_concurrent_collect; |
coleenp@4037 | 367 | |
coleenp@4037 | 368 | static uint _shrink_factor; |
coleenp@4037 | 369 | |
coleenp@4037 | 370 | static void set_capacity_until_GC(size_t v) { _capacity_until_GC = v; } |
coleenp@4037 | 371 | |
coleenp@4037 | 372 | static size_t shrink_factor() { return _shrink_factor; } |
coleenp@4037 | 373 | void set_shrink_factor(uint v) { _shrink_factor = v; } |
coleenp@4037 | 374 | |
coleenp@4037 | 375 | public: |
coleenp@4037 | 376 | |
coleenp@4037 | 377 | static size_t capacity_until_GC() { return _capacity_until_GC; } |
coleenp@4037 | 378 | static void inc_capacity_until_GC(size_t v) { _capacity_until_GC += v; } |
coleenp@4037 | 379 | static void dec_capacity_until_GC(size_t v) { |
coleenp@4037 | 380 | _capacity_until_GC = _capacity_until_GC > v ? _capacity_until_GC - v : 0; |
coleenp@4037 | 381 | } |
coleenp@4037 | 382 | static bool expand_after_GC() { return _expand_after_GC; } |
coleenp@4037 | 383 | static void set_expand_after_GC(bool v) { _expand_after_GC = v; } |
coleenp@4037 | 384 | |
coleenp@4037 | 385 | static bool should_concurrent_collect() { return _should_concurrent_collect; } |
coleenp@4037 | 386 | static void set_should_concurrent_collect(bool v) { |
coleenp@4037 | 387 | _should_concurrent_collect = v; |
coleenp@4037 | 388 | } |
coleenp@4037 | 389 | |
coleenp@4037 | 390 | // The amount to increase the high-water-mark (_capacity_until_GC) |
coleenp@4037 | 391 | static size_t delta_capacity_until_GC(size_t word_size); |
coleenp@4037 | 392 | |
coleenp@4037 | 393 | // It is expected that this will be called when the current capacity |
coleenp@4037 | 394 | // has been used and a GC should be considered. |
coleenp@4037 | 395 | static bool should_expand(VirtualSpaceList* vsl, size_t word_size); |
coleenp@4037 | 396 | |
coleenp@4037 | 397 | // Calculate the new high-water mark at which to induce |
coleenp@4037 | 398 | // a GC. |
coleenp@4037 | 399 | static void compute_new_size(); |
coleenp@4037 | 400 | }; |
coleenp@4037 | 401 | |
coleenp@4037 | 402 | #endif // SHARE_VM_MEMORY_METASPACE_HPP |