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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 DCHECK(args.length() == 2); | 52 DCHECK(args.length() == 2); |
53 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 53 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
54 CONVERT_ARG_CHECKED(JSTypedArray, result, 1); | 54 CONVERT_ARG_CHECKED(JSTypedArray, result, 1); |
55 CHECK(result->byte_length() == Smi::FromInt(2 * sizeof(double))); | 55 CHECK(result->byte_length() == Smi::FromInt(2 * sizeof(double))); |
56 FixedFloat64Array* array = FixedFloat64Array::cast(result->elements()); | 56 FixedFloat64Array* array = FixedFloat64Array::cast(result->elements()); |
57 double* y = static_cast<double*>(array->DataPtr()); | 57 double* y = static_cast<double*>(array->DataPtr()); |
58 return Smi::FromInt(fdlibm::rempio2(x, y)); | 58 return Smi::FromInt(fdlibm::rempio2(x, y)); |
59 } | 59 } |
60 | 60 |
61 | 61 |
62 RUNTIME_FUNCTION(Runtime_MathExpRT) { | |
63 HandleScope scope(isolate); | |
64 DCHECK(args.length() == 1); | |
65 isolate->counters()->math_exp_runtime()->Increment(); | |
66 | |
67 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | |
68 lazily_initialize_fast_exp(isolate); | |
69 return *isolate->factory()->NewNumber(fast_exp(x, isolate)); | |
70 } | |
71 | |
72 | |
73 // Slow version of Math.pow. We check for fast paths for special cases. | 62 // Slow version of Math.pow. We check for fast paths for special cases. |
74 // Used if VFP3 is not available. | 63 // Used if VFP3 is not available. |
75 RUNTIME_FUNCTION(Runtime_MathPow) { | 64 RUNTIME_FUNCTION(Runtime_MathPow) { |
76 HandleScope scope(isolate); | 65 HandleScope scope(isolate); |
77 DCHECK(args.length() == 2); | 66 DCHECK(args.length() == 2); |
78 isolate->counters()->math_pow_runtime()->Increment(); | 67 isolate->counters()->math_pow_runtime()->Increment(); |
79 | 68 |
80 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 69 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
81 | 70 |
82 // If the second argument is a smi, it is much faster to call the | 71 // If the second argument is a smi, it is much faster to call the |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 base::RandomNumberGenerator::XorShift128(&state0, &state1); | 151 base::RandomNumberGenerator::XorShift128(&state0, &state1); |
163 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); | 152 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); |
164 } | 153 } |
165 // Persist current state. | 154 // Persist current state. |
166 array[kState0Offset] = uint64_to_double(state0); | 155 array[kState0Offset] = uint64_to_double(state0); |
167 array[kState1Offset] = uint64_to_double(state1); | 156 array[kState1Offset] = uint64_to_double(state1); |
168 return *typed_array; | 157 return *typed_array; |
169 } | 158 } |
170 } // namespace internal | 159 } // namespace internal |
171 } // namespace v8 | 160 } // namespace v8 |
OLD | NEW |