OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/base/utils/random-number-generator.h" | 9 #include "src/base/utils/random-number-generator.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 RUNTIME_FUNCTION(Runtime_MathFround) { | 231 RUNTIME_FUNCTION(Runtime_MathFround) { |
232 HandleScope scope(isolate); | 232 HandleScope scope(isolate); |
233 DCHECK(args.length() == 1); | 233 DCHECK(args.length() == 1); |
234 | 234 |
235 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 235 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
236 float xf = DoubleToFloat32(x); | 236 float xf = DoubleToFloat32(x); |
237 return *isolate->factory()->NewNumber(xf); | 237 return *isolate->factory()->NewNumber(xf); |
238 } | 238 } |
239 | 239 |
240 | 240 |
241 RUNTIME_FUNCTION(Runtime_IsMinusZero) { | |
242 SealHandleScope shs(isolate); | |
243 DCHECK(args.length() == 1); | |
244 CONVERT_ARG_CHECKED(Object, obj, 0); | |
245 if (!obj->IsHeapNumber()) return isolate->heap()->false_value(); | |
246 HeapNumber* number = HeapNumber::cast(obj); | |
247 return isolate->heap()->ToBoolean(IsMinusZero(number->value())); | |
248 } | |
249 | |
250 | |
251 RUNTIME_FUNCTION(Runtime_GenerateRandomNumbers) { | 241 RUNTIME_FUNCTION(Runtime_GenerateRandomNumbers) { |
252 HandleScope scope(isolate); | 242 HandleScope scope(isolate); |
253 DCHECK(args.length() == 1); | 243 DCHECK(args.length() == 1); |
254 // Random numbers in the snapshot are not really that random. | 244 // Random numbers in the snapshot are not really that random. |
255 DCHECK(!isolate->bootstrapper()->IsActive()); | 245 DCHECK(!isolate->bootstrapper()->IsActive()); |
256 static const int kState0Offset = 0; | 246 static const int kState0Offset = 0; |
257 static const int kState1Offset = 1; | 247 static const int kState1Offset = 1; |
258 static const int kRandomBatchSize = 64; | 248 static const int kRandomBatchSize = 64; |
259 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_typed_array, 0); | 249 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_typed_array, 0); |
260 Handle<JSTypedArray> typed_array; | 250 Handle<JSTypedArray> typed_array; |
(...skipping 27 matching lines...) Expand all Loading... |
288 base::RandomNumberGenerator::XorShift128(&state0, &state1); | 278 base::RandomNumberGenerator::XorShift128(&state0, &state1); |
289 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); | 279 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); |
290 } | 280 } |
291 // Persist current state. | 281 // Persist current state. |
292 array[kState0Offset] = uint64_to_double(state0); | 282 array[kState0Offset] = uint64_to_double(state0); |
293 array[kState1Offset] = uint64_to_double(state1); | 283 array[kState1Offset] = uint64_to_double(state1); |
294 return *typed_array; | 284 return *typed_array; |
295 } | 285 } |
296 } // namespace internal | 286 } // namespace internal |
297 } // namespace v8 | 287 } // namespace v8 |
OLD | NEW |