Reviewers: Michael Starzinger,
Message:
Please take a look.
Description:
Fix compile errors on Windows introduced by r10983.
[email protected]
BUG=
TEST=
Please review this at https://chromiumcodereview.appspot.com/9652030/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/date.h
M src/objects.cc
M src/runtime.cc
Index: src/date.h
diff --git a/src/date.h b/src/date.h
index
a86f7440d7393d04013afdff89b8ef4c6714a094..fcd61db046715003564a6e0fa73e009001361ab9
100644
--- a/src/date.h
+++ b/src/date.h
@@ -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() {
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
7a46206eb12e14560cd286f28443cf78c05b5b80..69c4aa52e2f522b3683050df095082a621f323b4
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -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);
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
196f872d6f8a6f7074e0d4b58e243a5425e5731f..cc5aeab78f55c46446b016f848fb60c3ceadc612
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -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));
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev