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

Aleksey Shipilev shade at openjdk.org
Thu May 22 12:51:08 UTC 2025


On Thu, 22 May 2025 11:42:45 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> On x64, we always use the long form of mov immediate to load the klass base into a register. If the klass base fits into 32 bits, we could use the short form and save four instruction bytes. 
>> 
>> Before: mov uses 10 instruction bytes:
>> 
>> 
>>    35  ;; decode_klass_not_null
>>    36   0x00007f8b089e51c4:   movabs $0x82000000,%r11
>>    37   0x00007f8b089e51ce:   add    %r11,%r10
>> 
>> 
>> Now: mov uses 6 instruction bytes:
>> 
>> 
>>    35  ;; decode_klass_not_null
>>    36   0x00007fbe609e51c4:   mov    $0x82000000,%r11d
>>    37   0x00007fbe609e51ca:   add    %r11,%r10
>> 
>> 
>> Note that this optimization does not depend on zero-based addressing, and therefore we change class space reservation: we now always look in low-address regions first.
>> 
>> ----------
>> 
>> Tests: tier1 (GHA), tier 2 on x64 linux
>
> Thomas Stuefe has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains six commits:
> 
>  - redo patch
>  - 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
>  - 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

Some code density estimates:


$ for I in 1 2 3 4; do build/linux-x86_64-server-release/images/jdk/bin/java -XX:TieredStopAtLevel=${I} -Xcomp -XX:+CITime Hello.java 2>&1 | grep "Tier${I}" | cut -d' ' -f 3,23-; done

# Before
Tier1: nmethods_code_size: 7468288 bytes
Tier2: nmethods_code_size: 7947176 bytes
Tier3: nmethods_code_size: 17979088 bytes
Tier4: nmethods_code_size: 6113728 bytes

# After
Tier1: nmethods_code_size: 7421344 bytes    ; -0.6%
Tier2: nmethods_code_size: 7900176 bytes    ; -0.6%
Tier3: nmethods_code_size: 17805232 bytes   ; -1.0%
Tier4: nmethods_code_size: 6102368 bytes    ; -0.2%

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

PR Comment: https://git.openjdk.org/jdk/pull/17340#issuecomment-2901108812


More information about the hotspot-dev mailing list