[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 03:57:08 UTC 2022


On Tue, 15 Feb 2022 01:44:49 GMT, Fei Yang <fyang 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.cpp line 88:
> 
>> 86: 
>> 87: bool NativeInstruction::is_movptr_at(address instr) {
>> 88:   address pos = instr;
> 
> Why introduce another local "pos" here? We could use input param "instr" directly.

done.

> src/hotspot/cpu/riscv/nativeInst_riscv.hpp line 107:
> 
>> 105:     address slli2 = addi2 + instruction_size;
>> 106:     address last_instr = slli2 + instruction_size;
>> 107:     return extract_rs1(addi1) == extract_rd(lui) &&
> 
> We are extracting the same thing more than once here and other places, which I think could be optimized.

Thanks for the suggestion - used local variables to optimize it.

-- Tested a `test/jtreg/hotspot/compiler` in Qemu with no other errors found.

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

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


More information about the riscv-port-dev mailing list