On Fri, 30 Aug 2024 11:07:46 GMT, Stefan Karlsson <stef...@openjdk.org> wrote:

>> src/hotspot/share/gc/serial/defNewGeneration.cpp line 707:
>> 
>>> 705:       } else if (obj->is_forwarded()) {
>>> 706:         // To restore the klass-bits in the header.
>>> 707:         obj->forward_safe_init_mark();
>> 
>> I wonder if not modifying successful-forwarded objs is cleaner. Sth like:
>> 
>> 
>> reset_self_forwarded_in_space(space) {
>>   cur = space->bottom();
>>   top = space->top();
>> 
>>   while (cur < top) {
>>     obj = cast_to_oop(cur);
>> 
>>     if (obj->is_self_forwarded()) {
>>       obj->unset_self_forwarded();
>>       obj_size = obj->size();
>>     } else {
>>       assert(obj->is_forwarded(), "inv");
>>       obj_size = obj->forwardee()->size();
>>     }
>> 
>>     cur += obj_size;
>>   }
>> }
>> 
>> reset_self_forwarded_in_space(eden());
>> reset_self_forwarded_in_space(from());
>
> I was thinking the same, but there's a problem with that. If we get a 
> promotion failure in the young gen, we are leaving the dead objects marked as 
> forwarded. Then when the Full GC scans these regions with dead objects it 
> will mistakenly think that they have been marked alive because 
> `is_forwarded() == is_gc_marked()`. The code in `phase2_calculate_new_addr` 
> will then break when it looks for `is_gc_marked` objects.

FWIW, the ParallelGC does something very similar to what you propose, except 
that it walks bitmaps instead of paring the space to find the self-forwarded 
objects. It then has a check inside object_iterate to make sure that it doesn't 
expose the dead objects (in eden and the from space) to heap dumpers and 
histogram printers.

Because of the the code above, the SerialGC clears away the information about 
what objects are dead in eden and the from space, so heap dumpers and histogram 
printers will include these dead objects. We might want to fix that as a future 
RFE.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20677#discussion_r1738444174

Reply via email to