[riscv-port] RFR: 8281731: riscv: Refactor instruction extraction code in nativeInst_riscv.h/cpp [v2]

Yadong Wang yadongwang at openjdk.java.net
Wed Feb 16 03:09:42 UTC 2022


On Tue, 15 Feb 2022 06:38:09 GMT, Xiaolin Zheng <xlinzheng at openjdk.org> wrote:

>> src/hotspot/cpu/riscv/nativeInst_riscv.hpp line 160:
>> 
>>> 158:     const address addi4 = slli3 + instruction_size;
>>> 159:     const Register addi4_rs1 = extract_rs1(addi4);
>>> 160:     const Register addi4_rd  = extract_rd(addi4);
>> 
>> I don't think so many local variables are a good idea, at least it doesn't do much to improve readability, except to make the code verbose.
>
> In fact - I have the same thought though after revising the code. Seems sadly I cannot find a way to extract them only once and in the meantime keep the readability without introducing new local variables. I don't know - maybe turning back to [my original version](https://github.com/openjdk/riscv-port/blob/92273c63986eef7126194f32c28a915fb0abf11c/src/hotspot/cpu/riscv/nativeInst_riscv.hpp#L100-L116) is a choice?

Yes. In my personal opinion, it would be better.

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

PR: https://git.openjdk.java.net/riscv-port/pull/57


More information about the riscv-port-dev mailing list