Mercurial > hg > truffle
comparison src/share/vm/memory/metaspace.cpp @ 12236:c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
Reviewed-by: brutisso, ehelin
author | stefank |
---|---|
date | Thu, 12 Sep 2013 10:15:54 +0200 |
parents | d6c266999345 |
children | 335b388c4b28 |
comparison
equal
deleted
inserted
replaced
12235:d6c266999345 | 12236:c4c768305a8f |
---|---|
289 | 289 |
290 // Convenience functions for logical bottom and end | 290 // Convenience functions for logical bottom and end |
291 MetaWord* bottom() const { return (MetaWord*) _virtual_space.low(); } | 291 MetaWord* bottom() const { return (MetaWord*) _virtual_space.low(); } |
292 MetaWord* end() const { return (MetaWord*) _virtual_space.high(); } | 292 MetaWord* end() const { return (MetaWord*) _virtual_space.high(); } |
293 | 293 |
294 size_t reserved_words() const { return _virtual_space.reserved_size() / BytesPerWord; } | |
295 size_t expanded_words() const { return _virtual_space.committed_size() / BytesPerWord; } | |
296 size_t committed_words() const { return _virtual_space.actual_committed_size() / BytesPerWord; } | |
297 | |
294 // address of next available space in _virtual_space; | 298 // address of next available space in _virtual_space; |
295 // Accessors | 299 // Accessors |
296 VirtualSpaceNode* next() { return _next; } | 300 VirtualSpaceNode* next() { return _next; } |
297 void set_next(VirtualSpaceNode* v) { _next = v; } | 301 void set_next(VirtualSpaceNode* v) { _next = v; } |
298 | 302 |
325 // get space from the virtual space | 329 // get space from the virtual space |
326 Metachunk* take_from_committed(size_t chunk_word_size); | 330 Metachunk* take_from_committed(size_t chunk_word_size); |
327 | 331 |
328 // Allocate a chunk from the virtual space and return it. | 332 // Allocate a chunk from the virtual space and return it. |
329 Metachunk* get_chunk_vs(size_t chunk_word_size); | 333 Metachunk* get_chunk_vs(size_t chunk_word_size); |
330 Metachunk* get_chunk_vs_with_expand(size_t chunk_word_size); | |
331 | 334 |
332 // Expands/shrinks the committed space in a virtual space. Delegates | 335 // Expands/shrinks the committed space in a virtual space. Delegates |
333 // to Virtualspace | 336 // to Virtualspace |
334 bool expand_by(size_t words, bool pre_touch = false); | 337 bool expand_by(size_t words, bool pre_touch = false); |
335 bool shrink_by(size_t words); | |
336 | 338 |
337 // In preparation for deleting this node, remove all the chunks | 339 // In preparation for deleting this node, remove all the chunks |
338 // in the node from any freelist. | 340 // in the node from any freelist. |
339 void purge(ChunkManager* chunk_manager); | 341 void purge(ChunkManager* chunk_manager); |
340 | 342 |
341 #ifdef ASSERT | 343 #ifdef ASSERT |
342 // Debug support | 344 // Debug support |
343 static void verify_virtual_space_total(); | |
344 static void verify_virtual_space_count(); | |
345 void mangle(); | 345 void mangle(); |
346 #endif | 346 #endif |
347 | 347 |
348 void print_on(outputStream* st) const; | 348 void print_on(outputStream* st) const; |
349 }; | 349 }; |
427 // Can this virtual list allocate >1 spaces? Also, used to determine | 427 // Can this virtual list allocate >1 spaces? Also, used to determine |
428 // whether to allocate unlimited small chunks in this virtual space | 428 // whether to allocate unlimited small chunks in this virtual space |
429 bool _is_class; | 429 bool _is_class; |
430 bool can_grow() const { return !is_class() || !UseCompressedClassPointers; } | 430 bool can_grow() const { return !is_class() || !UseCompressedClassPointers; } |
431 | 431 |
432 // Sum of space in all virtual spaces and number of virtual spaces | 432 // Sum of reserved and committed memory in the virtual spaces |
433 size_t _virtual_space_total; | 433 size_t _reserved_words; |
434 size_t _committed_words; | |
435 | |
436 // Number of virtual spaces | |
434 size_t _virtual_space_count; | 437 size_t _virtual_space_count; |
435 | 438 |
436 ~VirtualSpaceList(); | 439 ~VirtualSpaceList(); |
437 | 440 |
438 VirtualSpaceNode* virtual_space_list() const { return _virtual_space_list; } | 441 VirtualSpaceNode* virtual_space_list() const { return _virtual_space_list; } |
442 } | 445 } |
443 void set_current_virtual_space(VirtualSpaceNode* v) { | 446 void set_current_virtual_space(VirtualSpaceNode* v) { |
444 _current_virtual_space = v; | 447 _current_virtual_space = v; |
445 } | 448 } |
446 | 449 |
447 void link_vs(VirtualSpaceNode* new_entry, size_t vs_word_size); | 450 void link_vs(VirtualSpaceNode* new_entry); |
448 | 451 |
449 // Get another virtual space and add it to the list. This | 452 // Get another virtual space and add it to the list. This |
450 // is typically prompted by a failed attempt to allocate a chunk | 453 // is typically prompted by a failed attempt to allocate a chunk |
451 // and is typically followed by the allocation of a chunk. | 454 // and is typically followed by the allocation of a chunk. |
452 bool grow_vs(size_t vs_word_size); | 455 bool grow_vs(size_t vs_word_size); |
459 | 462 |
460 Metachunk* get_new_chunk(size_t word_size, | 463 Metachunk* get_new_chunk(size_t word_size, |
461 size_t grow_chunks_by_words, | 464 size_t grow_chunks_by_words, |
462 size_t medium_chunk_bunch); | 465 size_t medium_chunk_bunch); |
463 | 466 |
467 bool expand_by(VirtualSpaceNode* node, size_t word_size, bool pre_touch = false); | |
468 | |
464 // Get the first chunk for a Metaspace. Used for | 469 // Get the first chunk for a Metaspace. Used for |
465 // special cases such as the boot class loader, reflection | 470 // special cases such as the boot class loader, reflection |
466 // class loader and anonymous class loader. | 471 // class loader and anonymous class loader. |
467 Metachunk* get_initialization_chunk(size_t word_size, size_t chunk_bunch); | 472 Metachunk* get_initialization_chunk(size_t word_size, size_t chunk_bunch); |
468 | 473 |
474 bool is_class() const { return _is_class; } | 479 bool is_class() const { return _is_class; } |
475 | 480 |
476 // Allocate the first virtualspace. | 481 // Allocate the first virtualspace. |
477 void initialize(size_t word_size); | 482 void initialize(size_t word_size); |
478 | 483 |
479 size_t virtual_space_total() { return _virtual_space_total; } | 484 size_t reserved_words() { return _reserved_words; } |
480 | 485 size_t reserved_bytes() { return reserved_words() * BytesPerWord; } |
481 void inc_virtual_space_total(size_t v); | 486 size_t committed_words() { return _committed_words; } |
482 void dec_virtual_space_total(size_t v); | 487 size_t committed_bytes() { return committed_words() * BytesPerWord; } |
488 | |
489 void inc_reserved_words(size_t v); | |
490 void dec_reserved_words(size_t v); | |
491 void inc_committed_words(size_t v); | |
492 void dec_committed_words(size_t v); | |
483 void inc_virtual_space_count(); | 493 void inc_virtual_space_count(); |
484 void dec_virtual_space_count(); | 494 void dec_virtual_space_count(); |
485 | 495 |
486 // Unlink empty VirtualSpaceNodes and free it. | 496 // Unlink empty VirtualSpaceNodes and free it. |
487 void purge(); | 497 void purge(); |
899 virtual_space()->print(); | 909 virtual_space()->print(); |
900 } | 910 } |
901 return result; | 911 return result; |
902 } | 912 } |
903 | 913 |
904 // Shrink the virtual space (commit more of the reserved space) | |
905 bool VirtualSpaceNode::shrink_by(size_t words) { | |
906 size_t bytes = words * BytesPerWord; | |
907 virtual_space()->shrink_by(bytes); | |
908 return true; | |
909 } | |
910 | |
911 // Add another chunk to the chunk list. | |
912 | |
913 Metachunk* VirtualSpaceNode::get_chunk_vs(size_t chunk_word_size) { | 914 Metachunk* VirtualSpaceNode::get_chunk_vs(size_t chunk_word_size) { |
914 assert_lock_strong(SpaceManager::expand_lock()); | 915 assert_lock_strong(SpaceManager::expand_lock()); |
915 Metachunk* result = take_from_committed(chunk_word_size); | 916 Metachunk* result = take_from_committed(chunk_word_size); |
916 if (result != NULL) { | 917 if (result != NULL) { |
917 inc_container_count(); | 918 inc_container_count(); |
918 } | 919 } |
919 return result; | 920 return result; |
920 } | |
921 | |
922 Metachunk* VirtualSpaceNode::get_chunk_vs_with_expand(size_t chunk_word_size) { | |
923 assert_lock_strong(SpaceManager::expand_lock()); | |
924 | |
925 Metachunk* new_chunk = get_chunk_vs(chunk_word_size); | |
926 | |
927 if (new_chunk == NULL) { | |
928 // Only a small part of the virtualspace is committed when first | |
929 // allocated so committing more here can be expected. | |
930 size_t page_size_words = os::vm_page_size() / BytesPerWord; | |
931 size_t aligned_expand_vs_by_words = align_size_up(chunk_word_size, | |
932 page_size_words); | |
933 expand_by(aligned_expand_vs_by_words, false); | |
934 new_chunk = get_chunk_vs(chunk_word_size); | |
935 } | |
936 return new_chunk; | |
937 } | 921 } |
938 | 922 |
939 bool VirtualSpaceNode::initialize() { | 923 bool VirtualSpaceNode::initialize() { |
940 | 924 |
941 if (!_rs.is_reserved()) { | 925 if (!_rs.is_reserved()) { |
993 VirtualSpaceNode* vsl = iter.get_next(); | 977 VirtualSpaceNode* vsl = iter.get_next(); |
994 delete vsl; | 978 delete vsl; |
995 } | 979 } |
996 } | 980 } |
997 | 981 |
998 void VirtualSpaceList::inc_virtual_space_total(size_t v) { | 982 void VirtualSpaceList::inc_reserved_words(size_t v) { |
999 assert_lock_strong(SpaceManager::expand_lock()); | 983 assert_lock_strong(SpaceManager::expand_lock()); |
1000 _virtual_space_total = _virtual_space_total + v; | 984 _reserved_words = _reserved_words + v; |
1001 } | 985 } |
1002 void VirtualSpaceList::dec_virtual_space_total(size_t v) { | 986 void VirtualSpaceList::dec_reserved_words(size_t v) { |
1003 assert_lock_strong(SpaceManager::expand_lock()); | 987 assert_lock_strong(SpaceManager::expand_lock()); |
1004 _virtual_space_total = _virtual_space_total - v; | 988 _reserved_words = _reserved_words - v; |
989 } | |
990 | |
991 void VirtualSpaceList::inc_committed_words(size_t v) { | |
992 assert_lock_strong(SpaceManager::expand_lock()); | |
993 _committed_words = _committed_words + v; | |
994 } | |
995 void VirtualSpaceList::dec_committed_words(size_t v) { | |
996 assert_lock_strong(SpaceManager::expand_lock()); | |
997 _committed_words = _committed_words - v; | |
1005 } | 998 } |
1006 | 999 |
1007 void VirtualSpaceList::inc_virtual_space_count() { | 1000 void VirtualSpaceList::inc_virtual_space_count() { |
1008 assert_lock_strong(SpaceManager::expand_lock()); | 1001 assert_lock_strong(SpaceManager::expand_lock()); |
1009 _virtual_space_count++; | 1002 _virtual_space_count++; |
1050 } else { | 1043 } else { |
1051 prev_vsl->set_next(vsl->next()); | 1044 prev_vsl->set_next(vsl->next()); |
1052 } | 1045 } |
1053 | 1046 |
1054 vsl->purge(chunk_manager()); | 1047 vsl->purge(chunk_manager()); |
1055 dec_virtual_space_total(vsl->reserved()->word_size()); | 1048 dec_reserved_words(vsl->reserved_words()); |
1049 dec_committed_words(vsl->committed_words()); | |
1056 dec_virtual_space_count(); | 1050 dec_virtual_space_count(); |
1057 purged_vsl = vsl; | 1051 purged_vsl = vsl; |
1058 delete vsl; | 1052 delete vsl; |
1059 } else { | 1053 } else { |
1060 prev_vsl = vsl; | 1054 prev_vsl = vsl; |
1104 | 1098 |
1105 VirtualSpaceList::VirtualSpaceList(size_t word_size ) : | 1099 VirtualSpaceList::VirtualSpaceList(size_t word_size ) : |
1106 _is_class(false), | 1100 _is_class(false), |
1107 _virtual_space_list(NULL), | 1101 _virtual_space_list(NULL), |
1108 _current_virtual_space(NULL), | 1102 _current_virtual_space(NULL), |
1109 _virtual_space_total(0), | 1103 _reserved_words(0), |
1104 _committed_words(0), | |
1110 _virtual_space_count(0) { | 1105 _virtual_space_count(0) { |
1111 MutexLockerEx cl(SpaceManager::expand_lock(), | 1106 MutexLockerEx cl(SpaceManager::expand_lock(), |
1112 Mutex::_no_safepoint_check_flag); | 1107 Mutex::_no_safepoint_check_flag); |
1113 bool initialization_succeeded = grow_vs(word_size); | 1108 bool initialization_succeeded = grow_vs(word_size); |
1114 | 1109 |
1121 | 1116 |
1122 VirtualSpaceList::VirtualSpaceList(ReservedSpace rs) : | 1117 VirtualSpaceList::VirtualSpaceList(ReservedSpace rs) : |
1123 _is_class(true), | 1118 _is_class(true), |
1124 _virtual_space_list(NULL), | 1119 _virtual_space_list(NULL), |
1125 _current_virtual_space(NULL), | 1120 _current_virtual_space(NULL), |
1126 _virtual_space_total(0), | 1121 _reserved_words(0), |
1122 _committed_words(0), | |
1127 _virtual_space_count(0) { | 1123 _virtual_space_count(0) { |
1128 MutexLockerEx cl(SpaceManager::expand_lock(), | 1124 MutexLockerEx cl(SpaceManager::expand_lock(), |
1129 Mutex::_no_safepoint_check_flag); | 1125 Mutex::_no_safepoint_check_flag); |
1130 VirtualSpaceNode* class_entry = new VirtualSpaceNode(rs); | 1126 VirtualSpaceNode* class_entry = new VirtualSpaceNode(rs); |
1131 bool succeeded = class_entry->initialize(); | 1127 bool succeeded = class_entry->initialize(); |
1132 _chunk_manager.free_chunks(SpecializedIndex)->set_size(SpecializedChunk); | 1128 _chunk_manager.free_chunks(SpecializedIndex)->set_size(SpecializedChunk); |
1133 _chunk_manager.free_chunks(SmallIndex)->set_size(ClassSmallChunk); | 1129 _chunk_manager.free_chunks(SmallIndex)->set_size(ClassSmallChunk); |
1134 _chunk_manager.free_chunks(MediumIndex)->set_size(ClassMediumChunk); | 1130 _chunk_manager.free_chunks(MediumIndex)->set_size(ClassMediumChunk); |
1135 assert(succeeded, " VirtualSpaceList initialization should not fail"); | 1131 assert(succeeded, " VirtualSpaceList initialization should not fail"); |
1136 link_vs(class_entry, rs.size()/BytesPerWord); | 1132 link_vs(class_entry); |
1137 } | 1133 } |
1138 | 1134 |
1139 size_t VirtualSpaceList::free_bytes() { | 1135 size_t VirtualSpaceList::free_bytes() { |
1140 return virtual_space_list()->free_words_in_vs() * BytesPerWord; | 1136 return virtual_space_list()->free_words_in_vs() * BytesPerWord; |
1141 } | 1137 } |
1154 VirtualSpaceNode* new_entry = new VirtualSpaceNode(vs_byte_size); | 1150 VirtualSpaceNode* new_entry = new VirtualSpaceNode(vs_byte_size); |
1155 if (!new_entry->initialize()) { | 1151 if (!new_entry->initialize()) { |
1156 delete new_entry; | 1152 delete new_entry; |
1157 return false; | 1153 return false; |
1158 } else { | 1154 } else { |
1155 assert(new_entry->reserved_words() == vs_word_size, "Must be"); | |
1159 // ensure lock-free iteration sees fully initialized node | 1156 // ensure lock-free iteration sees fully initialized node |
1160 OrderAccess::storestore(); | 1157 OrderAccess::storestore(); |
1161 link_vs(new_entry, vs_word_size); | 1158 link_vs(new_entry); |
1162 return true; | 1159 return true; |
1163 } | 1160 } |
1164 } | 1161 } |
1165 | 1162 |
1166 void VirtualSpaceList::link_vs(VirtualSpaceNode* new_entry, size_t vs_word_size) { | 1163 void VirtualSpaceList::link_vs(VirtualSpaceNode* new_entry) { |
1167 if (virtual_space_list() == NULL) { | 1164 if (virtual_space_list() == NULL) { |
1168 set_virtual_space_list(new_entry); | 1165 set_virtual_space_list(new_entry); |
1169 } else { | 1166 } else { |
1170 current_virtual_space()->set_next(new_entry); | 1167 current_virtual_space()->set_next(new_entry); |
1171 } | 1168 } |
1172 set_current_virtual_space(new_entry); | 1169 set_current_virtual_space(new_entry); |
1173 inc_virtual_space_total(vs_word_size); | 1170 inc_reserved_words(new_entry->reserved_words()); |
1171 inc_committed_words(new_entry->committed_words()); | |
1174 inc_virtual_space_count(); | 1172 inc_virtual_space_count(); |
1175 #ifdef ASSERT | 1173 #ifdef ASSERT |
1176 new_entry->mangle(); | 1174 new_entry->mangle(); |
1177 #endif | 1175 #endif |
1178 if (TraceMetavirtualspaceAllocation && Verbose) { | 1176 if (TraceMetavirtualspaceAllocation && Verbose) { |
1179 VirtualSpaceNode* vsl = current_virtual_space(); | 1177 VirtualSpaceNode* vsl = current_virtual_space(); |
1180 vsl->print_on(tty); | 1178 vsl->print_on(tty); |
1181 } | 1179 } |
1180 } | |
1181 | |
1182 bool VirtualSpaceList::expand_by(VirtualSpaceNode* node, size_t word_size, bool pre_touch) { | |
1183 size_t before = node->committed_words(); | |
1184 | |
1185 bool result = node->expand_by(word_size, pre_touch); | |
1186 | |
1187 size_t after = node->committed_words(); | |
1188 | |
1189 // after and before can be the same if the memory was pre-committed. | |
1190 assert(after >= before, "Must be"); | |
1191 inc_committed_words(after - before); | |
1192 | |
1193 return result; | |
1182 } | 1194 } |
1183 | 1195 |
1184 Metachunk* VirtualSpaceList::get_new_chunk(size_t word_size, | 1196 Metachunk* VirtualSpaceList::get_new_chunk(size_t word_size, |
1185 size_t grow_chunks_by_words, | 1197 size_t grow_chunks_by_words, |
1186 size_t medium_chunk_bunch) { | 1198 size_t medium_chunk_bunch) { |
1202 grow_chunks_by_words); | 1214 grow_chunks_by_words); |
1203 size_t page_size_words = os::vm_page_size() / BytesPerWord; | 1215 size_t page_size_words = os::vm_page_size() / BytesPerWord; |
1204 size_t aligned_expand_vs_by_words = align_size_up(expand_vs_by_words, | 1216 size_t aligned_expand_vs_by_words = align_size_up(expand_vs_by_words, |
1205 page_size_words); | 1217 page_size_words); |
1206 bool vs_expanded = | 1218 bool vs_expanded = |
1207 current_virtual_space()->expand_by(aligned_expand_vs_by_words, false); | 1219 expand_by(current_virtual_space(), aligned_expand_vs_by_words); |
1208 if (!vs_expanded) { | 1220 if (!vs_expanded) { |
1209 // Should the capacity of the metaspaces be expanded for | 1221 // Should the capacity of the metaspaces be expanded for |
1210 // this allocation? If it's the virtual space for classes and is | 1222 // this allocation? If it's the virtual space for classes and is |
1211 // being used for CompressedHeaders, don't allocate a new virtualspace. | 1223 // being used for CompressedHeaders, don't allocate a new virtualspace. |
1212 if (can_grow() && MetaspaceGC::should_expand(this, word_size)) { | 1224 if (can_grow() && MetaspaceGC::should_expand(this, word_size)) { |
1213 // Get another virtual space. | 1225 // Get another virtual space. |
1214 size_t grow_vs_words = | 1226 size_t grow_vs_words = |
1215 MAX2((size_t)VirtualSpaceSize, aligned_expand_vs_by_words); | 1227 MAX2((size_t)VirtualSpaceSize, aligned_expand_vs_by_words); |
1216 if (grow_vs(grow_vs_words)) { | 1228 if (grow_vs(grow_vs_words)) { |
1217 // Got it. It's on the list now. Get a chunk from it. | 1229 // Got it. It's on the list now. Get a chunk from it. |
1218 next = current_virtual_space()->get_chunk_vs_with_expand(grow_chunks_by_words); | 1230 assert(current_virtual_space()->expanded_words() == 0, |
1231 "New virtuals space nodes should not have expanded"); | |
1232 | |
1233 size_t grow_chunks_by_words_aligned = align_size_up(grow_chunks_by_words, | |
1234 page_size_words); | |
1235 // We probably want to expand by aligned_expand_vs_by_words here. | |
1236 expand_by(current_virtual_space(), grow_chunks_by_words_aligned); | |
1237 next = current_virtual_space()->get_chunk_vs(grow_chunks_by_words); | |
1219 } | 1238 } |
1220 } else { | 1239 } else { |
1221 // Allocation will fail and induce a GC | 1240 // Allocation will fail and induce a GC |
1222 if (TraceMetadataChunkAllocation && Verbose) { | 1241 if (TraceMetadataChunkAllocation && Verbose) { |
1223 gclog_or_tty->print_cr("VirtualSpaceList::get_new_chunk():" | 1242 gclog_or_tty->print_cr("VirtualSpaceList::get_new_chunk():" |
1323 // for non-class virtual space, compare against virtual spaces that are reserved. | 1342 // for non-class virtual space, compare against virtual spaces that are reserved. |
1324 // For class virtual space, we only compare against the committed space, not | 1343 // For class virtual space, we only compare against the committed space, not |
1325 // reserved space, because this is a larger space prereserved for compressed | 1344 // reserved space, because this is a larger space prereserved for compressed |
1326 // class pointers. | 1345 // class pointers. |
1327 if (!FLAG_IS_DEFAULT(MaxMetaspaceSize)) { | 1346 if (!FLAG_IS_DEFAULT(MaxMetaspaceSize)) { |
1328 size_t real_allocated = Metaspace::space_list()->virtual_space_total() + | 1347 size_t real_allocated = Metaspace::space_list()->reserved_words() + |
1329 MetaspaceAux::allocated_capacity_bytes(Metaspace::ClassType); | 1348 MetaspaceAux::allocated_capacity_bytes(Metaspace::ClassType); |
1330 if (real_allocated >= MaxMetaspaceSize) { | 1349 if (real_allocated >= MaxMetaspaceSize) { |
1331 return false; | 1350 return false; |
1332 } | 1351 } |
1333 } | 1352 } |
2613 return class_capacity + non_class_capacity; | 2632 return class_capacity + non_class_capacity; |
2614 } | 2633 } |
2615 | 2634 |
2616 size_t MetaspaceAux::reserved_bytes(Metaspace::MetadataType mdtype) { | 2635 size_t MetaspaceAux::reserved_bytes(Metaspace::MetadataType mdtype) { |
2617 VirtualSpaceList* list = Metaspace::get_space_list(mdtype); | 2636 VirtualSpaceList* list = Metaspace::get_space_list(mdtype); |
2618 return list == NULL ? 0 : list->virtual_space_total() * BytesPerWord; | 2637 return list == NULL ? 0 : list->reserved_bytes(); |
2638 } | |
2639 | |
2640 size_t MetaspaceAux::committed_bytes(Metaspace::MetadataType mdtype) { | |
2641 VirtualSpaceList* list = Metaspace::get_space_list(mdtype); | |
2642 return list == NULL ? 0 : list->committed_bytes(); | |
2619 } | 2643 } |
2620 | 2644 |
2621 size_t MetaspaceAux::min_chunk_size_words() { return Metaspace::first_chunk_word_size(); } | 2645 size_t MetaspaceAux::min_chunk_size_words() { return Metaspace::first_chunk_word_size(); } |
2622 | 2646 |
2623 size_t MetaspaceAux::free_chunks_total_words(Metaspace::MetadataType mdtype) { | 2647 size_t MetaspaceAux::free_chunks_total_words(Metaspace::MetadataType mdtype) { |
3355 if (using_class_space()) { | 3379 if (using_class_space()) { |
3356 out->print_cr("\nClass space manager: " INTPTR_FORMAT, class_vsm()); | 3380 out->print_cr("\nClass space manager: " INTPTR_FORMAT, class_vsm()); |
3357 class_vsm()->dump(out); | 3381 class_vsm()->dump(out); |
3358 } | 3382 } |
3359 } | 3383 } |
3384 | |
3385 /////////////// Unit tests /////////////// | |
3386 | |
3387 #ifndef PRODUCT | |
3388 | |
3389 class MetaspaceAuxTest : AllStatic { | |
3390 public: | |
3391 static void test_reserved() { | |
3392 size_t reserved = MetaspaceAux::reserved_bytes(); | |
3393 | |
3394 assert(reserved > 0, "assert"); | |
3395 | |
3396 size_t committed = MetaspaceAux::committed_bytes(); | |
3397 assert(committed <= reserved, "assert"); | |
3398 | |
3399 size_t reserved_metadata = MetaspaceAux::reserved_bytes(Metaspace::NonClassType); | |
3400 assert(reserved_metadata > 0, "assert"); | |
3401 assert(reserved_metadata <= reserved, "assert"); | |
3402 | |
3403 if (UseCompressedClassPointers) { | |
3404 size_t reserved_class = MetaspaceAux::reserved_bytes(Metaspace::ClassType); | |
3405 assert(reserved_class > 0, "assert"); | |
3406 assert(reserved_class < reserved, "assert"); | |
3407 } | |
3408 } | |
3409 | |
3410 static void test_committed() { | |
3411 size_t committed = MetaspaceAux::committed_bytes(); | |
3412 | |
3413 assert(committed > 0, "assert"); | |
3414 | |
3415 size_t reserved = MetaspaceAux::reserved_bytes(); | |
3416 assert(committed <= reserved, "assert"); | |
3417 | |
3418 size_t committed_metadata = MetaspaceAux::committed_bytes(Metaspace::NonClassType); | |
3419 assert(committed_metadata > 0, "assert"); | |
3420 assert(committed_metadata <= committed, "assert"); | |
3421 | |
3422 if (UseCompressedClassPointers) { | |
3423 size_t committed_class = MetaspaceAux::committed_bytes(Metaspace::ClassType); | |
3424 assert(committed_class > 0, "assert"); | |
3425 assert(committed_class < committed, "assert"); | |
3426 } | |
3427 } | |
3428 | |
3429 static void test() { | |
3430 test_reserved(); | |
3431 test_committed(); | |
3432 } | |
3433 }; | |
3434 | |
3435 void MetaspaceAux_test() { | |
3436 MetaspaceAuxTest::test(); | |
3437 } | |
3438 | |
3439 #endif |