RFR: 8305895: Implementation: JEP 450: Compact Object Headers (Experimental) [v7]

Erik Österlund eosterlund at openjdk.org
Thu May 11 10:41:50 UTC 2023


On Thu, 11 May 2023 10:31:22 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp line 250:
>> 
>>> 248:   Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(o), cast_from_oop<HeapWord*>(new_obj), new_obj_size);
>>> 249: 
>>> 250:   if (!new_obj->mark().is_marked()) {
>> 
>> For this check to work correctly, we are assuming that Copy::aligned_disjoint_words respects word level atomicity, even though we are using one of the non-atomic copying functions. That doesn't feel safe.
>
> True, it is not exactly safe. I wonder if we can plug this particular leak by doing the following:
> 
> 
>   // Copy obj
>   Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(o), cast_from_oop<HeapWord*>(new_obj), new_obj_size);
> 
>   if (UseCompactObjectHeaders) {
>     // The copy above is not atomic. Make sure we have seen the proper mark
>     // and re-install it into the copy, so that Klass* is guaranteed to be correct.
>     markWord mark = o->mark_acquire();
>     if (!mark.is_marked()) {
>       new_obj->set_mark(mark);
>       ContinuationGCSupport::transform_stack_chunk(new_obj);
>     } else {
>       // If we copied a mark-word that indicates 'forwarded' state, the object
>       // installation would not succeed. We cannot access Klass* anymore either.
>       // Skip the transformation.
>     }
>   } else {
>     ContinuationGCSupport::transform_stack_chunk(new_obj);
>   }

The load in mark_acquire can float up above the copying. So I don't think that will work either.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13844#discussion_r1190977091


More information about the hotspot-dev mailing list