Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(847)

Issue 104083003: Change dart2js' Random to honor the seed. (Closed)

Created:
7 years ago by Lasse Reichstein Nielsen
Modified:
7 years ago
Reviewers:
floitsch, ngeoffray
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Change dart2js' Random to honor the seed. Simulate the same RNG as the VM when a seed is passed. BUG= http://dartbug.com/15426 R=floitsch@google.com Committed: https://code.google.com/p/dart/source/detail?r=30893 Committed: https://code.google.com/p/dart/source/detail?r=30894

Patch Set 1 #

Total comments: 14

Patch Set 2 : Typo in comment. #

Patch Set 3 : Better generated code by using | instead of >> 0 #

Patch Set 4 : Address comments. #

Total comments: 10

Patch Set 5 : Address comments. #

Patch Set 6 : Fix typo #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1 line, -1 line) Patch
M sdk/lib/_internal/lib/math_patch.dart View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 9 (0 generated)
Lasse Reichstein Nielsen
7 years ago (2013-12-04 10:28:27 UTC) #1
ngeoffray
https://codereview.chromium.org/104083003/diff/1/sdk/lib/_internal/lib/math_patch.dart File sdk/lib/_internal/lib/math_patch.dart (right): https://codereview.chromium.org/104083003/diff/1/sdk/lib/_internal/lib/math_patch.dart#newcode97 sdk/lib/_internal/lib/math_patch.dart:97: _hi = (seed - _lo) ~/ _POW2_32; USe >> ...
7 years ago (2013-12-04 11:22:15 UTC) #2
ngeoffray
7 years ago (2013-12-04 11:22:16 UTC) #3
Lasse Reichstein Nielsen
https://codereview.chromium.org/104083003/diff/1/sdk/lib/_internal/lib/math_patch.dart File sdk/lib/_internal/lib/math_patch.dart (right): https://codereview.chromium.org/104083003/diff/1/sdk/lib/_internal/lib/math_patch.dart#newcode97 sdk/lib/_internal/lib/math_patch.dart:97: _hi = (seed - _lo) ~/ _POW2_32; Doesn't work, ...
7 years ago (2013-12-04 13:48:14 UTC) #4
floitsch
LGTM. https://codereview.chromium.org/104083003/diff/60001/sdk/lib/_internal/lib/math_patch.dart File sdk/lib/_internal/lib/math_patch.dart (right): https://codereview.chromium.org/104083003/diff/60001/sdk/lib/_internal/lib/math_patch.dart#newcode109 sdk/lib/_internal/lib/math_patch.dart:109: // The constant A is selected from "Numerical ...
7 years ago (2013-12-04 15:18:44 UTC) #5
Lasse Reichstein Nielsen
https://codereview.chromium.org/104083003/diff/60001/sdk/lib/_internal/lib/math_patch.dart File sdk/lib/_internal/lib/math_patch.dart (right): https://codereview.chromium.org/104083003/diff/60001/sdk/lib/_internal/lib/math_patch.dart#newcode109 sdk/lib/_internal/lib/math_patch.dart:109: // The constant A is selected from "Numerical Recipes ...
7 years ago (2013-12-05 13:06:13 UTC) #6
Lasse Reichstein Nielsen
Committed patchset #5 manually as r30893 (presubmit successful).
7 years ago (2013-12-05 13:07:01 UTC) #7
Lasse Reichstein Nielsen
Committed patchset #6 manually as r30894 (presubmit successful).
7 years ago (2013-12-05 13:19:21 UTC) #8
floitsch
7 years ago (2013-12-05 14:25:42 UTC) #9
Message was sent while issue was closed.
https://codereview.chromium.org/104083003/diff/60001/sdk/lib/_internal/lib/ma...
File sdk/lib/_internal/lib/math_patch.dart (right):

https://codereview.chromium.org/104083003/diff/60001/sdk/lib/_internal/lib/ma...
sdk/lib/_internal/lib/math_patch.dart:149: result = rnd32 % max;
On 2013/12/05 13:06:14, Lasse Reichstein Nielsen wrote:
> Better code generated, yey!
> 
> Could ofcourse still be smaller using JS("int", "# % #", rnd32, max), by
> avoiding the null check on rnd32.
> 
> The generated code is:
>     rnd32.toString;  // I assume this is a null test.
>     result = rnd32 % max;   //
> The null test might not be necessary because the next operation will also fail
> on a null (but that's just an optimization for dart2js).

null & x is a valid expression in JS...

Powered by Google App Engine
This is Rietveld 408576698