RFR: 8357258: x86: Improve receiver type profiling reliability [v3]

Vladimir Kozlov kvn at openjdk.org
Fri Nov 21 20:31:32 UTC 2025


On Wed, 24 Sep 2025 13:08:14 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> See the bug for discussion what issues current machinery has. 
>> 
>> This PR executes the plan outlined in the bug:
>>  1. Common the receiver type profiling code in interpreter and C1
>>  2. Rewrite receiver type profiling code to only do atomic receiver slot installations
>>  3. Trim `C1OptimizeVirtualCallProfiling` to only claim slots when receiver is installed 
>> 
>> This PR does _not_ do atomic counter updates themselves, as it may have much wider performance implications, including regressions. This PR should be at least performance neutral.
>> 
>> Additional testing:
>>   - [x] Linux x86_64 server fastdebug, `compiler/`
>>   - [x] Linux x86_64 server fastdebug, `all`
>
> Aleksey Shipilev has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains four commits:
> 
>  - Merge branch 'master' into JDK-8357258-x86-c1-optimize-virt-calls
>  - Merge branch 'master' into JDK-8357258-x86-c1-optimize-virt-calls
>  - Drop atomic counters
>  - Initial version

Few comments.

src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp line 1258:

> 1256:                                         Register recv) {
> 1257:   int mdp_offset = md->byte_offset_of_slot(data, in_ByteSize(0));
> 1258:   __ type_profile(recv, mdo, mdp_offset);

I looked on callers and `mdo` is not used after this code. I think we can convert it into `mdp` by adding `mdp_offset` so you don't need 3rd parameter for `type_profile()`.

src/hotspot/cpu/x86/macroAssembler_x86.cpp line 4807:

> 4805: 
> 4806:   Register offset = rscratch1;
> 4807:   assert_different_registers(mdp, recv, offset);

We also have `rscratch2` which we can use for registers shuffling in the following code.

src/hotspot/cpu/x86/macroAssembler_x86.cpp line 4818:

> 4816:   addptr(offset, receiver_step);
> 4817:   cmpptr(offset, end_receiver_offset);
> 4818:   jccb(Assembler::notEqual, L_loop);

Fix indention since these instructions also in the loop.

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

PR Review: https://git.openjdk.org/jdk/pull/25305#pullrequestreview-3494071362
PR Review Comment: https://git.openjdk.org/jdk/pull/25305#discussion_r2550739123
PR Review Comment: https://git.openjdk.org/jdk/pull/25305#discussion_r2550800089
PR Review Comment: https://git.openjdk.org/jdk/pull/25305#discussion_r2550750927


More information about the hotspot-compiler-dev mailing list