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

Side by Side Diff: src/scanner-base.h

Issue 6044009: Fix bug that happens when the first non-ASCII character of a literal is at a power-of-two position. (Closed)
Patch Set: Created 9 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
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-1017.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 Vector<byte> new_store = Vector<byte>::New(NewCapacity(kInitialCapacity)); 207 Vector<byte> new_store = Vector<byte>::New(NewCapacity(kInitialCapacity));
208 memcpy(new_store.start(), backing_store_.start(), position_); 208 memcpy(new_store.start(), backing_store_.start(), position_);
209 backing_store_.Dispose(); 209 backing_store_.Dispose();
210 backing_store_ = new_store; 210 backing_store_ = new_store;
211 } 211 }
212 212
213 void ConvertToUC16() { 213 void ConvertToUC16() {
214 ASSERT(is_ascii_); 214 ASSERT(is_ascii_);
215 Vector<byte> new_store; 215 Vector<byte> new_store;
216 int new_content_size = position_ * kUC16Size; 216 int new_content_size = position_ * kUC16Size;
217 if (new_content_size > backing_store_.length()) { 217 if (new_content_size >= backing_store_.length()) {
218 // Ensure room for all currently read characters as UC16 as well
219 // as the character about to be stored.
218 new_store = Vector<byte>::New(NewCapacity(new_content_size)); 220 new_store = Vector<byte>::New(NewCapacity(new_content_size));
219 } else { 221 } else {
220 new_store = backing_store_; 222 new_store = backing_store_;
221 } 223 }
222 char* src = reinterpret_cast<char*>(backing_store_.start()); 224 char* src = reinterpret_cast<char*>(backing_store_.start());
223 uc16* dst = reinterpret_cast<uc16*>(new_store.start()); 225 uc16* dst = reinterpret_cast<uc16*>(new_store.start());
224 for (int i = position_ - 1; i >= 0; i--) { 226 for (int i = position_ - 1; i >= 0; i--) {
225 dst[i] = src[i]; 227 dst[i] = src[i];
226 } 228 }
227 if (new_store.start() != backing_store_.start()) { 229 if (new_store.start() != backing_store_.start()) {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 // keyword with the current prefix). 616 // keyword with the current prefix).
615 const char* keyword_; 617 const char* keyword_;
616 int counter_; 618 int counter_;
617 Token::Value keyword_token_; 619 Token::Value keyword_token_;
618 }; 620 };
619 621
620 622
621 } } // namespace v8::internal 623 } } // namespace v8::internal
622 624
623 #endif // V8_SCANNER_BASE_H_ 625 #endif // V8_SCANNER_BASE_H_
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-1017.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698