On Mon, 30 Mar 2026 14:45:06 GMT, Aleksey Shipilev <[email protected]> wrote:

>> Andrew Haley has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   Fix up any out-of-range offsets
>
> src/hotspot/share/runtime/javaThread.cpp line 546:
> 
>> 544:     do {
>> 545:       state = os::random();
>> 546:     } while (state == 0);
> 
> Curious: why should not the initial state be zero?

When we're using CRC (i.e. a linear-feedback shift register) to generate random 
data, each step shifts the current state left by n bits then takes the 
remainder modulo some big binary polynomial. This is great unless you start 
with zero, in which case all results are zero. The alternative is to add a 
small constant every time, but unless that constant is carefully chosen you can 
get short cycles. Better to start with nonzero.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28541#discussion_r3010901379

Reply via email to