RFR: 8372285: G1: Micro-optimize x86 barrier code [v2]
Thomas Schatzl
tschatzl at openjdk.org
Fri Nov 21 10:02:52 UTC 2025
On Fri, 21 Nov 2025 09:52:28 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp line 131:
>>
>>> 129: __ cmpptr(addr, count);
>>> 130: __ jcc(Assembler::belowEqual, loop);
>>> 131: __ jmpb(done);
>>
>> Not related to this line, but for `jcc` there is also a `jccb` variant that could be used (line 121); you actually used it in other code. Since these short jumps have a signed displacement, they can also be used for backward jumps. (E.g. in below `__jmp(next_card)`, but maybe I'm overlooking something.
>
> Backward jumps are actually shortened automatically, because assembler knows when their offset is small. Only forward branches need this special (forward-looking) treatment: assembler has no advanced knowledge the jump can be short, so we have to tell it. This is our SOP: rely on automatic shortening where possible for backward branches, shorten the forward branches where it is obvious.
>
> Yes, I think we can shorten `__ jcc(Assembler::equal, is_clean_card);` too, let me try that.
Okay, thanks for the information, I am good with that. Although I think it would not hurt to make it explicit that we cared.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28446#discussion_r2549190865
More information about the hotspot-dev
mailing list