src/share/vm/utilities/globalDefinitions.hpp

changeset 6462
e2722a66aba7
parent 6461
bdd155477289
parent 5578
4c84d351cca9
child 6472
2b8e28fdf503
     1.1 --- a/src/share/vm/utilities/globalDefinitions.hpp	Thu Aug 22 09:39:54 2013 -0700
     1.2 +++ b/src/share/vm/utilities/globalDefinitions.hpp	Thu Sep 05 11:04:39 2013 -0700
     1.3 @@ -365,6 +365,8 @@
     1.4  // Klass encoding metaspace max size
     1.5  const uint64_t KlassEncodingMetaspaceMax = (uint64_t(max_juint) + 1) << LogKlassAlignmentInBytes;
     1.6  
     1.7 +const jlong CompressedKlassPointersBase = NOT_LP64(0) LP64_ONLY(CONST64(0x800000000));  // 32*G
     1.8 +
     1.9  // Machine dependent stuff
    1.10  
    1.11  #ifdef TARGET_ARCH_x86
    1.12 @@ -403,6 +405,14 @@
    1.13  
    1.14  #define align_size_up_(size, alignment) (((size) + ((alignment) - 1)) & ~((alignment) - 1))
    1.15  
    1.16 +inline bool is_size_aligned(size_t size, size_t alignment) {
    1.17 +  return align_size_up_(size, alignment) == size;
    1.18 +}
    1.19 +
    1.20 +inline bool is_ptr_aligned(void* ptr, size_t alignment) {
    1.21 +  return align_size_up_((intptr_t)ptr, (intptr_t)alignment) == (intptr_t)ptr;
    1.22 +}
    1.23 +
    1.24  inline intptr_t align_size_up(intptr_t size, intptr_t alignment) {
    1.25    return align_size_up_(size, alignment);
    1.26  }
    1.27 @@ -413,6 +423,16 @@
    1.28    return align_size_down_(size, alignment);
    1.29  }
    1.30  
    1.31 +#define is_size_aligned_(size, alignment) ((size) == (align_size_up_(size, alignment)))
    1.32 +
    1.33 +inline void* align_ptr_up(void* ptr, size_t alignment) {
    1.34 +  return (void*)align_size_up((intptr_t)ptr, (intptr_t)alignment);
    1.35 +}
    1.36 +
    1.37 +inline void* align_ptr_down(void* ptr, size_t alignment) {
    1.38 +  return (void*)align_size_down((intptr_t)ptr, (intptr_t)alignment);
    1.39 +}
    1.40 +
    1.41  // Align objects by rounding up their size, in HeapWord units.
    1.42  
    1.43  #define align_object_size_(size) align_size_up_(size, MinObjAlignment)
    1.44 @@ -431,6 +451,10 @@
    1.45    return align_size_up(offset, HeapWordsPerLong);
    1.46  }
    1.47  
    1.48 +inline void* align_pointer_up(const void* addr, size_t size) {
    1.49 +  return (void*) align_size_up_((uintptr_t)addr, size);
    1.50 +}
    1.51 +
    1.52  // Clamp an address to be within a specific page
    1.53  // 1. If addr is on the page it is returned as is
    1.54  // 2. If addr is above the page_address the start of the *next* page will be returned
    1.55 @@ -452,32 +476,6 @@
    1.56  // The expected size in bytes of a cache line, used to pad data structures.
    1.57  #define DEFAULT_CACHE_LINE_SIZE 64
    1.58  
    1.59 -// Bytes needed to pad type to avoid cache-line sharing; alignment should be the
    1.60 -// expected cache line size (a power of two).  The first addend avoids sharing
    1.61 -// when the start address is not a multiple of alignment; the second maintains
    1.62 -// alignment of starting addresses that happen to be a multiple.
    1.63 -#define PADDING_SIZE(type, alignment)                           \
    1.64 -  ((alignment) + align_size_up_(sizeof(type), alignment))
    1.65 -
    1.66 -// Templates to create a subclass padded to avoid cache line sharing.  These are
    1.67 -// effective only when applied to derived-most (leaf) classes.
    1.68 -
    1.69 -// When no args are passed to the base ctor.
    1.70 -template <class T, size_t alignment = DEFAULT_CACHE_LINE_SIZE>
    1.71 -class Padded: public T {
    1.72 -private:
    1.73 -  char _pad_buf_[PADDING_SIZE(T, alignment)];
    1.74 -};
    1.75 -
    1.76 -// When either 0 or 1 args may be passed to the base ctor.
    1.77 -template <class T, typename Arg1T, size_t alignment = DEFAULT_CACHE_LINE_SIZE>
    1.78 -class Padded01: public T {
    1.79 -public:
    1.80 -  Padded01(): T() { }
    1.81 -  Padded01(Arg1T arg1): T(arg1) { }
    1.82 -private:
    1.83 -  char _pad_buf_[PADDING_SIZE(T, alignment)];
    1.84 -};
    1.85  
    1.86  //----------------------------------------------------------------------------------------------------
    1.87  // Utility macros for compilers

mercurial