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" |
11 #include "src/codegen.h" | 11 #include "src/codegen.h" |
12 #include "src/third_party/fdlibm/fdlibm.h" | 12 #include "src/third_party/fdlibm/fdlibm.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 #define RUNTIME_UNARY_MATH(Name, name) \ | |
18 RUNTIME_FUNCTION(Runtime_Math##Name) { \ | |
19 HandleScope scope(isolate); \ | |
20 DCHECK(args.length() == 1); \ | |
21 isolate->counters()->math_##name##_runtime()->Increment(); \ | |
22 CONVERT_DOUBLE_ARG_CHECKED(x, 0); \ | |
23 return *isolate->factory()->NewHeapNumber(std::name(x)); \ | |
24 } | |
25 | |
26 RUNTIME_UNARY_MATH(LogRT, log) | |
27 #undef RUNTIME_UNARY_MATH | |
28 | |
29 | |
30 RUNTIME_FUNCTION(Runtime_DoubleHi) { | 17 RUNTIME_FUNCTION(Runtime_DoubleHi) { |
31 HandleScope scope(isolate); | 18 HandleScope scope(isolate); |
32 DCHECK(args.length() == 1); | 19 DCHECK(args.length() == 1); |
33 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 20 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
34 uint64_t unsigned64 = double_to_uint64(x); | 21 uint64_t unsigned64 = double_to_uint64(x); |
35 uint32_t unsigned32 = static_cast<uint32_t>(unsigned64 >> 32); | 22 uint32_t unsigned32 = static_cast<uint32_t>(unsigned64 >> 32); |
36 int32_t signed32 = bit_cast<int32_t, uint32_t>(unsigned32); | 23 int32_t signed32 = bit_cast<int32_t, uint32_t>(unsigned32); |
37 return *isolate->factory()->NewNumber(signed32); | 24 return *isolate->factory()->NewNumber(signed32); |
38 } | 25 } |
39 | 26 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 base::RandomNumberGenerator::XorShift128(&state0, &state1); | 187 base::RandomNumberGenerator::XorShift128(&state0, &state1); |
201 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); | 188 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); |
202 } | 189 } |
203 // Persist current state. | 190 // Persist current state. |
204 array[kState0Offset] = uint64_to_double(state0); | 191 array[kState0Offset] = uint64_to_double(state0); |
205 array[kState1Offset] = uint64_to_double(state1); | 192 array[kState1Offset] = uint64_to_double(state1); |
206 return *typed_array; | 193 return *typed_array; |
207 } | 194 } |
208 } // namespace internal | 195 } // namespace internal |
209 } // namespace v8 | 196 } // namespace v8 |
OLD | NEW |