RFR (M): 8087198: G1 card refinement: batching, sorting

Man Cao manc at google.com
Tue Nov 19 20:02:01 UTC 2019


Thanks for the feedback. I will address them soon.

One question about casting:

> I would prefer leaving the type alone here and instead using
>   static_cast<CardTable::CardValue*>(_node_buffer[i])
> (maybe packaged in a little helper here).
> But I have a strong dislike for reinterpret_cast (with whatever
> spelling) where it can reasonably be avoided.


There is a problem with G1RemSet::clean_card_before_refine(CardValue*&
card_ptr),
that it needs to modify the card_ptr. In order to make the code clean for
Edward's
two-finger compaction, the code needs to call
clean_card_before_refine(_node_buffer[i]) and able to modify
_node_buffer[i] in-place.

If we have "void** _node_buffer", then it cannot do
static_cast<CardValue*&>(_node_buffer[i])
or
static_cast<CardValue**>(&_node_buffer[i]).

I found a workaround:
Change to:
G1RemSet::clean_card_before_refine(CardValue** card_ptr_addr);
Then:
void* card_addr = &_node_buffer[i];
clean_card_before_refine(static_cast<CardValue**>(card_addr))

However, I think this is
basically reinterpret_cast<CardValue**>(&_node_buffer[i]).
Any suggestion on a better casting approach?

-Man



More information about the hotspot-gc-dev mailing list