RFR: 8314274: G1: Fix -Wconversion warnings around G1CardSetArray::_data

Kim Barrett kbarrett at openjdk.org
Tue Aug 15 18:29:08 UTC 2023


On Tue, 15 Aug 2023 13:26:14 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:

> Add value-range check and explicit type conversion. The second write has its check at the beginning of the method, so doesn't require an assertion.

Changes requested by kbarrett (Reviewer).

src/hotspot/share/gc/g1/g1CardSetContainers.inline.hpp line 148:

> 146:   assert(_size < LockBitMask, "Only support CardSetArray of size %u or smaller.", LockBitMask - 1);
> 147:   assert(card_in_region < (1u << sizeof(_data[0]) * BitsPerByte), "in-range");
> 148:   _data[0] = static_cast<EntryDataType>(card_in_region);

Shouldn't this be checked_cast rather than static_cast?

src/hotspot/share/gc/g1/g1CardSetContainers.inline.hpp line 199:

> 197:   }
> 198: 
> 199:   _data[num_entries] = static_cast<EntryDataType>(card_idx);

Shouldn't this be checked_cast rather than static_cast?

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

PR Review: https://git.openjdk.org/jdk/pull/15289#pullrequestreview-1579149392
PR Review Comment: https://git.openjdk.org/jdk/pull/15289#discussion_r1294959479
PR Review Comment: https://git.openjdk.org/jdk/pull/15289#discussion_r1294959577


More information about the hotspot-gc-dev mailing list