Tue, 05 Aug 2014 15:41:12 -0700
8034056: assert(_heap_alignment >= _space_alignment) failed: heap_alignment less than space_alignment
Reviewed-by: tschatzl, tamao
coleenp@4037 | 1 | /* |
coleenp@6678 | 2 | * Copyright (c) 2011, 2014, 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" |
ehelin@6420 | 29 | #include "memory/metaspaceChunkFreeListSummary.hpp" |
coleenp@4037 | 30 | #include "runtime/virtualspace.hpp" |
coleenp@4037 | 31 | #include "utilities/exceptions.hpp" |
coleenp@4037 | 32 | |
coleenp@4037 | 33 | // Metaspace |
coleenp@4037 | 34 | // |
coleenp@4037 | 35 | // Metaspaces are Arenas for the VM's metadata. |
coleenp@4037 | 36 | // They are allocated one per class loader object, and one for the null |
coleenp@4037 | 37 | // bootstrap class loader |
coleenp@4037 | 38 | // Eventually for bootstrap loader we'll have a read-only section and read-write |
coleenp@4037 | 39 | // to write for DumpSharedSpaces and read for UseSharedSpaces |
coleenp@4037 | 40 | // |
coleenp@4037 | 41 | // block X ---+ +-------------------+ |
coleenp@4037 | 42 | // | | Virtualspace | |
coleenp@4037 | 43 | // | | | |
coleenp@4037 | 44 | // | | | |
coleenp@4037 | 45 | // | |-------------------| |
coleenp@4037 | 46 | // | || Chunk | |
coleenp@4037 | 47 | // | || | |
coleenp@4037 | 48 | // | ||---------- | |
coleenp@4037 | 49 | // +------>||| block 0 | | |
coleenp@4037 | 50 | // ||---------- | |
coleenp@4037 | 51 | // ||| block 1 | | |
coleenp@4037 | 52 | // ||---------- | |
coleenp@4037 | 53 | // || | |
coleenp@4037 | 54 | // |-------------------| |
coleenp@4037 | 55 | // | | |
coleenp@4037 | 56 | // | | |
coleenp@4037 | 57 | // +-------------------+ |
coleenp@4037 | 58 | // |
coleenp@4037 | 59 | |
stefank@5771 | 60 | class ChunkManager; |
coleenp@4037 | 61 | class ClassLoaderData; |
jmasa@4196 | 62 | class Metablock; |
stefank@5771 | 63 | class Metachunk; |
ehelin@6417 | 64 | class MetaspaceTracer; |
coleenp@4037 | 65 | class MetaWord; |
coleenp@4037 | 66 | class Mutex; |
coleenp@4037 | 67 | class outputStream; |
coleenp@4037 | 68 | class SpaceManager; |
stefank@5771 | 69 | class VirtualSpaceList; |
coleenp@4037 | 70 | |
coleenp@4037 | 71 | // Metaspaces each have a SpaceManager and allocations |
coleenp@4037 | 72 | // are done by the SpaceManager. Allocations are done |
coleenp@4037 | 73 | // out of the current Metachunk. When the current Metachunk |
coleenp@4037 | 74 | // is exhausted, the SpaceManager gets a new one from |
coleenp@4037 | 75 | // the current VirtualSpace. When the VirtualSpace is exhausted |
coleenp@4037 | 76 | // the SpaceManager gets a new one. The SpaceManager |
coleenp@4037 | 77 | // also manages freelists of available Chunks. |
coleenp@4037 | 78 | // |
coleenp@4037 | 79 | // Currently the space manager maintains the list of |
coleenp@4037 | 80 | // virtual spaces and the list of chunks in use. Its |
coleenp@4037 | 81 | // allocate() method returns a block for use as a |
coleenp@4037 | 82 | // quantum of metadata. |
coleenp@4037 | 83 | |
coleenp@4037 | 84 | class Metaspace : public CHeapObj<mtClass> { |
coleenp@4037 | 85 | friend class VMStructs; |
coleenp@4037 | 86 | friend class SpaceManager; |
coleenp@4037 | 87 | friend class VM_CollectForMetadataAllocation; |
coleenp@4037 | 88 | friend class MetaspaceGC; |
coleenp@4037 | 89 | friend class MetaspaceAux; |
coleenp@4037 | 90 | |
coleenp@4037 | 91 | public: |
stefank@5863 | 92 | enum MetadataType { |
stefank@5863 | 93 | ClassType, |
stefank@5863 | 94 | NonClassType, |
stefank@5863 | 95 | MetadataTypeCount |
jmasa@5162 | 96 | }; |
jmasa@4382 | 97 | enum MetaspaceType { |
jmasa@4382 | 98 | StandardMetaspaceType, |
jmasa@4382 | 99 | BootMetaspaceType, |
jmasa@4382 | 100 | ROMetaspaceType, |
jmasa@4382 | 101 | ReadWriteMetaspaceType, |
jmasa@4382 | 102 | AnonymousMetaspaceType, |
jmasa@4382 | 103 | ReflectionMetaspaceType |
jmasa@4382 | 104 | }; |
coleenp@4037 | 105 | |
coleenp@4037 | 106 | private: |
jmasa@4382 | 107 | void initialize(Mutex* lock, MetaspaceType type); |
jmasa@4382 | 108 | |
stefank@5863 | 109 | // Get the first chunk for a Metaspace. Used for |
stefank@5863 | 110 | // special cases such as the boot class loader, reflection |
stefank@5863 | 111 | // class loader and anonymous class loader. |
stefank@5771 | 112 | Metachunk* get_initialization_chunk(MetadataType mdtype, |
stefank@5771 | 113 | size_t chunk_word_size, |
stefank@5771 | 114 | size_t chunk_bunch); |
stefank@5771 | 115 | |
jmasa@4382 | 116 | // Align up the word size to the allocation word size |
jmasa@4382 | 117 | static size_t align_word_size_up(size_t); |
coleenp@4037 | 118 | |
hseigel@5528 | 119 | // Aligned size of the metaspace. |
coleenp@6029 | 120 | static size_t _compressed_class_space_size; |
hseigel@5528 | 121 | |
coleenp@6029 | 122 | static size_t compressed_class_space_size() { |
coleenp@6029 | 123 | return _compressed_class_space_size; |
hseigel@5528 | 124 | } |
goetz@6487 | 125 | |
coleenp@6029 | 126 | static void set_compressed_class_space_size(size_t size) { |
coleenp@6029 | 127 | _compressed_class_space_size = size; |
hseigel@5528 | 128 | } |
hseigel@5528 | 129 | |
coleenp@4037 | 130 | static size_t _first_chunk_word_size; |
jmasa@4382 | 131 | static size_t _first_class_chunk_word_size; |
coleenp@4037 | 132 | |
stefank@5863 | 133 | static size_t _commit_alignment; |
stefank@5863 | 134 | static size_t _reserve_alignment; |
stefank@5863 | 135 | |
coleenp@4037 | 136 | SpaceManager* _vsm; |
coleenp@4037 | 137 | SpaceManager* vsm() const { return _vsm; } |
coleenp@4037 | 138 | |
coleenp@4037 | 139 | SpaceManager* _class_vsm; |
coleenp@4037 | 140 | SpaceManager* class_vsm() const { return _class_vsm; } |
coleenp@4037 | 141 | |
jmasa@5015 | 142 | // Allocate space for metadata of type mdtype. This is space |
jmasa@5015 | 143 | // within a Metachunk and is used by |
jmasa@5015 | 144 | // allocate(ClassLoaderData*, size_t, bool, MetadataType, TRAPS) |
coleenp@4037 | 145 | MetaWord* allocate(size_t word_size, MetadataType mdtype); |
coleenp@4037 | 146 | |
coleenp@4037 | 147 | // Virtual Space lists for both classes and other metadata |
coleenp@4037 | 148 | static VirtualSpaceList* _space_list; |
coleenp@4037 | 149 | static VirtualSpaceList* _class_space_list; |
coleenp@4037 | 150 | |
stefank@5771 | 151 | static ChunkManager* _chunk_manager_metadata; |
stefank@5771 | 152 | static ChunkManager* _chunk_manager_class; |
stefank@5771 | 153 | |
ehelin@6417 | 154 | static const MetaspaceTracer* _tracer; |
ehelin@6417 | 155 | |
stefank@5771 | 156 | public: |
coleenp@4037 | 157 | static VirtualSpaceList* space_list() { return _space_list; } |
coleenp@4037 | 158 | static VirtualSpaceList* class_space_list() { return _class_space_list; } |
ehelin@5531 | 159 | static VirtualSpaceList* get_space_list(MetadataType mdtype) { |
ehelin@5531 | 160 | assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype"); |
ehelin@5531 | 161 | return mdtype == ClassType ? class_space_list() : space_list(); |
ehelin@5531 | 162 | } |
coleenp@4037 | 163 | |
stefank@5771 | 164 | static ChunkManager* chunk_manager_metadata() { return _chunk_manager_metadata; } |
stefank@5771 | 165 | static ChunkManager* chunk_manager_class() { return _chunk_manager_class; } |
stefank@5771 | 166 | static ChunkManager* get_chunk_manager(MetadataType mdtype) { |
stefank@5771 | 167 | assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype"); |
stefank@5771 | 168 | return mdtype == ClassType ? chunk_manager_class() : chunk_manager_metadata(); |
stefank@5771 | 169 | } |
stefank@5771 | 170 | |
ehelin@6417 | 171 | static const MetaspaceTracer* tracer() { return _tracer; } |
ehelin@6417 | 172 | |
stefank@5771 | 173 | private: |
iklam@7089 | 174 | // These 2 methods are used by DumpSharedSpaces only, where only _vsm is used. So we will |
iklam@5208 | 175 | // maintain a single list for now. |
iklam@5208 | 176 | void record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size); |
iklam@7089 | 177 | void record_deallocation(void* ptr, size_t word_size); |
iklam@5208 | 178 | |
hseigel@5528 | 179 | #ifdef _LP64 |
hseigel@5528 | 180 | static void set_narrow_klass_base_and_shift(address metaspace_base, address cds_base); |
hseigel@5528 | 181 | |
hseigel@5528 | 182 | // Returns true if can use CDS with metaspace allocated as specified address. |
hseigel@5528 | 183 | static bool can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base); |
hseigel@5528 | 184 | |
hseigel@5528 | 185 | static void allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base); |
hseigel@5528 | 186 | |
hseigel@5528 | 187 | static void initialize_class_space(ReservedSpace rs); |
hseigel@5528 | 188 | #endif |
hseigel@5528 | 189 | |
iklam@5208 | 190 | class AllocRecord : public CHeapObj<mtClass> { |
iklam@5208 | 191 | public: |
iklam@5208 | 192 | AllocRecord(address ptr, MetaspaceObj::Type type, int byte_size) |
iklam@5208 | 193 | : _next(NULL), _ptr(ptr), _type(type), _byte_size(byte_size) {} |
iklam@5208 | 194 | AllocRecord *_next; |
iklam@5208 | 195 | address _ptr; |
iklam@5208 | 196 | MetaspaceObj::Type _type; |
iklam@5208 | 197 | int _byte_size; |
iklam@5208 | 198 | }; |
iklam@5208 | 199 | |
iklam@5208 | 200 | AllocRecord * _alloc_record_head; |
iklam@5208 | 201 | AllocRecord * _alloc_record_tail; |
iklam@5208 | 202 | |
hseigel@6027 | 203 | size_t class_chunk_size(size_t word_size); |
hseigel@6027 | 204 | |
coleenp@4037 | 205 | public: |
coleenp@4037 | 206 | |
jmasa@4382 | 207 | Metaspace(Mutex* lock, MetaspaceType type); |
coleenp@4037 | 208 | ~Metaspace(); |
coleenp@4037 | 209 | |
stefank@5863 | 210 | static void ergo_initialize(); |
coleenp@4037 | 211 | static void global_initialize(); |
ehelin@6722 | 212 | static void post_initialize(); |
coleenp@4037 | 213 | |
coleenp@4037 | 214 | static size_t first_chunk_word_size() { return _first_chunk_word_size; } |
jmasa@4382 | 215 | static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; } |
coleenp@4037 | 216 | |
stefank@5863 | 217 | static size_t reserve_alignment() { return _reserve_alignment; } |
stefank@5863 | 218 | static size_t reserve_alignment_words() { return _reserve_alignment / BytesPerWord; } |
stefank@5863 | 219 | static size_t commit_alignment() { return _commit_alignment; } |
stefank@5863 | 220 | static size_t commit_alignment_words() { return _commit_alignment / BytesPerWord; } |
stefank@5863 | 221 | |
coleenp@4037 | 222 | char* bottom() const; |
jmasa@5015 | 223 | size_t used_words_slow(MetadataType mdtype) const; |
ehelin@5703 | 224 | size_t free_words_slow(MetadataType mdtype) const; |
jmasa@5015 | 225 | size_t capacity_words_slow(MetadataType mdtype) const; |
coleenp@4037 | 226 | |
jmasa@5015 | 227 | size_t used_bytes_slow(MetadataType mdtype) const; |
jmasa@5015 | 228 | size_t capacity_bytes_slow(MetadataType mdtype) const; |
jmasa@5015 | 229 | |
stefank@5941 | 230 | static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size, |
stefank@5941 | 231 | bool read_only, MetaspaceObj::Type type, TRAPS); |
jmasa@4064 | 232 | void deallocate(MetaWord* ptr, size_t byte_size, bool is_class); |
coleenp@4037 | 233 | |
jmasa@4064 | 234 | MetaWord* expand_and_allocate(size_t size, |
jmasa@4064 | 235 | MetadataType mdtype); |
coleenp@4037 | 236 | |
coleenp@6678 | 237 | static bool contains(const void* ptr); |
coleenp@6678 | 238 | |
coleenp@4037 | 239 | void dump(outputStream* const out) const; |
coleenp@4037 | 240 | |
jmasa@5007 | 241 | // Free empty virtualspaces |
stefank@5771 | 242 | static void purge(MetadataType mdtype); |
jmasa@5007 | 243 | static void purge(); |
jmasa@5007 | 244 | |
stefank@5863 | 245 | static void report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, |
ehelin@6419 | 246 | MetaspaceObj::Type type, MetadataType mdtype, TRAPS); |
stefank@5863 | 247 | |
ehelin@6418 | 248 | static const char* metadata_type_name(Metaspace::MetadataType mdtype); |
ehelin@6418 | 249 | |
coleenp@4037 | 250 | void print_on(outputStream* st) const; |
coleenp@4037 | 251 | // Debugging support |
coleenp@4037 | 252 | void verify(); |
iklam@5208 | 253 | |
iklam@5208 | 254 | class AllocRecordClosure : public StackObj { |
iklam@5208 | 255 | public: |
iklam@5208 | 256 | virtual void doit(address ptr, MetaspaceObj::Type type, int byte_size) = 0; |
iklam@5208 | 257 | }; |
iklam@5208 | 258 | |
iklam@5208 | 259 | void iterate(AllocRecordClosure *closure); |
hseigel@5528 | 260 | |
ehelin@5694 | 261 | // Return TRUE only if UseCompressedClassPointers is True and DumpSharedSpaces is False. |
hseigel@5528 | 262 | static bool using_class_space() { |
ehelin@5694 | 263 | return NOT_LP64(false) LP64_ONLY(UseCompressedClassPointers && !DumpSharedSpaces); |
hseigel@5528 | 264 | } |
hseigel@5528 | 265 | |
mgerdin@5808 | 266 | static bool is_class_space_allocation(MetadataType mdType) { |
mgerdin@5808 | 267 | return mdType == ClassType && using_class_space(); |
mgerdin@5808 | 268 | } |
hseigel@6027 | 269 | |
coleenp@4037 | 270 | }; |
coleenp@4037 | 271 | |
coleenp@4037 | 272 | class MetaspaceAux : AllStatic { |
ehelin@5703 | 273 | static size_t free_chunks_total_words(Metaspace::MetadataType mdtype); |
jmasa@5015 | 274 | |
jmasa@5015 | 275 | // These methods iterate over the classloader data graph |
jmasa@5015 | 276 | // for the given Metaspace type. These are slow. |
jmasa@5015 | 277 | static size_t used_bytes_slow(Metaspace::MetadataType mdtype); |
ehelin@5703 | 278 | static size_t free_bytes_slow(Metaspace::MetadataType mdtype); |
jmasa@5015 | 279 | static size_t capacity_bytes_slow(Metaspace::MetadataType mdtype); |
ehelin@5703 | 280 | static size_t capacity_bytes_slow(); |
coleenp@4037 | 281 | |
jmasa@5015 | 282 | // Running sum of space in all Metachunks that has been |
jmasa@5015 | 283 | // allocated to a Metaspace. This is used instead of |
jmasa@5162 | 284 | // iterating over all the classloaders. One for each |
jmasa@5162 | 285 | // type of Metadata |
ehelin@6609 | 286 | static size_t _capacity_words[Metaspace:: MetadataTypeCount]; |
ehelin@6609 | 287 | // Running sum of space in all Metachunks that |
jmasa@5162 | 288 | // are being used for metadata. One for each |
jmasa@5162 | 289 | // type of Metadata. |
ehelin@6609 | 290 | static size_t _used_words[Metaspace:: MetadataTypeCount]; |
jmasa@5015 | 291 | |
jmasa@5015 | 292 | public: |
jmasa@5015 | 293 | // Decrement and increment _allocated_capacity_words |
jmasa@5162 | 294 | static void dec_capacity(Metaspace::MetadataType type, size_t words); |
jmasa@5162 | 295 | static void inc_capacity(Metaspace::MetadataType type, size_t words); |
jmasa@5015 | 296 | |
jmasa@5015 | 297 | // Decrement and increment _allocated_used_words |
jmasa@5162 | 298 | static void dec_used(Metaspace::MetadataType type, size_t words); |
jmasa@5162 | 299 | static void inc_used(Metaspace::MetadataType type, size_t words); |
jmasa@5015 | 300 | |
jmasa@5015 | 301 | // Total of space allocated to metadata in all Metaspaces. |
jmasa@5015 | 302 | // This sums the space used in each Metachunk by |
jmasa@5015 | 303 | // iterating over the classloader data graph |
jmasa@5015 | 304 | static size_t used_bytes_slow() { |
jmasa@5015 | 305 | return used_bytes_slow(Metaspace::ClassType) + |
jmasa@5015 | 306 | used_bytes_slow(Metaspace::NonClassType); |
stefank@4371 | 307 | } |
coleenp@4037 | 308 | |
jmasa@5015 | 309 | // Used by MetaspaceCounters |
ehelin@5703 | 310 | static size_t free_chunks_total_words(); |
ehelin@5703 | 311 | static size_t free_chunks_total_bytes(); |
ehelin@5703 | 312 | static size_t free_chunks_total_bytes(Metaspace::MetadataType mdtype); |
jmasa@5015 | 313 | |
ehelin@6609 | 314 | static size_t capacity_words(Metaspace::MetadataType mdtype) { |
ehelin@6609 | 315 | return _capacity_words[mdtype]; |
jmasa@5162 | 316 | } |
ehelin@6609 | 317 | static size_t capacity_words() { |
ehelin@6609 | 318 | return capacity_words(Metaspace::NonClassType) + |
ehelin@6609 | 319 | capacity_words(Metaspace::ClassType); |
jmasa@5162 | 320 | } |
ehelin@6609 | 321 | static size_t capacity_bytes(Metaspace::MetadataType mdtype) { |
ehelin@6609 | 322 | return capacity_words(mdtype) * BytesPerWord; |
jmasa@5015 | 323 | } |
ehelin@6609 | 324 | static size_t capacity_bytes() { |
ehelin@6609 | 325 | return capacity_words() * BytesPerWord; |
jmasa@5015 | 326 | } |
jmasa@5015 | 327 | |
ehelin@6609 | 328 | static size_t used_words(Metaspace::MetadataType mdtype) { |
ehelin@6609 | 329 | return _used_words[mdtype]; |
jmasa@5162 | 330 | } |
ehelin@6609 | 331 | static size_t used_words() { |
ehelin@6609 | 332 | return used_words(Metaspace::NonClassType) + |
ehelin@6609 | 333 | used_words(Metaspace::ClassType); |
jmasa@5162 | 334 | } |
ehelin@6609 | 335 | static size_t used_bytes(Metaspace::MetadataType mdtype) { |
ehelin@6609 | 336 | return used_words(mdtype) * BytesPerWord; |
jmasa@5015 | 337 | } |
ehelin@6609 | 338 | static size_t used_bytes() { |
ehelin@6609 | 339 | return used_words() * BytesPerWord; |
jmasa@5015 | 340 | } |
jmasa@5015 | 341 | |
jmasa@5015 | 342 | static size_t free_bytes(); |
ehelin@5531 | 343 | static size_t free_bytes(Metaspace::MetadataType mdtype); |
jmasa@5015 | 344 | |
ehelin@5703 | 345 | static size_t reserved_bytes(Metaspace::MetadataType mdtype); |
ehelin@5703 | 346 | static size_t reserved_bytes() { |
ehelin@5703 | 347 | return reserved_bytes(Metaspace::ClassType) + |
ehelin@5703 | 348 | reserved_bytes(Metaspace::NonClassType); |
stefank@4371 | 349 | } |
coleenp@4037 | 350 | |
stefank@5704 | 351 | static size_t committed_bytes(Metaspace::MetadataType mdtype); |
stefank@5704 | 352 | static size_t committed_bytes() { |
stefank@5704 | 353 | return committed_bytes(Metaspace::ClassType) + |
stefank@5704 | 354 | committed_bytes(Metaspace::NonClassType); |
stefank@5704 | 355 | } |
stefank@5704 | 356 | |
ehelin@5703 | 357 | static size_t min_chunk_size_words(); |
ehelin@5703 | 358 | static size_t min_chunk_size_bytes() { |
ehelin@5703 | 359 | return min_chunk_size_words() * BytesPerWord; |
stefank@4371 | 360 | } |
coleenp@4037 | 361 | |
ehelin@6420 | 362 | static bool has_chunk_free_list(Metaspace::MetadataType mdtype); |
ehelin@6420 | 363 | static MetaspaceChunkFreeListSummary chunk_free_list_summary(Metaspace::MetadataType mdtype); |
ehelin@6420 | 364 | |
coleenp@4037 | 365 | // Print change in used metadata. |
coleenp@4037 | 366 | static void print_metaspace_change(size_t prev_metadata_used); |
coleenp@4037 | 367 | static void print_on(outputStream * out); |
coleenp@4037 | 368 | static void print_on(outputStream * out, Metaspace::MetadataType mdtype); |
coleenp@4037 | 369 | |
hseigel@5528 | 370 | static void print_class_waste(outputStream* out); |
coleenp@4037 | 371 | static void print_waste(outputStream* out); |
coleenp@4037 | 372 | static void dump(outputStream* out); |
mgerdin@4264 | 373 | static void verify_free_chunks(); |
jmasa@5015 | 374 | // Checks that the values returned by allocated_capacity_bytes() and |
jmasa@5015 | 375 | // capacity_bytes_slow() are the same. |
jmasa@5015 | 376 | static void verify_capacity(); |
jmasa@5015 | 377 | static void verify_used(); |
jmasa@5015 | 378 | static void verify_metrics(); |
coleenp@4037 | 379 | }; |
coleenp@4037 | 380 | |
coleenp@4037 | 381 | // Metaspace are deallocated when their class loader are GC'ed. |
coleenp@4037 | 382 | // This class implements a policy for inducing GC's to recover |
coleenp@4037 | 383 | // Metaspaces. |
coleenp@4037 | 384 | |
coleenp@4037 | 385 | class MetaspaceGC : AllStatic { |
coleenp@4037 | 386 | |
stefank@5863 | 387 | // The current high-water-mark for inducing a GC. |
stefank@5863 | 388 | // When committed memory of all metaspaces reaches this value, |
stefank@5863 | 389 | // a GC is induced and the value is increased. Size is in bytes. |
stefank@5863 | 390 | static volatile intptr_t _capacity_until_GC; |
coleenp@4037 | 391 | |
coleenp@4037 | 392 | // For a CMS collection, signal that a concurrent collection should |
coleenp@4037 | 393 | // be started. |
coleenp@4037 | 394 | static bool _should_concurrent_collect; |
coleenp@4037 | 395 | |
coleenp@4037 | 396 | static uint _shrink_factor; |
coleenp@4037 | 397 | |
coleenp@4037 | 398 | static size_t shrink_factor() { return _shrink_factor; } |
coleenp@4037 | 399 | void set_shrink_factor(uint v) { _shrink_factor = v; } |
coleenp@4037 | 400 | |
coleenp@4037 | 401 | public: |
coleenp@4037 | 402 | |
ehelin@6722 | 403 | static void initialize(); |
ehelin@6722 | 404 | static void post_initialize(); |
stefank@5863 | 405 | |
stefank@5863 | 406 | static size_t capacity_until_GC(); |
ehelin@7254 | 407 | static bool inc_capacity_until_GC(size_t v, |
ehelin@7254 | 408 | size_t* new_cap_until_GC = NULL, |
ehelin@7254 | 409 | size_t* old_cap_until_GC = NULL); |
stefank@5863 | 410 | static size_t dec_capacity_until_GC(size_t v); |
coleenp@4037 | 411 | |
coleenp@4037 | 412 | static bool should_concurrent_collect() { return _should_concurrent_collect; } |
coleenp@4037 | 413 | static void set_should_concurrent_collect(bool v) { |
coleenp@4037 | 414 | _should_concurrent_collect = v; |
coleenp@4037 | 415 | } |
coleenp@4037 | 416 | |
coleenp@4037 | 417 | // The amount to increase the high-water-mark (_capacity_until_GC) |
stefank@5863 | 418 | static size_t delta_capacity_until_GC(size_t bytes); |
coleenp@4037 | 419 | |
stefank@5863 | 420 | // Tells if we have can expand metaspace without hitting set limits. |
stefank@5863 | 421 | static bool can_expand(size_t words, bool is_class); |
stefank@5863 | 422 | |
stefank@5863 | 423 | // Returns amount that we can expand without hitting a GC, |
stefank@5863 | 424 | // measured in words. |
stefank@5863 | 425 | static size_t allowed_expansion(); |
coleenp@4037 | 426 | |
coleenp@4037 | 427 | // Calculate the new high-water mark at which to induce |
coleenp@4037 | 428 | // a GC. |
coleenp@4037 | 429 | static void compute_new_size(); |
coleenp@4037 | 430 | }; |
coleenp@4037 | 431 | |
coleenp@4037 | 432 | #endif // SHARE_VM_MEMORY_METASPACE_HPP |