On Wed, 10 Jun 2026 12:39:07 GMT, Dingli Zhang <[email protected]> wrote:
>> This small change enables support for the with-hsdis=capstone option for the >> RISC-V target. >> It could be done because libcapstone is available in apt repositories. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > make/Hsdis.gmk line 52: > >> 50: else ifeq ($(call isTargetCpuArch, riscv), true) >> 51: CAPSTONE_ARCH := CS_ARCH_RISCV >> 52: CAPSTONE_MODE := CS_MODE_RISCV64 > > Thanks for this patch! > I also tested both cross-compilation and a native build, and both worked fine > with this change. > > Suggestion: > > CAPSTONE_MODE := 'CS_MODE_RISCV64|CS_MODE_RISCVC' > > > I have one small question: would it make sense to enable `CS_MODE_RISCVC` > here as well? > On rv64gc boards, this can be observed easily with `-XX:+PrintAssembly`: many > compressed instructions are not decoded and are shown as `.byte` instead. > > Although the RISC-V port wiki describes RV64G as the supported base > configuration and lists RVC as an explicitly enabled feature, RVC is widely > assumed in Linux-capable riscv64 environments today. I've just tested with a cross-compile and I see the same as @DingliZhang: [Instructions begin] ;; block B1 [0, 0] 0x0000003f983fe100: .byte 0x01, 0x00, 0x01, 0x00 0x0000003f983fe104: .byte 0x01, 0x00, 0x01, 0x00 0x0000003f983fe108: .byte 0x01, 0x00, 0x01, 0x00 0x0000003f983fe10c: .byte 0x01, 0x00, 0x01, 0x00 0x0000003f983fe110: .byte 0x01, 0x00, 0x01, 0x00 0x0000003f983fe114: .byte 0x01, 0x00, 0x01, 0x00 0x0000003f983fe118: .byte 0x01, 0x00, 0x01, 0x00 0x0000003f983fe11c: .byte 0x01, 0x00, 0x01, 0x00 0x0000003f983fe120: .byte 0x01, 0x00, 0x01, 0x00 0x0000003f983fe124: .byte 0x01, 0x00, 0x01, 0x00 [Entry Point] # {method} {0x0000003f3b0005f8} '''<init>''' '''()V''' in '''java/lang/Object''' # [sp+0x30] (sp of caller) 0x0000003f983fe128: ld t1, 0(a1) 0x0000003f983fe12c: srli t1, t1, 0x2a 0x0000003f983fe130: lwu t2, 8(t0) 0x0000003f983fe134: beq t1, t2, 0xc 0x0000003f983fe138: auipc t1, 0x7642 ; {runtime_call ic_miss_blob (shared runtime)} 0x0000003f983fe13c: jalr zero, t1, 0x2c8 ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/31424#discussion_r3397526434
