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

Side by Side Diff: src/date.js

Issue 196133017: Experimental parser: merge r19949 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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/date.cc ('k') | src/debug.cc » ('j') | no next file with comments »
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 28 matching lines...) Expand all
39 function ThrowDateTypeError() { 39 function ThrowDateTypeError() {
40 throw new $TypeError('this is not a Date object.'); 40 throw new $TypeError('this is not a Date object.');
41 } 41 }
42 42
43 43
44 var timezone_cache_time = NAN; 44 var timezone_cache_time = NAN;
45 var timezone_cache_timezone; 45 var timezone_cache_timezone;
46 46
47 function LocalTimezone(t) { 47 function LocalTimezone(t) {
48 if (NUMBER_IS_NAN(t)) return ""; 48 if (NUMBER_IS_NAN(t)) return "";
49 CheckDateCacheCurrent();
49 if (t == timezone_cache_time) { 50 if (t == timezone_cache_time) {
50 return timezone_cache_timezone; 51 return timezone_cache_timezone;
51 } 52 }
52 var timezone = %DateLocalTimezone(t); 53 var timezone = %DateLocalTimezone(t);
53 timezone_cache_time = t; 54 timezone_cache_time = t;
54 timezone_cache_timezone = timezone; 55 timezone_cache_timezone = timezone;
55 return timezone; 56 return timezone;
56 } 57 }
57 58
58 59
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 var value; 150 var value;
150 if (argc == 0) { 151 if (argc == 0) {
151 value = %DateCurrentTime(); 152 value = %DateCurrentTime();
152 SET_UTC_DATE_VALUE(this, value); 153 SET_UTC_DATE_VALUE(this, value);
153 } else if (argc == 1) { 154 } else if (argc == 1) {
154 if (IS_NUMBER(year)) { 155 if (IS_NUMBER(year)) {
155 value = year; 156 value = year;
156 } else if (IS_STRING(year)) { 157 } else if (IS_STRING(year)) {
157 // Probe the Date cache. If we already have a time value for the 158 // Probe the Date cache. If we already have a time value for the
158 // given time, we re-use that instead of parsing the string again. 159 // given time, we re-use that instead of parsing the string again.
160 CheckDateCacheCurrent();
159 var cache = Date_cache; 161 var cache = Date_cache;
160 if (cache.string === year) { 162 if (cache.string === year) {
161 value = cache.time; 163 value = cache.time;
162 } else { 164 } else {
163 value = DateParse(year); 165 value = DateParse(year);
164 if (!NUMBER_IS_NAN(value)) { 166 if (!NUMBER_IS_NAN(value)) {
165 cache.time = value; 167 cache.time = value;
166 cache.string = year; 168 cache.string = year;
167 } 169 }
168 } 170 }
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 function DateToJSON(key) { 738 function DateToJSON(key) {
737 var o = ToObject(this); 739 var o = ToObject(this);
738 var tv = DefaultNumber(o); 740 var tv = DefaultNumber(o);
739 if (IS_NUMBER(tv) && !NUMBER_IS_FINITE(tv)) { 741 if (IS_NUMBER(tv) && !NUMBER_IS_FINITE(tv)) {
740 return null; 742 return null;
741 } 743 }
742 return o.toISOString(); 744 return o.toISOString();
743 } 745 }
744 746
745 747
746 function ResetDateCache() { 748 var date_cache_version_holder;
749 var date_cache_version = NAN;
750
751
752 function CheckDateCacheCurrent() {
753 if (!date_cache_version_holder) {
754 date_cache_version_holder = %DateCacheVersion();
755 }
756 if (date_cache_version_holder[0] == date_cache_version) {
757 return;
758 }
759 date_cache_version = date_cache_version_holder[0];
760
747 // Reset the timezone cache: 761 // Reset the timezone cache:
748 timezone_cache_time = NAN; 762 timezone_cache_time = NAN;
749 timezone_cache_timezone = undefined; 763 timezone_cache_timezone = UNDEFINED;
750 764
751 // Reset the date cache: 765 // Reset the date cache:
752 cache = Date_cache; 766 cache = Date_cache;
753 cache.time = NAN; 767 cache.time = NAN;
754 cache.string = null; 768 cache.string = null;
755 } 769 }
756 770
757 771
758 // ------------------------------------------------------------------- 772 // -------------------------------------------------------------------
759 773
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 "toGMTString", DateToGMTString, 833 "toGMTString", DateToGMTString,
820 "toUTCString", DateToUTCString, 834 "toUTCString", DateToUTCString,
821 "getYear", DateGetYear, 835 "getYear", DateGetYear,
822 "setYear", DateSetYear, 836 "setYear", DateSetYear,
823 "toISOString", DateToISOString, 837 "toISOString", DateToISOString,
824 "toJSON", DateToJSON 838 "toJSON", DateToJSON
825 )); 839 ));
826 } 840 }
827 841
828 SetUpDate(); 842 SetUpDate();
OLDNEW
« no previous file with comments | « src/date.cc ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698