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

Side by Side Diff: src/scanner.h

Issue 11759008: Introduce ENABLE_LATIN_1 compile flag (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix FilterASCII Created 7 years, 11 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/runtime.cc ('k') | src/string.js » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 ~LiteralBuffer() { 177 ~LiteralBuffer() {
178 if (backing_store_.length() > 0) { 178 if (backing_store_.length() > 0) {
179 backing_store_.Dispose(); 179 backing_store_.Dispose();
180 } 180 }
181 } 181 }
182 182
183 INLINE(void AddChar(uint32_t code_unit)) { 183 INLINE(void AddChar(uint32_t code_unit)) {
184 if (position_ >= backing_store_.length()) ExpandBuffer(); 184 if (position_ >= backing_store_.length()) ExpandBuffer();
185 if (is_ascii_) { 185 if (is_ascii_) {
186 if (code_unit < kMaxAsciiCharCodeU) { 186 if (code_unit <= unibrow::Latin1::kMaxChar) {
187 backing_store_[position_] = static_cast<byte>(code_unit); 187 backing_store_[position_] = static_cast<byte>(code_unit);
188 position_ += kASCIISize; 188 position_ += kOneByteSize;
189 return; 189 return;
190 } 190 }
191 ConvertToUtf16(); 191 ConvertToUtf16();
192 } 192 }
193 ASSERT(code_unit < 0x10000u); 193 ASSERT(code_unit < 0x10000u);
194 *reinterpret_cast<uc16*>(&backing_store_[position_]) = code_unit; 194 *reinterpret_cast<uc16*>(&backing_store_[position_]) = code_unit;
195 position_ += kUC16Size; 195 position_ += kUC16Size;
196 } 196 }
197 197
198 bool is_ascii() { return is_ascii_; } 198 bool is_ascii() { return is_ascii_; }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 ASSERT(is_ascii_); 243 ASSERT(is_ascii_);
244 Vector<byte> new_store; 244 Vector<byte> new_store;
245 int new_content_size = position_ * kUC16Size; 245 int new_content_size = position_ * kUC16Size;
246 if (new_content_size >= backing_store_.length()) { 246 if (new_content_size >= backing_store_.length()) {
247 // Ensure room for all currently read code units as UC16 as well 247 // Ensure room for all currently read code units as UC16 as well
248 // as the code unit about to be stored. 248 // as the code unit about to be stored.
249 new_store = Vector<byte>::New(NewCapacity(new_content_size)); 249 new_store = Vector<byte>::New(NewCapacity(new_content_size));
250 } else { 250 } else {
251 new_store = backing_store_; 251 new_store = backing_store_;
252 } 252 }
253 char* src = reinterpret_cast<char*>(backing_store_.start()); 253 uint8_t* src = backing_store_.start();
254 uc16* dst = reinterpret_cast<uc16*>(new_store.start()); 254 uc16* dst = reinterpret_cast<uc16*>(new_store.start());
255 for (int i = position_ - 1; i >= 0; i--) { 255 for (int i = position_ - 1; i >= 0; i--) {
256 dst[i] = src[i]; 256 dst[i] = src[i];
257 } 257 }
258 if (new_store.start() != backing_store_.start()) { 258 if (new_store.start() != backing_store_.start()) {
259 backing_store_.Dispose(); 259 backing_store_.Dispose();
260 backing_store_ = new_store; 260 backing_store_ = new_store;
261 } 261 }
262 position_ = new_content_size; 262 position_ = new_content_size;
263 is_ascii_ = false; 263 is_ascii_ = false;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 bool has_multiline_comment_before_next_; 561 bool has_multiline_comment_before_next_;
562 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings. 562 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings.
563 bool harmony_scoping_; 563 bool harmony_scoping_;
564 // Whether we scan 'module', 'import', 'export' as keywords. 564 // Whether we scan 'module', 'import', 'export' as keywords.
565 bool harmony_modules_; 565 bool harmony_modules_;
566 }; 566 };
567 567
568 } } // namespace v8::internal 568 } } // namespace v8::internal
569 569
570 #endif // V8_SCANNER_H_ 570 #endif // V8_SCANNER_H_
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698