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

Roman Kennke rkennke at openjdk.org
Thu May 11 10:52:50 UTC 2023


On Thu, 11 May 2023 10:38:26 GMT, Erik Österlund <eosterlund at openjdk.org> wrote:

>> 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.

Hmm, right. I guess this is not only about atomicity. It's also possible that we see that it's not marked/forwarded, then ignore the transform_stack_chunk() call, which would be wrong.
The problem is that transform_stack_chunk() wants to access the Klass* to check is_stackChunk(). So maybe we need to extract the Klass* from the test_mark and pass it to (a new variant of) ContinuationSupport::transform_stack_chunk() which only uses that class? That should work, right?

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

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


More information about the hotspot-dev mailing list