RFR: 8298075: RISC-V: Implement post-call NOPs

Xiaolin Zheng xlinzheng at openjdk.org
Mon Dec 5 04:29:11 UTC 2022


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.

Thanks,
Xiaolin

[1] https://github.com/openjdk/jdk/blob/b49fd920b6690a8b828c85e45c10e5c4c54d2022/src/hotspot/share/code/nmethod.cpp#L1078-L1107

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

Commit messages:
 - May I take a ride?
 - RISC-V: Implement post-call NOPs

Changes: https://git.openjdk.org/jdk/pull/11502/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11502&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8298075
  Stats: 39 lines in 6 files changed: 32 ins; 0 del; 7 mod
  Patch: https://git.openjdk.org/jdk/pull/11502.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/11502/head:pull/11502

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


More information about the hotspot-dev mailing list