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

Xiaolin Zheng xlinzheng at openjdk.java.net
Tue Feb 15 06:41:38 UTC 2022

On Tue, 15 Feb 2022 06:22:03 GMT, Yadong Wang <yadongwang at openjdk.org> wrote:

>> Xiaolin Zheng has updated the pull request incrementally with two additional commits since the last revision:
>>  - Remove local vars
>>  - A little optimization
> 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?


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

More information about the riscv-port-dev mailing list