[test] Ensure random generator in JSTests does not use float arithmetic

Change-Id: I3530c3f50fdb805d68099108dc33d93abe6bdb39
Bug: v8:8344
Reviewed-on: https://chromium-review.googlesource.com/c/1379931
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58267}
This commit is contained in:
Sigurd Schneider 2018-12-17 10:25:13 +01:00 committed by Commit Bot
parent 3ad101f5bf
commit 6720666064
5 changed files with 5 additions and 0 deletions

View File

@ -87,6 +87,7 @@ Math.random = (function() {
var seed = 49734321; var seed = 49734321;
return function() { return function() {
// Robert Jenkins' 32 bit integer hash function. // Robert Jenkins' 32 bit integer hash function.
seed = seed & 0xffffffff;
seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff; seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff;
seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff; seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff;
seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff; seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff;

View File

@ -136,6 +136,7 @@ Math.random = (function() {
var seed = 49734321; var seed = 49734321;
return function() { return function() {
// Robert Jenkins' 32 bit integer hash function. // Robert Jenkins' 32 bit integer hash function.
seed = seed & 0xffffffff;
seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff; seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff;
seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff; seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff;
seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff; seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff;

View File

@ -106,6 +106,7 @@ BenchmarkSuite.ResetRNG = function() {
var seed = 49734321; var seed = 49734321;
return function() { return function() {
// Robert Jenkins' 32-bit integer hash function. // Robert Jenkins' 32-bit integer hash function.
seed = seed & 0xffffffff;
seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff; seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff;
seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff; seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff;
seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff; seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff;

View File

@ -60,6 +60,7 @@ function rand() {
// To make the test results predictable, we use a 100% deterministic // To make the test results predictable, we use a 100% deterministic
// alternative. // alternative.
// Robert Jenkins' 32 bit integer hash function. // Robert Jenkins' 32 bit integer hash function.
seed = seed & 0xffffffff;
seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff; seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff;
seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff; seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff;
seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff; seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff;

View File

@ -59,6 +59,7 @@ function rand() {
// To make the test results predictable, we use a 100% deterministic // To make the test results predictable, we use a 100% deterministic
// alternative. // alternative.
// Robert Jenkins' 32 bit integer hash function. // Robert Jenkins' 32 bit integer hash function.
seed = seed & 0xffffffff;
seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff; seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff;
seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff; seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff;
seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff; seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff;