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

Use %_IsMinusZero where applicable to replace hackery.

R=jarin@chromium.org
BUG=

Review URL: https://codereview.chromium.org/68453005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17649 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d8e85bf0
......@@ -1302,10 +1302,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
*/
function formatNumber(formatter, value) {
// Spec treats -0 and +0 as 0.
var number = $Number(value);
if (number === -0) {
number = 0;
}
var number = $Number(value) + 0;
return %InternalNumberFormat(formatter.formatter, number);
}
......
......@@ -117,9 +117,8 @@ function MathMax(arg1, arg2) { // length == 2
if (arg2 > arg1) return arg2;
if (arg1 > arg2) return arg1;
if (arg1 == arg2) {
// Make sure -0 is considered less than +0. -0 is never a Smi, +0 can be
// a Smi or a heap number.
return (arg1 == 0 && !%_IsSmi(arg1) && 1 / arg1 < 0) ? arg2 : arg1;
// Make sure -0 is considered less than +0.
return (arg1 === 0 && %_IsMinusZero(arg1)) ? arg2 : arg1;
}
// All comparisons failed, one of the arguments must be NaN.
return NAN;
......@@ -128,10 +127,8 @@ function MathMax(arg1, arg2) { // length == 2
for (var i = 0; i < length; i++) {
var n = %_Arguments(i);
if (!IS_NUMBER(n)) n = NonNumberToNumber(n);
// Make sure +0 is considered greater than -0. -0 is never a Smi, +0 can be
// a Smi or heap number.
if (NUMBER_IS_NAN(n) || n > r ||
(r == 0 && n == 0 && !%_IsSmi(r) && 1 / r < 0)) {
// Make sure +0 is considered greater than -0.
if (NUMBER_IS_NAN(n) || n > r || (r === 0 && n === 0 && %_IsMinusZero(r))) {
r = n;
}
}
......@@ -147,9 +144,8 @@ function MathMin(arg1, arg2) { // length == 2
if (arg2 > arg1) return arg1;
if (arg1 > arg2) return arg2;
if (arg1 == arg2) {
// Make sure -0 is considered less than +0. -0 is never a Smi, +0 can be
// a Smi or a heap number.
return (arg1 == 0 && !%_IsSmi(arg1) && 1 / arg1 < 0) ? arg1 : arg2;
// Make sure -0 is considered less than +0.
return (arg1 === 0 && %_IsMinusZero(arg1)) ? arg1 : arg2;
}
// All comparisons failed, one of the arguments must be NaN.
return NAN;
......@@ -158,10 +154,8 @@ function MathMin(arg1, arg2) { // length == 2
for (var i = 0; i < length; i++) {
var n = %_Arguments(i);
if (!IS_NUMBER(n)) n = NonNumberToNumber(n);
// Make sure -0 is considered less than +0. -0 is never a Smi, +0 can be a
// Smi or a heap number.
if (NUMBER_IS_NAN(n) || n < r ||
(r == 0 && n == 0 && !%_IsSmi(n) && 1 / n < 0)) {
// Make sure -0 is considered less than +0.
if (NUMBER_IS_NAN(n) || n < r || (r === 0 && n === 0 && %_IsMinusZero(n))) {
r = n;
}
}
......
......@@ -606,7 +606,9 @@ function SameValue(x, y) {
if (IS_NUMBER(x)) {
if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
// x is +0 and y is -0 or vice versa.
if (x === 0 && y === 0 && (1 / x) != (1 / y)) return false;
if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) {
return false;
}
}
return x === y;
}
......
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