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

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

Issue 140213003: - Large constants need to be marked as such. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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 | no next file » | 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/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // _state[kSTATE_HI] = seed >> 32; 119 // _state[kSTATE_HI] = seed >> 32;
120 DEFINE_NATIVE_ENTRY(Random_setupSeed, 2) { 120 DEFINE_NATIVE_ENTRY(Random_setupSeed, 2) {
121 GET_NON_NULL_NATIVE_ARGUMENT(Instance, receiver, arguments->NativeArgAt(0)); 121 GET_NON_NULL_NATIVE_ARGUMENT(Instance, receiver, arguments->NativeArgAt(0));
122 GET_NON_NULL_NATIVE_ARGUMENT(Integer, seed_int, arguments->NativeArgAt(1)); 122 GET_NON_NULL_NATIVE_ARGUMENT(Integer, seed_int, arguments->NativeArgAt(1));
123 const TypedData& array = TypedData::Handle(GetRandomStateArray(receiver)); 123 const TypedData& array = TypedData::Handle(GetRandomStateArray(receiver));
124 ASSERT(!seed_int.IsNull()); 124 ASSERT(!seed_int.IsNull());
125 ASSERT(!array.IsNull()); 125 ASSERT(!array.IsNull());
126 int64_t seed = 0; 126 int64_t seed = 0;
127 if (seed_int.IsBigint()) { 127 if (seed_int.IsBigint()) {
128 const Bigint& mask64 = Bigint::Handle( 128 const Bigint& mask64 = Bigint::Handle(
129 BigintOperations::NewFromUint64(0xffffffffffffffff)); 129 BigintOperations::NewFromUint64(0xffffffffffffffffLL));
130 Bigint& big_seed = Bigint::Handle(); 130 Bigint& big_seed = Bigint::Handle();
131 big_seed ^= seed_int.raw(); 131 big_seed ^= seed_int.raw();
132 Bigint& low64 = Bigint::Handle(); 132 Bigint& low64 = Bigint::Handle();
133 while (!big_seed.IsZero()) { 133 while (!big_seed.IsZero()) {
134 low64 = BigintOperations::BitAnd(big_seed, mask64); 134 low64 = BigintOperations::BitAnd(big_seed, mask64);
135 ASSERT(BigintOperations::FitsIntoUint64(low64)); 135 ASSERT(BigintOperations::FitsIntoUint64(low64));
136 seed ^= BigintOperations::ToUint64(low64); 136 seed ^= BigintOperations::ToUint64(low64);
137 big_seed = BigintOperations::ShiftRight(big_seed, 64); 137 big_seed = BigintOperations::ShiftRight(big_seed, 64);
138 } 138 }
139 } else { 139 } else {
140 seed = seed_int.AsInt64Value(); 140 seed = seed_int.AsInt64Value();
141 } 141 }
142 142
143 do { 143 do {
144 seed = seed + 0x5A17; 144 seed = seed + 0x5A17;
145 } while (seed == 0); 145 } while (seed == 0);
146 array.SetUint32(0, static_cast<uint32_t>(seed)); 146 array.SetUint32(0, static_cast<uint32_t>(seed));
147 array.SetUint32(array.ElementSizeInBytes(), 147 array.SetUint32(array.ElementSizeInBytes(),
148 static_cast<uint32_t>(seed >> 32)); 148 static_cast<uint32_t>(seed >> 32));
149 return Object::null(); 149 return Object::null();
150 } 150 }
151 151
152 } // namespace dart 152 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698