RFR: 8305898: Alternative self-forwarding mechanism [v18]
Roman Kennke
rkennke at openjdk.org
Mon Jul 24 10:39:46 UTC 2023
On Mon, 24 Jul 2023 07:29:53 GMT, mmyxym <duke at openjdk.org> wrote:
>> Roman Kennke has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 30 commits:
>>
>> - Merge branch 'JDK-8305896' into JDK-8305898
>> - Merge branch 'JDK-8305896' into JDK-8305898
>> - Update comment about mark-word layout
>> - Merge branch 'JDK-8305896' into JDK-8305898
>> - Fix tests on 32bit builds
>> - Merge branch 'JDK-8305896' into JDK-8305898
>> - Merge branch 'JDK-8305896' into JDK-8305898
>> - wqRevert "Rename self-forwarded -> forward-failed"
>>
>> This reverts commit 4d9713ca239da8e294c63887426bfb97240d3130.
>> - Merge branch 'JDK-8305896' into JDK-8305898
>> - Merge remote-tracking branch 'origin/JDK-8305898' into JDK-8305898
>> - ... and 20 more: https://git.openjdk.org/jdk/compare/524f9c52...3838ac05
>
> src/hotspot/share/gc/g1/g1ParScanThreadState.cpp line 210:
>
>> 208: markWord m = obj->mark();
>> 209: if (m.is_marked()) {
>> 210: obj = obj->forwardee(m);
>
> Shall we have a method "oop::forwardee_not_self" which guarantee to be not self fowarded? So we can remove the self-forward if-check in GC critical path.
Are there any paths that don't need to handle self-forwarded state?
Also, it seems to me that the path would be dominated by the load of the mark-word. Testing-and-branching for the self-forwarded bit seems like the minor problem there. It would be nice if we could tell the C++ compiler that the branch is expected to be uncommon, so it could shape the emitted code accordingly, but, afaik, we can't.
If we were to micro-optimize the forwarding-decoding, then it would be more useful to optimize the common pattern:
if (o->is_forwarded()) { // Loads and tests the mark-word
oop fwd = o->forwardee(); // Loads mark-word again, and decode forwardee.
...
}
To something like:
oop fwd = o->forwardee(); // Return nullptr when not forwarded
if (fwd != nullptr) {
...
}
There's a way to improve further on this, as I proposed back in the early versions of #5955, which also avoids the decoding altogether if not forwarded, but it's a little more clunky:
OopForwarding fwd(obj);
if (fwd.is_forwarded()) {
oop forwardee = fwd.forwardee();
...
}
where the scoped OopForwarding object would encapsulate the markWord and the testing and decoding of the fwd-ptr, but it has been rejected back then. But it would certainly help more than an oopDesc::forwardee_not_self() approach (if that were even possible, which I think it is not).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13779#discussion_r1272080209
More information about the hotspot-gc-dev
mailing list