RFR: 8287555: Tighten G1 G1BlockOffsetTable::block_start() code

Albert Mingkun Yang ayang at openjdk.org
Thu Jun 23 21:23:53 UTC 2022


On Tue, 7 Jun 2022 11:46:47 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

> Hi all,
> 
>   can I have reviews for this change that specializes `G1BlockOffsetTablePart::block_size` with a variant used for card aligned addresses including some cleanup of comments? This saves some unnecessary lookup of the block size of the object found as for refinement the start address is always aligned.
> 
> Testing: tier1, gha
> 
> Thanks,
>   Thomas

src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp line 166:

> 164:   // Returns the address of the start of the block containing "addr", assuming that
> 165:   // the given address is card-aligned.
> 166:   inline HeapWord* block_start_aligned(const void* addr) const;

I am not sure introducing another API is really that necessary. What I have in mind is sth like:


void block_start(const void* addr) {
  if (card_aligned(addr)) {
    fast_path
  } else {
    slow_path
  }
  assert_post-cond
}


I don't think the cost of if-check will be observable.

-------------

PR: https://git.openjdk.org/jdk/pull/9059



More information about the hotspot-gc-dev mailing list