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

Side by Side Diff: src/lexer/experimental-scanner.h

Issue 138123002: Experimental lexer: reset literals if the source was moved by GC. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 Vector<const char> ascii_string; 247 Vector<const char> ascii_string;
248 Vector<const uc16> utf16_string; 248 Vector<const uc16> utf16_string;
249 LiteralBuffer buffer; 249 LiteralBuffer buffer;
250 LiteralDesc() : beg_pos(-1), is_ascii(false), length(0) { } 250 LiteralDesc() : beg_pos(-1), is_ascii(false), length(0) { }
251 bool Valid(int pos) { return beg_pos == pos; } 251 bool Valid(int pos) { return beg_pos == pos; }
252 }; 252 };
253 253
254 virtual void Scan() = 0; 254 virtual void Scan() = 0;
255 virtual bool FillLiteral(const TokenDesc& token, LiteralDesc* literal) = 0; 255 virtual bool FillLiteral(const TokenDesc& token, LiteralDesc* literal) = 0;
256 256
257 void ResetLiterals() {
258 current_literal_->beg_pos = -1;
259 next_literal_->beg_pos = -1;
260 }
261
257 Isolate* isolate_; 262 Isolate* isolate_;
258 UnicodeCache* unicode_cache_; 263 UnicodeCache* unicode_cache_;
259 264
260 bool has_line_terminator_before_next_; 265 bool has_line_terminator_before_next_;
261 // Whether there is a multiline comment *with a line break* before the next 266 // Whether there is a multiline comment *with a line break* before the next
262 // token. 267 // token.
263 bool has_multiline_comment_before_next_; 268 bool has_multiline_comment_before_next_;
264 269
265 TokenDesc current_; // desc for current token (as returned by Next()) 270 TokenDesc current_; // desc for current token (as returned by Next())
266 TokenDesc next_; // desc for next token (one token look-ahead) 271 TokenDesc next_; // desc for next token (one token look-ahead)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 316
312 virtual void UpdateBufferBasedOnHandle() { 317 virtual void UpdateBufferBasedOnHandle() {
313 // We get a raw pointer from the Handle, but we also update it every time 318 // We get a raw pointer from the Handle, but we also update it every time
314 // there is a GC, so it is safe. 319 // there is a GC, so it is safe.
315 DisallowHeapAllocation no_gc; 320 DisallowHeapAllocation no_gc;
316 const Char* new_buffer = GetNewBufferBasedOnHandle(); 321 const Char* new_buffer = GetNewBufferBasedOnHandle();
317 if (new_buffer != buffer_) { 322 if (new_buffer != buffer_) {
318 int start_offset = start_ - buffer_; 323 int start_offset = start_ - buffer_;
319 int cursor_offset = cursor_ - buffer_; 324 int cursor_offset = cursor_ - buffer_;
320 int marker_offset = marker_ - buffer_; 325 int marker_offset = marker_ - buffer_;
326 int last_octal_end_offset = last_octal_end_ - buffer_;
321 buffer_ = new_buffer; 327 buffer_ = new_buffer;
322 buffer_end_ = buffer_ + source_handle_->length(); 328 buffer_end_ = buffer_ + source_handle_->length();
323 start_ = buffer_ + start_offset; 329 start_ = buffer_ + start_offset;
324 cursor_ = buffer_ + cursor_offset; 330 cursor_ = buffer_ + cursor_offset;
325 marker_ = buffer_ + marker_offset; 331 marker_ = buffer_ + marker_offset;
332 last_octal_end_ = buffer_ + last_octal_end_offset;
333 ResetLiterals();
326 } 334 }
327 } 335 }
328 336
329 protected: 337 protected:
330 virtual void Scan(); 338 virtual void Scan();
331 339
332 const Char* GetNewBufferBasedOnHandle() const; 340 const Char* GetNewBufferBasedOnHandle() const;
333 341
334 virtual bool FillLiteral(const TokenDesc& token, LiteralDesc* literal); 342 virtual bool FillLiteral(const TokenDesc& token, LiteralDesc* literal);
335 343
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 // character. 609 // character.
602 const Char* temp_cursor = last_octal_end_ - 1; 610 const Char* temp_cursor = last_octal_end_ - 1;
603 while (temp_cursor >= buffer_ && *temp_cursor >= '0' && *temp_cursor <= '7') 611 while (temp_cursor >= buffer_ && *temp_cursor >= '0' && *temp_cursor <= '7')
604 --temp_cursor; 612 --temp_cursor;
605 return Location(temp_cursor - buffer_ + 1, last_octal_end_ - buffer_); 613 return Location(temp_cursor - buffer_ + 1, last_octal_end_ - buffer_);
606 } 614 }
607 615
608 } } 616 } }
609 617
610 #endif // V8_LEXER_EXPERIMENTAL_SCANNER_H 618 #endif // V8_LEXER_EXPERIMENTAL_SCANNER_H
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698