RFR: 8340453: C2: Improve encoding of LoadNKlass for compact headers [v2]

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Thu Nov 14 09:51:30 UTC 2024


On Wed, 13 Nov 2024 19:45:36 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

>> We currently use the offset 4 as a placeholder in LoadNKlass, when running with compact headers. In reality, we are loading from offset 0, but we want to keep LoadNKlass on a separate memory slice from other mark-word-accesses, because LoadNKlass is essentially immutable memory. The consequence is that we need to figure out the address of the mark-word in the backend, and this is ugly.
>> 
>> However, we can do better. We can just as well load 4 bytes from offset 4, and shift by a 32 smaller shift. This has previously not been possible because we needed to check for the monitor bit in the markWord, but this is no longer necessary. This simplifies the code and even makes the instructions encoding a bit smaller.
>> 
>> Testing:
>>  - [x] tier1 aarch64 +UCOH 
>>  - [x] tier1 x86_64 +UCOH
>
> Roman Kennke has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Improve opto asm of LoadNKlass

src/hotspot/cpu/aarch64/aarch64.ad line 6701:

> 6699:   ins_cost(4 * INSN_COST);
> 6700:   format %{
> 6701:     "ldrw  $dst, $mem\t# compressed class ptr, shifted"

Suggestion:

    "ldrw  $dst, $mem\t# compressed class ptr, shifted\n\t"

src/hotspot/cpu/x86/x86_64.ad line 4372:

> 4370:   ins_cost(125); // XXX
> 4371:   format %{
> 4372:     "movl    $dst, $mem\t# compressed klass ptr, shifted"

Suggestion:

    "movl    $dst, $mem\t# compressed klass ptr, shifted\n\t"

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22078#discussion_r1841885880
PR Review Comment: https://git.openjdk.org/jdk/pull/22078#discussion_r1841886831


More information about the hotspot-compiler-dev mailing list