20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 * |
22 * |
23 */ |
23 */ |
24 |
24 |
25 #ifndef SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP_ |
25 #ifndef SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP |
26 #define SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP_ |
26 #define SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP |
27 |
27 |
|
28 #include "utilities/debug.hpp" |
28 #include "utilities/globalDefinitions.hpp" |
29 #include "utilities/globalDefinitions.hpp" |
29 |
|
30 |
30 |
31 class outputStream; |
31 class outputStream; |
32 |
32 |
33 namespace metaspace { |
33 namespace metaspace { |
34 namespace internals { |
34 |
|
35 enum ChunkSizes { // in words. |
|
36 ClassSpecializedChunk = 128, |
|
37 SpecializedChunk = 128, |
|
38 ClassSmallChunk = 256, |
|
39 SmallChunk = 512, |
|
40 ClassMediumChunk = 4 * K, |
|
41 MediumChunk = 8 * K |
|
42 }; |
35 |
43 |
36 // Print a size, in words, scaled. |
44 // Print a size, in words, scaled. |
37 void print_scaled_words(outputStream* st, size_t word_size, size_t scale = 0, int width = -1); |
45 void print_scaled_words(outputStream* st, size_t word_size, size_t scale = 0, int width = -1); |
38 |
46 |
39 // Convenience helper: prints a size value and a percentage. |
47 // Convenience helper: prints a size value and a percentage. |
48 |
56 |
49 // Prints a percentage value. Values smaller than 1% but not 0 are displayed as "<1%", values |
57 // Prints a percentage value. Values smaller than 1% but not 0 are displayed as "<1%", values |
50 // larger than 99% but not 100% are displayed as ">100%". |
58 // larger than 99% but not 100% are displayed as ">100%". |
51 void print_percentage(outputStream* st, size_t total, size_t part); |
59 void print_percentage(outputStream* st, size_t total, size_t part); |
52 |
60 |
53 } // namespace internals |
61 |
|
62 #define assert_is_aligned(value, alignment) \ |
|
63 assert(is_aligned((value), (alignment)), \ |
|
64 SIZE_FORMAT_HEX " is not aligned to " \ |
|
65 SIZE_FORMAT, (size_t)(uintptr_t)value, (alignment)) |
|
66 |
|
67 // Internal statistics. |
|
68 #ifdef ASSERT |
|
69 struct internal_statistics_t { |
|
70 // Number of allocations. |
|
71 uintx num_allocs; |
|
72 // Number of times a ClassLoaderMetaspace was born... |
|
73 uintx num_metaspace_births; |
|
74 // ... and died. |
|
75 uintx num_metaspace_deaths; |
|
76 // Number of times VirtualSpaceListNodes were created... |
|
77 uintx num_vsnodes_created; |
|
78 // ... and purged. |
|
79 uintx num_vsnodes_purged; |
|
80 // Number of times we expanded the committed section of the space. |
|
81 uintx num_committed_space_expanded; |
|
82 // Number of deallocations |
|
83 uintx num_deallocs; |
|
84 // Number of deallocations triggered from outside ("real" deallocations). |
|
85 uintx num_external_deallocs; |
|
86 // Number of times an allocation was satisfied from deallocated blocks. |
|
87 uintx num_allocs_from_deallocated_blocks; |
|
88 }; |
|
89 extern internal_statistics_t g_internal_statistics; |
|
90 #endif |
|
91 |
|
92 // ChunkIndex defines the type of chunk. |
|
93 // Chunk types differ by size: specialized < small < medium, chunks |
|
94 // larger than medium are humongous chunks of varying size. |
|
95 enum ChunkIndex { |
|
96 ZeroIndex = 0, |
|
97 SpecializedIndex = ZeroIndex, |
|
98 SmallIndex = SpecializedIndex + 1, |
|
99 MediumIndex = SmallIndex + 1, |
|
100 HumongousIndex = MediumIndex + 1, |
|
101 NumberOfFreeLists = 3, |
|
102 NumberOfInUseLists = 4 |
|
103 }; |
|
104 |
|
105 // Utility functions. |
|
106 size_t get_size_for_nonhumongous_chunktype(ChunkIndex chunk_type, bool is_class); |
|
107 ChunkIndex get_chunk_type_by_size(size_t size, bool is_class); |
|
108 |
|
109 ChunkIndex next_chunk_index(ChunkIndex i); |
|
110 ChunkIndex prev_chunk_index(ChunkIndex i); |
|
111 // Returns a descriptive name for a chunk type. |
|
112 const char* chunk_size_name(ChunkIndex index); |
|
113 |
|
114 // Verify chunk type. |
|
115 inline bool is_valid_chunktype(ChunkIndex index) { |
|
116 return index == SpecializedIndex || index == SmallIndex || |
|
117 index == MediumIndex || index == HumongousIndex; |
|
118 } |
|
119 |
|
120 inline bool is_valid_nonhumongous_chunktype(ChunkIndex index) { |
|
121 return is_valid_chunktype(index) && index != HumongousIndex; |
|
122 } |
|
123 |
54 } // namespace metaspace |
124 } // namespace metaspace |
55 |
125 |
56 #endif /* SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP_ */ |
126 #endif /* SHARE_MEMORY_METASPACE_METASPACESTATISTICS_HPP */ |
|
127 |