RFR: 8377225: RISC-V: Improve receiver type profiling reliability

Anjian Wen wenanjian at openjdk.org
Thu Feb 5 11:32:13 UTC 2026


On Tue, 20 Jan 2026 09:37:13 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> Same as JDK-8357258, this patch try to improve the receiver type profile reliability in riscv.
>> 
>> Functional Testing: tier1 Passed
>> Performance Testing: no regression
>> 
>> 
>> # Baseline
>> Benchmark                        (randomized)  Mode  Cnt   Score   Error  Units
>> InterfaceCalls.test1stInt2Types         false  avgt   12   9.371 ± 0.007  ns/op
>> InterfaceCalls.test1stInt2Types          true  avgt   12  14.168 ± 0.025  ns/op
>> InterfaceCalls.test1stInt3Types         false  avgt   12  38.390 ± 0.261  ns/op
>> InterfaceCalls.test1stInt3Types          true  avgt   12  39.634 ± 0.122  ns/op
>> InterfaceCalls.test1stInt5Types         false  avgt   12  40.960 ± 1.909  ns/op
>> InterfaceCalls.test1stInt5Types          true  avgt   12  41.235 ± 0.126  ns/op
>> InterfaceCalls.test2ndInt2Types         false  avgt   12  10.227 ± 0.333  ns/op
>> InterfaceCalls.test2ndInt2Types          true  avgt   12  14.657 ± 0.049  ns/op
>> InterfaceCalls.test2ndInt3Types         false  avgt   12  42.756 ± 0.563  ns/op
>> InterfaceCalls.test2ndInt3Types          true  avgt   12  50.112 ± 0.302  ns/op
>> InterfaceCalls.test2ndInt5Types         false  avgt   12  59.637 ± 1.900  ns/op
>> InterfaceCalls.test2ndInt5Types          true  avgt   12  56.992 ± 0.162  ns/op
>> InterfaceCalls.testIfaceCall            false  avgt   12  38.731 ± 0.749  ns/op
>> InterfaceCalls.testIfaceCall             true  avgt   12  38.218 ± 0.283  ns/op
>> InterfaceCalls.testIfaceExtCall         false  avgt   12  41.505 ± 3.659  ns/op
>> InterfaceCalls.testIfaceExtCall          true  avgt   12  39.611 ± 0.483  ns/op
>> InterfaceCalls.testMonomorphic          false  avgt   12   8.476 ± 0.011  ns/op
>> InterfaceCalls.testMonomorphic           true  avgt   12   8.475 ± 0.007  ns/op
>> 
>> # With Patch
>> Benchmark                        (randomized)  Mode  Cnt   Score   Error  Units
>> InterfaceCalls.test1stInt2Types         false  avgt   12   9.804 ± 0.401  ns/op
>> InterfaceCalls.test1stInt2Types          true  avgt   12  14.171 ± 0.029  ns/op
>> InterfaceCalls.test1stInt3Types         false  avgt   12  38.793 ± 0.677  ns/op
>> InterfaceCalls.test1stInt3Types          true  avgt   12  39.498 ± 0.351  ns/op
>> InterfaceCalls.test1stInt5Types         false  avgt   12  40.916 ± 0.771  ns/op
>> InterfaceCalls.test1stInt5Types          true  avgt   12  41.705 ± 1.356  ns/op
>> InterfaceCalls.test2ndInt2Types         false  avgt   12  10.222 ± 0.340  ns/op
>> InterfaceCalls.test2ndInt2Types          true  avgt   12  14.659 ± 0.033  n...
>
> src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 570:
> 
>> 568:   poly_count_offset    += mdp_offset;
>> 569: 
>> 570:   // Scale down to optimize encoding. Slots are pointer-sized.
> 
> I told this to Chad who did AArch64 port (https://github.com/openjdk/jdk/pull/29283): we do this trick in x86 code because with variable instruction sizes you would want to stay within 8-bit offsets if you can. I doubt it makes a difference for AArch64 or RISC-V. So you can simplify this part.

Thanks! I will take a look at your discussions on x86 and aarch64 carefully. Currently, I've simply implemented the replacement of assembly instructions, and I will make careful revisions later.

> src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 641:
> 
>> 639:   add(addr_reg, mdp, t0);
>> 640:   cmpxchg(/*addr*/ addr_reg, /*expected*/ x0, /*new*/ recv, Assembler::int64,
>> 641:           /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, /*result*/ recv);
> 
> As we discussed in AArch64 port of this, it is irrelevant for CAS to have a memory semantics here. You can do CAS without acquire/release here.

fixed!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29310#discussion_r2707566414
PR Review Comment: https://git.openjdk.org/jdk/pull/29310#discussion_r2767953818


More information about the hotspot-dev mailing list