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

Side by Side Diff: runtime/lib/math.cc

Issue 200483003: - Do not rely on time to seed the default PRNG. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/math_patch.dart » ('j') | runtime/lib/math_patch.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <ctype.h> // isspace. 5 #include <ctype.h> // isspace.
6 6
7 #include "vm/bootstrap_natives.h" 7 #include "vm/bootstrap_natives.h"
8 8
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 if (seed == 0) { 172 if (seed == 0) {
173 seed = 0x5a17; 173 seed = 0x5a17;
174 } 174 }
175 array.SetUint32(0, static_cast<uint32_t>(seed)); 175 array.SetUint32(0, static_cast<uint32_t>(seed));
176 array.SetUint32(array.ElementSizeInBytes(), 176 array.SetUint32(array.ElementSizeInBytes(),
177 static_cast<uint32_t>(seed >> 32)); 177 static_cast<uint32_t>(seed >> 32));
178 return Object::null(); 178 return Object::null();
179 } 179 }
180 180
181
182 DEFINE_NATIVE_ENTRY(Random_initialSeed, 0) {
183 Random* rnd = isolate->random();
184 int64_t seed = rnd->NextUInt32();
185 seed |= (static_cast<int64_t>(rnd->NextUInt32())) << 32;
siva 2014/03/14 17:27:13 I would prefer seed |= (static_cast<int64_t>(rnd-
186 return Integer::New(seed);
187 }
188
181 } // namespace dart 189 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/math_patch.dart » ('j') | runtime/lib/math_patch.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698