| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 222 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 223 lazily_initialize_fast_sqrt(isolate); | 223 lazily_initialize_fast_sqrt(isolate); |
| 224 return *isolate->factory()->NewNumber(fast_sqrt(x, isolate)); | 224 return *isolate->factory()->NewNumber(fast_sqrt(x, isolate)); |
| 225 } | 225 } |
| 226 | 226 |
| 227 | 227 |
| 228 RUNTIME_FUNCTION(Runtime_GenerateRandomNumbers) { | 228 RUNTIME_FUNCTION(Runtime_GenerateRandomNumbers) { |
| 229 HandleScope scope(isolate); | 229 HandleScope scope(isolate); |
| 230 DCHECK(args.length() == 1); | 230 DCHECK(args.length() == 1); |
| 231 // Random numbers in the snapshot are not really that random. | 231 // Random numbers in the snapshot are not really that random. |
| 232 DCHECK(!isolate->bootstrapper()->IsActive()); | 232 CHECK(!isolate->serializer_enabled()); |
| 233 static const int kState0Offset = 0; | 233 static const int kState0Offset = 0; |
| 234 static const int kState1Offset = 1; | 234 static const int kState1Offset = 1; |
| 235 static const int kRandomBatchSize = 64; | 235 static const int kRandomBatchSize = 64; |
| 236 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_typed_array, 0); | 236 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_typed_array, 0); |
| 237 Handle<JSTypedArray> typed_array; | 237 Handle<JSTypedArray> typed_array; |
| 238 // Allocate typed array if it does not yet exist. | 238 // Allocate typed array if it does not yet exist. |
| 239 if (maybe_typed_array->IsJSTypedArray()) { | 239 if (maybe_typed_array->IsJSTypedArray()) { |
| 240 typed_array = Handle<JSTypedArray>::cast(maybe_typed_array); | 240 typed_array = Handle<JSTypedArray>::cast(maybe_typed_array); |
| 241 } else { | 241 } else { |
| 242 static const int kByteLength = kRandomBatchSize * kDoubleSize; | 242 static const int kByteLength = kRandomBatchSize * kDoubleSize; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 265 base::RandomNumberGenerator::XorShift128(&state0, &state1); | 265 base::RandomNumberGenerator::XorShift128(&state0, &state1); |
| 266 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); | 266 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); |
| 267 } | 267 } |
| 268 // Persist current state. | 268 // Persist current state. |
| 269 array[kState0Offset] = uint64_to_double(state0); | 269 array[kState0Offset] = uint64_to_double(state0); |
| 270 array[kState1Offset] = uint64_to_double(state1); | 270 array[kState1Offset] = uint64_to_double(state1); |
| 271 return *typed_array; | 271 return *typed_array; |
| 272 } | 272 } |
| 273 } // namespace internal | 273 } // namespace internal |
| 274 } // namespace v8 | 274 } // namespace v8 |
| OLD | NEW |