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/codegen.h" | 10 #include "src/codegen.h" |
10 #include "src/third_party/fdlibm/fdlibm.h" | 11 #include "src/third_party/fdlibm/fdlibm.h" |
11 | 12 |
12 namespace v8 { | 13 namespace v8 { |
13 namespace internal { | 14 namespace internal { |
14 | 15 |
15 #define RUNTIME_UNARY_MATH(Name, name) \ | 16 #define RUNTIME_UNARY_MATH(Name, name) \ |
16 RUNTIME_FUNCTION(Runtime_Math##Name) { \ | 17 RUNTIME_FUNCTION(Runtime_Math##Name) { \ |
17 HandleScope scope(isolate); \ | 18 HandleScope scope(isolate); \ |
18 DCHECK(args.length() == 1); \ | 19 DCHECK(args.length() == 1); \ |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 238 |
238 | 239 |
239 RUNTIME_FUNCTION(Runtime_IsMinusZero) { | 240 RUNTIME_FUNCTION(Runtime_IsMinusZero) { |
240 SealHandleScope shs(isolate); | 241 SealHandleScope shs(isolate); |
241 DCHECK(args.length() == 1); | 242 DCHECK(args.length() == 1); |
242 CONVERT_ARG_CHECKED(Object, obj, 0); | 243 CONVERT_ARG_CHECKED(Object, obj, 0); |
243 if (!obj->IsHeapNumber()) return isolate->heap()->false_value(); | 244 if (!obj->IsHeapNumber()) return isolate->heap()->false_value(); |
244 HeapNumber* number = HeapNumber::cast(obj); | 245 HeapNumber* number = HeapNumber::cast(obj); |
245 return isolate->heap()->ToBoolean(IsMinusZero(number->value())); | 246 return isolate->heap()->ToBoolean(IsMinusZero(number->value())); |
246 } | 247 } |
| 248 |
| 249 |
| 250 RUNTIME_FUNCTION(Runtime_InitializeRNG) { |
| 251 HandleScope scope(isolate); |
| 252 DCHECK(args.length() == 0); |
| 253 static const int kSize = 4; |
| 254 Handle<FixedArray> array = isolate->factory()->NewFixedArray(kSize); |
| 255 uint16_t seeds[kSize]; |
| 256 do { |
| 257 isolate->random_number_generator()->NextBytes(seeds, |
| 258 kSize * sizeof(*seeds)); |
| 259 } while (!(seeds[0] && seeds[1] && seeds[2] && seeds[3])); |
| 260 for (int i = 0; i < kSize; i++) array->set(i, Smi::FromInt(seeds[i])); |
| 261 return *isolate->factory()->NewJSArrayWithElements(array); |
| 262 } |
247 } // namespace internal | 263 } // namespace internal |
248 } // namespace v8 | 264 } // namespace v8 |
OLD | NEW |