Revision: 19711
Author: [email protected]
Date: Fri Mar 7 10:01:00 2014 UTC
Log: Check and clear date cache in DateCurrentTime, DateLocalTimezone
and getTimezoneOffset.
BUG=142141
LOG=Y
[email protected]
Review URL: https://codereview.chromium.org/173793002
http://code.google.com/p/v8/source/detail?r=19711
Modified:
/branches/bleeding_edge/src/date.h
/branches/bleeding_edge/src/date.js
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/runtime.cc
=======================================
--- /branches/bleeding_edge/src/date.h Fri Mar 9 13:01:32 2012 UTC
+++ /branches/bleeding_edge/src/date.h Fri Mar 7 10:01:00 2014 UTC
@@ -121,6 +121,13 @@
int64_t local_ms = ToLocal(time_ms);
return static_cast<int>((time_ms - local_ms) / kMsPerMin);
}
+
+ void CheckTimezone() {
+ if (local_offset_ms_ != kInvalidLocalOffsetInMs &&
+ local_offset_ms_ != GetLocalOffsetFromOS()) {
+ ResetDateCache();
+ }
+ }
// ECMA 262 - 15.9.1.9
int64_t ToLocal(int64_t time_ms) {
=======================================
--- /branches/bleeding_edge/src/date.js Wed Dec 11 13:11:44 2013 UTC
+++ /branches/bleeding_edge/src/date.js Fri Mar 7 10:01:00 2014 UTC
@@ -42,16 +42,19 @@
var timezone_cache_time = NAN;
+var timezone_cache_timezone_offset = NAN;
var timezone_cache_timezone;
-function LocalTimezone(t) {
+function LocalTimezone(t, timezone_offset) {
if (NUMBER_IS_NAN(t)) return "";
- if (t == timezone_cache_time) {
+ if (t == timezone_cache_time &&
+ timezone_offset == timezone_cache_timezone_offset) {
return timezone_cache_timezone;
}
var timezone = %DateLocalTimezone(t);
timezone_cache_time = t;
timezone_cache_timezone = timezone;
+ timezone_cache_timezone_offset = timezone_offset;
return timezone;
}
@@ -245,9 +248,8 @@
function LocalTimezoneString(date) {
- var timezone = LocalTimezone(UTC_DATE_VALUE(date));
-
var timezoneOffset = -TIMEZONE_OFFSET(date);
+ var timezone = LocalTimezone(UTC_DATE_VALUE(date), timezoneOffset);
var sign = (timezoneOffset >= 0) ? 1 : -1;
var hours = FLOOR((sign * timezoneOffset)/60);
var min = FLOOR((sign * timezoneOffset)%60);
=======================================
--- /branches/bleeding_edge/src/objects.cc Thu Mar 6 13:07:51 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc Fri Mar 7 10:01:00 2014 UTC
@@ -16348,6 +16348,7 @@
int64_t time_ms = static_cast<int64_t>(value);
if (index == kTimezoneOffset) {
+ date_cache->CheckTimezone();
return Smi::FromInt(date_cache->TimezoneOffset(time_ms));
}
=======================================
--- /branches/bleeding_edge/src/runtime.cc Fri Mar 7 09:49:28 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc Fri Mar 7 10:01:00 2014 UTC
@@ -9547,6 +9547,7 @@
// time is milliseconds. Therefore, we floor the result of getting
// the OS time.
double millis = std::floor(OS::TimeCurrentMillis());
+ isolate->date_cache()->CheckTimezone();
return isolate->heap()->NumberFromDouble(millis);
}
@@ -9593,6 +9594,7 @@
ASSERT(args.length() == 1);
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
+ isolate->date_cache()->CheckTimezone();
int64_t time =
isolate->date_cache()->EquivalentTime(static_cast<int64_t>(x));
const char* zone = OS::LocalTimezone(static_cast<double>(time));
return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone));
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.