8241845: Shenandoah: align ShenandoahHeapRegions to cache lines

Reviewed-by: rkennke
This commit is contained in:
Aleksey Shipilev 2020-03-31 08:42:00 +02:00
parent 62df1e008f
commit 635cf02949
3 changed files with 18 additions and 6 deletions

View File

@ -178,6 +178,7 @@ jint ShenandoahHeap::initialize() {
size_t heap_page_size = UseLargePages ? (size_t)os::large_page_size() : (size_t)os::vm_page_size();
size_t bitmap_page_size = UseLargePages ? (size_t)os::large_page_size() : (size_t)os::vm_page_size();
size_t region_page_size = UseLargePages ? (size_t)os::large_page_size() : (size_t)os::vm_page_size();
//
// Reserve and commit memory for heap
@ -276,6 +277,15 @@ jint ShenandoahHeap::initialize() {
//
// Create regions and region sets
//
size_t region_align = align_up(sizeof(ShenandoahHeapRegion), SHENANDOAH_CACHE_LINE_SIZE);
size_t region_storage_size = align_up(region_align * _num_regions, region_page_size);
ReservedSpace region_storage(region_storage_size, region_page_size);
MemTracker::record_virtual_memory_type(region_storage.base(), mtGC);
if (!region_storage.special()) {
os::commit_memory_or_exit(region_storage.base(), region_storage_size, region_page_size, false,
"Cannot commit region memory");
}
_regions = NEW_C_HEAP_ARRAY(ShenandoahHeapRegion*, _num_regions, mtGC);
_free_set = new ShenandoahFreeSet(this, _num_regions);
@ -287,7 +297,10 @@ jint ShenandoahHeap::initialize() {
for (size_t i = 0; i < _num_regions; i++) {
HeapWord* start = (HeapWord*)sh_rs.base() + ShenandoahHeapRegion::region_size_words() * i;
bool is_committed = i < num_committed_regions;
ShenandoahHeapRegion* r = new ShenandoahHeapRegion(start, i, is_committed);
void* loc = region_storage.base() + i * region_align;
ShenandoahHeapRegion* r = new (loc) ShenandoahHeapRegion(start, i, is_committed);
assert(is_aligned(r, SHENANDOAH_CACHE_LINE_SIZE), "Sanity");
_marking_context->initialize_top_at_mark_start(r);
_regions[i] = r;

View File

@ -35,7 +35,7 @@
class VMStructs;
class ShenandoahHeapRegionStateConstant;
class ShenandoahHeapRegion : public CHeapObj<mtGC> {
class ShenandoahHeapRegion {
friend class VMStructs;
friend class ShenandoahHeapRegionStateConstant;
private:
@ -261,9 +261,6 @@ private:
HeapWord* _update_watermark;
// Claim some space at the end to protect next region
shenandoah_padding(0);
public:
ShenandoahHeapRegion(HeapWord* start, size_t index, bool committed);

View File

@ -30,7 +30,9 @@
// versions here. Shared code provides DEFAULT_CACHE_LINE_SIZE, which is
// inconveniently large by default.
#define SHENANDOAH_CACHE_LINE_SIZE 64
#define shenandoah_padding(id) \
DEFINE_PAD_MINUS_SIZE(id, 64, 0)
DEFINE_PAD_MINUS_SIZE(id, SHENANDOAH_CACHE_LINE_SIZE, 0)
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHPADDING_INLINE_HPP