3 ms·
> here was the comment above the previous implementation That's about a different RNG than the one that Mike Malone's article was about. The one you're pointin
by magicalist 11y ago
> here was the comment above the previous implementation
That's about a different RNG than the one that Mike Malone's article was about. The one you're pointing to was used on the C++ side of the world (and so doesn't have the concerns of JS numbers), the one the article was about was pure JS.
Part of the V8 update was to unify the RNGs (see the patch history), so now both use the same (better) RNG. On the JS side, the new C++ RNG is now used to fill a buffer of random numbers to amortize the cost of calling into C++ code from JS.
As for why these implementations were chosen: Mike Malone covers the commit history and probable source of the JS implementation fairly well (which is probably all you'll really get since it's been 6 years or so now). The old C++ implementation is relatively recent, with some hints to its choosing here: https://github.com/v8/v8/commit/eb381b9444c6b1ec78414d1c9375f67c320cae74 https://github.com/v8/v8/commit/eb381b9444c6b1ec78414d1c9375...