On Sat, 12 Nov 2022 01:35:39 GMT, Vladimir Ivanov <[email protected]> wrote:
>> Claes Redestad has updated the pull request incrementally with one
>> additional commit since the last revision:
>>
>> Missing & 0xff in StringLatin1::hashCode
>
> src/java.base/share/classes/jdk/internal/util/ArraysSupport.java line 185:
>
>> 183: */
>> 184: @IntrinsicCandidate
>> 185: public static int vectorizedHashCode(Object array, byte mode) {
>
> The intrinsic can be generalized by:
> 1. expanding `array` input into `base`, `offset`, and `length`. It will make
> it applicable to any type of data source (on-heap/off-heap `ByteBuffer`s,
> `MemorySegment`s.
> 2. passing initial value as a parameter.
>
> Basically, hash code computation can be represented as a reduction:
> `reduce(initial_val, (acc, v) -> 31 * acc + v, data)`. You hardcode the
> operation, but can make the rest variable.
>
> (Even the operation can be slightly generalized if you make 31 variable and
> then precompute the table at runtime. But right now I don't see much value in
> investing into that.)
I've been thinking of generalizing as thus as a possible follow-up: get the
base operation on entire arrays in, then generalize carefully while ensuring
that doesn't add too much complexity, introduce unforeseen overheads etc.
-------------
PR: https://git.openjdk.org/jdk/pull/10847