Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: src/date-delay.js

Issue 6441: - Added fast case for extending the JSObject properties storage.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/builtins.cc ('k') | src/handles.cc » ('j') | src/ic.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 18 matching lines...) Expand all
29 // ------------------------------------------------------------------- 29 // -------------------------------------------------------------------
30 30
31 // This file contains date support implemented in JavaScript. 31 // This file contains date support implemented in JavaScript.
32 32
33 33
34 // Keep reference to original values of some global properties. This 34 // Keep reference to original values of some global properties. This
35 // has the added benefit that the code in this file is isolated from 35 // has the added benefit that the code in this file is isolated from
36 // changes to these properties. 36 // changes to these properties.
37 const $Date = global.Date; 37 const $Date = global.Date;
38 38
39
40 // ECMA 262 - 15.9.1.2 39 // ECMA 262 - 15.9.1.2
41 function Day(time) { 40 function Day(time) {
42 return $floor(time/msPerDay); 41 return $floor(time/msPerDay);
43 } 42 }
44 43
45 44
46 // ECMA 262 - 5.2 45 // ECMA 262 - 5.2
47 function Modulo(value, remainder) { 46 function Modulo(value, remainder) {
48 var mod = value % remainder; 47 var mod = value % remainder;
49 return mod >= 0 ? mod : mod + remainder; 48 return mod >= 0 ? mod : mod + remainder;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // We solve this by mapping the time to a year with same leap-year-ness 119 // We solve this by mapping the time to a year with same leap-year-ness
121 // and same starting day for the year. 120 // and same starting day for the year.
122 // As an optimization we avoid finding an equivalent year in the common 121 // As an optimization we avoid finding an equivalent year in the common
123 // case. We are measuring in ms here so the 32 bit signed integer range 122 // case. We are measuring in ms here so the 32 bit signed integer range
124 // is +-(1<<30)*1000 ie approximately +-2.1e20. 123 // is +-(1<<30)*1000 ie approximately +-2.1e20.
125 if (t >= -2.1e12 && t <= 2.1e12) return t; 124 if (t >= -2.1e12 && t <= 2.1e12) return t;
126 var day = MakeDay(EquivalentYear(YearFromTime(t)), MonthFromTime(t), DateFromT ime(t)); 125 var day = MakeDay(EquivalentYear(YearFromTime(t)), MonthFromTime(t), DateFromT ime(t));
127 return TimeClip(MakeDate(day, TimeWithinDay(t))); 126 return TimeClip(MakeDate(day, TimeWithinDay(t)));
128 } 127 }
129 128
130
131 var local_time_offset;
132
133 function LocalTimeOffset() {
134 if (IS_UNDEFINED(local_time_offset)) {
135 local_time_offset = %DateLocalTimeOffset();
136 }
137 return local_time_offset;
138 }
139
140
141 var daylight_cache_time = $NaN; 129 var daylight_cache_time = $NaN;
142 var daylight_cache_offset; 130 var daylight_cache_offset;
143 131
144 function DaylightSavingsOffset(t) { 132 function DaylightSavingsOffset(t) {
145 if (t == daylight_cache_time) { 133 if (t == daylight_cache_time) {
146 return daylight_cache_offset; 134 return daylight_cache_offset;
147 } 135 }
148 var offset = %DateDaylightSavingsOffset(EquivalentTime(t)); 136 var offset = %DateDaylightSavingsOffset(EquivalentTime(t));
149 daylight_cache_time = t; 137 daylight_cache_time = t;
150 daylight_cache_offset = offset; 138 daylight_cache_offset = offset;
(...skipping 12 matching lines...) Expand all
163 timezone_cache_time = t; 151 timezone_cache_time = t;
164 timezone_cache_timezone = timezone; 152 timezone_cache_timezone = timezone;
165 return timezone; 153 return timezone;
166 } 154 }
167 155
168 156
169 function WeekDay(time) { 157 function WeekDay(time) {
170 return Modulo(Day(time) + 4, 7); 158 return Modulo(Day(time) + 4, 7);
171 } 159 }
172 160
161 var local_time_offset = %DateLocalTimeOffset();
173 162
174 function LocalTime(time) { 163 function LocalTime(time) {
175 if ($isNaN(time)) return time; 164 if ($isNaN(time)) return time;
176 return time + LocalTimeOffset() + DaylightSavingsOffset(time); 165 return time + local_time_offset + DaylightSavingsOffset(time);
177 } 166 }
178 167
179 168
180 function UTC(time) { 169 function UTC(time) {
181 if ($isNaN(time)) return time; 170 if ($isNaN(time)) return time;
182 var tmp = time - LocalTimeOffset(); 171 var tmp = time - local_time_offset;
183 return tmp - DaylightSavingsOffset(tmp); 172 return tmp - DaylightSavingsOffset(tmp);
184 } 173 }
185 174
186 175
187 // ECMA 262 - 15.9.1.10 176 // ECMA 262 - 15.9.1.10
188 function HourFromTime(time) { 177 function HourFromTime(time) {
189 return Modulo($floor(time / msPerHour), HoursPerDay); 178 return Modulo($floor(time / msPerHour), HoursPerDay);
190 } 179 }
191 180
192 181
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 512
524 513
525 function TimeString(time) { 514 function TimeString(time) {
526 return TwoDigitString(HourFromTime(time)) + ':' 515 return TwoDigitString(HourFromTime(time)) + ':'
527 + TwoDigitString(MinFromTime(time)) + ':' 516 + TwoDigitString(MinFromTime(time)) + ':'
528 + TwoDigitString(SecFromTime(time)); 517 + TwoDigitString(SecFromTime(time));
529 } 518 }
530 519
531 520
532 function LocalTimezoneString(time) { 521 function LocalTimezoneString(time) {
533 var timezoneOffset = (LocalTimeOffset() + DaylightSavingsOffset(time)) / msPer Minute; 522 var timezoneOffset = (local_time_offset + DaylightSavingsOffset(time)) / msPer Minute;
534 var sign = (timezoneOffset >= 0) ? 1 : -1; 523 var sign = (timezoneOffset >= 0) ? 1 : -1;
535 var hours = $floor((sign * timezoneOffset)/60); 524 var hours = $floor((sign * timezoneOffset)/60);
536 var min = $floor((sign * timezoneOffset)%60); 525 var min = $floor((sign * timezoneOffset)%60);
537 var gmt = ' GMT' + ((sign == 1) ? '+' : '-') + TwoDigitString(hours) + TwoDigi tString(min); 526 var gmt = ' GMT' + ((sign == 1) ? '+' : '-') + TwoDigitString(hours) + TwoDigi tString(min);
538 return gmt + ' (' + LocalTimezone(time) + ')'; 527 return gmt + ' (' + LocalTimezone(time) + ')';
539 } 528 }
540 529
541 530
542 function DatePrintString(time) { 531 function DatePrintString(time) {
543 return DateString(time) + ' ' + TimeString(time); 532 return DateString(time) + ' ' + TimeString(time);
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 "setFullYear", DateSetFullYear, 1005 "setFullYear", DateSetFullYear,
1017 "setUTCFullYear", DateSetUTCFullYear, 1006 "setUTCFullYear", DateSetUTCFullYear,
1018 "toGMTString", DateToGMTString, 1007 "toGMTString", DateToGMTString,
1019 "toUTCString", DateToUTCString, 1008 "toUTCString", DateToUTCString,
1020 "getYear", DateGetYear, 1009 "getYear", DateGetYear,
1021 "setYear", DateSetYear 1010 "setYear", DateSetYear
1022 )); 1011 ));
1023 } 1012 }
1024 1013
1025 SetupDate(); 1014 SetupDate();
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/handles.cc » ('j') | src/ic.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698