--- a/src/java.base/share/classes/java/util/random/Xoroshiro128StarStar.java Thu Aug 29 11:33:26 2019 -0300
+++ b/src/java.base/share/classes/java/util/random/Xoroshiro128StarStar.java Thu Nov 14 08:54:56 2019 -0400
@@ -154,9 +154,8 @@
this.x1 = x1;
// If x0 and x1 are both zero, we must choose nonzero values.
if ((x0 | x1) == 0) {
- // At least one of the two values generated here will be nonzero.
- this.x0 = RandomSupport.mixStafford13(x0 += RandomSupport.GOLDEN_RATIO_64);
- this.x1 = (x0 += RandomSupport.GOLDEN_RATIO_64);
+ this.x0 = RandomSupport.GOLDEN_RATIO_64;
+ this.x1 = RandomSupport.SILVER_RATIO_64;
}
}
@@ -244,13 +243,15 @@
public long nextLong() {
final long s0 = x0;
long s1 = x1;
- final long z = s0;
+ // Compute the result based on current state information
+ // (this allows the computation to be overlapped with state update).
+ final long result = Long.rotateLeft(s0 * 5, 7) * 9; // "starstar" mixing function
s1 ^= s0;
x0 = Long.rotateLeft(s0, 24) ^ s1 ^ (s1 << 16); // a, b
x1 = Long.rotateLeft(s1, 37); // c
- return Long.rotateLeft(z * 5, 7) * 9; // "starstar" mixing function
+ return result;
}
public BigInteger period() {