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

Unified Diff: src/js/math.js

Issue 2116753002: [builtins] Unify most of the remaining Math builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2102223005
Patch Set: 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
Index: src/js/math.js
diff --git a/src/js/math.js b/src/js/math.js
index 0a1c2b9ce87bff70c2ca5e6985dfff7deae43903..346da2459641ff59f625e14dc869eb823804cf0d 100644
--- a/src/js/math.js
+++ b/src/js/math.js
@@ -38,57 +38,17 @@ function MathRandom() {
return randomNumbers[--nextRandomIndex];
}
-// ES6 draft 09-27-13, section 20.2.2.28.
-function MathSign(x) {
- x = +x;
- if (x > 0) return 1;
- if (x < 0) return -1;
- // -0, 0 or NaN.
- return x;
-}
-
-// ES6 draft 09-27-13, section 20.2.2.5.
-function MathAsinh(x) {
- x = TO_NUMBER(x);
- // Idempotent for NaN, +/-0 and +/-Infinity.
- if (x === 0 || !NUMBER_IS_FINITE(x)) return x;
- if (x > 0) return %math_log(x + %math_sqrt(x * x + 1));
- // This is to prevent numerical errors caused by large negative x.
- return -%math_log(-x + %math_sqrt(x * x + 1));
-}
-
-// ES6 draft 09-27-13, section 20.2.2.3.
-function MathAcosh(x) {
- x = TO_NUMBER(x);
- if (x < 1) return NaN;
- // Idempotent for NaN and +Infinity.
- if (!NUMBER_IS_FINITE(x)) return x;
- return %math_log(x + %math_sqrt(x + 1) * %math_sqrt(x - 1));
-}
-
-
// -------------------------------------------------------------------
%AddNamedProperty(GlobalMath, toStringTagSymbol, "Math", READ_ONLY | DONT_ENUM);
-// Set up math constants.
-utils.InstallConstants(GlobalMath, [
- "PI", 3.1415926535897932,
- "SQRT1_2", 0.7071067811865476,
- "SQRT2", 1.4142135623730951
-]);
-
// Set up non-enumerable functions of the Math object and
// set their names.
utils.InstallFunctions(GlobalMath, DONT_ENUM, [
"random", MathRandom,
- "sign", MathSign,
- "asinh", MathAsinh,
- "acosh", MathAcosh
]);
%SetForceInlineFlag(MathRandom);
-%SetForceInlineFlag(MathSign);
// -------------------------------------------------------------------
// Exports

Powered by Google App Engine
This is Rietveld 408576698