RFR: 8298075: RISC-V: Implement post-call NOPs [v3]
Fei Yang
fyang at openjdk.org
Tue Dec 6 07:50:07 UTC 2022
On Mon, 5 Dec 2022 04:53:06 GMT, Xiaolin Zheng <xlinzheng at openjdk.org> wrote:
>> Same as [JDK-8287567](https://bugs.openjdk.org/browse/JDK-8287567), we need to implement post-call NOPs in the RISC-V backend.
>>
>> We use `li32` to implement it. `li32` will signed-extend the loaded imm32 to a 64-bit register. However, our reader `NativePostCallNop::displacement()` only needs the low 32 bits value so we are safe.
>>
>> The current post-call NOP is like:
>>
>> nop (always 4-byte, used for deoptimization, please see `NativePostCallNop::make_deopt()`)
>> lui zr, <imm20> (always 4-byte)
>> addiw zr, zr, <imm12> (always 4-byte)
>>
>>
>> The code size here is the same as the AArch64 counterpart, 12 bytes.
>>
>> The logic of setting the post-call NOP displacement is at `install_post_call_nop_displacement()` [1] when nmethods are being installed, so no one is running post-call NOPs when we are patching them.
>>
>> One can check them by directly using `java --enable-preview -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly`.
>>
>> Tested hotspot tier1~4 and jdk tier1~4 using fastdebug by force turning on `--enable-preview`; SPECjbb2015 and dacapo were tested without regressions found. Skynet JMH benchmark seems to have an improvement from `8662ms/op -> 8495ms/op`.
>>
>> Thanks,
>> Xiaolin
>>
>> [1] https://github.com/openjdk/jdk/blob/b49fd920b6690a8b828c85e45c10e5c4c54d2022/src/hotspot/share/code/nmethod.cpp#L1078-L1107
>
> Xiaolin Zheng has updated the pull request incrementally with one additional commit since the last revision:
>
> Better to remove the ASSERT for we already use assert()
src/hotspot/cpu/riscv/nativeInst_riscv.cpp line 448:
> 446:
> 447: int NativePostCallNop::displacement() const {
> 448: // discard the high 32-bit
Suggestion: // Discard the high 32 bits
-------------
PR: https://git.openjdk.org/jdk/pull/11502
More information about the hotspot-dev
mailing list