Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2623)

Unified Diff: src/builtins.cc

Issue 1574223002: Revert of [builtins] Refactor the remaining Date builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/builtins.h ('k') | src/compiler/js-intrinsic-lowering.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index dcb4f2307e1c1da77eeb643332f51687d974074a..17548e0fd8bdace0e131a6c223f87bc6343de0e1 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -2122,55 +2122,25 @@
}
-enum ToDateStringMode { kDateOnly, kTimeOnly, kDateAndTime };
-
-
// ES6 section 20.3.4.41.1 ToDateString(tv)
-void ToDateString(double time_val, Vector<char> str, DateCache* date_cache,
- ToDateStringMode mode = kDateAndTime) {
+void ToDateString(double time_val, Vector<char> str, DateCache* date_cache) {
if (std::isnan(time_val)) {
SNPrintF(str, "Invalid Date");
- return;
- }
- int64_t time_ms = static_cast<int64_t>(time_val);
- int64_t local_time_ms = date_cache->ToLocal(time_ms);
- int year, month, day, weekday, hour, min, sec, ms;
- date_cache->BreakDownTime(local_time_ms, &year, &month, &day, &weekday, &hour,
- &min, &sec, &ms);
- int timezone_offset = -date_cache->TimezoneOffset(time_ms);
- int timezone_hour = std::abs(timezone_offset) / 60;
- int timezone_min = std::abs(timezone_offset) % 60;
- const char* local_timezone = date_cache->LocalTimezone(time_ms);
- switch (mode) {
- case kDateOnly:
- SNPrintF(str, "%s %s %02d %4d", kShortWeekDays[weekday],
- kShortMonths[month], day, year);
- return;
- case kTimeOnly:
- SNPrintF(str, "%02d:%02d:%02d GMT%c%02d%02d (%s)", hour, min, sec,
- (timezone_offset < 0) ? '-' : '+', timezone_hour, timezone_min,
- local_timezone);
- return;
- case kDateAndTime:
- SNPrintF(str, "%s %s %02d %4d %02d:%02d:%02d GMT%c%02d%02d (%s)",
- kShortWeekDays[weekday], kShortMonths[month], day, year, hour,
- min, sec, (timezone_offset < 0) ? '-' : '+', timezone_hour,
- timezone_min, local_timezone);
- return;
- }
- UNREACHABLE();
-}
-
-
-Object* SetLocalDateValue(Handle<JSDate> date, double time_val) {
- if (time_val >= -DateCache::kMaxTimeBeforeUTCInMs &&
- time_val <= DateCache::kMaxTimeBeforeUTCInMs) {
- Isolate* const isolate = date->GetIsolate();
- time_val = isolate->date_cache()->ToUTC(static_cast<int64_t>(time_val));
} else {
- time_val = std::numeric_limits<double>::quiet_NaN();
- }
- return *JSDate::SetValue(date, TimeClip(time_val));
+ int64_t time_ms = static_cast<int64_t>(time_val);
+ int64_t local_time_ms = date_cache->ToLocal(time_ms);
+ int year, month, day, weekday, hour, min, sec, ms;
+ date_cache->BreakDownTime(local_time_ms, &year, &month, &day, &weekday,
+ &hour, &min, &sec, &ms);
+ int timezone_offset = -date_cache->TimezoneOffset(time_ms);
+ int timezone_hour = std::abs(timezone_offset) / 60;
+ int timezone_min = std::abs(timezone_offset) % 60;
+ const char* local_timezone = date_cache->LocalTimezone(time_ms);
+ SNPrintF(str, "%s %s %02d %4d %02d:%02d:%02d GMT%c%02d%02d (%s)",
+ kShortWeekDays[weekday], kShortMonths[month], day, year, hour, min,
+ sec, (timezone_offset < 0) ? '-' : '+', timezone_hour,
+ timezone_min, local_timezone);
+ }
}
} // namespace
@@ -2350,423 +2320,6 @@
}
-// ES6 section 20.3.4.20 Date.prototype.setDate ( date )
-BUILTIN(DatePrototypeSetDate) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setDate");
- Handle<Object> value = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(value));
- double time_val = date->value()->Number();
- if (!std::isnan(time_val)) {
- int64_t const time_ms = static_cast<int64_t>(time_val);
- int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
- int const days = isolate->date_cache()->DaysFromTime(local_time_ms);
- int time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, days);
- int year, month, day;
- isolate->date_cache()->YearMonthDayFromDays(days, &year, &month, &day);
- time_val = MakeDate(MakeDay(year, month, value->Number()), time_within_day);
- }
- return SetLocalDateValue(date, time_val);
-}
-
-
-// ES6 section 20.3.4.21 Date.prototype.setFullYear (year, month, date)
-BUILTIN(DatePrototypeSetFullYear) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setFullYear");
- int const argc = args.length() - 1;
- Handle<Object> year = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, year, Object::ToNumber(year));
- double y = year->Number(), m = 0.0, dt = 1.0;
- int time_within_day = 0;
- if (!std::isnan(date->value()->Number())) {
- int64_t const time_ms = static_cast<int64_t>(date->value()->Number());
- int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
- int const days = isolate->date_cache()->DaysFromTime(local_time_ms);
- time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, days);
- int year, month, day;
- isolate->date_cache()->YearMonthDayFromDays(days, &year, &month, &day);
- m = month;
- dt = day;
- }
- if (argc >= 2) {
- Handle<Object> month = args.at<Object>(2);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, month, Object::ToNumber(month));
- m = month->Number();
- if (argc >= 3) {
- Handle<Object> date = args.at<Object>(3);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, date, Object::ToNumber(date));
- dt = date->Number();
- }
- }
- double time_val = MakeDate(MakeDay(y, m, dt), time_within_day);
- return SetLocalDateValue(date, time_val);
-}
-
-
-// ES6 section 20.3.4.22 Date.prototype.setHours(hour, min, sec, ms)
-BUILTIN(DatePrototypeSetHours) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setHours");
- int const argc = args.length() - 1;
- Handle<Object> hour = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, hour, Object::ToNumber(hour));
- double h = hour->Number();
- double time_val = date->value()->Number();
- if (!std::isnan(time_val)) {
- int64_t const time_ms = static_cast<int64_t>(time_val);
- int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
- int day = isolate->date_cache()->DaysFromTime(local_time_ms);
- int time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, day);
- double m = (time_within_day / (60 * 1000)) % 60;
- double s = (time_within_day / 1000) % 60;
- double milli = time_within_day % 1000;
- if (argc >= 2) {
- Handle<Object> min = args.at<Object>(2);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, min, Object::ToNumber(min));
- m = min->Number();
- if (argc >= 3) {
- Handle<Object> sec = args.at<Object>(3);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, sec, Object::ToNumber(sec));
- s = sec->Number();
- if (argc >= 4) {
- Handle<Object> ms = args.at<Object>(4);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, ms, Object::ToNumber(ms));
- milli = ms->Number();
- }
- }
- }
- time_val = MakeDate(day, MakeTime(h, m, s, milli));
- }
- return SetLocalDateValue(date, time_val);
-}
-
-
-// ES6 section 20.3.4.23 Date.prototype.setMilliseconds(ms)
-BUILTIN(DatePrototypeSetMilliseconds) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setMilliseconds");
- Handle<Object> ms = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, ms, Object::ToNumber(ms));
- double time_val = date->value()->Number();
- if (!std::isnan(time_val)) {
- int64_t const time_ms = static_cast<int64_t>(time_val);
- int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
- int day = isolate->date_cache()->DaysFromTime(local_time_ms);
- int time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, day);
- int h = time_within_day / (60 * 60 * 1000);
- int m = (time_within_day / (60 * 1000)) % 60;
- int s = (time_within_day / 1000) % 60;
- time_val = MakeDate(day, MakeTime(h, m, s, ms->Number()));
- }
- return SetLocalDateValue(date, time_val);
-}
-
-
-// ES6 section 20.3.4.24 Date.prototype.setMinutes ( min, sec, ms )
-BUILTIN(DatePrototypeSetMinutes) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setMinutes");
- int const argc = args.length() - 1;
- Handle<Object> min = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, min, Object::ToNumber(min));
- double time_val = date->value()->Number();
- if (!std::isnan(time_val)) {
- int64_t const time_ms = static_cast<int64_t>(time_val);
- int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
- int day = isolate->date_cache()->DaysFromTime(local_time_ms);
- int time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, day);
- int h = time_within_day / (60 * 60 * 1000);
- double m = min->Number();
- double s = (time_within_day / 1000) % 60;
- double milli = time_within_day % 1000;
- if (argc >= 2) {
- Handle<Object> sec = args.at<Object>(2);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, sec, Object::ToNumber(sec));
- s = sec->Number();
- if (argc >= 3) {
- Handle<Object> ms = args.at<Object>(3);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, ms, Object::ToNumber(ms));
- milli = ms->Number();
- }
- }
- time_val = MakeDate(day, MakeTime(h, m, s, milli));
- }
- return SetLocalDateValue(date, time_val);
-}
-
-
-// ES6 section 20.3.4.25 Date.prototype.setMonth ( month, date )
-BUILTIN(DatePrototypeSetMonth) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setMonth");
- int const argc = args.length() - 1;
- Handle<Object> month = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, month, Object::ToNumber(month));
- double time_val = date->value()->Number();
- if (!std::isnan(time_val)) {
- int64_t const time_ms = static_cast<int64_t>(time_val);
- int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
- int days = isolate->date_cache()->DaysFromTime(local_time_ms);
- int time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, days);
- int year, unused, day;
- isolate->date_cache()->YearMonthDayFromDays(days, &year, &unused, &day);
- double m = month->Number();
- double dt = day;
- if (argc >= 2) {
- Handle<Object> date = args.at<Object>(2);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, date, Object::ToNumber(date));
- dt = date->Number();
- }
- time_val = MakeDate(MakeDay(year, m, dt), time_within_day);
- }
- return SetLocalDateValue(date, time_val);
-}
-
-
-// ES6 section 20.3.4.26 Date.prototype.setSeconds ( sec, ms )
-BUILTIN(DatePrototypeSetSeconds) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setSeconds");
- int const argc = args.length() - 1;
- Handle<Object> sec = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, sec, Object::ToNumber(sec));
- double time_val = date->value()->Number();
- if (!std::isnan(time_val)) {
- int64_t const time_ms = static_cast<int64_t>(time_val);
- int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
- int day = isolate->date_cache()->DaysFromTime(local_time_ms);
- int time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, day);
- int h = time_within_day / (60 * 60 * 1000);
- double m = (time_within_day / (60 * 1000)) % 60;
- double s = sec->Number();
- double milli = time_within_day % 1000;
- if (argc >= 2) {
- Handle<Object> ms = args.at<Object>(2);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, ms, Object::ToNumber(ms));
- milli = ms->Number();
- }
- time_val = MakeDate(day, MakeTime(h, m, s, milli));
- }
- return SetLocalDateValue(date, time_val);
-}
-
-
-// ES6 section 20.3.4.27 Date.prototype.setTime ( time )
-BUILTIN(DatePrototypeSetTime) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setTime");
- Handle<Object> value = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(value));
- return *JSDate::SetValue(date, TimeClip(value->Number()));
-}
-
-
-// ES6 section 20.3.4.28 Date.prototype.setUTCDate ( date )
-BUILTIN(DatePrototypeSetUTCDate) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setUTCDate");
- Handle<Object> value = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(value));
- if (std::isnan(date->value()->Number())) return date->value();
- int64_t const time_ms = static_cast<int64_t>(date->value()->Number());
- int const days = isolate->date_cache()->DaysFromTime(time_ms);
- int const time_within_day = isolate->date_cache()->TimeInDay(time_ms, days);
- int year, month, day;
- isolate->date_cache()->YearMonthDayFromDays(days, &year, &month, &day);
- double const time_val =
- MakeDate(MakeDay(year, month, value->Number()), time_within_day);
- return *JSDate::SetValue(date, TimeClip(time_val));
-}
-
-
-// ES6 section 20.3.4.29 Date.prototype.setUTCFullYear (year, month, date)
-BUILTIN(DatePrototypeSetUTCFullYear) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setUTCFullYear");
- int const argc = args.length() - 1;
- Handle<Object> year = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, year, Object::ToNumber(year));
- double y = year->Number(), m = 0.0, dt = 1.0;
- int time_within_day = 0;
- if (!std::isnan(date->value()->Number())) {
- int64_t const time_ms = static_cast<int64_t>(date->value()->Number());
- int const days = isolate->date_cache()->DaysFromTime(time_ms);
- time_within_day = isolate->date_cache()->TimeInDay(time_ms, days);
- int year, month, day;
- isolate->date_cache()->YearMonthDayFromDays(days, &year, &month, &day);
- m = month;
- dt = day;
- }
- if (argc >= 2) {
- Handle<Object> month = args.at<Object>(2);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, month, Object::ToNumber(month));
- m = month->Number();
- if (argc >= 3) {
- Handle<Object> date = args.at<Object>(3);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, date, Object::ToNumber(date));
- dt = date->Number();
- }
- }
- double const time_val = MakeDate(MakeDay(y, m, dt), time_within_day);
- return *JSDate::SetValue(date, TimeClip(time_val));
-}
-
-
-// ES6 section 20.3.4.30 Date.prototype.setUTCHours(hour, min, sec, ms)
-BUILTIN(DatePrototypeSetUTCHours) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setUTCHours");
- int const argc = args.length() - 1;
- Handle<Object> hour = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, hour, Object::ToNumber(hour));
- double h = hour->Number();
- double time_val = date->value()->Number();
- if (!std::isnan(time_val)) {
- int64_t const time_ms = static_cast<int64_t>(time_val);
- int day = isolate->date_cache()->DaysFromTime(time_ms);
- int time_within_day = isolate->date_cache()->TimeInDay(time_ms, day);
- double m = (time_within_day / (60 * 1000)) % 60;
- double s = (time_within_day / 1000) % 60;
- double milli = time_within_day % 1000;
- if (argc >= 2) {
- Handle<Object> min = args.at<Object>(2);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, min, Object::ToNumber(min));
- m = min->Number();
- if (argc >= 3) {
- Handle<Object> sec = args.at<Object>(3);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, sec, Object::ToNumber(sec));
- s = sec->Number();
- if (argc >= 4) {
- Handle<Object> ms = args.at<Object>(4);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, ms, Object::ToNumber(ms));
- milli = ms->Number();
- }
- }
- }
- time_val = MakeDate(day, MakeTime(h, m, s, milli));
- }
- return *JSDate::SetValue(date, TimeClip(time_val));
-}
-
-
-// ES6 section 20.3.4.31 Date.prototype.setUTCMilliseconds(ms)
-BUILTIN(DatePrototypeSetUTCMilliseconds) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setUTCMilliseconds");
- Handle<Object> ms = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, ms, Object::ToNumber(ms));
- double time_val = date->value()->Number();
- if (!std::isnan(time_val)) {
- int64_t const time_ms = static_cast<int64_t>(time_val);
- int day = isolate->date_cache()->DaysFromTime(time_ms);
- int time_within_day = isolate->date_cache()->TimeInDay(time_ms, day);
- int h = time_within_day / (60 * 60 * 1000);
- int m = (time_within_day / (60 * 1000)) % 60;
- int s = (time_within_day / 1000) % 60;
- time_val = MakeDate(day, MakeTime(h, m, s, ms->Number()));
- }
- return *JSDate::SetValue(date, TimeClip(time_val));
-}
-
-
-// ES6 section 20.3.4.32 Date.prototype.setUTCMinutes ( min, sec, ms )
-BUILTIN(DatePrototypeSetUTCMinutes) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setUTCMinutes");
- int const argc = args.length() - 1;
- Handle<Object> min = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, min, Object::ToNumber(min));
- double time_val = date->value()->Number();
- if (!std::isnan(time_val)) {
- int64_t const time_ms = static_cast<int64_t>(time_val);
- int day = isolate->date_cache()->DaysFromTime(time_ms);
- int time_within_day = isolate->date_cache()->TimeInDay(time_ms, day);
- int h = time_within_day / (60 * 60 * 1000);
- double m = min->Number();
- double s = (time_within_day / 1000) % 60;
- double milli = time_within_day % 1000;
- if (argc >= 2) {
- Handle<Object> sec = args.at<Object>(2);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, sec, Object::ToNumber(sec));
- s = sec->Number();
- if (argc >= 3) {
- Handle<Object> ms = args.at<Object>(3);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, ms, Object::ToNumber(ms));
- milli = ms->Number();
- }
- }
- time_val = MakeDate(day, MakeTime(h, m, s, milli));
- }
- return *JSDate::SetValue(date, TimeClip(time_val));
-}
-
-
-// ES6 section 20.3.4.31 Date.prototype.setUTCMonth ( month, date )
-BUILTIN(DatePrototypeSetUTCMonth) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setUTCMonth");
- int const argc = args.length() - 1;
- Handle<Object> month = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, month, Object::ToNumber(month));
- double time_val = date->value()->Number();
- if (!std::isnan(time_val)) {
- int64_t const time_ms = static_cast<int64_t>(time_val);
- int days = isolate->date_cache()->DaysFromTime(time_ms);
- int time_within_day = isolate->date_cache()->TimeInDay(time_ms, days);
- int year, unused, day;
- isolate->date_cache()->YearMonthDayFromDays(days, &year, &unused, &day);
- double m = month->Number();
- double dt = day;
- if (argc >= 2) {
- Handle<Object> date = args.at<Object>(2);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, date, Object::ToNumber(date));
- dt = date->Number();
- }
- time_val = MakeDate(MakeDay(year, m, dt), time_within_day);
- }
- return *JSDate::SetValue(date, TimeClip(time_val));
-}
-
-
-// ES6 section 20.3.4.34 Date.prototype.setUTCSeconds ( sec, ms )
-BUILTIN(DatePrototypeSetUTCSeconds) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setUTCSeconds");
- int const argc = args.length() - 1;
- Handle<Object> sec = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, sec, Object::ToNumber(sec));
- double time_val = date->value()->Number();
- if (!std::isnan(time_val)) {
- int64_t const time_ms = static_cast<int64_t>(time_val);
- int day = isolate->date_cache()->DaysFromTime(time_ms);
- int time_within_day = isolate->date_cache()->TimeInDay(time_ms, day);
- int h = time_within_day / (60 * 60 * 1000);
- double m = (time_within_day / (60 * 1000)) % 60;
- double s = sec->Number();
- double milli = time_within_day % 1000;
- if (argc >= 2) {
- Handle<Object> ms = args.at<Object>(2);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, ms, Object::ToNumber(ms));
- milli = ms->Number();
- }
- time_val = MakeDate(day, MakeTime(h, m, s, milli));
- }
- return *JSDate::SetValue(date, TimeClip(time_val));
-}
-
-
-// ES6 section 20.3.4.35 Date.prototype.toDateString ( )
-BUILTIN(DatePrototypeToDateString) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.toDateString");
- char buffer[128];
- Vector<char> str(buffer, arraysize(buffer));
- ToDateString(date->value()->Number(), str, isolate->date_cache(), kDateOnly);
- return *isolate->factory()->NewStringFromAsciiChecked(str.start());
-}
-
-
// ES6 section 20.3.4.36 Date.prototype.toISOString ( )
BUILTIN(DatePrototypeToISOString) {
HandleScope scope(isolate);
@@ -2796,48 +2349,6 @@
}
-// ES6 section 20.3.4.41 Date.prototype.toString ( )
-BUILTIN(DatePrototypeToString) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.toString");
- char buffer[128];
- Vector<char> str(buffer, arraysize(buffer));
- ToDateString(date->value()->Number(), str, isolate->date_cache());
- return *isolate->factory()->NewStringFromAsciiChecked(str.start());
-}
-
-
-// ES6 section 20.3.4.42 Date.prototype.toTimeString ( )
-BUILTIN(DatePrototypeToTimeString) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.toTimeString");
- char buffer[128];
- Vector<char> str(buffer, arraysize(buffer));
- ToDateString(date->value()->Number(), str, isolate->date_cache(), kTimeOnly);
- return *isolate->factory()->NewStringFromAsciiChecked(str.start());
-}
-
-
-// ES6 section 20.3.4.43 Date.prototype.toUTCString ( )
-BUILTIN(DatePrototypeToUTCString) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.toUTCString");
- double const time_val = date->value()->Number();
- if (std::isnan(time_val)) {
- return *isolate->factory()->NewStringFromAsciiChecked("Invalid Date");
- }
- char buffer[128];
- Vector<char> str(buffer, arraysize(buffer));
- int64_t time_ms = static_cast<int64_t>(time_val);
- int year, month, day, weekday, hour, min, sec, ms;
- isolate->date_cache()->BreakDownTime(time_ms, &year, &month, &day, &weekday,
- &hour, &min, &sec, &ms);
- SNPrintF(str, "%s, %02d %s %4d %02d:%02d:%02d GMT", kShortWeekDays[weekday],
- day, kShortMonths[month], year, hour, min, sec);
- return *isolate->factory()->NewStringFromAsciiChecked(str.start());
-}
-
-
// ES6 section 20.3.4.44 Date.prototype.valueOf ( )
BUILTIN(DatePrototypeValueOf) {
HandleScope scope(isolate);
@@ -2856,47 +2367,6 @@
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
JSDate::ToPrimitive(receiver, hint));
return *result;
-}
-
-
-// ES6 section B.2.4.1 Date.prototype.getYear ( )
-BUILTIN(DatePrototypeGetYear) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.getYear");
- double time_val = date->value()->Number();
- if (std::isnan(time_val)) return date->value();
- int64_t time_ms = static_cast<int64_t>(time_val);
- int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
- int days = isolate->date_cache()->DaysFromTime(local_time_ms);
- int year, month, day;
- isolate->date_cache()->YearMonthDayFromDays(days, &year, &month, &day);
- return Smi::FromInt(year - 1900);
-}
-
-
-// ES6 section B.2.4.2 Date.prototype.setYear ( year )
-BUILTIN(DatePrototypeSetYear) {
- HandleScope scope(isolate);
- CHECK_RECEIVER(JSDate, date, "Date.prototype.setYear");
- Handle<Object> year = args.atOrUndefined(isolate, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, year, Object::ToNumber(year));
- double m = 0.0, dt = 1.0, y = year->Number();
- if (0.0 <= y && y <= 99.0) {
- y = 1900.0 + DoubleToInteger(y);
- }
- int time_within_day = 0;
- if (!std::isnan(date->value()->Number())) {
- int64_t const time_ms = static_cast<int64_t>(date->value()->Number());
- int64_t local_time_ms = isolate->date_cache()->ToLocal(time_ms);
- int const days = isolate->date_cache()->DaysFromTime(local_time_ms);
- time_within_day = isolate->date_cache()->TimeInDay(local_time_ms, days);
- int year, month, day;
- isolate->date_cache()->YearMonthDayFromDays(days, &year, &month, &day);
- m = month;
- dt = day;
- }
- double time_val = MakeDate(MakeDay(y, m, dt), time_within_day);
- return SetLocalDateValue(date, time_val);
}
« no previous file with comments | « src/builtins.h ('k') | src/compiler/js-intrinsic-lowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698