Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Unified Diff: src/js/math.js

Issue 2102223005: [builtins] Migrate Math.hypot() to C++ builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@MathAbs
Patch Set: Do not add Math.hypot() to list of optimized functions. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/builtins.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/math.js
diff --git a/src/js/math.js b/src/js/math.js
index 3f48874e93b76ded669457c3471ae146a3ec40fe..0a1c2b9ce87bff70c2ca5e6985dfff7deae43903 100644
--- a/src/js/math.js
+++ b/src/js/math.js
@@ -66,34 +66,6 @@ function MathAcosh(x) {
return %math_log(x + %math_sqrt(x + 1) * %math_sqrt(x - 1));
}
-// ES6 draft 09-27-13, section 20.2.2.17.
-function MathHypot(x, y) { // Function length is 2.
- // We may want to introduce fast paths for two arguments and when
- // normalization to avoid overflow is not necessary. For now, we
- // simply assume the general case.
- var length = arguments.length;
- var max = 0;
- for (var i = 0; i < length; i++) {
- var n = %math_abs(arguments[i]);
- if (n > max) max = n;
- arguments[i] = n;
- }
- if (max === INFINITY) return INFINITY;
-
- // Kahan summation to avoid rounding errors.
- // Normalize the numbers to the largest one to avoid overflow.
- if (max === 0) max = 1;
- var sum = 0;
- var compensation = 0;
- for (var i = 0; i < length; i++) {
- var n = arguments[i] / max;
- var summand = n * n - compensation;
- var preliminary = sum + summand;
- compensation = (preliminary - sum) - summand;
- sum = preliminary;
- }
- return %math_sqrt(sum) * max;
-}
// -------------------------------------------------------------------
@@ -112,8 +84,7 @@ utils.InstallFunctions(GlobalMath, DONT_ENUM, [
"random", MathRandom,
"sign", MathSign,
"asinh", MathAsinh,
- "acosh", MathAcosh,
- "hypot", MathHypot,
+ "acosh", MathAcosh
]);
%SetForceInlineFlag(MathRandom);
« no previous file with comments | « src/builtins.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698