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

Side by Side Diff: src/runtime/runtime-maths.cc

Issue 1425693006: Store RNG state on function context. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 | « src/runtime/runtime.h ('k') | src/third_party/fdlibm/fdlibm.js » ('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 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
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
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/third_party/fdlibm/fdlibm.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698