OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // ES6 section 20.2.2.18 Math.hypot ( value1, value2, ...values ) | 353 // ES6 section 20.2.2.18 Math.hypot ( value1, value2, ...values ) |
354 BUILTIN(MathHypot) { | 354 BUILTIN(MathHypot) { |
355 HandleScope scope(isolate); | 355 HandleScope scope(isolate); |
356 int const length = args.length() - 1; | 356 int const length = args.length() - 1; |
357 if (length == 0) return Smi::kZero; | 357 if (length == 0) return Smi::kZero; |
358 DCHECK_LT(0, length); | 358 DCHECK_LT(0, length); |
359 double max = 0; | 359 double max = 0; |
360 bool one_arg_is_nan = false; | 360 bool one_arg_is_nan = false; |
361 List<double> abs_values(length); | 361 List<double> abs_values(length); |
362 for (int i = 0; i < length; i++) { | 362 for (int i = 0; i < length; i++) { |
363 Handle<Object> x = args.at<Object>(i + 1); | 363 Handle<Object> x = args.at(i + 1); |
364 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, x, Object::ToNumber(x)); | 364 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, x, Object::ToNumber(x)); |
365 double abs_value = std::abs(x->Number()); | 365 double abs_value = std::abs(x->Number()); |
366 | 366 |
367 if (std::isnan(abs_value)) { | 367 if (std::isnan(abs_value)) { |
368 one_arg_is_nan = true; | 368 one_arg_is_nan = true; |
369 } else { | 369 } else { |
370 abs_values.Add(abs_value); | 370 abs_values.Add(abs_value); |
371 if (max < abs_value) { | 371 if (max < abs_value) { |
372 max = abs_value; | 372 max = abs_value; |
373 } | 373 } |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 void Builtins::Generate_MathMax(MacroAssembler* masm) { | 570 void Builtins::Generate_MathMax(MacroAssembler* masm) { |
571 Generate_MathMaxMin(masm, MathMaxMinKind::kMax); | 571 Generate_MathMaxMin(masm, MathMaxMinKind::kMax); |
572 } | 572 } |
573 | 573 |
574 void Builtins::Generate_MathMin(MacroAssembler* masm) { | 574 void Builtins::Generate_MathMin(MacroAssembler* masm) { |
575 Generate_MathMaxMin(masm, MathMaxMinKind::kMin); | 575 Generate_MathMaxMin(masm, MathMaxMinKind::kMin); |
576 } | 576 } |
577 | 577 |
578 } // namespace internal | 578 } // namespace internal |
579 } // namespace v8 | 579 } // namespace v8 |
OLD | NEW |