RFR (M): 8087198: G1 card refinement: batching, sorting
Kim Barrett
kim.barrett at oracle.com
Tue Nov 19 22:01:41 UTC 2019
> On Nov 19, 2019, at 4:58 PM, Kim Barrett <kim.barrett at oracle.com> wrote:
>
>> On Nov 19, 2019, at 3:02 PM, Man Cao <manc at google.com> wrote:
>>
>> 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
>
> Ick! I forgot about clean_card_before_refine possibly updating.
> Given that, I think the various cures are worse; just go with the
> reinterpret_cast you had originally.
Of course, there is JDK-8225409 :)
More information about the hotspot-gc-dev
mailing list