Make Date.prototype an ordinary object
authorlittledan <littledan@chromium.org>
Mon, 31 Aug 2015 20:45:35 +0000 (13:45 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 31 Aug 2015 20:45:48 +0000 (20:45 +0000)
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

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

Cr-Commit-Position: refs/heads/master@{#30486}

src/date.js
test/mjsunit/date.js
test/mozilla/mozilla.status
test/test262-es6/test262-es6.status
test/test262/test262.status

index 4f49565..dd535b6 100644 (file)
@@ -16,6 +16,7 @@ var $createDate;
 // Imports
 
 var GlobalDate = global.Date;
+var GlobalObject = global.Object;
 var InternalArray = utils.InternalArray;
 var IsFinite;
 var MathAbs;
@@ -822,7 +823,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 adebbd1..33b5af4 100644 (file)
@@ -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 94278e3..2782715 100644 (file)
@@ -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 16068bf..c3496a3 100644 (file)
   '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 b9ef3c6..dd854d0 100644 (file)
   # 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