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 5058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5069 static Object* Runtime_Math_tan(Arguments args) { | 5069 static Object* Runtime_Math_tan(Arguments args) { |
5070 NoHandleAllocation ha; | 5070 NoHandleAllocation ha; |
5071 ASSERT(args.length() == 1); | 5071 ASSERT(args.length() == 1); |
5072 Counters::math_tan.Increment(); | 5072 Counters::math_tan.Increment(); |
5073 | 5073 |
5074 CONVERT_DOUBLE_CHECKED(x, args[0]); | 5074 CONVERT_DOUBLE_CHECKED(x, args[0]); |
5075 return TranscendentalCache::Get(TranscendentalCache::TAN, x); | 5075 return TranscendentalCache::Get(TranscendentalCache::TAN, x); |
5076 } | 5076 } |
5077 | 5077 |
5078 | 5078 |
5079 static Object* Runtime_DateMakeDay(Arguments args) { | 5079 static int MakeDay(int year, int month, int day) { |
5080 NoHandleAllocation ha; | |
5081 ASSERT(args.length() == 3); | |
5082 | |
5083 CONVERT_SMI_CHECKED(year, args[0]); | |
5084 CONVERT_SMI_CHECKED(month, args[1]); | |
5085 CONVERT_SMI_CHECKED(date, args[2]); | |
5086 | |
5087 static const int day_from_month[] = {0, 31, 59, 90, 120, 151, | 5080 static const int day_from_month[] = {0, 31, 59, 90, 120, 151, |
Mads Ager (chromium)
2010/03/12 08:00:21
Let's change these constants to follow the Google
| |
5088 181, 212, 243, 273, 304, 334}; | 5081 181, 212, 243, 273, 304, 334}; |
5089 static const int day_from_month_leap[] = {0, 31, 60, 91, 121, 152, | 5082 static const int day_from_month_leap[] = {0, 31, 60, 91, 121, 152, |
5090 182, 213, 244, 274, 305, 335}; | 5083 182, 213, 244, 274, 305, 335}; |
5091 | 5084 |
5092 year += month / 12; | 5085 year += month / 12; |
5093 month %= 12; | 5086 month %= 12; |
5094 if (month < 0) { | 5087 if (month < 0) { |
5095 year--; | 5088 year--; |
5096 month += 12; | 5089 month += 12; |
5097 } | 5090 } |
5098 | 5091 |
5099 ASSERT(month >= 0); | 5092 ASSERT(month >= 0); |
5100 ASSERT(month < 12); | 5093 ASSERT(month < 12); |
5101 | 5094 |
5102 // year_delta is an arbitrary number such that: | 5095 // year_delta is an arbitrary number such that: |
5103 // a) year_delta = -1 (mod 400) | 5096 // a) year_delta = -1 (mod 400) |
5104 // b) year + year_delta > 0 for years in the range defined by | 5097 // b) year + year_delta > 0 for years in the range defined by |
5105 // ECMA 262 - 15.9.1.1, i.e. upto 100,000,000 days on either side of | 5098 // ECMA 262 - 15.9.1.1, i.e. upto 100,000,000 days on either side of |
5106 // Jan 1 1970. This is required so that we don't run into integer | 5099 // Jan 1 1970. This is required so that we don't run into integer |
5107 // division of negative numbers. | 5100 // division of negative numbers. |
5108 // c) there shouldn't be overflow for 32-bit integers in the following | 5101 // c) there shouldn't be an overflow for 32-bit integers in the following |
5109 // operations. | 5102 // operations. |
5110 static const int year_delta = 399999; | 5103 static const int year_delta = 399999; |
5111 static const int base_day = 365 * (1970 + year_delta) + | 5104 static const int base_day = 365 * (1970 + year_delta) + |
5112 (1970 + year_delta) / 4 - | 5105 (1970 + year_delta) / 4 - |
5113 (1970 + year_delta) / 100 + | 5106 (1970 + year_delta) / 100 + |
5114 (1970 + year_delta) / 400; | 5107 (1970 + year_delta) / 400; |
5115 | 5108 |
5116 int year1 = year + year_delta; | 5109 int year1 = year + year_delta; |
5117 int day_from_year = 365 * year1 + | 5110 int day_from_year = 365 * year1 + |
5118 year1 / 4 - | 5111 year1 / 4 - |
5119 year1 / 100 + | 5112 year1 / 100 + |
5120 year1 / 400 - | 5113 year1 / 400 - |
5121 base_day; | 5114 base_day; |
5122 | 5115 |
5123 if (year % 4 || (year % 100 == 0 && year % 400 != 0)) { | 5116 if (year % 4 || (year % 100 == 0 && year % 400 != 0)) { |
5124 return Smi::FromInt(day_from_year + day_from_month[month] + date - 1); | 5117 return day_from_year + day_from_month[month] + day - 1; |
5125 } | 5118 } |
5126 | 5119 |
5127 return Smi::FromInt(day_from_year + day_from_month_leap[month] + date - 1); | 5120 return day_from_year + day_from_month_leap[month] + day - 1; |
5121 } | |
5122 | |
5123 | |
5124 static Object* Runtime_DateMakeDay(Arguments args) { | |
5125 NoHandleAllocation ha; | |
5126 ASSERT(args.length() == 3); | |
5127 | |
5128 CONVERT_SMI_CHECKED(year, args[0]); | |
5129 CONVERT_SMI_CHECKED(month, args[1]); | |
5130 CONVERT_SMI_CHECKED(date, args[2]); | |
5131 | |
5132 return Smi::FromInt(MakeDay(year, month, date)); | |
5133 } | |
5134 | |
5135 | |
5136 static const int kDays4Years[] = {0, 365, 2 * 365, 3 * 365 + 1}; | |
5137 static const int kDaysIn4Years = 4 * 365 + 1; | |
5138 static const int kDaysIn100Years = 25 * kDaysIn4Years - 1; | |
5139 static const int kDaysIn400Years = 4 * kDaysIn100Years + 1; | |
5140 static const int kDays1970to2000 = 30 * 365 + 7; | |
5141 static const int kDaysOffset = 1000 * kDaysIn400Years + 5 * kDaysIn400Years - | |
5142 kDays1970to2000; | |
5143 static const int kYearsOffset = 400000; | |
5144 | |
5145 static const char kDayInYear[] = { | |
Mads Ager (chromium)
2010/03/12 08:00:21
Could you add a comment stating the start and end
| |
5146 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5147 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5148 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5149 22, 23, 24, 25, 26, 27, 28, | |
5150 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5151 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5152 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5153 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5154 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5155 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5156 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5157 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5158 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5159 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5160 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5161 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5162 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5163 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5164 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5165 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5166 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5167 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5168 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5169 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5170 | |
5171 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5172 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5173 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5174 22, 23, 24, 25, 26, 27, 28, | |
5175 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5176 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5177 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5178 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5179 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5180 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5181 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5182 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5183 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5184 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5185 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5186 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5187 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5188 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5189 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5190 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5191 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5192 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5193 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5194 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5195 | |
5196 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5197 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5198 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5199 22, 23, 24, 25, 26, 27, 28, 29, | |
5200 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5201 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5202 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5203 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5204 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5205 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5206 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5207 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5208 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5209 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5210 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5211 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5212 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5213 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5214 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5215 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5216 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5217 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5218 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5219 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5220 | |
5221 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5222 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5223 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5224 22, 23, 24, 25, 26, 27, 28, | |
5225 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5226 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5227 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5228 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5229 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5230 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5231 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5232 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5233 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5234 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5235 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5236 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5237 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5238 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5239 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5240 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
5241 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5242 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
5243 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
5244 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; | |
5245 | |
5246 static const char kMonthInYear[] = { | |
Mads Ager (chromium)
2010/03/12 08:00:21
Comment with start and end year for this table?
| |
5247 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
5248 0, 0, 0, 0, 0, 0, | |
5249 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
5250 1, 1, 1, | |
5251 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
5252 2, 2, 2, 2, 2, 2, | |
5253 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | |
5254 3, 3, 3, 3, 3, | |
5255 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, | |
5256 4, 4, 4, 4, 4, 4, | |
5257 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | |
5258 5, 5, 5, 5, 5, | |
5259 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, | |
5260 6, 6, 6, 6, 6, 6, | |
5261 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
5262 7, 7, 7, 7, 7, 7, | |
5263 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, | |
5264 8, 8, 8, 8, 8, | |
5265 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, | |
5266 9, 9, 9, 9, 9, 9, | |
5267 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, | |
5268 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, | |
5269 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, | |
5270 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, | |
5271 | |
5272 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
5273 0, 0, 0, 0, 0, 0, | |
5274 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
5275 1, 1, 1, | |
5276 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
5277 2, 2, 2, 2, 2, 2, | |
5278 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | |
5279 3, 3, 3, 3, 3, | |
5280 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, | |
5281 4, 4, 4, 4, 4, 4, | |
5282 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | |
5283 5, 5, 5, 5, 5, | |
5284 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, | |
5285 6, 6, 6, 6, 6, 6, | |
5286 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
5287 7, 7, 7, 7, 7, 7, | |
5288 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, | |
5289 8, 8, 8, 8, 8, | |
5290 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, | |
5291 9, 9, 9, 9, 9, 9, | |
5292 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, | |
5293 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, | |
5294 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, | |
5295 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, | |
5296 | |
5297 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
5298 0, 0, 0, 0, 0, 0, | |
5299 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
5300 1, 1, 1, 1, | |
5301 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
5302 2, 2, 2, 2, 2, 2, | |
5303 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | |
5304 3, 3, 3, 3, 3, | |
5305 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, | |
5306 4, 4, 4, 4, 4, 4, | |
5307 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | |
5308 5, 5, 5, 5, 5, | |
5309 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, | |
5310 6, 6, 6, 6, 6, 6, | |
5311 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
5312 7, 7, 7, 7, 7, 7, | |
5313 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, | |
5314 8, 8, 8, 8, 8, | |
5315 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, | |
5316 9, 9, 9, 9, 9, 9, | |
5317 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, | |
5318 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, | |
5319 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, | |
5320 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, | |
5321 | |
5322 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
5323 0, 0, 0, 0, 0, 0, | |
5324 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
5325 1, 1, 1, | |
5326 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
5327 2, 2, 2, 2, 2, 2, | |
5328 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | |
5329 3, 3, 3, 3, 3, | |
5330 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, | |
5331 4, 4, 4, 4, 4, 4, | |
5332 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | |
5333 5, 5, 5, 5, 5, | |
5334 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, | |
5335 6, 6, 6, 6, 6, 6, | |
5336 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
5337 7, 7, 7, 7, 7, 7, | |
5338 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, | |
5339 8, 8, 8, 8, 8, | |
5340 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, | |
5341 9, 9, 9, 9, 9, 9, | |
5342 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, | |
5343 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, | |
5344 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, | |
5345 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11}; | |
5346 | |
5347 | |
5348 // This function works for dates from 1970 to 2099. | |
5349 static inline void DateYMDFromTimeAfter1970(int date, | |
5350 int &year, int &month, int &day) { | |
Mads Ager (chromium)
2010/03/12 08:00:21
One parameter per line when splitting like this.
| |
5351 #ifdef DEBUG | |
5352 int save_date = date; // Need this for ASSERTÂ in the end. | |
5353 #endif | |
5354 | |
5355 year = 1970 + (4 * date + 2) / kDaysIn4Years; | |
5356 date %= kDaysIn4Years; | |
5357 | |
5358 month = kMonthInYear[date]; | |
5359 day = kDayInYear[date]; | |
5360 | |
5361 ASSERT(MakeDay(year, month, day) == save_date); | |
5362 } | |
5363 | |
5364 | |
5365 static inline void DateYMDFromTimeSlow(int date, | |
5366 int &year, int &month, int &day) { | |
5367 #ifdef DEBUG | |
5368 int save_date = date; // Need this for ASSERTÂ in the end. | |
5369 #endif | |
5370 | |
5371 date += kDaysOffset; | |
5372 year = 400 * (date / kDaysIn400Years) - kYearsOffset; | |
5373 date %= kDaysIn400Years; | |
5374 | |
5375 ASSERT(MakeDay(year, 0, 1) + date == save_date); | |
5376 | |
5377 date--; | |
5378 int yd1 = date / kDaysIn100Years; | |
5379 date %= kDaysIn100Years; | |
5380 year += 100 * yd1; | |
5381 | |
5382 date++; | |
5383 int yd2 = date / kDaysIn4Years; | |
5384 date %= kDaysIn4Years; | |
5385 year += 4 * yd2; | |
5386 | |
5387 date--; | |
5388 int yd3 = date / 365; | |
5389 date %= 365; | |
5390 year += yd3; | |
5391 | |
5392 bool is_leap = (!yd1 || yd2) && !yd3; | |
5393 | |
5394 ASSERT(date >= -1); | |
5395 ASSERT(is_leap || date >= 0); | |
5396 ASSERT(date < 365 || is_leap && date < 366); | |
5397 ASSERT(is_leap == (year % 4 == 0 && (year % 100 || (year % 400 == 0)))); | |
5398 ASSERT(is_leap || MakeDay(year, 0, 1) + date == save_date); | |
5399 ASSERT(!is_leap || MakeDay(year, 0, 1) + date + 1 == save_date); | |
5400 | |
5401 if (is_leap) { | |
5402 day = kDayInYear[2*365 + 1 + date]; | |
5403 month = kMonthInYear[2*365 + 1 + date]; | |
5404 } else { | |
5405 day = kDayInYear[date]; | |
5406 month = kMonthInYear[date]; | |
5407 } | |
5408 | |
5409 ASSERT(MakeDay(year, month, day) == save_date); | |
5410 } | |
5411 | |
5412 | |
5413 static inline void DateYMDFromTime(int date, | |
5414 int &year, int &month, int &day) { | |
5415 if (date >= 0 && date < 32 * kDaysIn4Years) { | |
5416 DateYMDFromTimeAfter1970(date, year, month, day); | |
5417 } else { | |
5418 DateYMDFromTimeSlow(date, year, month, day); | |
5419 } | |
5420 } | |
5421 | |
5422 | |
5423 static Object* Runtime_DateYMDFromTime(Arguments args) { | |
5424 NoHandleAllocation ha; | |
5425 ASSERT(args.length() == 2); | |
5426 | |
5427 CONVERT_DOUBLE_CHECKED(t, args[0]); | |
5428 CONVERT_CHECKED(JSArray, res_array, args[1]); | |
5429 | |
5430 int year, month, day; | |
5431 DateYMDFromTime(static_cast<int>(floor(t / 86400000)), year, month, day); | |
5432 | |
5433 res_array->SetElement(0, Smi::FromInt(year)); | |
5434 res_array->SetElement(1, Smi::FromInt(month)); | |
5435 res_array->SetElement(2, Smi::FromInt(day)); | |
5436 | |
5437 return Heap::undefined_value(); | |
5128 } | 5438 } |
5129 | 5439 |
5130 | 5440 |
5131 static Object* Runtime_NewArgumentsFast(Arguments args) { | 5441 static Object* Runtime_NewArgumentsFast(Arguments args) { |
5132 NoHandleAllocation ha; | 5442 NoHandleAllocation ha; |
5133 ASSERT(args.length() == 3); | 5443 ASSERT(args.length() == 3); |
5134 | 5444 |
5135 JSFunction* callee = JSFunction::cast(args[0]); | 5445 JSFunction* callee = JSFunction::cast(args[0]); |
5136 Object** parameters = reinterpret_cast<Object**>(args[1]); | 5446 Object** parameters = reinterpret_cast<Object**>(args[1]); |
5137 const int length = Smi::cast(args[2])->value(); | 5447 const int length = Smi::cast(args[2])->value(); |
(...skipping 3607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8745 } else { | 9055 } else { |
8746 // Handle last resort GC and make sure to allow future allocations | 9056 // Handle last resort GC and make sure to allow future allocations |
8747 // to grow the heap without causing GCs (if possible). | 9057 // to grow the heap without causing GCs (if possible). |
8748 Counters::gc_last_resort_from_js.Increment(); | 9058 Counters::gc_last_resort_from_js.Increment(); |
8749 Heap::CollectAllGarbage(false); | 9059 Heap::CollectAllGarbage(false); |
8750 } | 9060 } |
8751 } | 9061 } |
8752 | 9062 |
8753 | 9063 |
8754 } } // namespace v8::internal | 9064 } } // namespace v8::internal |
OLD | NEW |