src/share/vm/utilities/globalDefinitions.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hsx-gc Sdiff src/share/vm/utilities

src/share/vm/utilities/globalDefinitions.hpp

Print this page




 393 // Note: this value must be a power of 2
 394 
 395 #define ARENA_AMALLOC_ALIGNMENT (2*BytesPerWord)
 396 
 397 // Signed variants of alignment helpers.  There are two versions of each, a macro
 398 // for use in places like enum definitions that require compile-time constant
 399 // expressions and a function for all other places so as to get type checking.
 400 
 401 #define align_size_up_(size, alignment) (((size) + ((alignment) - 1)) & ~((alignment) - 1))
 402 
 403 inline intptr_t align_size_up(intptr_t size, intptr_t alignment) {
 404   return align_size_up_(size, alignment);
 405 }
 406 
 407 #define align_size_down_(size, alignment) ((size) & ~((alignment) - 1))
 408 
 409 inline intptr_t align_size_down(intptr_t size, intptr_t alignment) {
 410   return align_size_down_(size, alignment);
 411 }
 412 


 413 // Align objects by rounding up their size, in HeapWord units.
 414 
 415 #define align_object_size_(size) align_size_up_(size, MinObjAlignment)
 416 
 417 inline intptr_t align_object_size(intptr_t size) {
 418   return align_size_up(size, MinObjAlignment);
 419 }
 420 
 421 inline bool is_object_aligned(intptr_t addr) {
 422   return addr == align_object_size(addr);
 423 }
 424 
 425 // Pad out certain offsets to jlong alignment, in HeapWord units.
 426 
 427 inline intptr_t align_object_offset(intptr_t offset) {
 428   return align_size_up(offset, HeapWordsPerLong);
 429 }
 430 




 431 // Clamp an address to be within a specific page
 432 // 1. If addr is on the page it is returned as is
 433 // 2. If addr is above the page_address the start of the *next* page will be returned
 434 // 3. Otherwise, if addr is below the page_address the start of the page will be returned
 435 inline address clamp_address_in_page(address addr, address page_address, intptr_t page_size) {
 436   if (align_size_down(intptr_t(addr), page_size) == align_size_down(intptr_t(page_address), page_size)) {
 437     // address is in the specified page, just return it as is
 438     return addr;
 439   } else if (addr > page_address) {
 440     // address is above specified page, return start of next page
 441     return (address)align_size_down(intptr_t(page_address), page_size) + page_size;
 442   } else {
 443     // address is below specified page, return start of page
 444     return (address)align_size_down(intptr_t(page_address), page_size);
 445   }
 446 }
 447 
 448 
 449 // The expected size in bytes of a cache line, used to pad data structures.
 450 #define DEFAULT_CACHE_LINE_SIZE 64
 451 
 452 // Bytes needed to pad type to avoid cache-line sharing; alignment should be the
 453 // expected cache line size (a power of two).  The first addend avoids sharing
 454 // when the start address is not a multiple of alignment; the second maintains
 455 // alignment of starting addresses that happen to be a multiple.
 456 #define PADDING_SIZE(type, alignment)                           \
 457   ((alignment) + align_size_up_(sizeof(type), alignment))
 458 
 459 // Templates to create a subclass padded to avoid cache line sharing.  These are
 460 // effective only when applied to derived-most (leaf) classes.
 461 
 462 // When no args are passed to the base ctor.
 463 template <class T, size_t alignment = DEFAULT_CACHE_LINE_SIZE>
 464 class Padded: public T {
 465 private:
 466   char _pad_buf_[PADDING_SIZE(T, alignment)];
 467 };
 468 
 469 // When either 0 or 1 args may be passed to the base ctor.
 470 template <class T, typename Arg1T, size_t alignment = DEFAULT_CACHE_LINE_SIZE>
 471 class Padded01: public T {
 472 public:
 473   Padded01(): T() { }
 474   Padded01(Arg1T arg1): T(arg1) { }
 475 private:
 476   char _pad_buf_[PADDING_SIZE(T, alignment)];
 477 };
 478 
 479 //----------------------------------------------------------------------------------------------------
 480 // Utility macros for compilers
 481 // used to silence compiler warnings
 482 
 483 #define Unused_Variable(var) var
 484 
 485 
 486 //----------------------------------------------------------------------------------------------------
 487 // Miscellaneous
 488 
 489 // 6302670 Eliminate Hotspot __fabsf dependency
 490 // All fabs() callers should call this function instead, which will implicitly
 491 // convert the operand to double, avoiding a dependency on __fabsf which
 492 // doesn't exist in early versions of Solaris 8.
 493 inline double fabsd(double value) {
 494   return fabs(value);
 495 }
 496 
 497 inline jint low (jlong value)                    { return jint(value); }




 393 // Note: this value must be a power of 2
 394 
 395 #define ARENA_AMALLOC_ALIGNMENT (2*BytesPerWord)
 396 
 397 // Signed variants of alignment helpers.  There are two versions of each, a macro
 398 // for use in places like enum definitions that require compile-time constant
 399 // expressions and a function for all other places so as to get type checking.
 400 
 401 #define align_size_up_(size, alignment) (((size) + ((alignment) - 1)) & ~((alignment) - 1))
 402 
 403 inline intptr_t align_size_up(intptr_t size, intptr_t alignment) {
 404   return align_size_up_(size, alignment);
 405 }
 406 
 407 #define align_size_down_(size, alignment) ((size) & ~((alignment) - 1))
 408 
 409 inline intptr_t align_size_down(intptr_t size, intptr_t alignment) {
 410   return align_size_down_(size, alignment);
 411 }
 412 
 413 #define is_size_aligned_(size, alignment) ((size) == (align_size_up_(size, alignment)))
 414 
 415 // Align objects by rounding up their size, in HeapWord units.
 416 
 417 #define align_object_size_(size) align_size_up_(size, MinObjAlignment)
 418 
 419 inline intptr_t align_object_size(intptr_t size) {
 420   return align_size_up(size, MinObjAlignment);
 421 }
 422 
 423 inline bool is_object_aligned(intptr_t addr) {
 424   return addr == align_object_size(addr);
 425 }
 426 
 427 // Pad out certain offsets to jlong alignment, in HeapWord units.
 428 
 429 inline intptr_t align_object_offset(intptr_t offset) {
 430   return align_size_up(offset, HeapWordsPerLong);
 431 }
 432 
 433 inline void* align_pointer_up(const void* addr, size_t size) {
 434   return (void*) align_size_up_((uintptr_t)addr, size);
 435 }
 436 
 437 // Clamp an address to be within a specific page
 438 // 1. If addr is on the page it is returned as is
 439 // 2. If addr is above the page_address the start of the *next* page will be returned
 440 // 3. Otherwise, if addr is below the page_address the start of the page will be returned
 441 inline address clamp_address_in_page(address addr, address page_address, intptr_t page_size) {
 442   if (align_size_down(intptr_t(addr), page_size) == align_size_down(intptr_t(page_address), page_size)) {
 443     // address is in the specified page, just return it as is
 444     return addr;
 445   } else if (addr > page_address) {
 446     // address is above specified page, return start of next page
 447     return (address)align_size_down(intptr_t(page_address), page_size) + page_size;
 448   } else {
 449     // address is below specified page, return start of page
 450     return (address)align_size_down(intptr_t(page_address), page_size);
 451   }
 452 }
 453 
 454 
 455 // The expected size in bytes of a cache line, used to pad data structures.
 456 #define DEFAULT_CACHE_LINE_SIZE 64
 457 


























 458 
 459 //----------------------------------------------------------------------------------------------------
 460 // Utility macros for compilers
 461 // used to silence compiler warnings
 462 
 463 #define Unused_Variable(var) var
 464 
 465 
 466 //----------------------------------------------------------------------------------------------------
 467 // Miscellaneous
 468 
 469 // 6302670 Eliminate Hotspot __fabsf dependency
 470 // All fabs() callers should call this function instead, which will implicitly
 471 // convert the operand to double, avoiding a dependency on __fabsf which
 472 // doesn't exist in early versions of Solaris 8.
 473 inline double fabsd(double value) {
 474   return fabs(value);
 475 }
 476 
 477 inline jint low (jlong value)                    { return jint(value); }


src/share/vm/utilities/globalDefinitions.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File