| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 143 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 144 | 144 |
| 145 // If the second argument is a smi, it is much faster to call the | 145 // If the second argument is a smi, it is much faster to call the |
| 146 // custom powi() function than the generic pow(). | 146 // custom powi() function than the generic pow(). |
| 147 if (args[1]->IsSmi()) { | 147 if (args[1]->IsSmi()) { |
| 148 int y = args.smi_at(1); | 148 int y = args.smi_at(1); |
| 149 return *isolate->factory()->NewNumber(power_double_int(x, y)); | 149 return *isolate->factory()->NewNumber(power_double_int(x, y)); |
| 150 } | 150 } |
| 151 | 151 |
| 152 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 152 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 153 double result = power_helper(x, y); | 153 double result = power_helper(isolate, x, y); |
| 154 if (std::isnan(result)) return isolate->heap()->nan_value(); | 154 if (std::isnan(result)) return isolate->heap()->nan_value(); |
| 155 return *isolate->factory()->NewNumber(result); | 155 return *isolate->factory()->NewNumber(result); |
| 156 } | 156 } |
| 157 | 157 |
| 158 | 158 |
| 159 // Fast version of Math.pow if we know that y is not an integer and y is not | 159 // Fast version of Math.pow if we know that y is not an integer and y is not |
| 160 // -0.5 or 0.5. Used as slow case from full codegen. | 160 // -0.5 or 0.5. Used as slow case from full codegen. |
| 161 RUNTIME_FUNCTION(Runtime_MathPowRT) { | 161 RUNTIME_FUNCTION(Runtime_MathPowRT) { |
| 162 HandleScope scope(isolate); | 162 HandleScope scope(isolate); |
| 163 DCHECK(args.length() == 2); | 163 DCHECK(args.length() == 2); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 return *isolate->factory()->NewNumber(Floor(value + 0.5)); | 217 return *isolate->factory()->NewNumber(Floor(value + 0.5)); |
| 218 } | 218 } |
| 219 | 219 |
| 220 | 220 |
| 221 RUNTIME_FUNCTION(Runtime_MathSqrt) { | 221 RUNTIME_FUNCTION(Runtime_MathSqrt) { |
| 222 HandleScope scope(isolate); | 222 HandleScope scope(isolate); |
| 223 DCHECK(args.length() == 1); | 223 DCHECK(args.length() == 1); |
| 224 isolate->counters()->math_sqrt()->Increment(); | 224 isolate->counters()->math_sqrt()->Increment(); |
| 225 | 225 |
| 226 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 226 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 227 return *isolate->factory()->NewNumber(fast_sqrt(x)); | 227 lazily_initialize_fast_sqrt(isolate); |
| 228 return *isolate->factory()->NewNumber(fast_sqrt(x, isolate)); |
| 228 } | 229 } |
| 229 | 230 |
| 230 | 231 |
| 231 RUNTIME_FUNCTION(Runtime_MathFround) { | 232 RUNTIME_FUNCTION(Runtime_MathFround) { |
| 232 HandleScope scope(isolate); | 233 HandleScope scope(isolate); |
| 233 DCHECK(args.length() == 1); | 234 DCHECK(args.length() == 1); |
| 234 | 235 |
| 235 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 236 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 236 float xf = DoubleToFloat32(x); | 237 float xf = DoubleToFloat32(x); |
| 237 return *isolate->factory()->NewNumber(xf); | 238 return *isolate->factory()->NewNumber(xf); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 base::RandomNumberGenerator::XorShift128(&state0, &state1); | 289 base::RandomNumberGenerator::XorShift128(&state0, &state1); |
| 289 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); | 290 array[i] = base::RandomNumberGenerator::ToDouble(state0, state1); |
| 290 } | 291 } |
| 291 // Persist current state. | 292 // Persist current state. |
| 292 array[kState0Offset] = uint64_to_double(state0); | 293 array[kState0Offset] = uint64_to_double(state0); |
| 293 array[kState1Offset] = uint64_to_double(state1); | 294 array[kState1Offset] = uint64_to_double(state1); |
| 294 return *typed_array; | 295 return *typed_array; |
| 295 } | 296 } |
| 296 } // namespace internal | 297 } // namespace internal |
| 297 } // namespace v8 | 298 } // namespace v8 |
| OLD | NEW |