Index: src/builtins/builtins-math-gen.cc |
diff --git a/src/builtins/builtins-math.cc b/src/builtins/builtins-math-gen.cc |
similarity index 90% |
copy from src/builtins/builtins-math.cc |
copy to src/builtins/builtins-math-gen.cc |
index 2054e4e428d1c83cb653fba8382c53502a314195..4498dd853d2ce8858c60e550793f355f9b11e18f 100644 |
--- a/src/builtins/builtins-math.cc |
+++ b/src/builtins/builtins-math-gen.cc |
@@ -1,13 +1,11 @@ |
-// Copyright 2016 the V8 project authors. All rights reserved. |
+// Copyright 2017 the V8 project authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "src/builtins/builtins-utils.h" |
+#include "src/builtins/builtins-utils-gen.h" |
#include "src/builtins/builtins.h" |
#include "src/code-factory.h" |
#include "src/code-stub-assembler.h" |
-#include "src/counters.h" |
-#include "src/objects-inl.h" |
namespace v8 { |
namespace internal { |
@@ -333,58 +331,6 @@ TF_BUILTIN(MathFround, CodeStubAssembler) { |
Return(result); |
} |
-// ES6 section 20.2.2.18 Math.hypot ( value1, value2, ...values ) |
-BUILTIN(MathHypot) { |
- HandleScope scope(isolate); |
- int const length = args.length() - 1; |
- if (length == 0) return Smi::kZero; |
- DCHECK_LT(0, length); |
- double max = 0; |
- bool one_arg_is_nan = false; |
- List<double> abs_values(length); |
- for (int i = 0; i < length; i++) { |
- Handle<Object> x = args.at(i + 1); |
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, x, Object::ToNumber(x)); |
- double abs_value = std::abs(x->Number()); |
- |
- if (std::isnan(abs_value)) { |
- one_arg_is_nan = true; |
- } else { |
- abs_values.Add(abs_value); |
- if (max < abs_value) { |
- max = abs_value; |
- } |
- } |
- } |
- |
- if (max == V8_INFINITY) { |
- return *isolate->factory()->NewNumber(V8_INFINITY); |
- } |
- |
- if (one_arg_is_nan) { |
- return isolate->heap()->nan_value(); |
- } |
- |
- if (max == 0) { |
- return Smi::kZero; |
- } |
- DCHECK_GT(max, 0); |
- |
- // Kahan summation to avoid rounding errors. |
- // Normalize the numbers to the largest one to avoid overflow. |
- double sum = 0; |
- double compensation = 0; |
- for (int i = 0; i < length; i++) { |
- double n = abs_values.at(i) / max; |
- double summand = n * n - compensation; |
- double preliminary = sum + summand; |
- compensation = (preliminary - sum) - summand; |
- sum = preliminary; |
- } |
- |
- return *isolate->factory()->NewNumber(std::sqrt(sum) * max); |
-} |
- |
// ES6 section 20.2.2.19 Math.imul ( x, y ) |
TF_BUILTIN(MathImul, CodeStubAssembler) { |
Node* x = Parameter(1); |