8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include "precompiled.hpp"
27 #include "memory/metaspace/freeBlocks.hpp"
28 #include "memory/metaspace/metaspaceCommon.hpp"
29 #include "memory/metaspace/metaspaceSettings.hpp"
30 #include "memory/metaspace/virtualSpaceNode.hpp"
31 #include "utilities/align.hpp"
32 #include "utilities/debug.hpp"
33 #include "utilities/globalDefinitions.hpp"
34 #include "utilities/ostream.hpp"
35
36 namespace metaspace {
37
38 // Print a size, in words, scaled.
39 void print_scaled_words(outputStream* st, size_t word_size, size_t scale, int width) {
40 print_human_readable_size(st, word_size * sizeof(MetaWord), scale, width);
41 }
42
43 // Convenience helper: prints a size value and a percentage.
44 void print_scaled_words_and_percentage(outputStream* st, size_t word_size, size_t compare_word_size, size_t scale, int width) {
45 print_scaled_words(st, word_size, scale, width);
46 st->print(" (");
47 print_percentage(st, compare_word_size, word_size);
151 st->print("%3.0f%%", p);
152 }
153 }
154 }
155
156 const char* loaders_plural(uintx num) {
157 return num == 1 ? "loader" : "loaders";
158 }
159
160 const char* classes_plural(uintx num) {
161 return num == 1 ? "class" : "classes";
162 }
163
164 void print_number_of_classes(outputStream* out, uintx classes, uintx classes_shared) {
165 out->print(UINTX_FORMAT " %s", classes, classes_plural(classes));
166 if (classes_shared > 0) {
167 out->print(" (" UINTX_FORMAT " shared)", classes_shared);
168 }
169 }
170
171 // Given a net allocation word size, return the raw word size we actually allocate.
172 // Note: externally visible for gtests.
173 //static
174 size_t get_raw_word_size_for_requested_word_size(size_t word_size) {
175 size_t byte_size = word_size * BytesPerWord;
176
177 // Deallocated metablocks are kept in a binlist which limits their minimal
178 // size to at least the size of a binlist item (2 words).
179 byte_size = MAX2(byte_size, FreeBlocks::MinWordSize * BytesPerWord);
180
181 // Metaspace allocations are aligned to word size.
182 byte_size = align_up(byte_size, AllocationAlignmentByteSize);
183
184 size_t raw_word_size = byte_size / BytesPerWord;
185 assert(raw_word_size * BytesPerWord == byte_size, "Sanity");
186 return raw_word_size;
187 }
188
189 } // namespace metaspace
190
|
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include "precompiled.hpp"
27 #include "memory/metaspace/freeBlocks.hpp"
28 #include "memory/metaspace/metaspaceAlignment.hpp"
29 #include "memory/metaspace/metaspaceCommon.hpp"
30 #include "memory/metaspace/metaspaceSettings.hpp"
31 #include "memory/metaspace/virtualSpaceNode.hpp"
32 #include "utilities/align.hpp"
33 #include "utilities/debug.hpp"
34 #include "utilities/globalDefinitions.hpp"
35 #include "utilities/ostream.hpp"
36
37 namespace metaspace {
38
39 // Print a size, in words, scaled.
40 void print_scaled_words(outputStream* st, size_t word_size, size_t scale, int width) {
41 print_human_readable_size(st, word_size * sizeof(MetaWord), scale, width);
42 }
43
44 // Convenience helper: prints a size value and a percentage.
45 void print_scaled_words_and_percentage(outputStream* st, size_t word_size, size_t compare_word_size, size_t scale, int width) {
46 print_scaled_words(st, word_size, scale, width);
47 st->print(" (");
48 print_percentage(st, compare_word_size, word_size);
152 st->print("%3.0f%%", p);
153 }
154 }
155 }
156
157 const char* loaders_plural(uintx num) {
158 return num == 1 ? "loader" : "loaders";
159 }
160
161 const char* classes_plural(uintx num) {
162 return num == 1 ? "class" : "classes";
163 }
164
165 void print_number_of_classes(outputStream* out, uintx classes, uintx classes_shared) {
166 out->print(UINTX_FORMAT " %s", classes, classes_plural(classes));
167 if (classes_shared > 0) {
168 out->print(" (" UINTX_FORMAT " shared)", classes_shared);
169 }
170 }
171
172 } // namespace metaspace
173
|