25
26 #ifndef SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP
27 #define SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP
28
29 #include "oops/compressedKlass.hpp"
30 #include "runtime/globals.hpp"
31 #include "utilities/align.hpp"
32 #include "utilities/debug.hpp"
33 #include "utilities/globalDefinitions.hpp"
34
35 class outputStream;
36
37 namespace metaspace {
38
39 // Metaspace allocation alignment:
40
41 // Metaspace allocations have to be aligned such that 64-bit values are aligned
42 // correctly. We currently don't hold members with a larger alignment requirement
43 // than 64-bit inside MetaData, so 8-byte alignment is enough.
44 //
45 // Klass* structures need to be aligned to KlassAlignmentInBytes, but since that is
46 // 64-bit, we don't need special handling for allocating Klass*.
47 //
48 // On 64-bit platforms, we align to word size; on 32-bit, we align to two words.
49
50 static const size_t AllocationAlignmentByteSize = 8;
51 STATIC_ASSERT(AllocationAlignmentByteSize == (size_t)KlassAlignmentInBytes);
52
53 static const size_t AllocationAlignmentWordSize = AllocationAlignmentByteSize / BytesPerWord;
54
55 // Returns the raw word size allocated for a given net allocation. This only matters on 32-bit, where
56 // allocations have to be 64-bit aligned too and therefore must be 2-word-aligned.
57 inline size_t get_raw_word_size_for_requested_word_size(size_t word_size) {
58 LP64_ONLY(STATIC_ASSERT(AllocationAlignmentWordSize == 1)); // rewrite if this does not hold true anymore
59 return LP64_ONLY(word_size) // no-op on 64-bit
60 NOT_LP64(align_up(word_size, AllocationAlignmentWordSize));
61 }
62
63 // Utility functions
64
65 // Print a size, in words, scaled.
66 void print_scaled_words(outputStream* st, size_t word_size, size_t scale = 0, int width = -1);
67
68 // Convenience helper: prints a size value and a percentage.
69 void print_scaled_words_and_percentage(outputStream* st, size_t word_size, size_t compare_word_size, size_t scale = 0, int width = -1);
70
71 // Print a human readable size.
|
25
26 #ifndef SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP
27 #define SHARE_MEMORY_METASPACE_METASPACECOMMON_HPP
28
29 #include "oops/compressedKlass.hpp"
30 #include "runtime/globals.hpp"
31 #include "utilities/align.hpp"
32 #include "utilities/debug.hpp"
33 #include "utilities/globalDefinitions.hpp"
34
35 class outputStream;
36
37 namespace metaspace {
38
39 // Metaspace allocation alignment:
40
41 // Metaspace allocations have to be aligned such that 64-bit values are aligned
42 // correctly. We currently don't hold members with a larger alignment requirement
43 // than 64-bit inside MetaData, so 8-byte alignment is enough.
44 //
45 // Klass* structures need to be aligned to Klass* alignment,
46 //
47 // On 64-bit platforms, we align to word size; on 32-bit, we align to two words.
48
49 static const size_t AllocationAlignmentByteSize = 8;
50
51 static const size_t AllocationAlignmentWordSize = AllocationAlignmentByteSize / BytesPerWord;
52
53 // Returns the raw word size allocated for a given net allocation. This only matters on 32-bit, where
54 // allocations have to be 64-bit aligned too and therefore must be 2-word-aligned.
55 inline size_t get_raw_word_size_for_requested_word_size(size_t word_size) {
56 LP64_ONLY(STATIC_ASSERT(AllocationAlignmentWordSize == 1)); // rewrite if this does not hold true anymore
57 return LP64_ONLY(word_size) // no-op on 64-bit
58 NOT_LP64(align_up(word_size, AllocationAlignmentWordSize));
59 }
60
61 // Utility functions
62
63 // Print a size, in words, scaled.
64 void print_scaled_words(outputStream* st, size_t word_size, size_t scale = 0, int width = -1);
65
66 // Convenience helper: prints a size value and a percentage.
67 void print_scaled_words_and_percentage(outputStream* st, size_t word_size, size_t compare_word_size, size_t scale = 0, int width = -1);
68
69 // Print a human readable size.
|