Revision: 17649
Author:   [email protected]
Date:     Tue Nov 12 14:20:53 2013 UTC
Log:      Use %_IsMinusZero where applicable to replace hackery.

[email protected]
BUG=

Review URL: https://codereview.chromium.org/68453005
http://code.google.com/p/v8/source/detail?r=17649

Modified:
 /branches/bleeding_edge/src/i18n.js
 /branches/bleeding_edge/src/math.js
 /branches/bleeding_edge/src/runtime.js

=======================================
--- /branches/bleeding_edge/src/i18n.js Wed Nov  6 18:19:26 2013 UTC
+++ /branches/bleeding_edge/src/i18n.js Tue Nov 12 14:20:53 2013 UTC
@@ -1302,10 +1302,7 @@
  */
 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);
 }
=======================================
--- /branches/bleeding_edge/src/math.js Fri Nov  8 13:44:27 2013 UTC
+++ /branches/bleeding_edge/src/math.js Tue Nov 12 14:20:53 2013 UTC
@@ -117,9 +117,8 @@
     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 @@
   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 @@
     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 @@
   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;
     }
   }
=======================================
--- /branches/bleeding_edge/src/runtime.js      Fri Nov  8 11:45:56 2013 UTC
+++ /branches/bleeding_edge/src/runtime.js      Tue Nov 12 14:20:53 2013 UTC
@@ -606,7 +606,9 @@
   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;
 }

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to