Revision: 5054
Author: [email protected]
Date: Tue Jul 13 05:53:53 2010
Log: Merge fixes for issue 736 and 764 to 2.1 branch for Chrome 5.

Review URL: http://codereview.chromium.org/2992001
http://code.google.com/p/v8/source/detail?r=5054

Modified:
 /branches/2.1/src/date.js
 /branches/2.1/src/json.js
 /branches/2.1/src/macros.py
 /branches/2.1/src/runtime.cc
 /branches/2.1/src/runtime.h
 /branches/2.1/src/version.cc
 /branches/2.1/test/mjsunit/date.js
 /branches/2.1/test/mjsunit/json.js

=======================================
--- /branches/2.1/src/date.js   Tue Mar 30 08:07:17 2010
+++ /branches/2.1/src/date.js   Tue Jul 13 05:53:53 2010
@@ -338,9 +338,10 @@
 function MakeDay(year, month, date) {
if (!$isFinite(year) || !$isFinite(month) || !$isFinite(date)) return $NaN;

-  year = TO_INTEGER(year);
-  month = TO_INTEGER(month);
-  date = TO_INTEGER(date);
+  // Convert to integer and map -0 to 0.
+  year = TO_INTEGER_MAP_MINUS_ZERO(year);
+  month = TO_INTEGER_MAP_MINUS_ZERO(month);
+  date = TO_INTEGER_MAP_MINUS_ZERO(date);

   if (year < kMinYear || year > kMaxYear ||
       month < kMinMonth || month > kMaxMonth ||
=======================================
--- /branches/2.1/src/json.js   Wed Mar 24 01:21:20 2010
+++ /branches/2.1/src/json.js   Tue Jul 13 05:53:53 2010
@@ -29,7 +29,7 @@

 function ParseJSONUnfiltered(text) {
   var s = $String(text);
-  var f = %CompileString(text, true);
+  var f = %CompileString(s, true);
   return f();
 }

=======================================
--- /branches/2.1/src/macros.py Wed Mar 24 01:21:20 2010
+++ /branches/2.1/src/macros.py Tue Jul 13 05:53:53 2010
@@ -112,6 +112,7 @@
 # Inline macros. Use %IS_VAR to make sure arg is evaluated only once.
 macro NUMBER_IS_NAN(arg) = (!%_IsSmi(%IS_VAR(arg)) && !(arg == arg));
 macro TO_INTEGER(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : ToInteger(arg));
+macro TO_INTEGER_MAP_MINUS_ZERO(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : %NumberToIntegerMapMinusZero(ToNumber(arg)));
 macro TO_INT32(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : (arg >> 0));
 macro TO_UINT32(arg) = (arg >>> 0);
macro TO_STRING_INLINE(arg) = (IS_STRING(%IS_VAR(arg)) ? arg : NonStringToString(arg));
=======================================
--- /branches/2.1/src/runtime.cc        Fri Apr 30 05:22:02 2010
+++ /branches/2.1/src/runtime.cc        Tue Jul 13 05:53:53 2010
@@ -5187,6 +5187,25 @@
   }
   return Heap::NumberFromDouble(DoubleToInteger(number));
 }
+
+
+static Object* Runtime_NumberToIntegerMapMinusZero(Arguments args) {
+  NoHandleAllocation ha;
+  ASSERT(args.length() == 1);
+
+  CONVERT_DOUBLE_CHECKED(number, args[0]);
+
+  // We do not include 0 so that we don't have to treat +0 / -0 cases.
+  if (number > 0 && number <= Smi::kMaxValue) {
+    return Smi::FromInt(static_cast<int>(number));
+  }
+
+  double double_value = DoubleToInteger(number);
+  // Map both -0 and +0 to +0.
+  if (double_value == 0) double_value = 0;
+
+  return Heap::NumberFromDouble(double_value);
+}


 static Object* Runtime_NumberToJSUint32(Arguments args) {
=======================================
--- /branches/2.1/src/runtime.h Tue Mar 30 07:14:28 2010
+++ /branches/2.1/src/runtime.h Tue Jul 13 05:53:53 2010
@@ -100,6 +100,7 @@
   \
   F(NumberToString, 1, 1) \
   F(NumberToInteger, 1, 1) \
+  F(NumberToIntegerMapMinusZero, 1, 1) \
   F(NumberToJSUint32, 1, 1) \
   F(NumberToJSInt32, 1, 1) \
   F(NumberToSmi, 1, 1) \
=======================================
--- /branches/2.1/src/version.cc        Fri Jun 25 01:09:12 2010
+++ /branches/2.1/src/version.cc        Tue Jul 13 05:53:53 2010
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     2
 #define MINOR_VERSION     1
 #define BUILD_NUMBER      10
-#define PATCH_LEVEL       14
+#define PATCH_LEVEL       15
 #define CANDIDATE_VERSION false

 // Define SONAME to have the SCons build the put a specific SONAME into the
=======================================
--- /branches/2.1/test/mjsunit/date.js  Wed Mar 24 01:21:20 2010
+++ /branches/2.1/test/mjsunit/date.js  Tue Jul 13 05:53:53 2010
@@ -154,6 +154,15 @@

 testToLocaleTimeString();

+// Test that -0 is treated correctly in MakeDay.
+var d = new Date();
+assertDoesNotThrow("d.setDate(-0)");
+assertDoesNotThrow("new Date(-0, -0, -0, -0, -0, -0. -0)");
+assertDoesNotThrow("new Date(0x40000000, 0x40000000, 0x40000000," +
+                   "0x40000000, 0x40000000, 0x40000000, 0x40000000)")
+assertDoesNotThrow("new Date(-0x40000001, -0x40000001, -0x40000001," +
+                   "-0x40000001, -0x40000001, -0x40000001, -0x40000001)")
+

 // Modified test from WebKit
 // LayoutTests/fast/js/script-tests/date-utc-timeclip.js:
=======================================
--- /branches/2.1/test/mjsunit/json.js  Fri Feb 19 00:53:10 2010
+++ /branches/2.1/test/mjsunit/json.js  Tue Jul 13 05:53:53 2010
@@ -85,7 +85,7 @@
 };
 assertEquals(null, n4.toJSON());

-assertEquals(Object.prototype, JSON.__proto__);
+assertTrue(Object.prototype === JSON.__proto__);
 assertEquals("[object JSON]", Object.prototype.toString.call(JSON));

 // DontEnum
@@ -313,3 +313,7 @@
 var x = 0;
 eval("(1); x++; (1)");
 TestInvalid('1); x++; (1');
+
+// Test string conversion of argument.
+var o = { toString: function() { return "42"; } };
+assertEquals(42, JSON.parse(o));

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to