RFR: 8315716: RISC-V: implement ChaCha20 intrinsic
Antonios Printezis
tonyp at openjdk.org
Wed Sep 27 10:09:43 UTC 2023
On Mon, 25 Sep 2023 11:47:40 GMT, Hamlin Li <mli at openjdk.org> wrote:
> Only vector version is included in this patch.
>
> ### Test
> The patch passed the jdk tests found via `find test/jdk/ -iname *ChaCha*`
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp line 4326:
> 4324: const Register tmp_addr = t1;
> 4325: const Register length = t2;
> 4326: const Register avl = x28;
Can you add the rest of the tmp registers to:
// temporary register(caller-save registers)
constexpr Register t0 = x5;
constexpr Register t1 = x6;
constexpr Register t2 = x7;
so you can use `t3` / `t4` here instead of `x28` / `x29`?
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp line 4338:
> 4336:
> 4337: RegSet saved_regs;
> 4338: __ push_reg(saved_regs, sp);
You're only using tmp registers it looks like? Is this needed, as the `saved_regs` set is empty?
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp line 4342:
> 4340: // Put 16 here, as com.sun.crypto.providerChaCha20Cipher.KS_MAX_LEN is 1024
> 4341: // in java level.
> 4342: __ li(avl, 16);
It's recommended to use `__ mv(avl, 16);` to copy a constant to a register.
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp line 4355:
> 4353:
> 4354: // Perform 10 iterations of the 8 quarter round set
> 4355: __ li(loop, 10);
`__ mv(loop, 10);`
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp line 4381:
> 4379:
> 4380: // Store result to key stream
> 4381: __ li(stride, 64);
`__ mv(stride, 64);`
src/hotspot/cpu/riscv/vm_version_riscv.cpp line 251:
> 249: FLAG_SET_DEFAULT(UseBlockZeroing, false);
> 250: }
> 251: if (UseRVV) {
What happens if someone enables `+UseChaCha20Intrinsics` without `+UseRVV`? Maybe check if `-UseRVV` and `+UseChaCha20Intrinsics` and disable it?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15899#discussion_r1336263149
PR Review Comment: https://git.openjdk.org/jdk/pull/15899#discussion_r1336260087
PR Review Comment: https://git.openjdk.org/jdk/pull/15899#discussion_r1336247004
PR Review Comment: https://git.openjdk.org/jdk/pull/15899#discussion_r1336248783
PR Review Comment: https://git.openjdk.org/jdk/pull/15899#discussion_r1336249320
PR Review Comment: https://git.openjdk.org/jdk/pull/15899#discussion_r1336241132
More information about the hotspot-dev
mailing list