<p dir="ltr">A few more comments/suggestions:</p>
<p dir="ltr">In g1CardCounts::ptr_2_card_num(), I'd assert that card_ptr >= _ct_bot. This is mostly to avoid a null card_ptr (or some other bogus value) causing the subtraction to go negative but then wrap around to a large size_t value that just happens to fit into the card range. Unlikely and maybe this is too paranoid, so up to you.</p>
<p dir="ltr">Also in this class, it's a bit strange that G1CardCounts::is_hot() also increments the count. I know the comments in the header say that count is updated but the name of the method implies it's just a read. Maybe call add_card_count() and then add an is_hot(int) method and call that with the return value of add_card_count?</p>
<p dir="ltr">G1CardCounts::clear_region -- there are some casts of const jbyte to jbyte at bottom of method. Perhaps if ptr_2_card_num() were changed to be taking const jbyte you wouldn't need the casts. I think marking as much things const as possible is good in general anyway ...</p>
<p dir="ltr">In the various places where values are asserted to be in some range, it may be useful to add the valid range to the error message so that if it triggers you get a bit more context/diagnostic info.</p>
<p dir="ltr">Thanks</p>
<p dir="ltr">Sent from my phone</p>