OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/date.h" | 5 #include "src/date.h" |
6 | 6 |
7 #include "src/objects.h" | 7 #include "src/objects.h" |
8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 | 13 |
14 static const int kDaysIn4Years = 4 * 365 + 1; | 14 static const int kDaysIn4Years = 4 * 365 + 1; |
15 static const int kDaysIn100Years = 25 * kDaysIn4Years - 1; | 15 static const int kDaysIn100Years = 25 * kDaysIn4Years - 1; |
16 static const int kDaysIn400Years = 4 * kDaysIn100Years + 1; | 16 static const int kDaysIn400Years = 4 * kDaysIn100Years + 1; |
17 static const int kDays1970to2000 = 30 * 365 + 7; | 17 static const int kDays1970to2000 = 30 * 365 + 7; |
18 static const int kDaysOffset = 1000 * kDaysIn400Years + 5 * kDaysIn400Years - | 18 static const int kDaysOffset = 1000 * kDaysIn400Years + 5 * kDaysIn400Years - |
19 kDays1970to2000; | 19 kDays1970to2000; |
20 static const int kYearsOffset = 400000; | 20 static const int kYearsOffset = 400000; |
21 static const char kDaysInMonths[] = | 21 static const char kDaysInMonths[] = |
22 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | 22 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; |
23 | 23 |
24 | 24 |
25 void DateCache::ResetDateCache() { | 25 void DateCache::ResetDateCache() { |
26 static const int kMaxStamp = Smi::kMaxValue; | 26 static const int kMaxStamp = Smi::kMaxValue; |
27 if (stamp_->value() >= kMaxStamp) { | 27 if (stamp_->value() >= kMaxStamp) { |
28 stamp_ = Smi::kZero; | 28 stamp_ = Smi::FromInt(0); |
29 } else { | 29 } else { |
30 stamp_ = Smi::FromInt(stamp_->value() + 1); | 30 stamp_ = Smi::FromInt(stamp_->value() + 1); |
31 } | 31 } |
32 DCHECK(stamp_ != Smi::FromInt(kInvalidStamp)); | 32 DCHECK(stamp_ != Smi::FromInt(kInvalidStamp)); |
33 for (int i = 0; i < kDSTSize; ++i) { | 33 for (int i = 0; i < kDSTSize; ++i) { |
34 ClearSegment(&dst_[i]); | 34 ClearSegment(&dst_[i]); |
35 } | 35 } |
36 dst_usage_counter_ = 0; | 36 dst_usage_counter_ = 0; |
37 before_ = &dst_[0]; | 37 before_ = &dst_[0]; |
38 after_ = &dst_[1]; | 38 after_ = &dst_[1]; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 if (result == NULL || result->last_used > dst_[i].last_used) { | 366 if (result == NULL || result->last_used > dst_[i].last_used) { |
367 result = &dst_[i]; | 367 result = &dst_[i]; |
368 } | 368 } |
369 } | 369 } |
370 ClearSegment(result); | 370 ClearSegment(result); |
371 return result; | 371 return result; |
372 } | 372 } |
373 | 373 |
374 } // namespace internal | 374 } // namespace internal |
375 } // namespace v8 | 375 } // namespace v8 |
OLD | NEW |