Commit d1333142 authored by yangguo@chromium.org's avatar yangguo@chromium.org

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
parent fea1d2b1
......@@ -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<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> 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<JSObject> 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) \
......
......@@ -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)
......
// 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();
......@@ -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);
......
......@@ -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
};
......
......@@ -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; } })));
......
......@@ -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) {
......
......@@ -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() {})));
......
......@@ -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; };
......
......@@ -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)));
......
......@@ -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)));
......
......@@ -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; } })));
......
......@@ -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)));
......
......@@ -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));
......
......@@ -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)));
......
......@@ -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
......
......@@ -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.
......
......@@ -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',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment