RFR: 8294087: RISC-V: RVC: Fix a potential alignment issue and add more alignment assertions for the patchable calls/nops [v7]

Feilong Jiang fjiang at openjdk.org
Thu Sep 22 06:16:23 UTC 2022


On Thu, 22 Sep 2022 05:57:03 GMT, Xiaolin Zheng <xlinzheng at openjdk.org> wrote:

>> With RVC turning on, we must carefully keep all runtime-patchable instructions aligned. Code is running at full speed, when patching unaligned instructions spanning cache lines, concurrency issues may occur. This patch fixes a potential alignment issue of the patchable nop after MachUEPNode, with adding some strong alignment assertions as well. (In fact, currently the `nop` in the Verified Entry Point is fortunately aligned to 4 under RVC even without this patch, so this patch doesn't change program behaviors.)
>> 
>> Tested hotspot tier1 and tier2 together with other patches on QEMU.
>
> Xiaolin Zheng has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Simply unify a remaining assertion

src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp line 1375:

> 1373: void LIR_Assembler::emit_static_call_stub() {
> 1374:   address call_pc = __ pc();
> 1375:   __ assert_alignment(call_pc);

As `assert_alignment` is defined as a  static method, there is no need for `__`. `MacroAssembler::assert_alignment(call_pc)` would be better.

src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp line 265:

> 263:     __ bind(local_guard);
> 264: 
> 265:     __ assert_alignment(__ pc());

ditto

src/hotspot/cpu/riscv/riscv.ad line 1321:

> 1319:   // insert a nop at the start of the prolog so we can patch in a
> 1320:   // branch if we need to invalidate the method later
> 1321:   __ assert_alignment(__ pc());

ditto

src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp line 1143:

> 1141: 
> 1142:     // First instruction must be a nop as it may need to be patched on deoptimisation
> 1143:     __ assert_alignment(__ pc());

ditto

src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp line 1295:

> 1293:   // If we have to make this method not-entrant we'll overwrite its
> 1294:   // first instruction with a jump.
> 1295:   __ assert_alignment(__ pc());

ditto

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

PR: https://git.openjdk.org/jdk/pull/10370


More information about the hotspot-dev mailing list