Reviewers: adamk,

Description:
Make Date.prototype an ordinary object

This is a change for ES2015. Date objects have mutable state, so having
a mutable prototype is bad for SES requirements, and it is an
inconsistency from the typical ES2015 class style of objects

BUG=v8:4004
LOG=Y
R=adamk

Please review this at https://codereview.chromium.org/1317403002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+12, -4 lines):
  M src/date.js
  M test/mjsunit/date.js
  M test/mozilla/mozilla.status
  M test/test262-es6/test262-es6.status
  M test/test262/test262.status


Index: src/date.js
diff --git a/src/date.js b/src/date.js
index 2be8bcb220a7f3ed91ea1fb6943fa79398d5e4a7..4de1cad006542495a4a252e5bfcc7538c8cbb091 100644
--- a/src/date.js
+++ b/src/date.js
@@ -16,6 +16,7 @@ var $createDate;
 // Imports

 var GlobalDate = global.Date;
+var GlobalObject = global.Object;
 var InternalArray = utils.InternalArray;
 var IsFinite;
 var MathAbs;
@@ -820,7 +821,7 @@ function CreateDate(time) {
 // -------------------------------------------------------------------

 %SetCode(GlobalDate, DateConstructor);
-%FunctionSetPrototype(GlobalDate, new GlobalDate(NAN));
+%FunctionSetPrototype(GlobalDate, new GlobalObject());

 // Set up non-enumerable properties of the Date object itself.
 utils.InstallFunctions(GlobalDate, DONT_ENUM, [
Index: test/mjsunit/date.js
diff --git a/test/mjsunit/date.js b/test/mjsunit/date.js
index adebbd141f704cedd75e28b911084f87c8599060..33b5af4f00d85ad218b8321d36da6f243098fe62 100644
--- a/test/mjsunit/date.js
+++ b/test/mjsunit/date.js
@@ -341,6 +341,11 @@ date.getYear();
 assertThrows(function() { Date.prototype.getYear.call(""); }, TypeError);
 assertUnoptimized(Date.prototype.getYear);

+(function TestDatePrototypeOrdinaryObject() {
+  assertEquals(Object.prototype, Date.prototype.__proto__);
+  assertThrows(function () { Date.prototype.toString() }, TypeError);
+})();
+
 delete Date.prototype.getUTCFullYear;
 delete Date.prototype.getUTCMonth;
 delete Date.prototype.getUTCDate;
Index: test/mozilla/mozilla.status
diff --git a/test/mozilla/mozilla.status b/test/mozilla/mozilla.status
index 94278e39b30e2aca222e55b1a2d53cab5dc0a82e..27827159ce9b4f038193c2e441af0dcd62a512c8 100644
--- a/test/mozilla/mozilla.status
+++ b/test/mozilla/mozilla.status
@@ -85,6 +85,8 @@
   'ecma/String/15.5.4.8-1': [FAIL],
   'ecma/String/15.5.4.9-1': [FAIL],

+  # Date.prototype is an Object, not a Date
+  'ecma/Date/15.9.5': [FAIL],

   ##################### SKIPPED TESTS #####################

Index: test/test262-es6/test262-es6.status
diff --git a/test/test262-es6/test262-es6.status b/test/test262-es6/test262-es6.status index 16068bf0cacbe0326955f93da2a6f049d6b6af5a..c3496a3a56b63401b71f891b40e0d07148e8151c 100644
--- a/test/test262-es6/test262-es6.status
+++ b/test/test262-es6/test262-es6.status
@@ -295,9 +295,6 @@
   'built-ins/Symbol/species/builtin-getter-name': [FAIL],
   'built-ins/Symbol/species/subclassing': [FAIL],

-  # https://code.google.com/p/v8/issues/detail?id=4004
-  'built-ins/Date/prototype/setFullYear/15.9.5.40_1': [FAIL],
-
   # https://code.google.com/p/v8/issues/detail?id=4002
   'built-ins/Error/prototype/S15.11.4_A2': [FAIL],

Index: test/test262/test262.status
diff --git a/test/test262/test262.status b/test/test262/test262.status
index b9ef3c68f4f58eca60e7e63dab1fc6c25deaa821..dd854d00621da10e6bbb6eaf0cd57fc6bd371b5b 100644
--- a/test/test262/test262.status
+++ b/test/test262/test262.status
@@ -284,6 +284,9 @@
# ES6 says for dates to default to the local timezone if none is specified
   '15.9.1.15-1': [FAIL],

+  # ES6 makes Date.prototype an Object, not a Date
+  '15.9.5.40_1': [FAIL],
+
   ######################## NEEDS INVESTIGATION ###########################

# These test failures are specific to the intl402 suite and need investigation


--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to