RFR: 8315716: RISC-V: implement ChaCha20 intrinsic
Hamlin Li
mli at openjdk.org
Wed Sep 27 10:09:44 UTC 2023
On Mon, 25 Sep 2023 18:42:15 GMT, Antonios Printezis <tonyp 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`?
sure
> 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.
Is there a difference between mv and li? Seems that mv(...) is calling li(...)?
template<typename T, ENABLE_IF(std::is_integral<T>::value)>
inline void mv(Register Rd, T o) { li(Rd, (int64_t)o); }
Or the recommendation is a code convention?
> 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?
Nice catch! Thanks Tony!
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15899#discussion_r1337584807
PR Review Comment: https://git.openjdk.org/jdk/pull/15899#discussion_r1337578231
PR Review Comment: https://git.openjdk.org/jdk/pull/15899#discussion_r1337573555
More information about the hotspot-dev
mailing list