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

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

Issue 1393373003: Remove isolate argument from handle allocation: Part I (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Cleanups Created 5 years, 2 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
« no previous file with comments | « no previous file | runtime/lib/mirrors.cc » ('j') | no next file with comments »
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/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/native_entry.h" 10 #include "vm/native_entry.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 const uint64_t state_hi = array.GetUint32(array.ElementSizeInBytes()); 103 const uint64_t state_hi = array.GetUint32(array.ElementSizeInBytes());
104 const uint64_t A = 0xffffda61; 104 const uint64_t A = 0xffffda61;
105 uint64_t state = (A * state_lo) + state_hi; 105 uint64_t state = (A * state_lo) + state_hi;
106 array.SetUint32(0, static_cast<uint32_t>(state)); 106 array.SetUint32(0, static_cast<uint32_t>(state));
107 array.SetUint32(array.ElementSizeInBytes(), 107 array.SetUint32(array.ElementSizeInBytes(),
108 static_cast<uint32_t>(state >> 32)); 108 static_cast<uint32_t>(state >> 32));
109 return Object::null(); 109 return Object::null();
110 } 110 }
111 111
112 112
113 RawTypedData* CreateRandomState(Isolate* isolate, uint64_t seed) { 113 RawTypedData* CreateRandomState(Zone* zone, uint64_t seed) {
114 const TypedData& result = TypedData::Handle( 114 const TypedData& result = TypedData::Handle(
115 isolate, TypedData::New(kTypedDataUint32ArrayCid, 2)); 115 zone, TypedData::New(kTypedDataUint32ArrayCid, 2));
116 result.SetUint32(0, static_cast<uint32_t>(seed)); 116 result.SetUint32(0, static_cast<uint32_t>(seed));
117 result.SetUint32(result.ElementSizeInBytes(), 117 result.SetUint32(result.ElementSizeInBytes(),
118 static_cast<uint32_t>(seed >> 32)); 118 static_cast<uint32_t>(seed >> 32));
119 return result.raw(); 119 return result.raw();
120 } 120 }
121 121
122 122
123 uint64_t mix64(uint64_t n) { 123 uint64_t mix64(uint64_t n) {
124 // Thomas Wang 64-bit mix. 124 // Thomas Wang 64-bit mix.
125 // http://www.concentric.net/~Ttwang/tech/inthash.htm 125 // http://www.concentric.net/~Ttwang/tech/inthash.htm
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 seed = (seed * 1037) ^ mix64(low64); 180 seed = (seed * 1037) ^ mix64(low64);
181 digit += 2; 181 digit += 2;
182 } while (digit < used); 182 } while (digit < used);
183 } else { 183 } else {
184 seed = mix64(static_cast<uint64_t>(seed_int.AsInt64Value())); 184 seed = mix64(static_cast<uint64_t>(seed_int.AsInt64Value()));
185 } 185 }
186 186
187 if (seed == 0) { 187 if (seed == 0) {
188 seed = 0x5a17; 188 seed = 0x5a17;
189 } 189 }
190 return CreateRandomState(isolate, seed); 190 return CreateRandomState(zone, seed);
191 } 191 }
192 192
193 193
194 DEFINE_NATIVE_ENTRY(Random_initialSeed, 0) { 194 DEFINE_NATIVE_ENTRY(Random_initialSeed, 0) {
195 Random* rnd = isolate->random(); 195 Random* rnd = isolate->random();
196 uint64_t seed = rnd->NextUInt32(); 196 uint64_t seed = rnd->NextUInt32();
197 seed |= (static_cast<uint64_t>(rnd->NextUInt32()) << 32); 197 seed |= (static_cast<uint64_t>(rnd->NextUInt32()) << 32);
198 return CreateRandomState(isolate, seed); 198 return CreateRandomState(zone, seed);
199 } 199 }
200 200
201 } // namespace dart 201 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/mirrors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698