src/share/vm/utilities/globalDefinitions.hpp

changeset 4889
cc32ccaaf47f
parent 4465
203f64878aab
child 4913
7a5aec879506
     1.1 --- a/src/share/vm/utilities/globalDefinitions.hpp	Wed Apr 03 16:43:09 2013 -0700
     1.2 +++ b/src/share/vm/utilities/globalDefinitions.hpp	Thu Apr 04 10:01:26 2013 -0700
     1.3 @@ -419,6 +419,24 @@
     1.4    return align_size_up(offset, HeapWordsPerLong);
     1.5  }
     1.6  
     1.7 +// Clamp an address to be within a specific page
     1.8 +// 1. If addr is on the page it is returned as is
     1.9 +// 2. If addr is above the page_address the start of the *next* page will be returned
    1.10 +// 3. Otherwise, if addr is below the page_address the start of the page will be returned
    1.11 +inline address clamp_address_in_page(address addr, address page_address, intptr_t page_size) {
    1.12 +  if (align_size_down(intptr_t(addr), page_size) == align_size_down(intptr_t(page_address), page_size)) {
    1.13 +    // address is in the specified page, just return it as is
    1.14 +    return addr;
    1.15 +  } else if (addr > page_address) {
    1.16 +    // address is above specified page, return start of next page
    1.17 +    return (address)align_size_down(intptr_t(page_address), page_size) + page_size;
    1.18 +  } else {
    1.19 +    // address is below specified page, return start of page
    1.20 +    return (address)align_size_down(intptr_t(page_address), page_size);
    1.21 +  }
    1.22 +}
    1.23 +
    1.24 +
    1.25  // The expected size in bytes of a cache line, used to pad data structures.
    1.26  #define DEFAULT_CACHE_LINE_SIZE 64
    1.27  
    1.28 @@ -1296,4 +1314,15 @@
    1.29    return *(void**)addr;
    1.30  }
    1.31  
    1.32 +
    1.33 +#ifndef PRODUCT
    1.34 +
    1.35 +// For unit testing only
    1.36 +class GlobalDefinitions {
    1.37 +public:
    1.38 +  static void test_globals();
    1.39 +};
    1.40 +
    1.41 +#endif // PRODUCT
    1.42 +
    1.43  #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP

mercurial