Commit 57306b59 authored by mathias's avatar mathias Committed by Commit bot

Avoid built-ins in `Date.prototype.toISOString`

TEST=mjsunit/date
BUG=v8:4226
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#29240}
parent 2c979b96
......@@ -747,12 +747,12 @@ function PadInt(n, digits) {
}
// ECMA 262 - 15.9.5.43
// ECMA 262 - 20.3.4.36
function DateToISOString() {
CHECK_DATE(this);
var t = UTC_DATE_VALUE(this);
if (NUMBER_IS_NAN(t)) throw MakeRangeError(kInvalidTimeValue);
var year = this.getUTCFullYear();
var year = UTC_YEAR(this);
var year_string;
if (year >= 0 && year <= 9999) {
year_string = PadInt(year, 4);
......@@ -764,12 +764,12 @@ function DateToISOString() {
}
}
return year_string +
'-' + PadInt(this.getUTCMonth() + 1, 2) +
'-' + PadInt(this.getUTCDate(), 2) +
'T' + PadInt(this.getUTCHours(), 2) +
':' + PadInt(this.getUTCMinutes(), 2) +
':' + PadInt(this.getUTCSeconds(), 2) +
'.' + PadInt(this.getUTCMilliseconds(), 3) +
'-' + PadInt(UTC_MONTH(this) + 1, 2) +
'-' + PadInt(UTC_DAY(this), 2) +
'T' + PadInt(UTC_HOUR(this), 2) +
':' + PadInt(UTC_MIN(this), 2) +
':' + PadInt(UTC_SEC(this), 2) +
'.' + PadInt(UTC_MS(this), 3) +
'Z';
}
......
......@@ -340,3 +340,12 @@ date.getYear();
%OptimizeFunctionOnNextCall(Date.prototype.getYear);
assertThrows(function() { Date.prototype.getYear.call(""); }, TypeError);
assertUnoptimized(Date.prototype.getYear);
delete Date.prototype.getUTCFullYear;
delete Date.prototype.getUTCMonth;
delete Date.prototype.getUTCDate;
delete Date.prototype.getUTCHours;
delete Date.prototype.getUTCMinutes;
delete Date.prototype.getUTCSeconds;
delete Date.prototype.getUTCMilliseconds;
date.toISOString();
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