168
169 // Number of chunks in the free chunks list
170 size_t free_chunks_count();
171
172 void inc_free_chunks_total(size_t v, size_t count = 1) {
173 Atomic::add_ptr(count, &_free_chunks_count);
174 Atomic::add_ptr(v, &_free_chunks_total);
175 }
176 ChunkTreeDictionary* humongous_dictionary() {
177 return &_humongous_dictionary;
178 }
179
180 ChunkList* free_chunks(ChunkIndex index);
181
182 // Returns the list for the given chunk word size.
183 ChunkList* find_free_chunks_list(size_t word_size);
184
185 // Remove from a list by size. Selects list based on size of chunk.
186 Metachunk* free_chunks_get(size_t chunk_word_size);
187
188 // Debug support
189 void verify();
190 void slow_verify() {
191 if (metaspace_slow_verify) {
192 verify();
193 }
194 }
195 void locked_verify();
196 void slow_locked_verify() {
197 if (metaspace_slow_verify) {
198 locked_verify();
199 }
200 }
201 void verify_free_chunks_total();
202
203 void locked_print_free_chunks(outputStream* st);
204 void locked_print_sum_free_chunks(outputStream* st);
205
206 void print_on(outputStream* st) const;
207 };
2618 size_t MetaspaceAux::free_chunks_total_words(Metaspace::MetadataType mdtype) {
2619 ChunkManager* chunk_manager = Metaspace::get_chunk_manager(mdtype);
2620 if (chunk_manager == NULL) {
2621 return 0;
2622 }
2623 chunk_manager->slow_verify();
2624 return chunk_manager->free_chunks_total_words();
2625 }
2626
2627 size_t MetaspaceAux::free_chunks_total_bytes(Metaspace::MetadataType mdtype) {
2628 return free_chunks_total_words(mdtype) * BytesPerWord;
2629 }
2630
2631 size_t MetaspaceAux::free_chunks_total_words() {
2632 return free_chunks_total_words(Metaspace::ClassType) +
2633 free_chunks_total_words(Metaspace::NonClassType);
2634 }
2635
2636 size_t MetaspaceAux::free_chunks_total_bytes() {
2637 return free_chunks_total_words() * BytesPerWord;
2638 }
2639
2640 void MetaspaceAux::print_metaspace_change(size_t prev_metadata_used) {
2641 gclog_or_tty->print(", [Metaspace:");
2642 if (PrintGCDetails && Verbose) {
2643 gclog_or_tty->print(" " SIZE_FORMAT
2644 "->" SIZE_FORMAT
2645 "(" SIZE_FORMAT ")",
2646 prev_metadata_used,
2647 allocated_used_bytes(),
2648 reserved_bytes());
2649 } else {
2650 gclog_or_tty->print(" " SIZE_FORMAT "K"
2651 "->" SIZE_FORMAT "K"
2652 "(" SIZE_FORMAT "K)",
2653 prev_metadata_used/K,
2654 allocated_used_bytes()/K,
2655 reserved_bytes()/K);
2656 }
2657
|
168
169 // Number of chunks in the free chunks list
170 size_t free_chunks_count();
171
172 void inc_free_chunks_total(size_t v, size_t count = 1) {
173 Atomic::add_ptr(count, &_free_chunks_count);
174 Atomic::add_ptr(v, &_free_chunks_total);
175 }
176 ChunkTreeDictionary* humongous_dictionary() {
177 return &_humongous_dictionary;
178 }
179
180 ChunkList* free_chunks(ChunkIndex index);
181
182 // Returns the list for the given chunk word size.
183 ChunkList* find_free_chunks_list(size_t word_size);
184
185 // Remove from a list by size. Selects list based on size of chunk.
186 Metachunk* free_chunks_get(size_t chunk_word_size);
187
188 void index_bounds_check(ChunkIndex index) const {
189 assert(index == SpecializedIndex ||
190 index == SmallIndex ||
191 index == MediumIndex ||
192 index == HumongousIndex, err_msg("Bad index: " INT32_FORMAT, (int) index));
193 }
194
195 size_t num_free_chunks(ChunkIndex index) const {
196 index_bounds_check(index);
197
198 if (index == HumongousIndex) {
199 return _humongous_dictionary.total_free_blocks();
200 }
201
202 ssize_t count = _free_chunks[index].count();
203 return count == -1 ? 0 : (size_t) count;
204 }
205
206 size_t size_free_chunks_in_bytes(ChunkIndex index) const {
207 index_bounds_check(index);
208
209 size_t word_size = 0;
210 if (index == HumongousIndex) {
211 word_size = _humongous_dictionary.total_size();
212 } else {
213 const size_t size_per_chunk_in_words = _free_chunks[index].size();
214 word_size = size_per_chunk_in_words * num_free_chunks(index);
215 }
216
217 return word_size * BytesPerWord;
218 }
219
220 // Debug support
221 void verify();
222 void slow_verify() {
223 if (metaspace_slow_verify) {
224 verify();
225 }
226 }
227 void locked_verify();
228 void slow_locked_verify() {
229 if (metaspace_slow_verify) {
230 locked_verify();
231 }
232 }
233 void verify_free_chunks_total();
234
235 void locked_print_free_chunks(outputStream* st);
236 void locked_print_sum_free_chunks(outputStream* st);
237
238 void print_on(outputStream* st) const;
239 };
2650 size_t MetaspaceAux::free_chunks_total_words(Metaspace::MetadataType mdtype) {
2651 ChunkManager* chunk_manager = Metaspace::get_chunk_manager(mdtype);
2652 if (chunk_manager == NULL) {
2653 return 0;
2654 }
2655 chunk_manager->slow_verify();
2656 return chunk_manager->free_chunks_total_words();
2657 }
2658
2659 size_t MetaspaceAux::free_chunks_total_bytes(Metaspace::MetadataType mdtype) {
2660 return free_chunks_total_words(mdtype) * BytesPerWord;
2661 }
2662
2663 size_t MetaspaceAux::free_chunks_total_words() {
2664 return free_chunks_total_words(Metaspace::ClassType) +
2665 free_chunks_total_words(Metaspace::NonClassType);
2666 }
2667
2668 size_t MetaspaceAux::free_chunks_total_bytes() {
2669 return free_chunks_total_words() * BytesPerWord;
2670 }
2671
2672 bool MetaspaceAux::has_chunk_free_list(Metaspace::MetadataType mdtype) {
2673 return Metaspace::get_chunk_manager(mdtype) != NULL;
2674 }
2675
2676 MetaspaceChunkFreeListSummary MetaspaceAux::chunk_free_list_summary(Metaspace::MetadataType mdtype) {
2677 if (!has_chunk_free_list(mdtype)) {
2678 return MetaspaceChunkFreeListSummary();
2679 }
2680
2681 ChunkManager *cm = Metaspace::get_chunk_manager(mdtype);
2682 return MetaspaceChunkFreeListSummary(cm->num_free_chunks(SpecializedIndex),
2683 cm->num_free_chunks(SmallIndex),
2684 cm->num_free_chunks(MediumIndex),
2685 cm->num_free_chunks(HumongousIndex),
2686 cm->size_free_chunks_in_bytes(SpecializedIndex),
2687 cm->size_free_chunks_in_bytes(SmallIndex),
2688 cm->size_free_chunks_in_bytes(MediumIndex),
2689 cm->size_free_chunks_in_bytes(HumongousIndex));
2690 }
2691
2692 void MetaspaceAux::print_metaspace_change(size_t prev_metadata_used) {
2693 gclog_or_tty->print(", [Metaspace:");
2694 if (PrintGCDetails && Verbose) {
2695 gclog_or_tty->print(" " SIZE_FORMAT
2696 "->" SIZE_FORMAT
2697 "(" SIZE_FORMAT ")",
2698 prev_metadata_used,
2699 allocated_used_bytes(),
2700 reserved_bytes());
2701 } else {
2702 gclog_or_tty->print(" " SIZE_FORMAT "K"
2703 "->" SIZE_FORMAT "K"
2704 "(" SIZE_FORMAT "K)",
2705 prev_metadata_used/K,
2706 allocated_used_bytes()/K,
2707 reserved_bytes()/K);
2708 }
2709
|