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

Side by Side Diff: src/dateparser.cc

Issue 558041: RFC: Try to be much more careful with where we skip the write barrier by:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 10 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/globals.h » ('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 2008 the V8 project authors. All rights reserved. 1 // Copyright 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 day = comp_[0]; 65 day = comp_[0];
66 year = comp_[1]; 66 year = comp_[1];
67 } 67 }
68 } 68 }
69 69
70 if (Between(year, 0, 49)) year += 2000; 70 if (Between(year, 0, 49)) year += 2000;
71 else if (Between(year, 50, 99)) year += 1900; 71 else if (Between(year, 50, 99)) year += 1900;
72 72
73 if (!Smi::IsValid(year) || !IsMonth(month) || !IsDay(day)) return false; 73 if (!Smi::IsValid(year) || !IsMonth(month) || !IsDay(day)) return false;
74 74
75 output->set(YEAR, 75 output->set(YEAR, Smi::FromInt(year));
76 Smi::FromInt(year), 76 output->set(MONTH, Smi::FromInt(month - 1)); // 0-based
77 SKIP_WRITE_BARRIER); 77 output->set(DAY, Smi::FromInt(day));
78 output->set(MONTH,
79 Smi::FromInt(month - 1),
80 SKIP_WRITE_BARRIER); // 0-based
81 output->set(DAY,
82 Smi::FromInt(day),
83 SKIP_WRITE_BARRIER);
84 return true; 78 return true;
85 } 79 }
86 80
87 81
88 bool DateParser::TimeComposer::Write(FixedArray* output) { 82 bool DateParser::TimeComposer::Write(FixedArray* output) {
89 // All time slots default to 0 83 // All time slots default to 0
90 while (index_ < kSize) { 84 while (index_ < kSize) {
91 comp_[index_++] = 0; 85 comp_[index_++] = 0;
92 } 86 }
93 87
94 int& hour = comp_[0]; 88 int& hour = comp_[0];
95 int& minute = comp_[1]; 89 int& minute = comp_[1];
96 int& second = comp_[2]; 90 int& second = comp_[2];
97 91
98 if (hour_offset_ != kNone) { 92 if (hour_offset_ != kNone) {
99 if (!IsHour12(hour)) return false; 93 if (!IsHour12(hour)) return false;
100 hour %= 12; 94 hour %= 12;
101 hour += hour_offset_; 95 hour += hour_offset_;
102 } 96 }
103 97
104 if (!IsHour(hour) || !IsMinute(minute) || !IsSecond(second)) return false; 98 if (!IsHour(hour) || !IsMinute(minute) || !IsSecond(second)) return false;
105 99
106 output->set(HOUR, 100 output->set(HOUR, Smi::FromInt(hour));
107 Smi::FromInt(hour), 101 output->set(MINUTE, Smi::FromInt(minute));
108 SKIP_WRITE_BARRIER); 102 output->set(SECOND, Smi::FromInt(second));
109 output->set(MINUTE,
110 Smi::FromInt(minute),
111 SKIP_WRITE_BARRIER);
112 output->set(SECOND,
113 Smi::FromInt(second),
114 SKIP_WRITE_BARRIER);
115 return true; 103 return true;
116 } 104 }
117 105
118 bool DateParser::TimeZoneComposer::Write(FixedArray* output) { 106 bool DateParser::TimeZoneComposer::Write(FixedArray* output) {
119 if (sign_ != kNone) { 107 if (sign_ != kNone) {
120 if (hour_ == kNone) hour_ = 0; 108 if (hour_ == kNone) hour_ = 0;
121 if (minute_ == kNone) minute_ = 0; 109 if (minute_ == kNone) minute_ = 0;
122 int total_seconds = sign_ * (hour_ * 3600 + minute_ * 60); 110 int total_seconds = sign_ * (hour_ * 3600 + minute_ * 60);
123 if (!Smi::IsValid(total_seconds)) return false; 111 if (!Smi::IsValid(total_seconds)) return false;
124 output->set(UTC_OFFSET, 112 output->set(UTC_OFFSET, Smi::FromInt(total_seconds));
125 Smi::FromInt(total_seconds),
126 SKIP_WRITE_BARRIER);
127 } else { 113 } else {
128 output->set(UTC_OFFSET, 114 output->set_null(UTC_OFFSET);
129 Heap::null_value(),
130 SKIP_WRITE_BARRIER);
131 } 115 }
132 return true; 116 return true;
133 } 117 }
134 118
135 const int8_t DateParser::KeywordTable:: 119 const int8_t DateParser::KeywordTable::
136 array[][DateParser::KeywordTable::kEntrySize] = { 120 array[][DateParser::KeywordTable::kEntrySize] = {
137 {'j', 'a', 'n', DateParser::MONTH_NAME, 1}, 121 {'j', 'a', 'n', DateParser::MONTH_NAME, 1},
138 {'f', 'e', 'b', DateParser::MONTH_NAME, 2}, 122 {'f', 'e', 'b', DateParser::MONTH_NAME, 2},
139 {'m', 'a', 'r', DateParser::MONTH_NAME, 3}, 123 {'m', 'a', 'r', DateParser::MONTH_NAME, 3},
140 {'a', 'p', 'r', DateParser::MONTH_NAME, 4}, 124 {'a', 'p', 'r', DateParser::MONTH_NAME, 4},
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if (j == kPrefixLength && 161 if (j == kPrefixLength &&
178 (len <= kPrefixLength || array[i][kTypeOffset] == MONTH_NAME)) { 162 (len <= kPrefixLength || array[i][kTypeOffset] == MONTH_NAME)) {
179 return i; 163 return i;
180 } 164 }
181 } 165 }
182 return i; 166 return i;
183 } 167 }
184 168
185 169
186 } } // namespace v8::internal 170 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698