Reviewers: rossberg,
Message:
PTAL
Description:
Check and clear date cache in DateLocalTimezone and getTimezoneOffset.
BUG=142141
Please review this at https://codereview.chromium.org/173793002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+9, -0 lines):
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
fcd61db046715003564a6e0fa73e009001361ab9..3bcfee97030975bfa0051534b8b93473d33e8488
100644
--- a/src/date.h
+++ b/src/date.h
@@ -122,6 +122,13 @@ class DateCache {
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) {
return time_ms + LocalOffsetInMs() +
DaylightSavingsOffsetInMs(time_ms);
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
9ecbe6a157c560f15ec91d1ae1a14e50aecd0574..1576f8a6b1224ebac299254d669a0aff9024c4d7
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -16324,6 +16324,7 @@ Object* JSDate::GetUTCField(FieldIndex index,
int64_t time_ms = static_cast<int64_t>(value);
if (index == kTimezoneOffset) {
+ date_cache->CheckTimezone();
return Smi::FromInt(date_cache->TimezoneOffset(time_ms));
}
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
55013f1b4e45241f652841ad863113a50ced4615..5d10a3660610ea712f8feb2b61596df100fbe72c
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -9661,6 +9661,7 @@ RUNTIME_FUNCTION(MaybeObject*,
Runtime_DateLocalTimezone) {
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/groups/opt_out.