-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Math.random to use xorshift128+ #145
Conversation
Hi @suwc, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
TTYL, MSBOT; |
Reviewers: @LouisLaf @ianwjhalliday @abchatra |
👏 Change looks good to me. |
Looks good to me as well. |
Yep, LGTM too |
seed = s1.QuadPart; | ||
|
||
ThreadContext *threadContext = scriptContext->GetThreadContext(); | ||
threadContext->GetEntropy().AddThreadCycleTime(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like entropy class isn't used anymore, so imo we should get rid of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entropy class is used for telemetry and cannot be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that rand_s() calls may fail, entropy class call is added back in as a backup.
…ath.random() from linear congruential generator (LCG) to xorshift128+ (http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf) to be interoperable with other browsers: http://jandemooij.nl/blog/2015/11/30/testing-math-random-crushing-the-browser/ https://bugzilla.mozilla.org/show_bug.cgi?id=322529 http://v8project.blogspot.com/2015/12/theres-mathrandom-and-then-theres.html Also included: - inlining of Math.random() for X64 - override switches for PRNG seeds This change pass all 96 TestU01 Crush tests.
Addressing #31
Update the underlying pseudo-random number generator (PRNG) used by Math.random() from
linear congruential generator (LCG) to xorshift128+ (http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf)
to be interoperable with other browsers:
http://jandemooij.nl/blog/2015/11/30/testing-math-random-crushing-the-browser/
https://bugzilla.mozilla.org/show_bug.cgi?id=322529
http://v8project.blogspot.com/2015/12/theres-mathrandom-and-then-theres.html
Also included:
This change passed all 96 TestU01 Crush tests.