From d1333142e2107e030f9d9883f059f475e65abec3 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Wed, 16 Jul 2014 14:00:15 +0000 Subject: [PATCH] Ship ES6 Math functions. R=rossberg@chromium.org BUG=v8:2938 LOG=Y Review URL: https://codereview.chromium.org/394833002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22434 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/bootstrapper.cc | 12 - src/flag-definitions.h | 2 - src/harmony-math.js | 246 --------------------- src/math.js | 232 ++++++++++++++++++- src/objects.h | 47 ++-- test/mjsunit/es6/math-cbrt.js | 2 - test/mjsunit/es6/math-clz32.js | 2 +- test/mjsunit/es6/math-expm1.js | 2 +- test/mjsunit/es6/math-fround.js | 2 - test/mjsunit/es6/math-hyperbolic.js | 2 - test/mjsunit/es6/math-hypot.js | 2 - test/mjsunit/es6/math-log1p.js | 2 - test/mjsunit/es6/math-log2-log10.js | 2 - test/mjsunit/es6/math-sign.js | 2 - test/mjsunit/es6/math-trunc.js | 2 - .../js/Object-getOwnPropertyNames-expected.txt | 2 +- tools/generate-runtime-tests.py | 2 +- tools/gyp/v8.gyp | 1 - 18 files changed, 258 insertions(+), 306 deletions(-) delete mode 100644 src/harmony-math.js diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 53d8e36..aaa0f3f 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -202,7 +202,6 @@ class Genesis BASE_EMBEDDED { // Installs the contents of the native .js files on the global objects. // Used for creating a context from scratch. void InstallNativeFunctions(); - void InstallExperimentalBuiltinFunctionIds(); void InstallExperimentalNativeFunctions(); Handle InstallInternalArray(Handle builtins, const char* name, @@ -2016,11 +2015,9 @@ bool Genesis::InstallExperimentalNatives() { INSTALL_EXPERIMENTAL_NATIVE(i, iteration, "string-iterator.js") INSTALL_EXPERIMENTAL_NATIVE(i, strings, "harmony-string.js") INSTALL_EXPERIMENTAL_NATIVE(i, arrays, "harmony-array.js") - INSTALL_EXPERIMENTAL_NATIVE(i, maths, "harmony-math.js") } InstallExperimentalNativeFunctions(); - InstallExperimentalBuiltinFunctionIds(); return true; } @@ -2072,15 +2069,6 @@ void Genesis::InstallBuiltinFunctionIds() { } -void Genesis::InstallExperimentalBuiltinFunctionIds() { - HandleScope scope(isolate()); - if (FLAG_harmony_maths) { - Handle holder = ResolveBuiltinIdHolder(native_context(), "Math"); - InstallBuiltinFunctionId(holder, "clz32", kMathClz32); - } -} - - // Do not forget to update macros.py with named constant // of cache id. #define JSFUNCTION_RESULT_CACHE_LIST(F) \ diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 3f43c7e..f4e7116 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -164,7 +164,6 @@ DEFINE_BOOL(harmony_numeric_literals, false, "enable harmony numeric literals (0o77, 0b11)") DEFINE_BOOL(harmony_strings, false, "enable harmony string") DEFINE_BOOL(harmony_arrays, false, "enable harmony arrays") -DEFINE_BOOL(harmony_maths, false, "enable harmony math functions") DEFINE_BOOL(harmony_arrow_functions, false, "enable harmony arrow functions") DEFINE_BOOL(harmony, false, "enable all harmony features (except typeof)") @@ -184,7 +183,6 @@ DEFINE_IMPLICATION(harmony_generators, harmony_symbols) DEFINE_IMPLICATION(harmony_iteration, harmony_symbols) DEFINE_IMPLICATION(harmony, es_staging) -DEFINE_IMPLICATION(es_staging, harmony_maths) DEFINE_IMPLICATION(es_staging, harmony_symbols) DEFINE_IMPLICATION(es_staging, harmony_collections) diff --git a/src/harmony-math.js b/src/harmony-math.js deleted file mode 100644 index 4a8d95b..0000000 --- a/src/harmony-math.js +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright 2013 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. - -'use strict'; - -// ES6 draft 09-27-13, section 20.2.2.28. -function MathSign(x) { - x = TO_NUMBER_INLINE(x); - if (x > 0) return 1; - if (x < 0) return -1; - if (x === 0) return x; - return NAN; -} - - -// ES6 draft 09-27-13, section 20.2.2.34. -function MathTrunc(x) { - x = TO_NUMBER_INLINE(x); - if (x > 0) return MathFloor(x); - if (x < 0) return MathCeil(x); - if (x === 0) return x; - return NAN; -} - - -// ES6 draft 09-27-13, section 20.2.2.30. -function MathSinh(x) { - if (!IS_NUMBER(x)) x = NonNumberToNumber(x); - // Idempotent for NaN, +/-0 and +/-Infinity. - if (x === 0 || !NUMBER_IS_FINITE(x)) return x; - return (MathExp(x) - MathExp(-x)) / 2; -} - - -// ES6 draft 09-27-13, section 20.2.2.12. -function MathCosh(x) { - if (!IS_NUMBER(x)) x = NonNumberToNumber(x); - if (!NUMBER_IS_FINITE(x)) return MathAbs(x); - return (MathExp(x) + MathExp(-x)) / 2; -} - - -// ES6 draft 09-27-13, section 20.2.2.33. -function MathTanh(x) { - if (!IS_NUMBER(x)) x = NonNumberToNumber(x); - // Idempotent for +/-0. - if (x === 0) return x; - // Returns +/-1 for +/-Infinity. - if (!NUMBER_IS_FINITE(x)) return MathSign(x); - var exp1 = MathExp(x); - var exp2 = MathExp(-x); - return (exp1 - exp2) / (exp1 + exp2); -} - - -// ES6 draft 09-27-13, section 20.2.2.5. -function MathAsinh(x) { - if (!IS_NUMBER(x)) x = NonNumberToNumber(x); - // Idempotent for NaN, +/-0 and +/-Infinity. - if (x === 0 || !NUMBER_IS_FINITE(x)) return x; - if (x > 0) return MathLog(x + MathSqrt(x * x + 1)); - // This is to prevent numerical errors caused by large negative x. - return -MathLog(-x + MathSqrt(x * x + 1)); -} - - -// ES6 draft 09-27-13, section 20.2.2.3. -function MathAcosh(x) { - if (!IS_NUMBER(x)) x = NonNumberToNumber(x); - if (x < 1) return NAN; - // Idempotent for NaN and +Infinity. - if (!NUMBER_IS_FINITE(x)) return x; - return MathLog(x + MathSqrt(x + 1) * MathSqrt(x - 1)); -} - - -// ES6 draft 09-27-13, section 20.2.2.7. -function MathAtanh(x) { - if (!IS_NUMBER(x)) x = NonNumberToNumber(x); - // Idempotent for +/-0. - if (x === 0) return x; - // Returns NaN for NaN and +/- Infinity. - if (!NUMBER_IS_FINITE(x)) return NAN; - return 0.5 * MathLog((1 + x) / (1 - x)); -} - - -// ES6 draft 09-27-13, section 20.2.2.21. -function MathLog10(x) { - return MathLog(x) * 0.434294481903251828; // log10(x) = log(x)/log(10). -} - - -// ES6 draft 09-27-13, section 20.2.2.22. -function MathLog2(x) { - return MathLog(x) * 1.442695040888963407; // log2(x) = log(x)/log(2). -} - - -// 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 = %_ArgumentsLength(); - var args = new InternalArray(length); - var max = 0; - for (var i = 0; i < length; i++) { - var n = %_Arguments(i); - if (!IS_NUMBER(n)) n = NonNumberToNumber(n); - if (n === INFINITY || n === -INFINITY) return INFINITY; - n = MathAbs(n); - if (n > max) max = n; - args[i] = n; - } - - // 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 = args[i] / max; - var summand = n * n - compensation; - var preliminary = sum + summand; - compensation = (preliminary - sum) - summand; - sum = preliminary; - } - return MathSqrt(sum) * max; -} - - -// ES6 draft 09-27-13, section 20.2.2.16. -function MathFroundJS(x) { - return %MathFround(TO_NUMBER_INLINE(x)); -} - - -function MathClz32(x) { - x = ToUint32(TO_NUMBER_INLINE(x)); - if (x == 0) return 32; - var result = 0; - // Binary search. - if ((x & 0xFFFF0000) === 0) { x <<= 16; result += 16; }; - if ((x & 0xFF000000) === 0) { x <<= 8; result += 8; }; - if ((x & 0xF0000000) === 0) { x <<= 4; result += 4; }; - if ((x & 0xC0000000) === 0) { x <<= 2; result += 2; }; - if ((x & 0x80000000) === 0) { x <<= 1; result += 1; }; - return result; -} - - -// ES6 draft 09-27-13, section 20.2.2.9. -// Cube root approximation, refer to: http://metamerist.com/cbrt/cbrt.htm -// Using initial approximation adapted from Kahan's cbrt and 4 iterations -// of Newton's method. -function MathCbrt(x) { - if (!IS_NUMBER(x)) x = NonNumberToNumber(x); - if (x == 0 || !NUMBER_IS_FINITE(x)) return x; - return x >= 0 ? CubeRoot(x) : -CubeRoot(-x); -} - -macro NEWTON_ITERATION_CBRT(x, approx) - (1.0 / 3.0) * (x / (approx * approx) + 2 * approx); -endmacro - -function CubeRoot(x) { - var approx_hi = MathFloor(%_DoubleHi(x) / 3) + 0x2A9F7893; - var approx = %_ConstructDouble(approx_hi, 0); - approx = NEWTON_ITERATION_CBRT(x, approx); - approx = NEWTON_ITERATION_CBRT(x, approx); - approx = NEWTON_ITERATION_CBRT(x, approx); - return NEWTON_ITERATION_CBRT(x, approx); -} - - - -// ES6 draft 09-27-13, section 20.2.2.14. -// Use Taylor series to approximate. -// exp(x) - 1 at 0 == -1 + exp(0) + exp'(0)*x/1! + exp''(0)*x^2/2! + ... -// == x/1! + x^2/2! + x^3/3! + ... -// The closer x is to 0, the fewer terms are required. -function MathExpm1(x) { - if (!IS_NUMBER(x)) x = NonNumberToNumber(x); - var xabs = MathAbs(x); - if (xabs < 2E-7) { - return x * (1 + x * (1/2)); - } else if (xabs < 6E-5) { - return x * (1 + x * (1/2 + x * (1/6))); - } else if (xabs < 2E-2) { - return x * (1 + x * (1/2 + x * (1/6 + - x * (1/24 + x * (1/120 + x * (1/720)))))); - } else { // Use regular exp if not close enough to 0. - return MathExp(x) - 1; - } -} - - -// ES6 draft 09-27-13, section 20.2.2.20. -// Use Taylor series to approximate. With y = x + 1; -// log(y) at 1 == log(1) + log'(1)(y-1)/1! + log''(1)(y-1)^2/2! + ... -// == 0 + x - x^2/2 + x^3/3 ... -// The closer x is to 0, the fewer terms are required. -function MathLog1p(x) { - if (!IS_NUMBER(x)) x = NonNumberToNumber(x); - var xabs = MathAbs(x); - if (xabs < 1E-7) { - return x * (1 - x * (1/2)); - } else if (xabs < 3E-5) { - return x * (1 - x * (1/2 - x * (1/3))); - } else if (xabs < 7E-3) { - return x * (1 - x * (1/2 - x * (1/3 - x * (1/4 - - x * (1/5 - x * (1/6 - x * (1/7))))))); - } else { // Use regular log if not close enough to 0. - return MathLog(1 + x); - } -} - - -function ExtendMath() { - %CheckIsBootstrapping(); - - // Set up the non-enumerable functions on the Math object. - InstallFunctions($Math, DONT_ENUM, $Array( - "sign", MathSign, - "trunc", MathTrunc, - "sinh", MathSinh, - "cosh", MathCosh, - "tanh", MathTanh, - "asinh", MathAsinh, - "acosh", MathAcosh, - "atanh", MathAtanh, - "log10", MathLog10, - "log2", MathLog2, - "hypot", MathHypot, - "fround", MathFroundJS, - "clz32", MathClz32, - "cbrt", MathCbrt, - "log1p", MathLog1p, - "expm1", MathExpm1 - )); -} - - -ExtendMath(); diff --git a/src/math.js b/src/math.js index 6491399..9dc4b37 100644 --- a/src/math.js +++ b/src/math.js @@ -254,6 +254,220 @@ function TrigonometricInterpolation(x, phase) { * (1 - (phase & 2)) + 0; } + +// ES6 draft 09-27-13, section 20.2.2.28. +function MathSign(x) { + x = TO_NUMBER_INLINE(x); + if (x > 0) return 1; + if (x < 0) return -1; + if (x === 0) return x; + return NAN; +} + + +// ES6 draft 09-27-13, section 20.2.2.34. +function MathTrunc(x) { + x = TO_NUMBER_INLINE(x); + if (x > 0) return MathFloor(x); + if (x < 0) return MathCeil(x); + if (x === 0) return x; + return NAN; +} + + +// ES6 draft 09-27-13, section 20.2.2.30. +function MathSinh(x) { + if (!IS_NUMBER(x)) x = NonNumberToNumber(x); + // Idempotent for NaN, +/-0 and +/-Infinity. + if (x === 0 || !NUMBER_IS_FINITE(x)) return x; + return (MathExp(x) - MathExp(-x)) / 2; +} + + +// ES6 draft 09-27-13, section 20.2.2.12. +function MathCosh(x) { + if (!IS_NUMBER(x)) x = NonNumberToNumber(x); + if (!NUMBER_IS_FINITE(x)) return MathAbs(x); + return (MathExp(x) + MathExp(-x)) / 2; +} + + +// ES6 draft 09-27-13, section 20.2.2.33. +function MathTanh(x) { + if (!IS_NUMBER(x)) x = NonNumberToNumber(x); + // Idempotent for +/-0. + if (x === 0) return x; + // Returns +/-1 for +/-Infinity. + if (!NUMBER_IS_FINITE(x)) return MathSign(x); + var exp1 = MathExp(x); + var exp2 = MathExp(-x); + return (exp1 - exp2) / (exp1 + exp2); +} + + +// ES6 draft 09-27-13, section 20.2.2.5. +function MathAsinh(x) { + if (!IS_NUMBER(x)) x = NonNumberToNumber(x); + // Idempotent for NaN, +/-0 and +/-Infinity. + if (x === 0 || !NUMBER_IS_FINITE(x)) return x; + if (x > 0) return MathLog(x + MathSqrt(x * x + 1)); + // This is to prevent numerical errors caused by large negative x. + return -MathLog(-x + MathSqrt(x * x + 1)); +} + + +// ES6 draft 09-27-13, section 20.2.2.3. +function MathAcosh(x) { + if (!IS_NUMBER(x)) x = NonNumberToNumber(x); + if (x < 1) return NAN; + // Idempotent for NaN and +Infinity. + if (!NUMBER_IS_FINITE(x)) return x; + return MathLog(x + MathSqrt(x + 1) * MathSqrt(x - 1)); +} + + +// ES6 draft 09-27-13, section 20.2.2.7. +function MathAtanh(x) { + if (!IS_NUMBER(x)) x = NonNumberToNumber(x); + // Idempotent for +/-0. + if (x === 0) return x; + // Returns NaN for NaN and +/- Infinity. + if (!NUMBER_IS_FINITE(x)) return NAN; + return 0.5 * MathLog((1 + x) / (1 - x)); +} + + +// ES6 draft 09-27-13, section 20.2.2.21. +function MathLog10(x) { + return MathLog(x) * 0.434294481903251828; // log10(x) = log(x)/log(10). +} + + +// ES6 draft 09-27-13, section 20.2.2.22. +function MathLog2(x) { + return MathLog(x) * 1.442695040888963407; // log2(x) = log(x)/log(2). +} + + +// 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 = %_ArgumentsLength(); + var args = new InternalArray(length); + var max = 0; + for (var i = 0; i < length; i++) { + var n = %_Arguments(i); + if (!IS_NUMBER(n)) n = NonNumberToNumber(n); + if (n === INFINITY || n === -INFINITY) return INFINITY; + n = MathAbs(n); + if (n > max) max = n; + args[i] = n; + } + + // 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 = args[i] / max; + var summand = n * n - compensation; + var preliminary = sum + summand; + compensation = (preliminary - sum) - summand; + sum = preliminary; + } + return MathSqrt(sum) * max; +} + + +// ES6 draft 09-27-13, section 20.2.2.16. +function MathFroundJS(x) { + return %MathFround(TO_NUMBER_INLINE(x)); +} + + +function MathClz32(x) { + x = ToUint32(TO_NUMBER_INLINE(x)); + if (x == 0) return 32; + var result = 0; + // Binary search. + if ((x & 0xFFFF0000) === 0) { x <<= 16; result += 16; }; + if ((x & 0xFF000000) === 0) { x <<= 8; result += 8; }; + if ((x & 0xF0000000) === 0) { x <<= 4; result += 4; }; + if ((x & 0xC0000000) === 0) { x <<= 2; result += 2; }; + if ((x & 0x80000000) === 0) { x <<= 1; result += 1; }; + return result; +} + + +// ES6 draft 09-27-13, section 20.2.2.9. +// Cube root approximation, refer to: http://metamerist.com/cbrt/cbrt.htm +// Using initial approximation adapted from Kahan's cbrt and 4 iterations +// of Newton's method. +function MathCbrt(x) { + if (!IS_NUMBER(x)) x = NonNumberToNumber(x); + if (x == 0 || !NUMBER_IS_FINITE(x)) return x; + return x >= 0 ? CubeRoot(x) : -CubeRoot(-x); +} + +macro NEWTON_ITERATION_CBRT(x, approx) + (1.0 / 3.0) * (x / (approx * approx) + 2 * approx); +endmacro + +function CubeRoot(x) { + var approx_hi = MathFloor(%_DoubleHi(x) / 3) + 0x2A9F7893; + var approx = %_ConstructDouble(approx_hi, 0); + approx = NEWTON_ITERATION_CBRT(x, approx); + approx = NEWTON_ITERATION_CBRT(x, approx); + approx = NEWTON_ITERATION_CBRT(x, approx); + return NEWTON_ITERATION_CBRT(x, approx); +} + + + +// ES6 draft 09-27-13, section 20.2.2.14. +// Use Taylor series to approximate. +// exp(x) - 1 at 0 == -1 + exp(0) + exp'(0)*x/1! + exp''(0)*x^2/2! + ... +// == x/1! + x^2/2! + x^3/3! + ... +// The closer x is to 0, the fewer terms are required. +function MathExpm1(x) { + if (!IS_NUMBER(x)) x = NonNumberToNumber(x); + var xabs = MathAbs(x); + if (xabs < 2E-7) { + return x * (1 + x * (1/2)); + } else if (xabs < 6E-5) { + return x * (1 + x * (1/2 + x * (1/6))); + } else if (xabs < 2E-2) { + return x * (1 + x * (1/2 + x * (1/6 + + x * (1/24 + x * (1/120 + x * (1/720)))))); + } else { // Use regular exp if not close enough to 0. + return MathExp(x) - 1; + } +} + + +// ES6 draft 09-27-13, section 20.2.2.20. +// Use Taylor series to approximate. With y = x + 1; +// log(y) at 1 == log(1) + log'(1)(y-1)/1! + log''(1)(y-1)^2/2! + ... +// == 0 + x - x^2/2 + x^3/3 ... +// The closer x is to 0, the fewer terms are required. +function MathLog1p(x) { + if (!IS_NUMBER(x)) x = NonNumberToNumber(x); + var xabs = MathAbs(x); + if (xabs < 1E-7) { + return x * (1 - x * (1/2)); + } else if (xabs < 3E-5) { + return x * (1 - x * (1/2 - x * (1/3))); + } else if (xabs < 7E-3) { + return x * (1 - x * (1/2 - x * (1/3 - x * (1/4 - + x * (1/5 - x * (1/6 - x * (1/7))))))); + } else { // Use regular log if not close enough to 0. + return MathLog(1 + x); + } +} + // ------------------------------------------------------------------- function SetUpMath() { @@ -300,7 +514,23 @@ function SetUpMath() { "pow", MathPow, "max", MathMax, "min", MathMin, - "imul", MathImul + "imul", MathImul, + "sign", MathSign, + "trunc", MathTrunc, + "sinh", MathSinh, + "cosh", MathCosh, + "tanh", MathTanh, + "asinh", MathAsinh, + "acosh", MathAcosh, + "atanh", MathAtanh, + "log10", MathLog10, + "log2", MathLog2, + "hypot", MathHypot, + "fround", MathFroundJS, + "clz32", MathClz32, + "cbrt", MathCbrt, + "log1p", MathLog1p, + "expm1", MathExpm1 )); %SetInlineBuiltinFlag(MathCeil); diff --git a/src/objects.h b/src/objects.h index 74b4264..d33bead 100644 --- a/src/objects.h +++ b/src/objects.h @@ -7019,27 +7019,28 @@ class Script: public Struct { // // Installation of ids for the selected builtin functions is handled // by the bootstrapper. -#define FUNCTIONS_WITH_ID_LIST(V) \ - V(Array.prototype, indexOf, ArrayIndexOf) \ - V(Array.prototype, lastIndexOf, ArrayLastIndexOf) \ - V(Array.prototype, push, ArrayPush) \ - V(Array.prototype, pop, ArrayPop) \ - V(Array.prototype, shift, ArrayShift) \ - V(Function.prototype, apply, FunctionApply) \ - V(String.prototype, charCodeAt, StringCharCodeAt) \ - V(String.prototype, charAt, StringCharAt) \ - V(String, fromCharCode, StringFromCharCode) \ - V(Math, floor, MathFloor) \ - V(Math, round, MathRound) \ - V(Math, ceil, MathCeil) \ - V(Math, abs, MathAbs) \ - V(Math, log, MathLog) \ - V(Math, exp, MathExp) \ - V(Math, sqrt, MathSqrt) \ - V(Math, pow, MathPow) \ - V(Math, max, MathMax) \ - V(Math, min, MathMin) \ - V(Math, imul, MathImul) +#define FUNCTIONS_WITH_ID_LIST(V) \ + V(Array.prototype, indexOf, ArrayIndexOf) \ + V(Array.prototype, lastIndexOf, ArrayLastIndexOf) \ + V(Array.prototype, push, ArrayPush) \ + V(Array.prototype, pop, ArrayPop) \ + V(Array.prototype, shift, ArrayShift) \ + V(Function.prototype, apply, FunctionApply) \ + V(String.prototype, charCodeAt, StringCharCodeAt) \ + V(String.prototype, charAt, StringCharAt) \ + V(String, fromCharCode, StringFromCharCode) \ + V(Math, floor, MathFloor) \ + V(Math, round, MathRound) \ + V(Math, ceil, MathCeil) \ + V(Math, abs, MathAbs) \ + V(Math, log, MathLog) \ + V(Math, exp, MathExp) \ + V(Math, sqrt, MathSqrt) \ + V(Math, pow, MathPow) \ + V(Math, max, MathMax) \ + V(Math, min, MathMin) \ + V(Math, imul, MathImul) \ + V(Math, clz32, MathClz32) enum BuiltinFunctionId { kArrayCode, @@ -7049,9 +7050,7 @@ enum BuiltinFunctionId { #undef DECLARE_FUNCTION_ID // Fake id for a special case of Math.pow. Note, it continues the // list of math functions. - kMathPowHalf, - // Installed only on --harmony-maths. - kMathClz32 + kMathPowHalf }; diff --git a/test/mjsunit/es6/math-cbrt.js b/test/mjsunit/es6/math-cbrt.js index 83d9eb5..713c020 100644 --- a/test/mjsunit/es6/math-cbrt.js +++ b/test/mjsunit/es6/math-cbrt.js @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-maths - assertTrue(isNaN(Math.cbrt(NaN))); assertTrue(isNaN(Math.cbrt(function() {}))); assertTrue(isNaN(Math.cbrt({ toString: function() { return NaN; } }))); diff --git a/test/mjsunit/es6/math-clz32.js b/test/mjsunit/es6/math-clz32.js index 816f6a9..3cbd4c3 100644 --- a/test/mjsunit/es6/math-clz32.js +++ b/test/mjsunit/es6/math-clz32.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-maths --allow-natives-syntax +// Flags: --allow-natives-syntax [NaN, Infinity, -Infinity, 0, -0, "abc", "Infinity", "-Infinity", {}].forEach( function(x) { diff --git a/test/mjsunit/es6/math-expm1.js b/test/mjsunit/es6/math-expm1.js index de915c0..b4e31a9 100644 --- a/test/mjsunit/es6/math-expm1.js +++ b/test/mjsunit/es6/math-expm1.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-maths --no-fast-math +// Flags: --no-fast-math assertTrue(isNaN(Math.expm1(NaN))); assertTrue(isNaN(Math.expm1(function() {}))); diff --git a/test/mjsunit/es6/math-fround.js b/test/mjsunit/es6/math-fround.js index ea432ea..6142eb3 100644 --- a/test/mjsunit/es6/math-fround.js +++ b/test/mjsunit/es6/math-fround.js @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-maths - // Monkey-patch Float32Array. Float32Array = function(x) { this[0] = 0; }; diff --git a/test/mjsunit/es6/math-hyperbolic.js b/test/mjsunit/es6/math-hyperbolic.js index c45a19c..1ceb951 100644 --- a/test/mjsunit/es6/math-hyperbolic.js +++ b/test/mjsunit/es6/math-hyperbolic.js @@ -25,8 +25,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --harmony-maths - [Math.sinh, Math.cosh, Math.tanh, Math.asinh, Math.acosh, Math.atanh]. forEach(function(fun) { assertTrue(isNaN(fun(NaN))); diff --git a/test/mjsunit/es6/math-hypot.js b/test/mjsunit/es6/math-hypot.js index 1052627..d2392df 100644 --- a/test/mjsunit/es6/math-hypot.js +++ b/test/mjsunit/es6/math-hypot.js @@ -25,8 +25,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --harmony-maths - assertTrue(isNaN(Math.hypot({}))); assertTrue(isNaN(Math.hypot(undefined, 1))); assertTrue(isNaN(Math.hypot(1, undefined))); diff --git a/test/mjsunit/es6/math-log1p.js b/test/mjsunit/es6/math-log1p.js index eefea6e..01f3533 100644 --- a/test/mjsunit/es6/math-log1p.js +++ b/test/mjsunit/es6/math-log1p.js @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-maths - assertTrue(isNaN(Math.log1p(NaN))); assertTrue(isNaN(Math.log1p(function() {}))); assertTrue(isNaN(Math.log1p({ toString: function() { return NaN; } }))); diff --git a/test/mjsunit/es6/math-log2-log10.js b/test/mjsunit/es6/math-log2-log10.js index 2ab4960..4479894 100644 --- a/test/mjsunit/es6/math-log2-log10.js +++ b/test/mjsunit/es6/math-log2-log10.js @@ -25,8 +25,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --harmony-maths - [Math.log10, Math.log2].forEach( function(fun) { assertTrue(isNaN(fun(NaN))); assertTrue(isNaN(fun(fun))); diff --git a/test/mjsunit/es6/math-sign.js b/test/mjsunit/es6/math-sign.js index 8a89d62..65f1609 100644 --- a/test/mjsunit/es6/math-sign.js +++ b/test/mjsunit/es6/math-sign.js @@ -25,8 +25,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --harmony-maths - assertEquals("Infinity", String(1/Math.sign(0))); assertEquals("-Infinity", String(1/Math.sign(-0))); assertEquals(1, Math.sign(100)); diff --git a/test/mjsunit/es6/math-trunc.js b/test/mjsunit/es6/math-trunc.js index ed91ed1..9231576 100644 --- a/test/mjsunit/es6/math-trunc.js +++ b/test/mjsunit/es6/math-trunc.js @@ -25,8 +25,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --harmony-maths - assertEquals("Infinity", String(1/Math.trunc(0))); assertEquals("-Infinity", String(1/Math.trunc(-0))); assertEquals("Infinity", String(1/Math.trunc(Math.PI/4))); diff --git a/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt b/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt index 52babed..0947e7c 100644 --- a/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt +++ b/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt @@ -81,7 +81,7 @@ FAIL getSortedOwnPropertyNames(RegExp) should be $&,$',$*,$+,$1,$2,$3,$4,$5,$6,$ PASS getSortedOwnPropertyNames(RegExp.prototype) is ['compile', 'constructor', 'exec', 'global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'test', 'toString'] FAIL getSortedOwnPropertyNames(Error) should be length,name,prototype. Was arguments,caller,captureStackTrace,length,name,prototype,stackTraceLimit. PASS getSortedOwnPropertyNames(Error.prototype) is ['constructor', 'message', 'name', 'toString'] -FAIL getSortedOwnPropertyNames(Math) should be E,LN10,LN2,LOG10E,LOG2E,PI,SQRT1_2,SQRT2,abs,acos,asin,atan,atan2,ceil,cos,exp,floor,log,max,min,pow,random,round,sin,sqrt,tan. Was E,LN10,LN2,LOG10E,LOG2E,PI,SQRT1_2,SQRT2,abs,acos,asin,atan,atan2,ceil,cos,exp,floor,imul,log,max,min,pow,random,round,sin,sqrt,tan. +FAIL getSortedOwnPropertyNames(Math) should be E,LN10,LN2,LOG10E,LOG2E,PI,SQRT1_2,SQRT2,abs,acos,asin,atan,atan2,ceil,cos,exp,floor,log,max,min,pow,random,round,sin,sqrt,tan. Was E,LN10,LN2,LOG10E,LOG2E,PI,SQRT1_2,SQRT2,abs,acos,acosh,asin,asinh,atan,atan2,atanh,cbrt,ceil,clz32,cos,cosh,exp,expm1,floor,fround,hypot,imul,log,log10,log1p,log2,max,min,pow,random,round,sign,sin,sinh,sqrt,tan,tanh,trunc. PASS getSortedOwnPropertyNames(JSON) is ['parse', 'stringify'] PASS globalPropertyNames.indexOf('NaN') != -1 is true PASS globalPropertyNames.indexOf('Infinity') != -1 is true diff --git a/tools/generate-runtime-tests.py b/tools/generate-runtime-tests.py index 85b96d4..b1c00a6 100755 --- a/tools/generate-runtime-tests.py +++ b/tools/generate-runtime-tests.py @@ -51,7 +51,7 @@ EXPECTED_FUNCTION_COUNT = 417 EXPECTED_FUZZABLE_COUNT = 332 EXPECTED_CCTEST_COUNT = 8 EXPECTED_UNKNOWN_COUNT = 4 -EXPECTED_BUILTINS_COUNT = 810 +EXPECTED_BUILTINS_COUNT = 809 # Don't call these at all. diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index 5ab74a4..3f2f44a 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -1336,7 +1336,6 @@ '../../src/string-iterator.js', '../../src/harmony-string.js', '../../src/harmony-array.js', - '../../src/harmony-math.js' ], 'libraries_bin_file': '<(SHARED_INTERMEDIATE_DIR)/libraries.bin', 'libraries_experimental_bin_file': '<(SHARED_INTERMEDIATE_DIR)/libraries-experimental.bin', -- 2.7.4