RFR: 8291550: RISC-V: jdk uses misaligned memory access when AvoidUnalignedAccess enabled [v3]
Fei Yang
fyang at openjdk.org
Fri Apr 28 04:11:24 UTC 2023
On Wed, 26 Apr 2023 10:40:28 GMT, Vladimir Kempik <vkempik at openjdk.org> wrote:
>> Please review this attempt to remove misaligned loads and stores in risc-v specific part of jdk.
>>
>> The patch has two main parts:
>> - opcodes loads/stores is now using put_native_uX/get_native_uX
>> - some code in template interp got changed to prevent misaligned loads
>>
>> perf stat numbers for trp_lam ( misaligned loads) and trp_sam ( misaligned stores) before the patch:
>>
>> 169598 trp_lam
>> 13562 trp_sam
>>
>>
>> after the patch both numbers are zeroes.
>> I can see template interpreter to be ~40 % faster on hifive unmatched ( 1 repetition of renaissance philosophers in -Xint mode), and the same performance ( before and after the patch) on thead rvb-ice ( which supports misaligned stores/loads in hw)
>>
>> tier testing on hw is in progress
>
> Vladimir Kempik has updated the pull request incrementally with one additional commit since the last revision:
>
> spaces
src/hotspot/cpu/riscv/assembler_riscv.hpp line 1955:
> 1953: target &= ~mask;
> 1954: target |= val;
> 1955: sd_c_instr(a, target);
Compressed instructions are supposed to be located at some addresses at least 2-bytes aligned. So I am thinking that there shouldn't be any unaligned access happening here.
src/hotspot/cpu/riscv/macroAssembler_riscv.hpp line 349:
> 347: #define assert_addr_alignment_cond(cond, addr) assert(!(cond) || is_aligned(addr, 4), "bad addr alignment: " INTPTR_FORMAT, p2i(addr))
> 348: #define assert_addr_alignment(addr) assert_addr_alignment_cond(true, addr)
> 349: #define assert_offset_alignment_cond(cond, offset) assert(!(cond) || ((offset) % 4) == 0, "bad offset alignment: %d", offset)
Looks like these macros are not used anywhere?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13645#discussion_r1179903107
PR Review Comment: https://git.openjdk.org/jdk/pull/13645#discussion_r1179903332
More information about the hotspot-dev
mailing list