RFR: 8242038: G1: Lazily initialize RSHashTables

Claes Redestad claes.redestad at oracle.com
Tue Apr 7 14:52:17 UTC 2020



On 2020-04-07 10:03, Kim Barrett wrote:
>> On Apr 7, 2020, at 3:57 AM, Kim Barrett <kim.barrett at oracle.com> wrote:
>> Morover, the RSHashTable constructor calls RSHashTable::clear(). That
>> calls SparsePRTEntry::size(), whose value is computed from
>> G1RSetSparseRegionEntries, which is a product flag which doesn't have
>> its final value at static initialization time. Oops!
> 
> Oh, and SparsePRTEntry::size() is also called to size the array.
> 
> Probably the thing that makes this not just crash quickly is that the special
> empty_table doesn’t seem to get used as anything other than a marker / sentinal.
> 

Good catches, Kim,

I've reworked the initialization of the empty RSHashTable
to avoid calling SparsePRTEntry::size and doing C-heap allocation with a
dedicated (private) constructor:

http://cr.openjdk.java.net/~redestad/8242038/open.01/

- the empty table only needs a _buckets with a NullEntry (-1) at index 0
   along with a capacity_mask of 0. This ensures get_entry works without
   any added logic

- _entries can safely be NULL for the empty table; all accessors assert
   index < _num_entries or equivalent

- adjusted iterator so that it deals with a RSHashTable with capacity 0

The empty_table is accessed from SparsePRT, so needs to be accessible.

Hope this address all your concerns!

Testing: passed tier1-2, tier3-4 ongoing.

/Claes

(Footnote: Rather than a public empty_table static, we could make
SparsePRT a friend of RSHashTable and let everything be private, which
might make sense since RSHashTable is really just an implementation
detail of SparsePRT. It looks like that would remove the need for
RSHashTableBucketIter, too.)



More information about the hotspot-gc-dev mailing list