RFR: 8315716: RISC-V: implement ChaCha20 intrinsic

Robbin Ehn rehn at openjdk.org
Wed Sep 27 10:09:44 UTC 2023


On Mon, 25 Sep 2023 17:53:37 GMT, Hamlin Li <mli at openjdk.org> wrote:

>> At https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#7-vector-loads-and-stores, there is a statement, ```Vector loads and stores can be masked, and they only access memory or raise exceptions for active elements.```
>> Seems it will not "touch memory outside of the arrays" when store back to key stream array(which in java heap)
>
> Anyway, I think your suggestion make more sense, I've modified as you suggested.
> Thanks Robbin for the detailed reviewing!

It's the paragraph above:

The tail elements during a vector instruction’s execution are the elements past the current vector length setting specified in vl.


This means they are outside of your working set (body).


When a set is marked agnostic, the corresponding set of destination elements in any vector destination operand
can either retain the value they previously held, or are overwritten with 1s. Within a single vector instruction, each
destination element can be either left undisturbed or overwritten with 1s, in any combination, and the pattern of
undisturbed or overwritten with 1s is not required to be deterministic when the instruction is executed with the same
inputs.


Maybe this can't happen here since you work with such nice size.
But the arrays result and startState will be initialized to zero when allocated.
We don't want anything changing bytes which the VM didn't write to and we must be sure never to write outside of these. 

So tail is what comes after you data, in our case that will be Java heap, so we must always be sure only to write to the body.

Did that make sense?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15899#discussion_r1336226148


More information about the hotspot-dev mailing list