RFR: 8275527: Refactor forward pointer access [v4]

Stefan Karlsson stefank at openjdk.java.net
Mon Nov 1 09:31:14 UTC 2021

On Thu, 28 Oct 2021 12:35:37 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

>> Accessing the forward pointer is currently a little inconsistent. Some code paths call oopDesc::forwardee() / oopDesc::is_forwarded(), some code paths call forwardee() and check it for ==/!= NULL, some code paths even call markWord::decode_pointer() and markWord::is_marked() instead.
>> This change attempts to make the situation more consistent. For simple cases it preserves oopDesc::forwardee() / is_forwarded(), some cases need to use the markWord for consistency in concurrent GC, they now use markWord::forwardee() and markWord::is_forwarded(). Also, checking whether or not an object is forwarded is now consistently done using is_forwarded() and not by checking forwardee ==/!= NULL. This also resolves the mess in G1 full GC that changes not-forwarded objects to have a NULL (fake-) pointer. This is not necessary, because we can just as well use the lock bits to determine whether or not the object is forwarded.
>> Testing:
>>  - [x] tier
>>  - [x] tier2
>>  - [x] hotspot_gc
> Roman Kennke has updated the pull request incrementally with one additional commit since the last revision:
>   Move forward impl into markWord and add assert

Thanks for doing this change. This looks good to me. I've added a comment below that I think would be nice to get resolved somehow, though I don't need to re-review if you update with any of the suggestions.

src/hotspot/share/oops/markWord.hpp line 253:

> 251:     return cast_to_oop(decode_pointer());
> 252:   }
> 253: };

This brings the forwarded/forwardee terminology into the markWord. The markWord was previously decoupled from those to concepts. I would personally let those function names stay in oopDesc and not leak down into the markWord. If you do want to keep it here, could you update the comments at the top that describes the bits?

//    [ptr             | 11]  marked             used to mark an object


Marked as reviewed by stefank (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/5955

More information about the hotspot-gc-dev mailing list