Commit 9bdce030 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Sanitize typing of Date builtins.

Put the types for the Date builtins into the TypeCache, and add
support for Date.prototype.getDay and Date.prototype.getMinutes.

R=epertoso@chromium.org
BUG=v8:5267

Review-Url: https://codereview.chromium.org/2296593002
Cr-Commit-Position: refs/heads/master@{#39005}
parent 76ea8f2f
......@@ -104,12 +104,46 @@ class TypeCache final {
Type* const kStringLengthType =
CreateNative(CreateRange(0.0, String::kMaxLength), Type::TaggedSigned());
// The JSDate::value properties always contains a tagged number in the range
// The JSDate::day property always contains a tagged number in the range
// [1, 31] or NaN.
Type* const kJSDateDayType =
Type::Union(CreateRange(1, 31.0), Type::NaN(), zone());
// The JSDate::hour property always contains a tagged number in the range
// [0, 23] or NaN.
Type* const kJSDateHourType =
Type::Union(CreateRange(0, 23.0), Type::NaN(), zone());
// The JSDate::minute property always contains a tagged number in the range
// [0, 59] or NaN.
Type* const kJSDateMinuteType =
Type::Union(CreateRange(0, 59.0), Type::NaN(), zone());
// The JSDate::month property always contains a tagged number in the range
// [0, 11] or NaN.
Type* const kJSDateMonthType =
Type::Union(CreateRange(0, 11.0), Type::NaN(), zone());
// The JSDate::second property always contains a tagged number in the range
// [0, 59] or NaN.
Type* const kJSDateSecondType = kJSDateMinuteType;
// The JSDate::value property always contains a tagged number in the range
// [-kMaxTimeInMs, kMaxTimeInMs] or NaN.
Type* const kJSDateValueType = Type::Union(
CreateRange(-DateCache::kMaxTimeInMs, DateCache::kMaxTimeInMs),
Type::NaN(), zone());
// The JSDate::weekday property always contains a tagged number in the range
// [0, 6] or NaN.
Type* const kJSDateWeekdayType =
Type::Union(CreateRange(0, 6.0), Type::NaN(), zone());
// The JSDate::year property always contains a tagged number in the signed
// small range or NaN.
Type* const kJSDateYearType =
Type::Union(Type::SignedSmall(), Type::NaN(), zone());
#define TYPED_ARRAY(TypeName, type_name, TYPE_NAME, ctype, size) \
Type* const k##TypeName##Array = CreateArray(k##TypeName);
TYPED_ARRAYS(TYPED_ARRAY)
......
......@@ -1336,24 +1336,23 @@ Type* Typer::Visitor::JSCallFunctionTyper(Type* fun, Typer* t) {
case kMathClz32:
return t->cache_.kZeroToThirtyTwo;
// Date functions.
case kDateGetFullYear:
return Type::Union(Type::Range(-271821.0, 275760.0, t->zone()),
Type::NaN(), t->zone());
case kDateGetDate:
return Type::Union(Type::Range(1.0, 31.0, t->zone()), Type::NaN(),
t->zone());
return t->cache_.kJSDateDayType;
case kDateGetDay:
return t->cache_.kJSDateWeekdayType;
case kDateGetFullYear:
return t->cache_.kJSDateYearType;
case kDateGetHours:
return Type::Union(Type::Range(0.0, 23.0, t->zone()), Type::NaN(),
t->zone());
return t->cache_.kJSDateHourType;
case kDateGetMilliseconds:
return Type::Union(Type::Range(0.0, 59.0, t->zone()), Type::NaN(),
return Type::Union(Type::Range(0.0, 999.0, t->zone()), Type::NaN(),
t->zone());
case kDateGetMinutes:
return t->cache_.kJSDateMinuteType;
case kDateGetMonth:
return Type::Union(Type::Range(0.0, 11.0, t->zone()), Type::NaN(),
t->zone());
return t->cache_.kJSDateMonthType;
case kDateGetSeconds:
return Type::Union(Type::Range(0.0, 59.0, t->zone()), Type::NaN(),
t->zone());
return t->cache_.kJSDateSecondType;
case kDateGetTime:
return t->cache_.kJSDateValueType;
// Number functions.
......
......@@ -6870,9 +6870,11 @@ class Script: public Struct {
V(Array.prototype, pop, ArrayPop) \
V(Array.prototype, shift, ArrayShift) \
V(Date.prototype, getDate, DateGetDate) \
V(Date.prototype, getDay, DateGetDay) \
V(Date.prototype, getFullYear, DateGetFullYear) \
V(Date.prototype, getHours, DateGetHours) \
V(Date.prototype, getMilliseconds, DateGetMilliseconds) \
V(Date.prototype, getMinutes, DateGetMinutes) \
V(Date.prototype, getMonth, DateGetMonth) \
V(Date.prototype, getSeconds, DateGetSeconds) \
V(Date.prototype, getTime, DateGetTime) \
......
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