OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 5626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5637 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, | 5637 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, |
5638 9, 9, 9, 9, 9, 9, | 5638 9, 9, 9, 9, 9, 9, |
5639 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, | 5639 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, |
5640 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, | 5640 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, |
5641 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, | 5641 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, |
5642 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11}; | 5642 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11}; |
5643 | 5643 |
5644 | 5644 |
5645 // This function works for dates from 1970 to 2099. | 5645 // This function works for dates from 1970 to 2099. |
5646 static inline void DateYMDFromTimeAfter1970(int date, | 5646 static inline void DateYMDFromTimeAfter1970(int date, |
5647 int &year, int &month, int &day) { | 5647 int& year, int& month, int& day) { |
5648 #ifdef DEBUG | 5648 #ifdef DEBUG |
5649 int save_date = date; // Need this for ASSERT in the end. | 5649 int save_date = date; // Need this for ASSERT in the end. |
5650 #endif | 5650 #endif |
5651 | 5651 |
5652 year = 1970 + (4 * date + 2) / kDaysIn4Years; | 5652 year = 1970 + (4 * date + 2) / kDaysIn4Years; |
5653 date %= kDaysIn4Years; | 5653 date %= kDaysIn4Years; |
5654 | 5654 |
5655 month = kMonthInYear[date]; | 5655 month = kMonthInYear[date]; |
5656 day = kDayInYear[date]; | 5656 day = kDayInYear[date]; |
5657 | 5657 |
5658 ASSERT(MakeDay(year, month, day) == save_date); | 5658 ASSERT(MakeDay(year, month, day) == save_date); |
5659 } | 5659 } |
5660 | 5660 |
5661 | 5661 |
5662 static inline void DateYMDFromTimeSlow(int date, | 5662 static inline void DateYMDFromTimeSlow(int date, |
5663 int &year, int &month, int &day) { | 5663 int& year, int& month, int& day) { |
5664 #ifdef DEBUG | 5664 #ifdef DEBUG |
5665 int save_date = date; // Need this for ASSERT in the end. | 5665 int save_date = date; // Need this for ASSERT in the end. |
5666 #endif | 5666 #endif |
5667 | 5667 |
5668 date += kDaysOffset; | 5668 date += kDaysOffset; |
5669 year = 400 * (date / kDaysIn400Years) - kYearsOffset; | 5669 year = 400 * (date / kDaysIn400Years) - kYearsOffset; |
5670 date %= kDaysIn400Years; | 5670 date %= kDaysIn400Years; |
5671 | 5671 |
5672 ASSERT(MakeDay(year, 0, 1) + date == save_date); | 5672 ASSERT(MakeDay(year, 0, 1) + date == save_date); |
5673 | 5673 |
(...skipping 27 matching lines...) Expand all Loading... |
5701 } else { | 5701 } else { |
5702 day = kDayInYear[date]; | 5702 day = kDayInYear[date]; |
5703 month = kMonthInYear[date]; | 5703 month = kMonthInYear[date]; |
5704 } | 5704 } |
5705 | 5705 |
5706 ASSERT(MakeDay(year, month, day) == save_date); | 5706 ASSERT(MakeDay(year, month, day) == save_date); |
5707 } | 5707 } |
5708 | 5708 |
5709 | 5709 |
5710 static inline void DateYMDFromTime(int date, | 5710 static inline void DateYMDFromTime(int date, |
5711 int &year, int &month, int &day) { | 5711 int& year, int& month, int& day) { |
5712 if (date >= 0 && date < 32 * kDaysIn4Years) { | 5712 if (date >= 0 && date < 32 * kDaysIn4Years) { |
5713 DateYMDFromTimeAfter1970(date, year, month, day); | 5713 DateYMDFromTimeAfter1970(date, year, month, day); |
5714 } else { | 5714 } else { |
5715 DateYMDFromTimeSlow(date, year, month, day); | 5715 DateYMDFromTimeSlow(date, year, month, day); |
5716 } | 5716 } |
5717 } | 5717 } |
5718 | 5718 |
5719 | 5719 |
5720 static Object* Runtime_DateYMDFromTime(Arguments args) { | 5720 static Object* Runtime_DateYMDFromTime(Arguments args) { |
5721 NoHandleAllocation ha; | 5721 NoHandleAllocation ha; |
(...skipping 3660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9382 } else { | 9382 } else { |
9383 // Handle last resort GC and make sure to allow future allocations | 9383 // Handle last resort GC and make sure to allow future allocations |
9384 // to grow the heap without causing GCs (if possible). | 9384 // to grow the heap without causing GCs (if possible). |
9385 Counters::gc_last_resort_from_js.Increment(); | 9385 Counters::gc_last_resort_from_js.Increment(); |
9386 Heap::CollectAllGarbage(false); | 9386 Heap::CollectAllGarbage(false); |
9387 } | 9387 } |
9388 } | 9388 } |
9389 | 9389 |
9390 | 9390 |
9391 } } // namespace v8::internal | 9391 } } // namespace v8::internal |
OLD | NEW |