RFR: 8305898: Alternative self-forwarding mechanism [v19]

Stefan Karlsson stefank at openjdk.org
Fri Aug 25 19:16:18 UTC 2023


On Fri, 25 Aug 2023 15:01:30 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

>> src/hotspot/share/oops/oop.inline.hpp line 292:
>> 
>>> 290:     m = m.set_self_forwarded();
>>> 291:     assert(forwardee(m) == cast_to_oop(this), "encoding must be reversible");
>>> 292:     set_mark(m);
>> 
>> Could you explain why we need to restore the displaced mark word here? I wonder why it matters what the old mark word is and why this code can't be changed to something like this:
>> 
>>     markWord m = markWord::prototype().set_self_forwarded();
>>     set_mark(m);
>
> The main reason why we need to implement the self-forwarding is to preserve the upper bits of the mark-word (specifically, the Klass* that we want to place there with JEP 450). If the header is displaced, we would install the self-forwarded bit in the tagged native-pointer that is in the header, meaning we loose the ability to get to the actual header to fetch the Klass*. We do restore the header later, but GC needs access to the Klass* meanwhile.

Thanks. While reviewing this patch I was thinking about the current JDK code, which as far as I understand doesn't need to restore the displaced header here.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13779#discussion_r1306061533


More information about the hotspot-gc-dev mailing list