416 // Pad out certain offsets to jlong alignment, in HeapWord units. |
416 // Pad out certain offsets to jlong alignment, in HeapWord units. |
417 |
417 |
418 inline intptr_t align_object_offset(intptr_t offset) { |
418 inline intptr_t align_object_offset(intptr_t offset) { |
419 return align_size_up(offset, HeapWordsPerLong); |
419 return align_size_up(offset, HeapWordsPerLong); |
420 } |
420 } |
|
421 |
|
422 // Clamp an address to be within a specific page |
|
423 // 1. If addr is on the page it is returned as is |
|
424 // 2. If addr is above the page_address the start of the *next* page will be returned |
|
425 // 3. Otherwise, if addr is below the page_address the start of the page will be returned |
|
426 inline address clamp_address_in_page(address addr, address page_address, intptr_t page_size) { |
|
427 if (align_size_down(intptr_t(addr), page_size) == align_size_down(intptr_t(page_address), page_size)) { |
|
428 // address is in the specified page, just return it as is |
|
429 return addr; |
|
430 } else if (addr > page_address) { |
|
431 // address is above specified page, return start of next page |
|
432 return (address)align_size_down(intptr_t(page_address), page_size) + page_size; |
|
433 } else { |
|
434 // address is below specified page, return start of page |
|
435 return (address)align_size_down(intptr_t(page_address), page_size); |
|
436 } |
|
437 } |
|
438 |
421 |
439 |
422 // The expected size in bytes of a cache line, used to pad data structures. |
440 // The expected size in bytes of a cache line, used to pad data structures. |
423 #define DEFAULT_CACHE_LINE_SIZE 64 |
441 #define DEFAULT_CACHE_LINE_SIZE 64 |
424 |
442 |
425 // Bytes needed to pad type to avoid cache-line sharing; alignment should be the |
443 // Bytes needed to pad type to avoid cache-line sharing; alignment should be the |