hotspot/src/share/vm/memory/padded.hpp
changeset 27165 785a8d56024c
parent 23458 947a3d680f3e
child 46619 a3919f5e8d2b
equal deleted inserted replaced
27164:6523fa019ffa 27165:785a8d56024c
    74 // minimal amount of padding needed to make the size of the objects be aligned.
    74 // minimal amount of padding needed to make the size of the objects be aligned.
    75 // This will help reducing false sharing,
    75 // This will help reducing false sharing,
    76 // if the start address is a multiple of alignment.
    76 // if the start address is a multiple of alignment.
    77 template <class T, size_t alignment = DEFAULT_CACHE_LINE_SIZE>
    77 template <class T, size_t alignment = DEFAULT_CACHE_LINE_SIZE>
    78 class PaddedEnd : public PaddedEndImpl<T, PADDED_END_SIZE(T, alignment)> {
    78 class PaddedEnd : public PaddedEndImpl<T, PADDED_END_SIZE(T, alignment)> {
    79   // C++ don't allow zero-length arrays. The padding is put in a
    79   // C++ doesn't allow zero-length arrays. The padding is put in a
    80   // super class that is specialized for the pad_size == 0 case.
    80   // super class that is specialized for the pad_size == 0 case.
    81 };
    81 };
       
    82 
       
    83 // Similar to PaddedEnd, this macro defines a _pad_buf#id field
       
    84 // that is (alignment - size) bytes in size. This macro is used
       
    85 // to add padding in between non-class fields in a class or struct.
       
    86 #define DEFINE_PAD_MINUS_SIZE(id, alignment, size) \
       
    87           char _pad_buf##id[(alignment) - (size)]
    82 
    88 
    83 // Helper class to create an array of PaddedEnd<T> objects. All elements will
    89 // Helper class to create an array of PaddedEnd<T> objects. All elements will
    84 // start at a multiple of alignment and the size will be aligned to alignment.
    90 // start at a multiple of alignment and the size will be aligned to alignment.
    85 template <class T, MEMFLAGS flags, size_t alignment = DEFAULT_CACHE_LINE_SIZE>
    91 template <class T, MEMFLAGS flags, size_t alignment = DEFAULT_CACHE_LINE_SIZE>
    86 class PaddedArray {
    92 class PaddedArray {