Revision: 10987
Author: [email protected]
Date: Fri Mar 9 05:01:32 2012
Log: Fix compile errors on Windows introduced by r10983.
[email protected]
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/9652030
http://code.google.com/p/v8/source/detail?r=10987
Modified:
/branches/bleeding_edge/src/date.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/mjsunit/date.js
=======================================
--- /branches/bleeding_edge/src/date.h Fri Mar 9 04:07:29 2012
+++ /branches/bleeding_edge/src/date.h Fri Mar 9 05:01:32 2012
@@ -51,6 +51,11 @@
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 @@
// 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() {
=======================================
--- /branches/bleeding_edge/src/objects.cc Fri Mar 9 04:07:29 2012
+++ /branches/bleeding_edge/src/objects.cc Fri Mar 9 05:01:32 2012
@@ -12987,7 +12987,7 @@
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 @@
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);
=======================================
--- /branches/bleeding_edge/src/runtime.cc Fri Mar 9 04:07:29 2012
+++ /branches/bleeding_edge/src/runtime.cc Fri Mar 9 05:01:32 2012
@@ -7569,8 +7569,13 @@
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 @@
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 @@
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));
}
=======================================
--- /branches/bleeding_edge/test/mjsunit/date.js Mon Oct 31 04:15:23 2011
+++ /branches/bleeding_edge/test/mjsunit/date.js Fri Mar 9 05:01:32 2012
@@ -187,6 +187,12 @@
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.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev