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

Unified Diff: src/scanner.cc

Issue 1102523003: Implement a 'trial parse' step, that will abort pre-parsing excessively (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use a seperate 'hint' bit for "to be executed once" code aging. Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scanner.h ('k') | src/scanner-character-streams.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner.cc
diff --git a/src/scanner.cc b/src/scanner.cc
index aa5ae4a5e93c317dd804d92420b792fdf0707221..3092e33da83b8663944ca508100857650a541da2 100644
--- a/src/scanner.cc
+++ b/src/scanner.cc
@@ -29,15 +29,26 @@ Handle<String> LiteralBuffer::Internalize(Isolate* isolate) const {
}
+// Default implementation for streams that do not support bookmarks.
+bool Utf16CharacterStream::SetBookmark() { return false; }
+void Utf16CharacterStream::ResetToBookmark() { UNREACHABLE(); }
+
+
// ----------------------------------------------------------------------------
// Scanner
Scanner::Scanner(UnicodeCache* unicode_cache)
: unicode_cache_(unicode_cache),
+ bookmark_c0_(kNoBookmark),
octal_pos_(Location::invalid()),
harmony_modules_(false),
harmony_classes_(false),
- harmony_unicode_(false) {}
+ harmony_unicode_(false) {
+ bookmark_current_.literal_chars = &bookmark_current_literal_;
+ bookmark_current_.raw_literal_chars = &bookmark_current_raw_literal_;
+ bookmark_next_.literal_chars = &bookmark_next_literal_;
+ bookmark_next_.raw_literal_chars = &bookmark_next_raw_literal_;
+}
void Scanner::Initialize(Utf16CharacterStream* source) {
@@ -1426,6 +1437,56 @@ int Scanner::FindSymbol(DuplicateFinder* finder, int value) {
}
+bool Scanner::SetBookmark() {
+ if (c0_ != kNoBookmark && bookmark_c0_ == kNoBookmark &&
+ source_->SetBookmark()) {
+ bookmark_c0_ = c0_;
+ CopyTokenDesc(&bookmark_current_, &current_);
+ CopyTokenDesc(&bookmark_next_, &next_);
+ return true;
+ }
+ return false;
+}
+
+
+void Scanner::ResetToBookmark() {
+ DCHECK(BookmarkHasBeenSet()); // Caller hasn't called SetBookmark.
+
+ source_->ResetToBookmark();
+ c0_ = bookmark_c0_;
+ StartLiteral();
+ StartRawLiteral();
+ CopyTokenDesc(&next_, &bookmark_current_);
+ current_ = next_;
+ StartLiteral();
+ StartRawLiteral();
+ CopyTokenDesc(&next_, &bookmark_next_);
+
+ bookmark_c0_ = kBookmarkWasApplied;
+}
+
+
+bool Scanner::BookmarkHasBeenSet() { return bookmark_c0_ >= 0; }
+
+
+bool Scanner::BookmarkHasBeenReset() {
+ return bookmark_c0_ == kBookmarkWasApplied;
+}
+
+
+void Scanner::DropBookmark() { bookmark_c0_ = kNoBookmark; }
+
+
+void Scanner::CopyTokenDesc(TokenDesc* to, TokenDesc* from) {
+ DCHECK_NOT_NULL(to);
+ DCHECK_NOT_NULL(from);
+ to->token = from->token;
+ to->location = from->location;
+ to->literal_chars->CopyFrom(from->literal_chars);
+ to->raw_literal_chars->CopyFrom(from->raw_literal_chars);
+}
+
+
int DuplicateFinder::AddOneByteSymbol(Vector<const uint8_t> key, int value) {
return AddSymbol(key, true, value);
}
« no previous file with comments | « src/scanner.h ('k') | src/scanner-character-streams.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698