JDK-8275055 : Improve HeapRegionRemSet::split_card()
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 18
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • Submitted: 2021-10-11
  • Updated: 2021-10-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Description
The method HeapRegionRemSet::split_card() looks as follows:

  HeapRegion* hr = G1CollectedHeap::heap()->heap_region_containing(from);
  card_region = hr->hrm_index();
  card_within_region = (uint)(pointer_delta((HeapWord*)from, hr->bottom()) >> (CardTable::card_shift - LogHeapWordSize));

I.e. from a memory POV:
 - load of Universe::_heap
 - calculating using it (loading heap bottom,) loading heap region size shift)
 - look up heap region hr
 - indirect loads from heap region hr (index, bottom)

This can be done simpler:

  uintptr_t offset = pointer_delta(from, _heap_base_address, 1);
  card_region = offset >> _split_card_shift;
  card_within_region = (offset & _split_card_mask) >> CardTable::card_shift;

- one load of heap base address
- load and shift by precalculated value
- mask by value plus shift

This change also enables card region virtualization.