RFR: 8360000: RISC-V: implement aot [v2]

Fei Yang fyang at openjdk.org
Mon Jul 7 07:59:44 UTC 2025


On Fri, 4 Jul 2025 13:50:05 GMT, Hamlin Li <mli at openjdk.org> wrote:

>> Hi,
>> Can you help to review this patch?
>> 
>> https://openjdk.org/jeps/483 introduced aot (class loading/linking) and subsequent prs introduced more features related to it, like preserve adapters(c2i/i2c) and runtime blobs in AOT code cache.
>> 
>> Riscv should support these features and resolve relative issues.
>> 
>> ## Test
>> 
>> ### jtreg
>> 
>> run tier1/2/3 and hotspot_cds tests, no new failure found compared to master jdk. 
>> 
>> ### Performance
>> 
>> perf command to run the simplest Hello world java program:
>> * (perf stat -r 100 ${JAVA_HOME}/bin/java -XX:AOTCache=$AOT_CACHE -cp $CLASS_PATH Hello > /dev/null) 2>&1 | grep elapsed
>> 
>> perf data:
>> * (with patch): 0.181730 +- 0.000296 seconds time elapsed ( +- 0.16% )
>> * (without patch): 0.196627 +- 0.000227 seconds time elapsed ( +- 0.12% )
>> 
>> Thanks
>
> Hamlin Li has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - pass msg via a0 in stop
>  - comment

Thanks for the update. Several minor comments remain after more closer look.

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 800:

> 798:   push_reg(RegSet::of(t1, xmethod), sp);   // push << t1 & xmethod >> to sp
> 799:   movptr(t1, RuntimeAddress(entry_point), t0);
> 800:   jalr(t1);

This movptr + jalr sequence could be further simplified into `rt_call(entry_point)`, which could help save one add instruction.

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 4930:

> 4928:   push_reg(saved_regs, sp);
> 4929: 
> 4930:   movptr(t1, ExternalAddress(CAST_FROM_FN_PTR(address, Thread::current)));

It will be more consistent with other places in riscv-specific code where we move an ExternalAddress into a register if we do: `la(t1, ExternalAddress(CAST_FROM_FN_PTR(address, Thread::current)))`.

src/hotspot/cpu/riscv/runtime_riscv.cpp line 63:

> 61: UncommonTrapBlob* OptoRuntime::generate_uncommon_trap_blob() {
> 62:   // Allocate space for the code
> 63:   ResourceMark rm;

Seems more reasonable to move this `ResourceMark rm;` closer to its user `CodeBuffer buffer(name, 2048, 1024);`.
Similar for other changes in this file and src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp.

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

PR Review: https://git.openjdk.org/jdk/pull/26101#pullrequestreview-2992544544
PR Review Comment: https://git.openjdk.org/jdk/pull/26101#discussion_r2189220673
PR Review Comment: https://git.openjdk.org/jdk/pull/26101#discussion_r2189240643
PR Review Comment: https://git.openjdk.org/jdk/pull/26101#discussion_r2189274053


More information about the hotspot-dev mailing list