OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 12969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12980 Object* JSDate::DoGetField(FieldIndex index) { | 12980 Object* JSDate::DoGetField(FieldIndex index) { |
12981 ASSERT(index != kDateValue); | 12981 ASSERT(index != kDateValue); |
12982 | 12982 |
12983 DateCache* date_cache = GetIsolate()->date_cache(); | 12983 DateCache* date_cache = GetIsolate()->date_cache(); |
12984 | 12984 |
12985 if (index < kFirstUncachedField) { | 12985 if (index < kFirstUncachedField) { |
12986 Object* stamp = cache_stamp(); | 12986 Object* stamp = cache_stamp(); |
12987 if (stamp != date_cache->stamp() && stamp->IsSmi()) { | 12987 if (stamp != date_cache->stamp() && stamp->IsSmi()) { |
12988 // Since the stamp is not NaN, the value is also not NaN. | 12988 // Since the stamp is not NaN, the value is also not NaN. |
12989 int64_t local_time_ms = | 12989 int64_t local_time_ms = |
12990 static_cast<int64_t>(date_cache->ToLocal(value()->Number())); | 12990 date_cache->ToLocal(static_cast<int64_t>(value()->Number())); |
12991 SetLocalFields(local_time_ms, date_cache); | 12991 SetLocalFields(local_time_ms, date_cache); |
12992 } | 12992 } |
12993 switch (index) { | 12993 switch (index) { |
12994 case kYear: return year(); | 12994 case kYear: return year(); |
12995 case kMonth: return month(); | 12995 case kMonth: return month(); |
12996 case kDay: return day(); | 12996 case kDay: return day(); |
12997 case kWeekday: return weekday(); | 12997 case kWeekday: return weekday(); |
12998 case kHour: return hour(); | 12998 case kHour: return hour(); |
12999 case kMinute: return min(); | 12999 case kMinute: return min(); |
13000 case kSecond: return sec(); | 13000 case kSecond: return sec(); |
13001 default: UNREACHABLE(); | 13001 default: UNREACHABLE(); |
13002 } | 13002 } |
13003 } | 13003 } |
13004 | 13004 |
13005 if (index >= kFirstUTCField) { | 13005 if (index >= kFirstUTCField) { |
13006 return GetUTCField(index, value()->Number(), date_cache); | 13006 return GetUTCField(index, value()->Number(), date_cache); |
13007 } | 13007 } |
13008 | 13008 |
13009 double time = value()->Number(); | 13009 double time = value()->Number(); |
13010 if (isnan(time)) return GetIsolate()->heap()->nan_value(); | 13010 if (isnan(time)) return GetIsolate()->heap()->nan_value(); |
13011 | 13011 |
13012 int64_t local_time_ms = static_cast<int64_t>(date_cache->ToLocal(time)); | 13012 int64_t local_time_ms = date_cache->ToLocal(static_cast<int64_t>(time)); |
13013 int days = DateCache::DaysFromTime(local_time_ms); | 13013 int days = DateCache::DaysFromTime(local_time_ms); |
13014 | 13014 |
13015 if (index == kDays) return Smi::FromInt(days); | 13015 if (index == kDays) return Smi::FromInt(days); |
13016 | 13016 |
13017 int time_in_day_ms = DateCache::TimeInDay(local_time_ms, days); | 13017 int time_in_day_ms = DateCache::TimeInDay(local_time_ms, days); |
13018 if (index == kMillisecond) return Smi::FromInt(time_in_day_ms % 1000); | 13018 if (index == kMillisecond) return Smi::FromInt(time_in_day_ms % 1000); |
13019 ASSERT(index == kTimeInDay); | 13019 ASSERT(index == kTimeInDay); |
13020 return Smi::FromInt(time_in_day_ms); | 13020 return Smi::FromInt(time_in_day_ms); |
13021 } | 13021 } |
13022 | 13022 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13094 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13094 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13095 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13095 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13096 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13096 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13097 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13097 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13098 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13098 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13099 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13099 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13100 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13100 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13101 } | 13101 } |
13102 | 13102 |
13103 } } // namespace v8::internal | 13103 } } // namespace v8::internal |
OLD | NEW |