Commit cb2f2a23 authored by ulan@chromium.org's avatar ulan@chromium.org

Fix compile errors on Windows introduced by r10983.

R=mstarzinger@chromium.org
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/9652030

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10987 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9ad61f63
......@@ -51,6 +51,11 @@ class DateCache {
static const int64_t kMaxTimeInMs =
static_cast<int64_t>(864000000) * 10000000;
// Conservative upper bound on time that can be stored in JSDate
// before UTC conversion.
static const int64_t kMaxTimeBeforeUTCInMs =
kMaxTimeInMs + 10 * kMsPerDay;
// Sentinel that denotes an invalid local offset.
static const int kInvalidLocalOffsetInMs = kMaxInt;
// Sentinel that denotes an invalid cache stamp.
......@@ -176,7 +181,8 @@ class DateCache {
// These functions are virtual so that we can override them when testing.
virtual int GetDaylightSavingsOffsetFromOS(int64_t time_sec) {
return static_cast<int>(OS::DaylightSavingsOffset(time_sec * 1000));
double time_ms = static_cast<double>(time_sec * 1000);
return static_cast<int>(OS::DaylightSavingsOffset(time_ms));
}
virtual int GetLocalOffsetFromOS() {
......
......@@ -12987,7 +12987,7 @@ Object* JSDate::DoGetField(FieldIndex index) {
if (stamp != date_cache->stamp() && stamp->IsSmi()) {
// Since the stamp is not NaN, the value is also not NaN.
int64_t local_time_ms =
static_cast<int64_t>(date_cache->ToLocal(value()->Number()));
date_cache->ToLocal(static_cast<int64_t>(value()->Number()));
SetLocalFields(local_time_ms, date_cache);
}
switch (index) {
......@@ -13009,7 +13009,7 @@ Object* JSDate::DoGetField(FieldIndex index) {
double time = value()->Number();
if (isnan(time)) return GetIsolate()->heap()->nan_value();
int64_t local_time_ms = static_cast<int64_t>(date_cache->ToLocal(time));
int64_t local_time_ms = date_cache->ToLocal(static_cast<int64_t>(time));
int days = DateCache::DaysFromTime(local_time_ms);
if (index == kDays) return Smi::FromInt(days);
......
......@@ -7569,8 +7569,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DateSetValue) {
if (isnan(time)) {
value = isolate->heap()->nan_value();
is_value_nan = true;
} else if (!is_utc &&
(time < -DateCache::kMaxTimeBeforeUTCInMs ||
time > DateCache::kMaxTimeBeforeUTCInMs)) {
value = isolate->heap()->nan_value();
is_value_nan = true;
} else {
time = is_utc ? time : date_cache->ToUTC(time);
time = is_utc ? time : date_cache->ToUTC(static_cast<int64_t>(time));
if (time < -DateCache::kMaxTimeInMs ||
time > DateCache::kMaxTimeInMs) {
value = isolate->heap()->nan_value();
......@@ -9059,7 +9064,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) {
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
int64_t time = isolate->date_cache()->EquivalentTime(static_cast<int64_t>(x));
const char* zone = OS::LocalTimezone(time);
const char* zone = OS::LocalTimezone(static_cast<double>(time));
return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone));
}
......@@ -9071,7 +9076,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) {
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x));
return isolate->heap()->NumberFromDouble(time);
return isolate->heap()->NumberFromDouble(static_cast<double>(time));
}
......
......@@ -187,6 +187,12 @@ d = new Date(1969, 12, 1, Infinity);
assertTrue(isNaN(d.getTime()));
d = new Date(1969, 12, 1, -Infinity);
assertTrue(isNaN(d.getTime()));
d = new Date(1969, 12, 1, 0);
d.setTime(Math.pow(2, 64));
assertTrue(isNaN(d.getTime()));
d = new Date(1969, 12, 1, 0);
d.setTime(Math.pow(-2, 64));
assertTrue(isNaN(d.getTime()));
// Test creation with obscure date values.
......
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