RFR: JDK-8323497: On x64, use 32-bit immediate moves for narrow klass base if possible [v3]

Thomas Stuefe stuefe at openjdk.org
Wed Feb 21 07:47:09 UTC 2024


On Tue, 20 Feb 2024 11:22:19 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> Thomas Stuefe has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>> 
>>  - Merge branch 'openjdk:master' into use-32bit-immediate-moves-on-x64-for-klass-encoding-base
>>  - Merge branch 'openjdk:master' into use-32bit-immediate-moves-on-x64-for-klass-encoding-base
>>  - remove obsolete comment
>>  - use-32bit-immediate-moves-on-x64-for-klass-encoding-base
>
> src/hotspot/cpu/x86/macroAssembler_x86.cpp line 5596:
> 
>> 5594:   if (CompressedKlassPointers::base() != nullptr) {
>> 5595:     // Uses 32-bit mov if base is small enough
>> 5596:     movptr(tmp, (intptr_t)CompressedKlassPointers::base());
> 
> If we can reserve the base in the low 2G then this could be optimized further to `addq(r, CompressedKlassPointers::base())` and if `LogKlassAlignmentInBytes` is 8 (as asserted in `decode_and_move_klass_not_null` below), we can shorten the whole sequence into `leaq(r, Address(noreg, r, Address::times_8, CompressedKlassPointers::base())`

Nice! But could we do this in a follow-up RFE? I don't have any more time to spend on this atm, and I would like to get this PR at least integrated. It has been sitting in review for 7 weeks now.

I opened a follow-up RFE: https://bugs.openjdk.org/browse/JDK-8326383

(about the leaq, we may move to a different encoding scheme with a different shift value with Lilliput, so I am hesitant to put in too much work that relies on a 8-byte shift)

> src/hotspot/cpu/x86/macroAssembler_x86.cpp line 5620:
> 
>> 5618:     } else {
>> 5619:       xorq(dst, dst);
>> 5620:     }
> 
> This can also be 1 instruction when the base is smaller than $2^{31}$.

See my remark above.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17340#discussion_r1497034895
PR Review Comment: https://git.openjdk.org/jdk/pull/17340#discussion_r1497035134


More information about the hotspot-dev mailing list